Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87f19e62b0 |
No files matched your search
@@ -1,10 +1,9 @@
|
||||
# PlaceholderAPI-Expansion
|
||||
PlaceholderAPI Expansion for MiniPlaceholders
|
||||
# PlaceholderAdapter-Expansion
|
||||
PlaceholderAdapter Expansion for MiniPlaceholders
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
- Paper
|
||||
- Folia
|
||||
- Velocity
|
||||
|
||||
### If you are using Velocity
|
||||
@@ -16,31 +15,31 @@ On Velocity there is an additional optional `expiry` parameter for how long the
|
||||
|
||||
## Placeholders
|
||||
|
||||
- `<placeholderapi_global:(placeholder)>`
|
||||
- `<placeholder-adapter_global:(placeholder)>`
|
||||
Velocity:
|
||||
- `<placeholderapi_global:(placeholder):(expiry)>`
|
||||
- `<placeholder-adapter_global:(placeholder):(expiry)>`
|
||||
|
||||
This placeholder does not require any player to work.
|
||||
Its operation would be similar to running the command `/papi parse --null (placeholders)`
|
||||
|
||||
- `<placeholderapi_player:(placeholder)>`
|
||||
- `<placeholder-adapter_player:(placeholder)>`
|
||||
Velocity:
|
||||
- `<placeholderapi_player:(placeholder):(expiry)>`
|
||||
- `<placeholder-adapter_player:(placeholder):(expiry)>`
|
||||
|
||||
This placeholder requires an online player to function.
|
||||
Its operation would be similar to running the `/papi parse me (placeholders)` command
|
||||
|
||||
- `<placeholderapi_relational:(placeholder)>`
|
||||
- `<placeholder-adapter_relational:(placeholder)>`
|
||||
Velocity:
|
||||
- `<placeholderapi_relational:(placeholder):(expiry)>`
|
||||
- `<placeholder-adapter_relational:(placeholder):(expiry)>`
|
||||
|
||||
This placeholder requires two online players to work.
|
||||
The functioning of this placeholder depends on whether the plugin in which it is used has relational placeholder support
|
||||
|
||||
If you want to nest the result of the placeholder inside another placeholder, add the string argument.
|
||||
For example:
|
||||
- `<placeholderapi_player:%player_name%:string>`
|
||||
- `<placeholderapi_player:%player_name%:string:30000>`
|
||||
- `<placeholder-adapter_papi_player:%player_name%:string>`
|
||||
- `<placeholder-adapter_player:%player_name%:string:30000>`
|
||||
|
||||
## Downloads
|
||||
|
||||
|
||||
@@ -4,10 +4,23 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.miniplaceholders)
|
||||
implementation(projects.placeholderapiExpansionPaper)
|
||||
implementation(projects.placeholderapiExpansionVelocity)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply<JavaPlugin>()
|
||||
tasks {
|
||||
withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(21)
|
||||
}
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("${rootProject.name}-${project.version}.jar")
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
group = io.github.miniplaceholders
|
||||
version = 1.2.0
|
||||
description = PlaceholderAPI-Expansion
|
||||
version = 2.0.0
|
||||
description = PlaceholderAdapter-Expansion
|
||||
@@ -2,14 +2,14 @@ metadata.format.version = "1.1"
|
||||
|
||||
[versions]
|
||||
|
||||
velocity = "3.2.0-SNAPSHOT"
|
||||
paper = "1.19.3-R0.1-SNAPSHOT"
|
||||
velocity = "3.4.0-SNAPSHOT"
|
||||
paper = "1.21.8-R0.1-SNAPSHOT"
|
||||
|
||||
blossom = "1.3.1"
|
||||
shadow = "8.1.1"
|
||||
blossom = "2.1.0"
|
||||
shadow = "9.0.1"
|
||||
runtask = "2.2.3"
|
||||
|
||||
miniplaceholders = "2.2.3"
|
||||
miniplaceholders = "3.0.0-SNAPSHOT"
|
||||
adventure = "4.13.1"
|
||||
|
||||
[libraries]
|
||||
@@ -23,6 +23,6 @@ proxybridge = "net.william278:papiproxybridge:1.4.2"
|
||||
[plugins]
|
||||
|
||||
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }
|
||||
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
|
||||
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
||||
runvelocity = { id = "xyz.jpenilla.run-velocity", version.ref = "runtask" }
|
||||
runpaper = { id = "xyz.jpenilla.run-velocity", version.ref = "runtask" }
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -2,27 +2,8 @@ plugins {
|
||||
java
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.paper.api)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.placeholderapi)
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
filesMatching("paper-plugin.yml") {
|
||||
expand("version" to project.version)
|
||||
}
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
+23
-29
@@ -1,26 +1,21 @@
|
||||
package io.github.miniplaceholders.expansion.placeholderapi.paper;
|
||||
|
||||
import io.github.miniplaceholders.api.utils.LegacyUtils;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
package io.github.miniplaceholders.expansion.placeholderadapter.paper;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.utils.LegacyStrings;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.*;
|
||||
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.AMPERSAND_CHAR;
|
||||
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.SECTION_CHAR;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class PaperPlugin extends JavaPlugin {
|
||||
public final class PaperPlatform {
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
this.getSLF4JLogger().info("Starting PlaceholderAPI Expansion for MiniPlaceholders Paper");
|
||||
|
||||
Expansion.builder("placeholderapi")
|
||||
.filter(Player.class)
|
||||
public static Expansion provideExpansion() {
|
||||
return Expansion.builder("placeholder-adapter")
|
||||
.globalPlaceholder("global", (queue, ctx) -> {
|
||||
final String argument = queue.popOr("You need to provide a placeholder").value();
|
||||
final String papiParsed = PlaceholderAPI.setPlaceholders(
|
||||
@@ -29,43 +24,42 @@ public final class PaperPlugin extends JavaPlugin {
|
||||
).replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
if (parseString(queue)) {
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
|
||||
} else {
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
|
||||
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
|
||||
}
|
||||
})
|
||||
.audiencePlaceholder("player", (aud, queue, ctx) -> {
|
||||
.audiencePlaceholder(Player.class, "player", (player, queue, ctx) -> {
|
||||
final String argument = queue.popOr("You need to provide a placeholder").value();
|
||||
final String papiParsed = PlaceholderAPI.setPlaceholders(
|
||||
(Player)aud,
|
||||
player,
|
||||
argument
|
||||
).replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
if (parseString(queue)) {
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
|
||||
} else {
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
|
||||
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
|
||||
}
|
||||
})
|
||||
.relationalPlaceholder("relational", (player, toShow, queue, ctx) -> {
|
||||
.relationalPlaceholder(Player.class, "relational", (player, toShow, queue, ctx) -> {
|
||||
final String argument = queue.popOr("You need to provide a placeholder").value();
|
||||
final String papiParsed = PlaceholderAPI.setRelationalPlaceholders(
|
||||
(Player) player,
|
||||
(Player) toShow,
|
||||
player,
|
||||
toShow,
|
||||
argument
|
||||
).replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
if (parseString(queue)) {
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
|
||||
} else {
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
|
||||
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
|
||||
}
|
||||
})
|
||||
.build()
|
||||
.register();
|
||||
.build();
|
||||
}
|
||||
|
||||
private boolean parseString(ArgumentQueue queue) {
|
||||
private static boolean parseString(ArgumentQueue queue) {
|
||||
return queue.hasNext() && queue.pop().lowerValue().equals("string");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
name: PlaceholderAPI-Expansion
|
||||
version: '${version}'
|
||||
author: 4drian3d
|
||||
main: io.github.miniplaceholders.expansion.placeholderapi.paper.PaperPlugin
|
||||
api-version: '1.19'
|
||||
folia-supported: true
|
||||
dependencies:
|
||||
- name: MiniPlaceholders
|
||||
required: true
|
||||
- name: PlaceholderAPI
|
||||
required: true
|
||||
+15
-2
@@ -1,9 +1,22 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
rootProject.name = "PlaceholderAPI-Expansion"
|
||||
rootProject.name = "PlaceholderAdapter-Expansion"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://central.sonatype.com/repository/maven-snapshots/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.william278.net/releases/")
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||
}
|
||||
|
||||
arrayOf("paper", "velocity").forEach {
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package io.github.miniplaceholders.expansion.placeholderadapter;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import io.github.miniplaceholders.api.provider.ExpansionProvider;
|
||||
import io.github.miniplaceholders.api.provider.LoadRequirement;
|
||||
import io.github.miniplaceholders.api.types.Platform;
|
||||
import io.github.miniplaceholders.expansion.placeholderadapter.velocity.VelocityPlatform;
|
||||
import io.github.miniplaceholders.expansion.placeholderadapter.paper.PaperPlatform;
|
||||
|
||||
public final class AdapterExpansionProvider implements ExpansionProvider {
|
||||
@Override
|
||||
public Expansion provideExpansion() {
|
||||
return switch (MiniPlaceholders.platform()) {
|
||||
case PAPER -> PaperPlatform.provideExpansion();
|
||||
case VELOCITY -> VelocityPlatform.provideExpansion();
|
||||
default -> throw new UnsupportedOperationException("Unsupported Platform");
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadRequirement loadRequirement() {
|
||||
return LoadRequirement.allOf(
|
||||
LoadRequirement.platform(Platform.PAPER, Platform.VELOCITY),
|
||||
LoadRequirement.requiredComplement("placeholderapi", "PlaceholderAPI"),
|
||||
LoadRequirement.requiredComplement("papiproxybridge")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
provider-class=io.github.miniplaceholders.expansion.placeholderadapter.AdapterExpansionProvider
|
||||
@@ -3,12 +3,6 @@ plugins {
|
||||
alias(libs.plugins.blossom)
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.william278.net/releases/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.proxybridge)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
@@ -16,16 +10,3 @@ dependencies {
|
||||
annotationProcessor(libs.velocity.api)
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
|
||||
blossom {
|
||||
replaceTokenIn("src/main/java/io/github/miniplaceholders/expansion/placeholderapi/velocity/VelocityPlugin.java")
|
||||
replaceToken("{version}", project.version)
|
||||
}
|
||||
+19
-44
@@ -1,18 +1,12 @@
|
||||
package io.github.miniplaceholders.expansion.placeholderapi.velocity;
|
||||
package io.github.miniplaceholders.expansion.placeholderadapter.velocity;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.utils.LegacyUtils;
|
||||
import io.github.miniplaceholders.api.utils.LegacyStrings;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import net.william278.papiproxybridge.api.PlaceholderAPI;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
@@ -23,24 +17,12 @@ import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.AMPERSAND_CHAR;
|
||||
import static net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.SECTION_CHAR;
|
||||
|
||||
@Plugin(
|
||||
id = "placeholderapi-expansion",
|
||||
name = "PlaceholderAPI Expansion",
|
||||
version = "{version}",
|
||||
authors = { "4drian3d" },
|
||||
dependencies = {
|
||||
@Dependency(id = "miniplaceholders"),
|
||||
@Dependency(id = "papiproxybridge")
|
||||
}
|
||||
)
|
||||
public final class VelocityPlugin {
|
||||
@Inject
|
||||
private Logger logger;
|
||||
public final class VelocityPlatform {
|
||||
private static final UUID NULL_UUID = UUID.randomUUID();
|
||||
private static final PlaceholderAPI instance = PlaceholderAPI.createInstance();
|
||||
private static final ConcurrentMap<Long, PlaceholderAPI> cachedInstances = Maps.newConcurrentMap();
|
||||
|
||||
private PlaceholderAPI getAPI(ArgumentQueue queue) {
|
||||
private static PlaceholderAPI getAPI(ArgumentQueue queue) {
|
||||
if (!queue.hasNext()) return instance;
|
||||
OptionalInt optExpiry = queue.pop().asInt();
|
||||
|
||||
@@ -53,13 +35,9 @@ public final class VelocityPlugin {
|
||||
return api;
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
this.logger.info("Starting PlaceholderAPI Expansion for MiniPlaceholders Velocity");
|
||||
|
||||
Expansion.builder("placeholderapi")
|
||||
.filter(Player.class)
|
||||
|
||||
public static Expansion provideExpansion() {
|
||||
return Expansion.builder("placeholder-adapter")
|
||||
.globalPlaceholder("global", (queue, ctx) -> {
|
||||
final String argument = queue.popOr("You need to provide a placeholder").value();
|
||||
boolean isString = parseString(queue);
|
||||
@@ -71,14 +49,13 @@ public final class VelocityPlugin {
|
||||
.replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
if (isString) {
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
|
||||
} else {
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
|
||||
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
|
||||
}
|
||||
})
|
||||
.audiencePlaceholder("player", (aud, queue, ctx) -> {
|
||||
.audiencePlaceholder(Player.class, "player", (player, queue, ctx) -> {
|
||||
final String argument = queue.popOr("You need to provide a placeholder").value();
|
||||
final Player player = (Player)aud;
|
||||
boolean isString = parseString(queue);
|
||||
PlaceholderAPI api = getAPI(queue);
|
||||
final String papiParsed = api
|
||||
@@ -88,34 +65,32 @@ public final class VelocityPlugin {
|
||||
.replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
if (isString) {
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
|
||||
} else {
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
|
||||
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
|
||||
}
|
||||
})
|
||||
.relationalPlaceholder("relational", (audience, audienceToShow, queue, ctx) -> {
|
||||
.relationalPlaceholder(Player.class, "relational", (player, playerToShow, queue, ctx) -> {
|
||||
final String argument = queue.popOr("You need to provide a placeholder").value();
|
||||
final Player player = (Player) audience;
|
||||
final Player toShow = (Player) audienceToShow;
|
||||
boolean isString = parseString(queue);
|
||||
PlaceholderAPI api = getAPI(queue);
|
||||
final String papiParsed = api
|
||||
.formatPlaceholders(argument, player.getUniqueId(), toShow.getUniqueId())
|
||||
.formatPlaceholders(argument, player.getUniqueId(), playerToShow.getUniqueId())
|
||||
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
|
||||
.join()
|
||||
.replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
if (isString) {
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
|
||||
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
|
||||
} else {
|
||||
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
|
||||
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
|
||||
}
|
||||
})
|
||||
.build()
|
||||
.register();
|
||||
.build();
|
||||
}
|
||||
|
||||
private boolean parseString(ArgumentQueue queue) {
|
||||
private static boolean parseString(ArgumentQueue queue) {
|
||||
//noinspection DataFlowIssue
|
||||
boolean isString = queue.hasNext() && queue.peek().lowerValue().equals("string");
|
||||
if (isString) queue.pop();
|
||||
return isString;
|
||||
Reference in new issue
Block a user