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
@@ -1 +0,0 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -1,3 +0,0 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -0,0 +1,30 @@
|
||||
name: Java CI with Gradle
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: 'gradle'
|
||||
- name: Build with Gradle
|
||||
uses: nick-invision/retry@v3
|
||||
with:
|
||||
timeout_minutes: 5
|
||||
max_attempts: 2
|
||||
command: gradle build
|
||||
@@ -1,38 +1,55 @@
|
||||
# PlaceholderAPI-Expansion
|
||||
1.19.4 branch of 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
|
||||
## Supported Placeholder Providers
|
||||
|
||||
- [PlaceholderAPI](https://modrinth.com/plugin/placeholderapi) (Bukkit/Paper)
|
||||
- [TextPlaceholderAPI](https://modrinth.com/mod/placeholder-api) (Fabric)
|
||||
- [PAPIProxyBridge](https://modrinth.com/plugin/papiproxybridge) (Velocity)
|
||||
|
||||
> [!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
-3
@@ -1,12 +1,28 @@
|
||||
plugins {
|
||||
java
|
||||
alias(libs.plugins.shadow)
|
||||
eclipse
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.placeholderapiExpansionPaper)
|
||||
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
|
||||
+24
-10
@@ -2,23 +2,37 @@ metadata.format.version = "1.1"
|
||||
|
||||
[versions]
|
||||
|
||||
velocity = "3.2.0-SNAPSHOT"
|
||||
paper = "1.19.4-R0.1-SNAPSHOT"
|
||||
velocity = "3.4.0-SNAPSHOT"
|
||||
paper = "1.21.8-R0.1-SNAPSHOT"
|
||||
|
||||
blossom = "1.3.1"
|
||||
shadow = "8.3.6"
|
||||
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.6" }
|
||||
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]
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -57,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -85,8 +83,7 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -114,7 +111,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -147,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -155,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -204,16 +201,16 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+12
-14
@@ -13,8 +13,6 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -59,22 +57,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
+1
-20
@@ -2,27 +2,8 @@ plugins {
|
||||
java
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://repo.papermc.io/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
|
||||
+27
-4
@@ -1,14 +1,37 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
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").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
|
||||
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
java
|
||||
alias(libs.plugins.blossom)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.proxybridge)
|
||||
compileOnly(libs.miniplaceholders)
|
||||
compileOnly(libs.velocity.api)
|
||||
annotationProcessor(libs.velocity.api)
|
||||
}
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package io.github.miniplaceholders.expansion.placeholderadapter.velocity;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
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.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 = Maps.newConcurrentMap();
|
||||
|
||||
private static 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;
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
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(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);
|
||||
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(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();
|
||||
boolean isString = parseString(queue);
|
||||
PlaceholderAPI api = getAPI(queue);
|
||||
final String papiParsed = api
|
||||
.formatPlaceholders(argument, player.getUniqueId(), playerToShow.getUniqueId())
|
||||
.completeOnTimeout(argument, 100, TimeUnit.MILLISECONDS)
|
||||
.join()
|
||||
.replace(SECTION_CHAR, AMPERSAND_CHAR);
|
||||
|
||||
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
|
||||
boolean isString = queue.hasNext() && queue.peek().lowerValue().equals("string");
|
||||
if (isString) queue.pop();
|
||||
return isString;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user