31 Commits
Author SHA1 Message Date
Adrian Gonzales 9fb13036bf Merge remote-tracking branch 'origin/main' 2025-08-30 16:24:58 -05:00
Adrian Gonzales 1ba0fec35b release: Version 2.1.0 2025-08-30 16:24:35 -05:00
Adrian 50ce51f490 Merge pull request #40 from MiniPlaceholders/renovate/shadow
chore(deps): update dependency com.gradleup.shadow to v9.1.0
2025-08-30 16:15:06 -05:00
Adrian 62770d32e9 Merge pull request #41 from MiniPlaceholders/feat/fabric
Added support for TextPlaceholderAPI
2025-08-30 12:46:16 -05:00
Adrian Gonzales dbc80800f0 ci: Updated jdk used 2025-08-30 12:33:37 -05:00
Adrian Gonzales 9236a4f01d misc: expansion 2025-08-30 12:32:00 -05:00
Adrian Gonzales 741882d723 misc: Removed Download link 2025-08-30 12:30:38 -05:00
Adrian Gonzales 6788e43c8f misc: Updated README 2025-08-30 12:30:06 -05:00
Adrian Gonzales ba54223de6 Merge branch 'main' into feat/fabric
# Conflicts:
#	gradle/libs.versions.toml
2025-08-30 11:47:01 -05:00
renovate[bot] dac82c9b93 chore(deps): update dependency com.gradleup.shadow to v9.1.0 2025-08-30 16:44:03 +00:00
Adrian Gonzales 3108f531aa feat(fabric): Added support for TextPlaceholderAPI 2025-08-30 11:43:33 -05:00
Adrian 033069b2db Merge pull request #27 from MiniPlaceholders/renovate/nick-invision-retry-3.x
chore(deps): update nick-invision/retry action to v3
2025-08-28 14:33:44 -05:00
renovate[bot] 1d931a9228 chore(deps): update nick-invision/retry action to v3 2025-08-28 19:26:25 +00:00
Adrian c1cc41ff09 Merge pull request #37 from MiniPlaceholders/renovate/actions-setup-java-5.x
chore(deps): update actions/setup-java action to v5
2025-08-25 15:23:29 -05:00
Adrian 2ec76033e9 Merge pull request #38 from MiniPlaceholders/renovate/miniplaceholders
fix(deps): update dependency io.github.miniplaceholders:miniplaceholders-api to v3.0.1
2025-08-25 15:23:21 -05:00
Adrian Gonzales 1ba0bcc3c7 fix: Fixed papiproxybridge compatibility 2025-08-24 03:59:44 -05:00
renovate[bot] 00e309c335 fix(deps): update dependency io.github.miniplaceholders:miniplaceholders-api to v3.0.1 2025-08-23 06:08:56 +00:00
Adrian 22f4c06b0b Merge pull request #36 from MiniPlaceholders/renovate/miniplaceholders
fix(deps): update dependency io.github.miniplaceholders:miniplaceholders-api to v3.0.0
2025-08-21 15:01:44 -05:00
renovate[bot] 4d6b792918 chore(deps): update actions/setup-java action to v5 2025-08-21 05:46:09 +00:00
renovate[bot] 92c451a66d fix(deps): update dependency io.github.miniplaceholders:miniplaceholders-api to v3.0.0 2025-08-21 05:46:02 +00:00
Adrian df54aa012b Merge pull request #26 from MiniPlaceholders/renovate/net.william278-papiproxybridge-1.x
fix(deps): update dependency net.william278:papiproxybridge to v1.8.4
2025-08-20 21:28:06 -05:00
Adrian 71240bbe1c Merge pull request #28 from MiniPlaceholders/renovate/runtask
chore(deps): update dependency xyz.jpenilla.run-velocity to v2.3.1
2025-08-20 21:27:49 -05:00
Adrian d1c22f97b6 Merge pull request #34 from MiniPlaceholders/renovate/actions-checkout-5.x
chore(deps): update actions/checkout action to v5
2025-08-20 21:27:41 -05:00
renovate[bot] 1ad79cb356 fix(deps): update dependency net.william278:papiproxybridge to v1.8.4 2025-08-21 02:08:43 +00:00
Adrian 85d81f917d Merge pull request #32 from MiniPlaceholders/renovate/me.clip-placeholderapi-2.x
fix(deps): update dependency me.clip:placeholderapi to v2.11.6
2025-08-20 21:08:20 -05:00
renovate[bot] 1e41f17d91 chore(deps): update dependency xyz.jpenilla.run-velocity to v2.3.1 2025-08-20 07:08:25 +00:00
Adrian 3869ee4aa6 Merge pull request #35 from MiniPlaceholders/renovate/shadow
chore(deps): update dependency com.gradleup.shadow to v9.0.2
2025-08-20 02:07:59 -05:00
renovate[bot] 3ed2bc908a fix(deps): update dependency me.clip:placeholderapi to v2.11.6 2025-08-20 00:59:28 +00:00
renovate[bot] f1a0b1e3b9 chore(deps): update dependency com.gradleup.shadow to v9.0.2 2025-08-15 04:24:39 +00:00
renovate[bot] d2ce09cf94 chore(deps): update actions/checkout action to v5 2025-08-14 06:53:59 +00:00
Adrian Gonzales 87f19e62b0 feat!: Updated to MiniPlaceholders v3 2025-08-14 01:52:53 -05:00
17 changed files with 342 additions and 252 deletions

