Compare commits
26
Commits
main
...
feat/fabric
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbc80800f0 | ||
|
|
9236a4f01d | ||
|
|
741882d723 | ||
|
|
6788e43c8f | ||
|
|
ba54223de6 | ||
|
|
3108f531aa | ||
|
|
033069b2db | ||
|
|
1d931a9228 | ||
|
|
c1cc41ff09 | ||
|
|
2ec76033e9 | ||
|
|
1ba0bcc3c7 | ||
|
|
00e309c335 | ||
|
|
22f4c06b0b | ||
|
|
4d6b792918 | ||
|
|
92c451a66d | ||
|
|
df54aa012b | ||
|
|
71240bbe1c | ||
|
|
d1c22f97b6 | ||
|
|
1ad79cb356 | ||
|
|
85d81f917d | ||
|
|
1e41f17d91 | ||
|
|
3869ee4aa6 | ||
|
|
3ed2bc908a | ||
|
|
f1a0b1e3b9 | ||
|
|
d2ce09cf94 | ||
|
|
87f19e62b0 |
No files matched your search
@@ -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
|
||||
|
||||
@@ -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://modrinth.com/plugin/miniplaceholders-placeholderapi-expansion)
|
||||
- `<placeholder-adapter_papi_player:%player_name%:string>`
|
||||
- `<placeholder-adapter_player:%player_name%:string:30000>`
|
||||
+19
-2
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
+47
@@ -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
@@ -1,3 +1,3 @@
|
||||
group = io.github.miniplaceholders
|
||||
version = 1.2.0
|
||||
description = PlaceholderAPI-Expansion
|
||||
version = 2.1.0-SNAPSHOT
|
||||
description = PlaceholderAdapter-Expansion
|
||||
+25
-11
@@ -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.0.2"
|
||||
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
@@ -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
@@ -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))
|
||||
+23
-30
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
+46
@@ -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
|
||||
@@ -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
-45
@@ -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.Builder provideBuilder() {
|
||||
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,31 @@ 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();
|
||||
});
|
||||
}
|
||||
|
||||
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