No files matched your search

+5 -5
View File
@@ -15,15 +15,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
- uses: actions/checkout@v5
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Build with Gradle
uses: nick-invision/retry@v2
uses: nick-invision/retry@v3
with:
timeout_minutes: 5
max_attempts: 2
+31 -23
View File
@@ -1,47 +1,55 @@
# PlaceholderAPI-Expansion
PlaceholderAPI Expansion for MiniPlaceholders
# PlaceholderAdapter-Expansion
PlaceholderAdapter Expansion for MiniPlaceholders
## Supported Platforms
This expansion provides support for multiple placeholder plugins so that they can be used in MiniPlaceholders
- Paper
- Folia
- Velocity
## Supported Placeholder Providers
### If you are using Velocity
- [PlaceholderAPI](https://modrinth.com/plugin/placeholderapi) (Bukkit/Paper)
- [TextPlaceholderAPI](https://modrinth.com/mod/placeholder-api) (Fabric)
- [PAPIProxyBridge](https://modrinth.com/plugin/papiproxybridge) (Velocity)
In order to use PlaceholderAPI placeholders with MiniPlaceholders Velocity,
you must install [PAPIProxyBridge](https://modrinth.com/plugin/papiproxybridge) according to its installation guide
On Velocity there is an additional optional `expiry` parameter for how long the placeholder should be cached. This value is in milliseconds.
> [!IMPORTANT]
> If you are using Velocity, in order to use PlaceholderAPI placeholders with MiniPlaceholders Velocity,
> you must install [PAPIProxyBridge](https://modrinth.com/plugin/papiproxybridge) according to its installation guide
>
> On Velocity there is an additional optional `expiry` parameter for how long the placeholder should be cached. This value is in milliseconds.
## Placeholders
- `<placeholderapi_global:(placeholder)>`
### Global
- `<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)>`
### Audience
- `<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)>`
### Relational
> [!NOTE]
> This type of placeholder is not supported by TextPlaceholderAPI, so it will only be available in Paper and Velocity
- `<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
## Nesting
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>`
## Downloads
[![](https://raw.githubusercontent.com/Prospector/badges/master/modrinth-badge-72h-padded.png)](https://modrinth.com/plugin/miniplaceholders-placeholderapi-expansion)
- `<placeholder-adapter_papi_player:%player_name%:string>`
- `<placeholder-adapter_player:%player_name%:string:30000>`
+19 -2
View File
@@ -4,8 +4,25 @@ plugins {
}
dependencies {
implementation(projects.placeholderapiExpansionPaper)
implementation(projects.placeholderapiExpansionVelocity)
compileOnly(libs.adventure.api)
compileOnly(libs.miniplaceholders)
implementation(projects.placeholderAdapterExpansionPaper)
implementation(projects.placeholderAdapterExpansionVelocity)
implementation(projects.placeholderAdapterExpansionFabric) {
isTransitive = false
}
}
allprojects {
apply<JavaPlugin>()
tasks {
withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release.set(21)
}
}
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
tasks {
+13
View File
@@ -0,0 +1,13 @@
plugins {
id("fabric-loom")
}
dependencies {
compileOnly(libs.miniplaceholders)
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.api)
modImplementation(libs.adventure.platform.fabric)
modImplementation(libs.placeholderapi.fabric)
}
@@ -0,0 +1,47 @@
package io.github.miniplaceholders.expansion.placeholderadapter.fabric;
import eu.pb4.placeholders.api.PlaceholderContext;
import eu.pb4.placeholders.api.Placeholders;
import io.github.miniplaceholders.api.Expansion;
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
public class FabricPlatform {
public static Expansion.Builder provideBuilder(Object platformInstance) {
final MinecraftServer server = (MinecraftServer) platformInstance;
final MinecraftServerAudiences serverAudiences = MinecraftServerAudiences.of(server);
return Expansion.builder("placeholder-adapter")
.globalPlaceholder("global", (queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final Component papiParsed = serverAudiences.asAdventure(
Placeholders.parseText(net.minecraft.network.chat.Component.literal(argument), PlaceholderContext.of(server))
);
if (parseString(queue)) {
return Tag.preProcessParsed(miniMessage().serialize(papiParsed));
} else {
return Tag.selfClosingInserting(papiParsed);
}
})
.audiencePlaceholder(ServerPlayer.class, "player", (player, queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final Component papiParsed = serverAudiences.asAdventure(
Placeholders.parseText(net.minecraft.network.chat.Component.literal(argument), PlaceholderContext.of(player))
);
if (parseString(queue)) {
return Tag.preProcessParsed(miniMessage().serialize(papiParsed));
} else {
return Tag.selfClosingInserting(papiParsed);
}
});
}
private static boolean parseString(ArgumentQueue queue) {
return queue.hasNext() && queue.pop().lowerValue().equals("string");
}
}
+2 -2
View File
@@ -1,3 +1,3 @@
group = io.github.miniplaceholders
version = 1.2.0
description = PlaceholderAPI-Expansion
version = 2.1.0
description = PlaceholderAdapter-Expansion
+25 -11
View File
@@ -2,27 +2,41 @@ 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"
runtask = "2.2.3"
blossom = "2.1.0"
shadow = "9.1.0"
runtask = "2.3.1"
miniplaceholders = "2.2.3"
adventure = "4.13.1"
miniplaceholders = "3.0.1"
adventure = "4.24.0"
adventurefabric = "6.6.0"
fabric-loader = "0.17.2"
fabric-api = "0.131.0+1.21.8"
minecraft = "1.21.8"
[libraries]
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
adventure-platform-fabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurefabric" }
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }
placeholderapi = { group = "me.clip", name = "placeholderapi", version = "2.11.5" }
proxybridge = "net.william278:papiproxybridge:1.4.2"
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
placeholderapi-bukkit = { group = "me.clip", name = "placeholderapi", version = "2.11.6" }
placeholderapi-fabric = { group = "eu.pb4", name = "placeholder-api", version = "2.7.2+1.21.8" }
proxybridge = "net.william278:papiproxybridge:1.8.4"
[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
View File
@@ -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
+1 -20
View File
@@ -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)
compileOnly(libs.placeholderapi.bukkit)
}
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))
@@ -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.Builder provideBuilder() {
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,41 @@ 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();
});
}
private boolean parseString(ArgumentQueue queue) {
private static boolean parseString(ArgumentQueue queue) {
return queue.hasNext() && queue.pop().lowerValue().equals("string");
}
}
-11
View File
@@ -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
+28 -5
View File
@@ -1,14 +1,37 @@
@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/")
maven("https://maven.nucleoid.xyz/") { name = "Nucleoid" }
}
}
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven("https://maven.fabricmc.net/")
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
id("fabric-loom") version "1.11.7"
}
arrayOf("paper", "velocity").forEach {
include("placeholderapi-expansion-$it")
arrayOf("paper", "velocity", "fabric").forEach {
include("placeholder-adapter-expansion-$it")
project(":placeholderapi-expansion-$it").projectDir = file(it)
project(":placeholder-adapter-expansion-$it").projectDir = file(it)
}
@@ -0,0 +1,46 @@
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.provider.PlatformData;
import io.github.miniplaceholders.api.types.Platform;
import io.github.miniplaceholders.expansion.placeholderadapter.velocity.VelocityPlatform;
import io.github.miniplaceholders.expansion.placeholderadapter.paper.PaperPlatform;
import io.github.miniplaceholders.expansion.placeholderadapter.fabric.FabricPlatform;
import team.unnamed.inject.Inject;
public final class AdapterExpansionProvider implements ExpansionProvider {
@Inject
private PlatformData platformData;
@Override
public Expansion provideExpansion() {
final Expansion.Builder builder = switch (MiniPlaceholders.platform()) {
case PAPER -> PaperPlatform.provideBuilder();
case VELOCITY -> VelocityPlatform.provideBuilder();
case FABRIC -> FabricPlatform.provideBuilder(platformData.serverInstance());
default -> throw new UnsupportedOperationException("Unsupported Platform");
};
return builder.author("MiniPlaceholders Contributors")
.version("2.1.0")
.build();
}
@Override
public LoadRequirement loadRequirement() {
return LoadRequirement.allOf(
LoadRequirement.platform(Platform.PAPER, Platform.VELOCITY, Platform.FABRIC),
LoadRequirement.requiredComplement(
// Paper
"placeholderapi", "PlaceholderAPI",
// Velocity
"papiproxybridge",
// Fabric
"placeholder-api"
)
);
}
}
@@ -0,0 +1 @@
provider-class=io.github.miniplaceholders.expansion.placeholderadapter.AdapterExpansionProvider
-19
View File
@@ -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)
}
@@ -0,0 +1,100 @@
package io.github.miniplaceholders.expansion.placeholderadapter.velocity;
import com.velocitypowered.api.proxy.Player;
import io.github.miniplaceholders.api.Expansion;
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 java.util.OptionalInt;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
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;
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 = new ConcurrentHashMap<>();
private static PlaceholderAPI getAPI(ArgumentQueue queue) {
if (!queue.hasNext()) return instance;
final OptionalInt optExpiry = queue.pop().asInt();
if (optExpiry.isEmpty()) return instance;
final long expiry = optExpiry.getAsInt();
return cachedInstances.computeIfAbsent(expiry, (key) -> {
final PlaceholderAPI api = PlaceholderAPI.createInstance();
api.setCacheExpiry(key);
return api;
});
}
public static Expansion.Builder provideBuilder() {
return Expansion.builder("placeholder-adapter")
.globalPlaceholder("global", (queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final boolean isString = parseString(queue);
final PlaceholderAPI api = getAPI(queue);
final String papiParsed = api
.formatPlaceholders(argument, NULL_UUID)
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
.thenApply(st -> st.replace(SECTION_CHAR, AMPERSAND_CHAR))
.handle((result, ex) -> ex == null ? "" : result)
.join();
if (isString) {
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
} else {
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
}
})
.audiencePlaceholder(Player.class, "player", (player, queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
boolean isString = parseString(queue);
final PlaceholderAPI api = getAPI(queue);
final String papiParsed = api
.formatPlaceholders(argument, player.getUniqueId())
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
.thenApply(st -> st.replace(SECTION_CHAR, AMPERSAND_CHAR))
.handle((result, ex) -> ex == null ? "" : result)
.join();
if (isString) {
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
} else {
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
}
})
.relationalPlaceholder(Player.class, "relational", (player, playerToShow, queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
final boolean isString = parseString(queue);
final PlaceholderAPI api = getAPI(queue);
final String papiParsed = api
.formatPlaceholders(argument, player.getUniqueId(), playerToShow.getUniqueId())
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
.thenApply(st -> st.replace(SECTION_CHAR, AMPERSAND_CHAR))
.handle((result, ex) -> ex == null ? "" : result)
.join();
if (isString) {
return Tag.preProcessParsed(miniMessage().serialize(LegacyStrings.parsePossibleLegacy(papiParsed)));
} else {
return Tag.selfClosingInserting(LegacyStrings.parsePossibleLegacy(papiParsed));
}
});
}
private static boolean parseString(ArgumentQueue queue) {
//noinspection DataFlowIssue
final boolean isString = queue.hasNext() && queue.peek().lowerValue().equals("string");
if (isString) queue.pop();
return isString;
}
}
@@ -1,123 +0,0 @@
package io.github.miniplaceholders.expansion.placeholderapi.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 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;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
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;
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) {
if (!queue.hasNext()) return instance;
OptionalInt optExpiry = queue.pop().asInt();
if (optExpiry.isEmpty()) return instance;
Long expiry = (long) optExpiry.getAsInt();
return cachedInstances.computeIfAbsent(expiry, (key) -> {
PlaceholderAPI api = PlaceholderAPI.createInstance();
api.setCacheExpiry(key);
return api;
});
}
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
this.logger.info("Starting PlaceholderAPI Expansion for MiniPlaceholders Velocity");
Expansion.builder("placeholderapi")
.filter(Player.class)
.globalPlaceholder("global", (queue, ctx) -> {
final String argument = queue.popOr("You need to provide a placeholder").value();
boolean isString = parseString(queue);
PlaceholderAPI api = getAPI(queue);
final String papiParsed = api
.formatPlaceholders(argument, NULL_UUID)
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
.join()
.replace(SECTION_CHAR, AMPERSAND_CHAR);
if (isString) {
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
} else {
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
}
})
.audiencePlaceholder("player", (aud, 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
.formatPlaceholders(argument, player.getUniqueId())
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
.join()
.replace(SECTION_CHAR, AMPERSAND_CHAR);
if (isString) {
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
} else {
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
}
})
.relationalPlaceholder("relational", (audience, audienceToShow, 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())
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
.join()
.replace(SECTION_CHAR, AMPERSAND_CHAR);
if (isString) {
return Tag.preProcessParsed(miniMessage().serialize(LegacyUtils.parsePossibleLegacy(papiParsed)));
} else {
return Tag.selfClosingInserting(LegacyUtils.parsePossibleLegacy(papiParsed));
}
})
.build()
.register();
}
private boolean parseString(ArgumentQueue queue) {
boolean isString = queue.hasNext() && queue.peek().lowerValue().equals("string");
if (isString) queue.pop();
return isString;
}
}