mirror of
https://github.com/MiniPlaceholders/MiniPlaceholders.git
synced 2026-11-05 01:00:06 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adde850c52 | ||
|
|
94d97b97eb | ||
|
|
122e338e4e | ||
|
|
32fa6bc38d | ||
|
|
373c061089 | ||
|
|
8addfe3829 | ||
|
|
0e7fe5fec2 | ||
|
|
f0bce37135 | ||
|
|
4bd423bba8 | ||
|
|
2d75b5f36e | ||
|
|
a0fd80f883 | ||
|
|
e846e2989b | ||
|
|
aa0e6a1d51 | ||
|
|
702465f922 | ||
|
|
012a322dca | ||
|
|
c780f1c046 | ||
|
|
51c1c71b7f | ||
|
|
530f0ae96b | ||
|
|
c5fdf94d27 | ||
|
|
855f9ca7ff | ||
|
|
e24c08fad0 | ||
|
|
b1faea8c2d | ||
|
|
ed5005be67 | ||
|
|
1003e666e4 | ||
|
|
c7dde0986a | ||
|
|
167c9101be | ||
|
|
a04b7ef182 | ||
|
|
97b5f2b77e | ||
|
|
32cfd1b0a7 | ||
|
|
9be5a6c676 | ||
|
|
64e634033e | ||
|
|
d66dadadab | ||
|
|
3a78626d80 | ||
|
|
7f8325b605 | ||
|
|
759ca10c4f | ||
|
|
6e5bca56c1 | ||
|
|
c21201e948 | ||
|
|
41a35ce3ce | ||
|
|
31f5f286eb | ||
|
|
ce4c694f87 | ||
|
|
62ab9feaea | ||
|
|
076aa128fd | ||
|
|
e2dba8c7ac | ||
|
|
d40e6e2cd8 | ||
|
|
ecbf3d3ee4 | ||
|
|
b0c980672d | ||
|
|
40890cfbd0 | ||
|
|
beee6c6266 | ||
|
|
b0fb3dc4d8 | ||
|
|
a9c3128698 | ||
|
|
a7a7558fdf | ||
|
|
5adab32ef0 | ||
|
|
36ca8be51b | ||
|
|
6254e29eec | ||
|
|
08e57e8e98 | ||
|
|
a1cdb1a212 | ||
|
|
aa86a36ba1 | ||
|
|
0310f1a260 | ||
|
|
28b56abf3b | ||
|
|
504eff952f | ||
|
|
cb75bcb84b | ||
|
|
a78e988132 | ||
|
|
e5b8b36014 | ||
|
|
0cc1c4bdd6 | ||
|
|
ee4e23d658 | ||
|
|
407807948c | ||
|
|
634011dee0 | ||
|
|
12596860b1 | ||
|
|
1ecabc43d6 | ||
|
|
bae4722945 | ||
|
|
df07b08a45 | ||
|
|
b2c73f521d | ||
|
|
977ba115d0 | ||
|
|
2b2c3ecddf | ||
|
|
c63e59aca6 | ||
|
|
de9b8e78d1 | ||
|
|
922e0dceb0 | ||
|
|
68644fd9cd | ||
|
|
d3e3092ca1 | ||
|
|
af07305052 | ||
|
|
ef2c7d80bc | ||
|
|
be94b7e078 | ||
|
|
901335174c | ||
|
|
2b05d77cf8 | ||
|
|
f4c0a7e100 | ||
|
|
87465740c6 | ||
|
|
0f8144a9fb | ||
|
|
3808fc9d89 | ||
|
|
a7cc73fe7d | ||
|
|
8ac0c398d7 | ||
|
|
25618c0d42 | ||
|
|
9b61e8efa0 | ||
|
|
ad95e239bc | ||
|
|
d18ff640d2 | ||
|
|
7536d32055 | ||
|
|
5dffb9c251 | ||
|
|
e75baceb77 | ||
|
|
f2c6aa08f4 | ||
|
|
7727dca940 | ||
|
|
151b2dc2a4 | ||
|
|
16e3d09204 | ||
|
|
62c11dd84a | ||
|
|
77913be0fa | ||
|
|
685f67146d | ||
|
|
6f524b056a | ||
|
|
36f1cce813 | ||
|
|
4061c8acbe | ||
|
|
319731cef0 | ||
|
|
9e29afa9c5 | ||
|
|
9655509c2f | ||
|
|
26f1042d17 | ||
|
|
84c39e9205 | ||
|
|
77327661f3 | ||
|
|
b725fd2bae | ||
|
|
f9a5acaaaf | ||
|
|
fe613ce82d | ||
|
|
21839e1e37 | ||
|
|
25d1588032 | ||
|
|
92583013db | ||
|
|
89a7bdb208 | ||
|
|
0e7d4cb6dd | ||
|
|
159b96579f | ||
|
|
efb155a171 | ||
|
|
71ad7fb399 | ||
|
|
8b219fd553 | ||
|
|
9899f0bab4 | ||
|
|
7044e43483 | ||
|
|
36f1739704 | ||
|
|
d173de4250 | ||
|
|
410fe06117 | ||
|
|
e198769698 | ||
|
|
41ff8c1e12 | ||
|
|
344af47d19 | ||
|
|
756b1e9b43 | ||
|
|
85b7a24770 | ||
|
|
7f484f33f0 | ||
|
|
5d21522fa7 | ||
|
|
176266c9d5 | ||
|
|
c5bf073888 | ||
|
|
f2cbd1db75 | ||
|
|
e995e5441e | ||
|
|
f776f8ae61 | ||
|
|
a26f92e75c | ||
|
|
b030f02aac | ||
|
|
4336746bf3 | ||
|
|
e7e87a72dd | ||
|
|
0dce995222 |
No files matched your search
@@ -10,22 +10,22 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
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: 10
|
||||
max_attempts: 2
|
||||
command: gradle build
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: MiniPlaceholders
|
||||
path: jar/MiniPlaceholders-*.jar
|
||||
@@ -21,7 +21,7 @@ MiniMessage Component-based Placeholders for Paper, Fabric, Sponge, Folia and Ve
|
||||
- `/vminiplaceholders parse me "[message with placeholders]"`
|
||||
- `/vminiplaceholders parse player [some-player] "[message with placeholders]"`
|
||||
|
||||
### Paper | Folia | Fabric | Krypton
|
||||
### Paper | Folia | Fabric
|
||||
|
||||
- `/miniplaceholders <parse|help> player [some-player] "[message with placeholders]`
|
||||
- `/miniplaceholders parse player [some-player] "[message with placeholders]"`
|
||||
|
||||
@@ -6,7 +6,7 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.adventure.api)
|
||||
compileOnly(libs.adventure.minimesssage)
|
||||
compileOnly(libs.adventure.minimessage)
|
||||
compileOnly(libs.adventure.serializer.legacy)
|
||||
compileOnly(projects.miniplaceholdersConnect)
|
||||
|
||||
@@ -14,7 +14,7 @@ dependencies {
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
testImplementation(libs.adventure.api)
|
||||
testImplementation(libs.adventure.minimesssage)
|
||||
testImplementation(libs.adventure.minimessage)
|
||||
testImplementation(libs.adventure.serializer.plain)
|
||||
testImplementation(libs.adventure.serializer.legacy)
|
||||
}
|
||||
|
||||
@@ -43,6 +43,20 @@ public sealed interface Expansion permits ExpansionImpl {
|
||||
*/
|
||||
@NotNull String name();
|
||||
|
||||
/**
|
||||
* Get the author of this expansion
|
||||
* @return the author or null
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Nullable String author();
|
||||
|
||||
/**
|
||||
* Get the version of this expansion
|
||||
* @return the version or null
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Nullable String version();
|
||||
|
||||
/**
|
||||
* Get the {@link TagResolver} of the desired {@link Audience}
|
||||
* @param audience the audience
|
||||
@@ -217,5 +231,25 @@ public sealed interface Expansion permits ExpansionImpl {
|
||||
*/
|
||||
@Contract("_ -> this")
|
||||
@NotNull Builder filter(final @Nullable Predicate<@NotNull Audience> predicate);
|
||||
|
||||
/**
|
||||
* Sets the author of this expansion
|
||||
*
|
||||
* @param author the author of this expansion
|
||||
* @return the {@link Builder} itself
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Contract("_ -> this")
|
||||
@NotNull Builder author(final @Nullable String author);
|
||||
|
||||
/**
|
||||
* Sets the version of this expansion
|
||||
*
|
||||
* @param version the version of this expansion
|
||||
* @return the {@link Builder} itself
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@Contract("_ -> this")
|
||||
@NotNull Builder version(final @Nullable String version);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.kyori.adventure.text.minimessage.Context;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.intellij.lang.annotations.Subst;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -27,6 +28,8 @@ final class ExpansionImpl implements Expansion {
|
||||
private final TagResolver globalPlaceholders;
|
||||
private final Class<? extends Audience> filterClass;
|
||||
private final Predicate<Audience> predicateFilter;
|
||||
private final String author;
|
||||
private final String version;
|
||||
|
||||
ExpansionImpl(
|
||||
@NotNull final String expansionName,
|
||||
@@ -34,8 +37,11 @@ final class ExpansionImpl implements Expansion {
|
||||
@Nullable final Collection<Tags.Relational> relationalPlaceholders,
|
||||
@Nullable final TagResolver globalPlaceholders,
|
||||
@Nullable final Class<? extends Audience> filterClass,
|
||||
@Nullable final Predicate<Audience> predicateFilter){
|
||||
this.name = expansionName+"-";
|
||||
@Nullable final Predicate<Audience> predicateFilter,
|
||||
@Nullable final String author,
|
||||
@Nullable final String version
|
||||
) {
|
||||
this.name = expansionName;
|
||||
this.audiencePlaceholders = audiencePlaceholders != null
|
||||
? audiencePlaceholders.toArray(EMPTY_SINGLE_AUDIENCE)
|
||||
: EMPTY_SINGLE_AUDIENCE;
|
||||
@@ -45,6 +51,8 @@ final class ExpansionImpl implements Expansion {
|
||||
this.globalPlaceholders = globalPlaceholders;
|
||||
this.filterClass = filterClass;
|
||||
this.predicateFilter = predicateFilter;
|
||||
this.author = author;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +60,16 @@ final class ExpansionImpl implements Expansion {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String author(){
|
||||
return this.author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String version(){
|
||||
return this.version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull TagResolver audiencePlaceholders(@NotNull Audience audience) {
|
||||
if (audiencePlaceholders.length == 0) return TagResolver.empty();
|
||||
@@ -131,15 +149,19 @@ final class ExpansionImpl implements Expansion {
|
||||
|
||||
static final class Builder implements Expansion.Builder {
|
||||
private final String expansionName;
|
||||
@Subst("server")
|
||||
private final String expansionPrefix;
|
||||
private Set<Tags.Single> audiencePlaceholders;
|
||||
private Set<Tags.Relational> relationalPlaceholders;
|
||||
private TagResolver.Builder globalPlaceholders;
|
||||
private Class<? extends Audience> filterClass;
|
||||
private Predicate<Audience> predicateFilter;
|
||||
private String author;
|
||||
private String version;
|
||||
|
||||
Builder(@NotNull final String name){
|
||||
this.expansionName = nonNullOrEmptyString(name, "Expansion name")
|
||||
.toLowerCase(Locale.ROOT).concat("_");
|
||||
this.expansionName = nonNullOrEmptyString(name, "Expansion name");
|
||||
this.expansionPrefix = name.toLowerCase(Locale.ROOT).concat("_");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,7 +171,7 @@ final class ExpansionImpl implements Expansion {
|
||||
|
||||
if (this.audiencePlaceholders == null) this.audiencePlaceholders = new HashSet<>();
|
||||
|
||||
this.audiencePlaceholders.add(Tags.single(expansionName+key, audiencePlaceholder));
|
||||
this.audiencePlaceholders.add(Tags.single(expansionPrefix+key, audiencePlaceholder));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -160,7 +182,7 @@ final class ExpansionImpl implements Expansion {
|
||||
|
||||
if (this.relationalPlaceholders == null) this.relationalPlaceholders = new HashSet<>();
|
||||
|
||||
this.relationalPlaceholders.add(Tags.relational(expansionName+"rel_"+key, relationalPlaceholder));
|
||||
this.relationalPlaceholders.add(Tags.relational(expansionPrefix+"rel_"+key, relationalPlaceholder));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -171,7 +193,7 @@ final class ExpansionImpl implements Expansion {
|
||||
|
||||
if (this.globalPlaceholders == null) this.globalPlaceholders = TagResolver.builder();
|
||||
|
||||
this.globalPlaceholders.tag(expansionName+key, function);
|
||||
this.globalPlaceholders.tag(expansionPrefix+key, function);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -182,7 +204,7 @@ final class ExpansionImpl implements Expansion {
|
||||
|
||||
if (this.globalPlaceholders == null) this.globalPlaceholders = TagResolver.builder();
|
||||
|
||||
this.globalPlaceholders.tag(expansionName+key, tag);
|
||||
this.globalPlaceholders.tag(expansionPrefix+key, tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -198,6 +220,18 @@ final class ExpansionImpl implements Expansion {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expansion.@NotNull Builder author(@Nullable final String author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expansion.@NotNull Builder version(@Nullable final String version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Expansion build(){
|
||||
return new ExpansionImpl(
|
||||
@@ -206,7 +240,9 @@ final class ExpansionImpl implements Expansion {
|
||||
this.relationalPlaceholders,
|
||||
this.globalPlaceholders != null ? this.globalPlaceholders.build() : TagResolver.empty(),
|
||||
this.filterClass,
|
||||
this.predicateFilter
|
||||
this.predicateFilter,
|
||||
this.version,
|
||||
this.author
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import io.github.miniplaceholders.api.enums.Platform;
|
||||
import io.github.miniplaceholders.connect.InternalPlatform;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.github.miniplaceholders.api.utils.Resolvers.applyIfNotEmpty;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
@@ -35,6 +37,7 @@ public final class MiniPlaceholders {
|
||||
* @return the platform
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public static @NotNull Platform getPlatform() {
|
||||
return switch (InternalPlatform.platform()) {
|
||||
case PAPER -> Platform.PAPER;
|
||||
@@ -208,4 +211,15 @@ public final class MiniPlaceholders {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain all available registered expansions
|
||||
*
|
||||
* @return all available registered expansions
|
||||
* @since 2.3.0
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static Stream<Expansion> getExpansionsAvailable() {
|
||||
return expansions.stream();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ public enum Platform {
|
||||
/**Velocity Platform */
|
||||
VELOCITY,
|
||||
/**Krypton Platform */
|
||||
@Deprecated(forRemoval = true, since = "2.3.0")
|
||||
KRYPTON,
|
||||
/**Fabric Platform */
|
||||
FABRIC,
|
||||
|
||||
@@ -7,6 +7,9 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
|
||||
/**
|
||||
@@ -68,7 +71,10 @@ public final class LegacyUtils {
|
||||
* @return a parsed string
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public static @NotNull Component parsePossibleLegacy(@Nullable String string, @NotNull final Context context) {
|
||||
public static @NotNull Component parsePossibleLegacy(
|
||||
@Nullable String string,
|
||||
final @NotNull Context context
|
||||
) {
|
||||
if (string == null || string.isEmpty()) return Component.empty();
|
||||
if (string.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1) {
|
||||
string = string.replace(LegacyComponentSerializer.SECTION_CHAR, LegacyComponentSerializer.AMPERSAND_CHAR);
|
||||
@@ -97,7 +103,10 @@ public final class LegacyUtils {
|
||||
* @return a parsed string
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public static @NotNull Component parsePossibleLegacy(@Nullable String string, @NotNull final TagResolver resolver) {
|
||||
public static @NotNull Component parsePossibleLegacy(
|
||||
@Nullable String string,
|
||||
final @NotNull TagResolver resolver
|
||||
) {
|
||||
if (string == null || string.isEmpty()) return Component.empty();
|
||||
if (string.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1) {
|
||||
string = string.replace(LegacyComponentSerializer.SECTION_CHAR, LegacyComponentSerializer.AMPERSAND_CHAR);
|
||||
@@ -112,4 +121,47 @@ public final class LegacyUtils {
|
||||
resolver
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided string contains legacy formatting.
|
||||
*
|
||||
* @param string the string input
|
||||
* @return whether the string has legacy content
|
||||
* @see LegacyComponentSerializer#AMPERSAND_CHAR
|
||||
* @see LegacyComponentSerializer#SECTION_CHAR
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static boolean hasLegacyFormat(final String string) {
|
||||
requireNonNull(string, "string");
|
||||
return string.indexOf(LegacyComponentSerializer.SECTION_CHAR) != -1
|
||||
|| string.indexOf(LegacyComponentSerializer.AMPERSAND_CHAR) != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the input to a type depending on whether it contains legacy formatting or not.
|
||||
*
|
||||
* @param string the string input
|
||||
* @param legacyMapping the mapping function in case the string contains legacy formatting
|
||||
* @param modernMapping the mapping function in case the string does not contain any legacy character type,
|
||||
* being safe to use with MiniMessage
|
||||
* @return the mapped result
|
||||
* @param <R> the result type
|
||||
* @see LegacyComponentSerializer#AMPERSAND_CHAR
|
||||
* @see LegacyComponentSerializer#SECTION_CHAR
|
||||
* @see #hasLegacyFormat(String)
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public static <R> R mapLegacyOrElse(
|
||||
final @NotNull String string,
|
||||
final @NotNull Function<String, R> legacyMapping,
|
||||
final @NotNull Function<String, R> modernMapping
|
||||
) {
|
||||
requireNonNull(legacyMapping, "legacyMapping");
|
||||
requireNonNull(modernMapping, "modernInput");
|
||||
if (hasLegacyFormat(string)) {
|
||||
return legacyMapping.apply(string);
|
||||
} else {
|
||||
return modernMapping.apply(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ public final class TagsUtils {
|
||||
* @return a new basic self closing Tag of a string
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static @NotNull Tag staticTag(@NotNull String string) {
|
||||
return Tag.selfClosingInserting(Component.text(string));
|
||||
}
|
||||
@@ -51,6 +52,7 @@ public final class TagsUtils {
|
||||
* @return a new basic self closing Tag of a component
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Deprecated
|
||||
public static @NotNull Tag staticTag(@NotNull Component component) {
|
||||
return Tag.selfClosingInserting(component);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ package io.github.miniplaceholders.test;
|
||||
|
||||
import io.github.miniplaceholders.api.utils.LegacyUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.Inserting;
|
||||
import net.kyori.adventure.text.minimessage.tag.PreProcess;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LegacyTest {
|
||||
@Test
|
||||
@@ -17,4 +20,23 @@ class LegacyTest {
|
||||
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMapLegacyOrElse() {
|
||||
final String legacyInput = "&fhi <red>aaaa";
|
||||
Tag legacyProcessedTag = LegacyUtils.mapLegacyOrElse(
|
||||
legacyInput,
|
||||
legacy -> Tag.inserting(LegacyUtils.parsePossibleLegacy(legacy)),
|
||||
Tag::preProcessParsed
|
||||
);
|
||||
assertInstanceOf(Inserting.class, legacyProcessedTag);
|
||||
|
||||
final String modernInput = "<rainbow>aaaaaaaaaaaaa";
|
||||
Tag modernProcessedTag = LegacyUtils.mapLegacyOrElse(
|
||||
modernInput,
|
||||
__ -> fail(),
|
||||
Tag::preProcessParsed
|
||||
);
|
||||
assertInstanceOf(PreProcess.class, modernProcessedTag);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,8 @@ class MiniPlaceholdersTest {
|
||||
.build();
|
||||
expansion.register();
|
||||
|
||||
assertNotNull(MiniPlaceholders.getExpansionByName("testregistration"));
|
||||
|
||||
assertTrue(expansion.registered());
|
||||
assertThrows(IllegalStateException.class, expansion::register);
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ repositories {
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,5 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.configurationcache.extensions.capitalized
|
||||
|
||||
val Project.capitalizeName: String
|
||||
get() = this.name.substring(17).capitalized()
|
||||
get() = this.name.substring(17)
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
|
||||
|
||||
fun Project.simpleName(): String = this.name.substring(17)
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
options.release.set(21)
|
||||
}
|
||||
jar {
|
||||
manifest {
|
||||
@@ -22,7 +22,7 @@ tasks {
|
||||
|
||||
java{
|
||||
toolchain{
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
vendor.set(JvmVendorSpec.ADOPTIUM)
|
||||
}
|
||||
}
|
||||
@@ -5,76 +5,96 @@ plugins {
|
||||
signing
|
||||
id("org.jetbrains.dokka")
|
||||
}
|
||||
/*
|
||||
val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") {
|
||||
dependsOn(tasks.dokkaHtml)
|
||||
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
|
||||
archiveClassifier.set("javadoc")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifact(tasks["dokkaHtmlJar"])
|
||||
repositories {
|
||||
maven {
|
||||
credentials(PasswordCredentials::class)
|
||||
val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
|
||||
|
||||
if (project.version.toString().endsWith("SNAPSHOT")) {
|
||||
name = "SonatypeSnapshots"
|
||||
setUrl(snapshots)
|
||||
} else {
|
||||
name = "OSSRH"
|
||||
setUrl(central)
|
||||
}
|
||||
}
|
||||
}
|
||||
from(components["java"])
|
||||
pom {
|
||||
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
|
||||
licenses {
|
||||
license {
|
||||
name.set("Apache License 2.0")
|
||||
url.set("https://opensource.org/license/apache-2-0/")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection.set("scm:git:https://github.com/MiniPlaceholders/MiniPlaceholders.git")
|
||||
developerConnection.set("scm:git:ssh://git@github.com/MiniPlaceholders/MiniPlaceholders.git")
|
||||
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id.set("4drian3d")
|
||||
name.set("Adrian Gonzales")
|
||||
email.set("adriangonzalesval@gmail.com")
|
||||
}
|
||||
}
|
||||
issueManagement {
|
||||
name.set("GitHub")
|
||||
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/issues")
|
||||
}
|
||||
ciManagement {
|
||||
name.set("GitHub Actions")
|
||||
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/actions")
|
||||
}
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(configurations.archives.get())
|
||||
sign(publishing.publications["maven"])
|
||||
sign(tasks["dokkaHtmlJar"])
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}*/
|
||||
//val dokkaHtmlJar by tasks.registering(Jar::class) {
|
||||
// description = "A HTML Documentation JAR containing Dokka HTML"
|
||||
// from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
|
||||
// archiveClassifier.set("javadoc")
|
||||
//}
|
||||
//
|
||||
//dokka {
|
||||
// dokkaSourceSets.main {
|
||||
// includes.from("README.md")
|
||||
// sourceLink {
|
||||
// localDirectory.set(rootDir)
|
||||
// remoteUrl("https://github.com/MiniPlaceholders/MiniPlaceholders/tree/main")
|
||||
// remoteLineSuffix.set("#L")
|
||||
// }
|
||||
// }
|
||||
// pluginsConfiguration.html {
|
||||
// footerMessage.set("(c) MiniPlaceholders | 4drian3d")
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//publishing {
|
||||
// publications {
|
||||
// register<MavenPublication>("maven") {
|
||||
// artifact(dokkaHtmlJar)
|
||||
// repositories {
|
||||
// maven {
|
||||
// credentials {
|
||||
// username = property("sonatypeTokenUsername")?.toString() ?: ""
|
||||
// password = property("sonatypeTokenPassword")?.toString() ?: ""
|
||||
// }
|
||||
// val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
// val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
|
||||
//
|
||||
// if (project.version.toString().endsWith("SNAPSHOT")) {
|
||||
// name = "SonatypeSnapshots"
|
||||
// setUrl(snapshots)
|
||||
// } else {
|
||||
// name = "OSSRH"
|
||||
// setUrl(central)
|
||||
// }
|
||||
// }
|
||||
// maven(file("build/dev-maven")) {
|
||||
// name = "DevMaven"
|
||||
// }
|
||||
// }
|
||||
// from(components["java"])
|
||||
// pom {
|
||||
// url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
|
||||
// licenses {
|
||||
// license {
|
||||
// name.set("Apache License 2.0")
|
||||
// url.set("https://opensource.org/license/apache-2-0/")
|
||||
// }
|
||||
// }
|
||||
// scm {
|
||||
// connection.set("scm:git:https://github.com/MiniPlaceholders/MiniPlaceholders.git")
|
||||
// developerConnection.set("scm:git:ssh://git@github.com/MiniPlaceholders/MiniPlaceholders.git")
|
||||
// url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
|
||||
// }
|
||||
// developers {
|
||||
// developer {
|
||||
// id.set("4drian3d")
|
||||
// name.set("Adrian Gonzales")
|
||||
// email.set("adriangonzalesval@gmail.com")
|
||||
// }
|
||||
// }
|
||||
// issueManagement {
|
||||
// name.set("GitHub")
|
||||
// url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/issues")
|
||||
// }
|
||||
// ciManagement {
|
||||
// name.set("GitHub Actions")
|
||||
// url.set("https://github.com/MiniPlaceholders/MiniPlaceholders/actions")
|
||||
// }
|
||||
// name.set(project.name)
|
||||
// description.set(project.description)
|
||||
// url.set("https://github.com/MiniPlaceholders/MiniPlaceholders")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//signing {
|
||||
// useGpgCmd()
|
||||
// sign(configurations.archives.get())
|
||||
// sign(publishing.publications["maven"])
|
||||
// sign(dokkaHtmlJar.get())
|
||||
//}
|
||||
//
|
||||
//java {
|
||||
// withSourcesJar()
|
||||
//}
|
||||
@@ -9,7 +9,10 @@ publishing {
|
||||
create<MavenPublication>("maven") {
|
||||
repositories {
|
||||
maven {
|
||||
credentials(PasswordCredentials::class)
|
||||
credentials {
|
||||
username = property("sonatypeTokenUsername")?.toString() ?: ""
|
||||
password = property("sonatypeTokenPassword")?.toString() ?: ""
|
||||
}
|
||||
val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("miniplaceholders.base")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
tasks {
|
||||
@@ -9,10 +9,10 @@ tasks {
|
||||
archiveClassifier.set("")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
relocate("net.william278.desertwell", "io.github.miniplaceholders.libs.desertwell")
|
||||
relocate("cloud.commandframework", "io.github.miniplaceholders.libs.cloud")
|
||||
if (project.simpleName() != "sponge") {
|
||||
relocate("io.leangen.geantyref", "io.github.miniplaceholders.libs.geantyref")
|
||||
}
|
||||
relocate("org.incendo.cloud", "io.github.miniplaceholders.libs.cloud")
|
||||
// if (project.simpleName() != "sponge") {
|
||||
// relocate("io.leangen.geantyref", "io.github.miniplaceholders.libs.geantyref")
|
||||
// }
|
||||
destinationDirectory.set(file("${project.rootDir}/jar"))
|
||||
}
|
||||
build {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.20" apply false
|
||||
kotlin("jvm") version "2.1.10" apply false
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
@@ -14,7 +14,7 @@ dependencies {
|
||||
isTransitive = false
|
||||
}
|
||||
compileOnly(libs.adventure.api)
|
||||
compileOnly(libs.adventure.minimesssage)
|
||||
compileOnly(libs.adventure.minimessage)
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -1,198 +0,0 @@
|
||||
package io.github.miniplaceholders.common;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import cloud.commandframework.minecraft.extras.AudienceProvider;
|
||||
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler;
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.builder.AbstractBuilder;
|
||||
import net.kyori.adventure.permission.PermissionChecker;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.util.TriState;
|
||||
import net.william278.desertwell.about.AboutMenu;
|
||||
import net.william278.desertwell.util.Version;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static net.kyori.adventure.text.Component.newline;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
|
||||
public final class PlaceholdersCommand<A extends Audience> {
|
||||
private final Supplier<ArrayList<String>> playersSuggestions;
|
||||
private final Function<String, Audience> toAudience;
|
||||
private final BiPredicate<A, String> hasPermission;
|
||||
private final String command;
|
||||
private final CommandManager<A> commandManager;
|
||||
|
||||
private PlaceholdersCommand(
|
||||
final Supplier<ArrayList<String>> playersSuggestions,
|
||||
final Function<String, Audience> toAudience,
|
||||
final BiPredicate<A, String> hasPermission,
|
||||
final String command,
|
||||
final CommandManager<A> commandManager
|
||||
) {
|
||||
this.playersSuggestions = playersSuggestions;
|
||||
this.toAudience = toAudience;
|
||||
this.hasPermission = hasPermission;
|
||||
this.command = command;
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
private static final Component TITLE = miniMessage().deserialize("<gradient:#4d8bff:#a4ff96>MiniPlaceholders</gradient>");
|
||||
private static final Component HELP = text()
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:white:aqua><st><b> </st> <title> <st><b> </st>", Placeholder.component("title", TITLE)))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:#9694ff:#5269ff>Commands:</gradient>"))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>help</aqua>"))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>parse</aqua> <#8fadff><player | me></#8fadff> <#99ffb6><player></#99ffb6>"))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:white:aqua><st><b> "))
|
||||
.build();
|
||||
|
||||
private static final Component INFO = AboutMenu.builder()
|
||||
.title(TITLE)
|
||||
.description(text("MiniMessage Component-based Placeholders for Paper, Folia, Fabric, Velocity, Sponge and Krypton platforms"))
|
||||
.credits("Author", AboutMenu.Credit.of("4drian3d").url("https://github.com/4drian3d"))
|
||||
.credits("Contributors", AboutMenu.Credit.of("Sliman4"))
|
||||
.buttons(
|
||||
AboutMenu.Link.of("https://github.com/MiniPlaceholders/MiniPlaceholders/wiki/User-Getting-Started").text("Documentation").icon("⛏"),
|
||||
AboutMenu.Link.of("https://discord.gg/5NMMzK5mAn").text("Discord").color(TextColor.color(0x7289da)).icon("⭐"),
|
||||
AboutMenu.Link.of("https://modrinth.com/plugin/miniplaceholders").text("Downloads").color(TextColor.color(0xff496e)).icon("↓")
|
||||
).version(Version.fromString(PluginConstants.VERSION))
|
||||
.build()
|
||||
.toComponent();
|
||||
|
||||
private Command.Builder<A> rootBuilder() {
|
||||
return commandManager.commandBuilder(command);
|
||||
}
|
||||
|
||||
public void register() {
|
||||
new MinecraftExceptionHandler<A>()
|
||||
.withDefaultHandlers()
|
||||
.withDecorator(component -> Component.text().append(TITLE).appendSpace().append(component).build())
|
||||
.apply(commandManager, AudienceProvider.nativeAudience());
|
||||
|
||||
commandManager.command(rootBuilder()
|
||||
.permission(src -> {
|
||||
if (hasPermission != null) {
|
||||
return hasPermission.test(src, "miniplaceholders.command");
|
||||
}
|
||||
return src
|
||||
.get(PermissionChecker.POINTER)
|
||||
.map(checker -> checker.value("miniplaceholders.command"))
|
||||
.orElse(TriState.FALSE) != TriState.FALSE;
|
||||
})
|
||||
.handler(handler -> handler.getSender().sendMessage(INFO)));
|
||||
final CommandArgument<A, String> sourceArgument = StringArgument.<A>builder("source")
|
||||
.single()
|
||||
.withDefaultDescription(ArgumentDescription.of("The source from which the message will be parsed"))
|
||||
.withSuggestionsProvider((ctx, st) -> {
|
||||
final List<String> suggestions = playersSuggestions.get();
|
||||
suggestions.add("me");
|
||||
return suggestions;
|
||||
})
|
||||
.build();
|
||||
final CommandArgument<A, String> stringArgument = StringArgument.<A>builder("message")
|
||||
.greedy()
|
||||
.withDefaultDescription(ArgumentDescription.of("Message to be parsed"))
|
||||
.build();
|
||||
|
||||
commandManager.command(
|
||||
rootBuilder().literal("parse")
|
||||
.argument(sourceArgument)
|
||||
.argument(stringArgument)
|
||||
.permission("miniplaceholders.command.parse")
|
||||
.handler(handler -> {
|
||||
final String source = handler.get(sourceArgument);
|
||||
|
||||
final Audience objective = "me".equals(source)
|
||||
? handler.getSender()
|
||||
: toAudience.apply(source);
|
||||
if (objective == null){
|
||||
handler.getSender().sendMessage(text("You must specify a valid player", RED));
|
||||
return;
|
||||
}
|
||||
final String toParse = handler.get(stringArgument);
|
||||
|
||||
final Component parsed = miniMessage().deserialize(
|
||||
toParse,
|
||||
MiniPlaceholders.getAudienceGlobalPlaceholders(objective)
|
||||
);
|
||||
handler.getSender().sendMessage(parsed);
|
||||
})
|
||||
);
|
||||
commandManager.command(
|
||||
rootBuilder().literal("help")
|
||||
.permission("miniplaceholders.command.help")
|
||||
.handler(handler -> handler.getSender().sendMessage(HELP))
|
||||
);
|
||||
}
|
||||
|
||||
public static <A extends Audience> Builder<A> builder() {
|
||||
return new Builder<>();
|
||||
}
|
||||
|
||||
public final static class Builder<A extends Audience> implements AbstractBuilder<PlaceholdersCommand<A>> {
|
||||
private Supplier<ArrayList<String>> playersSuggestions;
|
||||
private Function<String, Audience> toAudience;
|
||||
private BiPredicate<A, String> hasPermission;
|
||||
private String command;
|
||||
private CommandManager<A> commandManager;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder<A> playerSuggestions(final Supplier<@NotNull ArrayList<@NotNull String>> playersSuggestions) {
|
||||
this.playersSuggestions = playersSuggestions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> toAudience(final @NotNull Function<@NotNull String, @Nullable Audience> argumentToAudience) {
|
||||
this.toAudience = argumentToAudience;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> hasPermissionCheck(final @NotNull BiPredicate<@NotNull A, @NotNull String> hasPermission) {
|
||||
this.hasPermission = hasPermission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> command(final String command) {
|
||||
this.command = command;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> manager(CommandManager<A> commandManager) {
|
||||
this.commandManager = commandManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlaceholdersCommand<A> build() {
|
||||
return new PlaceholdersCommand<>(
|
||||
requireNonNull(playersSuggestions),
|
||||
requireNonNull(toAudience),
|
||||
hasPermission,
|
||||
command,
|
||||
commandManager
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package io.github.miniplaceholders.common.command;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AudienceConverter {
|
||||
@Nullable Audience convert(@NotNull String string);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.github.miniplaceholders.common.command;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PermissionTester<S extends Audience> {
|
||||
boolean hasPermission(@NotNull S source, @NotNull String permission);
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package io.github.miniplaceholders.common.command;
|
||||
|
||||
import io.github.miniplaceholders.common.command.node.ExpansionsNode;
|
||||
import io.github.miniplaceholders.common.command.node.HelpNode;
|
||||
import io.github.miniplaceholders.common.command.node.ParseNode;
|
||||
import io.github.miniplaceholders.common.command.node.RootNode;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.builder.AbstractBuilder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.minecraft.extras.AudienceProvider;
|
||||
import org.incendo.cloud.minecraft.extras.MinecraftExceptionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
|
||||
public record PlaceholdersCommand<A extends Audience>(
|
||||
PlayerSuggestions playersSuggestions,
|
||||
AudienceConverter audienceConverter,
|
||||
PermissionTester<A> hasPermission,
|
||||
String command,
|
||||
CommandManager<A> commandManager
|
||||
) {
|
||||
|
||||
public static final Component TITLE = miniMessage().deserialize("<gradient:#4d8bff:#a4ff96>MiniPlaceholders</gradient>");
|
||||
public static final Component HEADER = miniMessage().deserialize(
|
||||
"<gradient:aqua:white:aqua><st><b> </st> <title> <st><b> </st>", Placeholder.component("title", TITLE));
|
||||
public static final Component FOOTER = miniMessage().deserialize(
|
||||
"<gradient:aqua:white:aqua><st><b> ");
|
||||
|
||||
public void register() {
|
||||
//noinspection unchecked
|
||||
MinecraftExceptionHandler.create(AudienceProvider.nativeAudience())
|
||||
.defaultHandlers()
|
||||
.decorator(component -> Component.text().append(TITLE).appendSpace().append(component))
|
||||
.registerTo((CommandManager<Audience>) commandManager);
|
||||
|
||||
// Nodes
|
||||
Stream.of(new RootNode<>(hasPermission), new HelpNode<A>(), new ParseNode<A>(playersSuggestions, audienceConverter), new ExpansionsNode<A>())
|
||||
.map(handler -> handler.apply(commandManager.commandBuilder(command)))
|
||||
.forEach(commandManager::command);
|
||||
}
|
||||
|
||||
public static <A extends Audience> Builder<A> builder() {
|
||||
return new Builder<>();
|
||||
}
|
||||
|
||||
public final static class Builder<A extends Audience> implements AbstractBuilder<PlaceholdersCommand<A>> {
|
||||
private PlayerSuggestions playersSuggestions;
|
||||
private AudienceConverter audienceConverter;
|
||||
private PermissionTester<A> hasPermission;
|
||||
private String command;
|
||||
private CommandManager<A> commandManager;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder<A> playerSuggestions(final @NotNull PlayerSuggestions playersSuggestions) {
|
||||
this.playersSuggestions = playersSuggestions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> toAudience(final @NotNull AudienceConverter audienceConverter) {
|
||||
this.audienceConverter = audienceConverter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> hasPermissionCheck(final @Nullable PermissionTester<A> hasPermission) {
|
||||
this.hasPermission = hasPermission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> command(final @NotNull String command) {
|
||||
this.command = command;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<A> manager(final @NotNull CommandManager<A> commandManager) {
|
||||
this.commandManager = commandManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlaceholdersCommand<A> build() {
|
||||
return new PlaceholdersCommand<>(
|
||||
requireNonNull(playersSuggestions),
|
||||
requireNonNull(audienceConverter),
|
||||
hasPermission,
|
||||
requireNonNull(command),
|
||||
requireNonNull(commandManager)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package io.github.miniplaceholders.common.command;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PlayerSuggestions {
|
||||
@NotNull ArrayList<String> suggest();
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package io.github.miniplaceholders.common.command.node;
|
||||
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.incendo.cloud.Command;
|
||||
|
||||
import static io.github.miniplaceholders.common.command.PlaceholdersCommand.FOOTER;
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
|
||||
public final class ExpansionsNode<S extends Audience> implements Node<S> {
|
||||
@Override
|
||||
public Command.Builder<S> apply(Command.Builder<S> rootBuilder) {
|
||||
return rootBuilder.literal("expansions")
|
||||
.permission("miniplaceholders.command.expansions")
|
||||
.handler(handler -> {
|
||||
TextComponent.Builder builder = Component.text()
|
||||
.appendNewline()
|
||||
.append(miniMessage().deserialize(
|
||||
"<gradient:aqua:white:aqua><st><b> </st> <gradient:#4d8bff:#a4ff96>MiniPlaceholders</gradient> Expansions <st><b> </gradient>"
|
||||
))
|
||||
.appendNewline()
|
||||
.append(MiniPlaceholders.getExpansionsAvailable()
|
||||
.map(expansion -> {
|
||||
final TextComponent.Builder expansionMetaBuilder = Component.text();
|
||||
final String expansionName = expansion.name();
|
||||
final String expansionAuthor = expansion.author();
|
||||
final String expansionVersion = expansion.version();
|
||||
|
||||
expansionMetaBuilder.append(Component.text(expansionName, NamedTextColor.GRAY));
|
||||
if (expansionAuthor != null) {
|
||||
expansionMetaBuilder.appendNewline()
|
||||
.append(Component.text("Author: ", TextColor.color(0x29fbff)))
|
||||
.append(Component.text(expansionAuthor, NamedTextColor.GRAY));
|
||||
}
|
||||
if (expansionVersion != null){
|
||||
expansionMetaBuilder.appendNewline()
|
||||
.append(Component.text("Version: ", TextColor.color(0xff7b61)))
|
||||
.append(Component.text(expansionVersion, NamedTextColor.GRAY));
|
||||
}
|
||||
return Component.text()
|
||||
.content(expansion.name())
|
||||
.hoverEvent(expansionMetaBuilder.build())
|
||||
.build();
|
||||
}).collect(Component.toComponent(Component.text(" | "))))
|
||||
.appendNewline()
|
||||
.append(FOOTER);
|
||||
handler.sender().sendMessage(builder.build());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.miniplaceholders.common.command.node;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.incendo.cloud.Command;
|
||||
|
||||
import static io.github.miniplaceholders.common.command.PlaceholdersCommand.FOOTER;
|
||||
import static io.github.miniplaceholders.common.command.PlaceholdersCommand.HEADER;
|
||||
import static net.kyori.adventure.text.Component.newline;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
|
||||
public final class HelpNode<S extends Audience> implements Node<S> {
|
||||
private static final Component HELP = text()
|
||||
.append(newline(), HEADER)
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:#9694ff:#5269ff>Commands:</gradient>"))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>help</aqua>"))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>parse</aqua> <#8fadff><player | me></#8fadff> <#99ffb6><player></#99ffb6>"))
|
||||
.append(newline(), miniMessage().deserialize(
|
||||
"<gradient:aqua:#94d1ff>/miniplaceholders</gradient> <aqua>expansions</aqua>"))
|
||||
.append(newline(), FOOTER)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public Command.Builder<S> apply(Command.Builder<S> rootBuilder) {
|
||||
return rootBuilder.literal("help")
|
||||
.permission("miniplaceholders.command.help")
|
||||
.handler(handler -> handler.sender().sendMessage(HELP));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.github.miniplaceholders.common.command.node;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.incendo.cloud.Command;
|
||||
|
||||
public sealed interface Node<S extends Audience> permits ExpansionsNode, HelpNode, ParseNode, RootNode {
|
||||
Command.Builder<S> apply(Command.Builder<S> rootBuilder);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package io.github.miniplaceholders.common.command.node;
|
||||
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import io.github.miniplaceholders.common.command.AudienceConverter;
|
||||
import io.github.miniplaceholders.common.command.PlayerSuggestions;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.component.CommandComponent;
|
||||
import org.incendo.cloud.component.TypedCommandComponent;
|
||||
import org.incendo.cloud.description.Description;
|
||||
import org.incendo.cloud.parser.standard.StringParser;
|
||||
import org.incendo.cloud.suggestion.SuggestionProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
|
||||
|
||||
public record ParseNode<S extends Audience>(
|
||||
PlayerSuggestions playerSuggestions,
|
||||
AudienceConverter audienceConverter
|
||||
) implements Node<S> {
|
||||
@Override
|
||||
public Command.Builder<S> apply(Command.Builder<S> rootBuilder) {
|
||||
final TypedCommandComponent<S, String> sourceArgument = CommandComponent.<S, String>ofType(String.class, "source")
|
||||
.parser(StringParser.stringParser(StringParser.StringMode.SINGLE))
|
||||
.description(Description.of("The source from which the message will be parsed"))
|
||||
.suggestionProvider(SuggestionProvider.blockingStrings((ctx, st) -> {
|
||||
final List<String> suggestions = playerSuggestions.suggest();
|
||||
suggestions.add("me");
|
||||
return suggestions;
|
||||
}))
|
||||
.build();
|
||||
final TypedCommandComponent<S, String> stringArgument = CommandComponent.<S, String>ofType(String.class, "message")
|
||||
.parser(StringParser.greedyStringParser())
|
||||
.description(Description.of("Message to be parsed"))
|
||||
.build();
|
||||
|
||||
return rootBuilder.literal("parse")
|
||||
.argument(sourceArgument)
|
||||
.argument(stringArgument)
|
||||
.permission("miniplaceholders.command.parse")
|
||||
.handler(handler -> {
|
||||
final String source = handler.get(sourceArgument);
|
||||
|
||||
final Audience objective = "me".equals(source)
|
||||
? handler.sender()
|
||||
: audienceConverter.convert(source);
|
||||
if (objective == null){
|
||||
handler.sender().sendMessage(text("You must specify a valid player", RED));
|
||||
return;
|
||||
}
|
||||
final String toParse = handler.get(stringArgument);
|
||||
|
||||
final Component parsed = miniMessage().deserialize(
|
||||
toParse,
|
||||
MiniPlaceholders.getAudienceGlobalPlaceholders(objective)
|
||||
);
|
||||
handler.sender().sendMessage(parsed);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package io.github.miniplaceholders.common.command.node;
|
||||
|
||||
import io.github.miniplaceholders.common.PluginConstants;
|
||||
import io.github.miniplaceholders.common.command.PermissionTester;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.permission.PermissionChecker;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.util.TriState;
|
||||
import net.william278.desertwell.about.AboutMenu;
|
||||
import net.william278.desertwell.util.Version;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.permission.Permission;
|
||||
import org.incendo.cloud.permission.PermissionResult;
|
||||
|
||||
import static io.github.miniplaceholders.common.command.PlaceholdersCommand.TITLE;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
|
||||
public record RootNode<S extends Audience>(PermissionTester<S> hasPermission) implements Node<S> {
|
||||
private static final Component INFO = AboutMenu.builder()
|
||||
.title(TITLE)
|
||||
.description(text("MiniMessage Component-based Placeholders for Paper, Folia, Fabric, Velocity and Sponge platforms"))
|
||||
.credits("Author", AboutMenu.Credit.of("4drian3d").url("https://github.com/4drian3d"))
|
||||
.credits("Contributors",
|
||||
AboutMenu.Credit.of("Sliman4"),
|
||||
AboutMenu.Credit.of("Stampede2011"),
|
||||
AboutMenu.Credit.of("powercasgamer")
|
||||
)
|
||||
.buttons(
|
||||
AboutMenu.Link.of("https://github.com/MiniPlaceholders/MiniPlaceholders/wiki/User-Getting-Started").text("Documentation").icon("⛏"),
|
||||
AboutMenu.Link.of("https://discord.gg/5NMMzK5mAn").text("Discord").color(TextColor.color(0x7289da)).icon("⭐"),
|
||||
AboutMenu.Link.of("https://modrinth.com/plugin/miniplaceholders").text("Downloads").color(TextColor.color(0xff496e)).icon("↓")
|
||||
).version(Version.fromString(PluginConstants.VERSION))
|
||||
.build()
|
||||
.toComponent();
|
||||
|
||||
@Override
|
||||
public Command.Builder<S> apply(Command.Builder<S> rootBuilder) {
|
||||
return rootBuilder
|
||||
.permission(src -> {
|
||||
if (hasPermission != null) {
|
||||
return PermissionResult.of(hasPermission.hasPermission(src, "miniplaceholders.command"), Permission.permission("miniplaceholders.command"));
|
||||
}
|
||||
return PermissionResult.of(src.get(PermissionChecker.POINTER)
|
||||
.map(checker -> checker.value("miniplaceholders.command"))
|
||||
.orElse(TriState.FALSE) != TriState.FALSE,
|
||||
Permission.permission("miniplaceholders.command")
|
||||
);
|
||||
})
|
||||
.handler(handler -> handler.sender().sendMessage(INFO));
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@ package io.github.miniplaceholders.connect;
|
||||
|
||||
public enum InternalPlatform {
|
||||
|
||||
PAPER, VELOCITY, KRYPTON, FABRIC, SPONGE;
|
||||
PAPER, VELOCITY,
|
||||
@Deprecated(forRemoval = true, since = "2.3.0")
|
||||
KRYPTON,
|
||||
FABRIC, SPONGE;
|
||||
|
||||
private static InternalPlatform actualPlatform;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id("miniplaceholders.auto.module")
|
||||
id("fabric-loom")
|
||||
id("quiet-fabric-loom")
|
||||
alias(libs.plugins.shadow)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ dependencies {
|
||||
|
||||
includeDependency(libs.adventure.platform.fabric)
|
||||
includeDependency(libs.adventure.serializer.legacy)
|
||||
includeDependency(libs.adventure.minimessage)
|
||||
includeDependency(libs.luckopermissionsapi)
|
||||
includeDependency(libs.cloud.fabric)
|
||||
includeDependency(libs.cloud.core)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package io.github.miniplaceholders.fabric;
|
||||
|
||||
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
|
||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.common.PlaceholdersCommand;
|
||||
import io.github.miniplaceholders.common.PluginConstants;
|
||||
import io.github.miniplaceholders.common.command.PlaceholdersCommand;
|
||||
import io.github.miniplaceholders.common.PlaceholdersPlugin;
|
||||
import io.github.miniplaceholders.connect.InternalPlatform;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
@@ -16,13 +15,15 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.packs.PackResources;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.incendo.cloud.SenderMapper;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.fabric.FabricServerCommandManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FabricMod implements ModInitializer, PlaceholdersPlugin {
|
||||
private final Logger logger = LoggerFactory.getLogger("miniplaceholders");
|
||||
@@ -47,11 +48,19 @@ public class FabricMod implements ModInitializer, PlaceholdersPlugin {
|
||||
@Override
|
||||
public void loadDefaultExpansions() {
|
||||
Expansion.builder("server")
|
||||
.author("MiniPlaceholders Contributors")
|
||||
.version(PluginConstants.VERSION)
|
||||
.globalPlaceholder("name", Tag.preProcessParsed(this.minecraftServer.getServerModName()))
|
||||
.globalPlaceholder("online", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getPlayerCount())))
|
||||
.globalPlaceholder("version", (ctx, queue) -> Tag.preProcessParsed(this.minecraftServer.getServerVersion()))
|
||||
.globalPlaceholder("max_players", (ctx, queue) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getMaxPlayers())))
|
||||
.globalPlaceholder("unique_joins", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.minecraftServer.getProfileCache().load().size())))
|
||||
.globalPlaceholder("unique_joins", (queue, ctx) -> {
|
||||
final var profileCache = this.minecraftServer.getProfileCache();
|
||||
if (profileCache == null) {
|
||||
return Tag.preProcessParsed("0");
|
||||
}
|
||||
return Tag.preProcessParsed(Integer.toString(profileCache.load().size()));
|
||||
})
|
||||
.globalPlaceholder("tps_1m", (ctx, queue) -> Tag.preProcessParsed(tickManager.getTps1m().formattedAverage()))
|
||||
.globalPlaceholder("tps_5m", (ctx, queue) -> Tag.preProcessParsed(tickManager.getTps5m().formattedAverage()))
|
||||
//.globalPlaceholder("tps_15m", (ctx, queue) -> Tag.preProcessParsed(tickManager.getTps15m().formattedAverage()))
|
||||
@@ -73,7 +82,7 @@ public class FabricMod implements ModInitializer, PlaceholdersPlugin {
|
||||
}
|
||||
return Tag.preProcessParsed(Integer.toString(entities));
|
||||
})
|
||||
.globalPlaceholder("mspt", (queue, ctx) -> Tag.preProcessParsed(MSPT_FORMAT.format(this.minecraftServer.getAverageTickTime())))
|
||||
.globalPlaceholder("mspt", (queue, ctx) -> Tag.preProcessParsed(MSPT_FORMAT.format(this.minecraftServer.getAverageTickTimeNanos())))
|
||||
.globalPlaceholder("datapack_list", (queue, ctx) ->
|
||||
Tag.selfClosingInserting(this.minecraftServer.getResourceManager()
|
||||
.listPacks()
|
||||
@@ -97,9 +106,8 @@ public class FabricMod implements ModInitializer, PlaceholdersPlugin {
|
||||
@Override
|
||||
public void registerPlatformCommand() {
|
||||
final FabricServerCommandManager<CommandSourceStack> commandManager = new FabricServerCommandManager<>(
|
||||
AsynchronousCommandExecutionCoordinator.simpleCoordinator(),
|
||||
Function.identity(),
|
||||
Function.identity()
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
SenderMapper.identity()
|
||||
);
|
||||
PlaceholdersCommand.<CommandSourceStack>builder()
|
||||
.hasPermissionCheck((source, permission) -> Permissions.check(source, permission, 4))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"id": "miniplaceholders",
|
||||
"version": "${version}",
|
||||
"name": "MiniPlaceholders",
|
||||
"description": "MiniMessage Component-based Placeholders for PaperMC, Fabric, Krypton and Velocity platforms",
|
||||
"description": "MiniMessage Component-based Placeholders for Paper, Fabric, Sponge, Folia and Velocity platforms",
|
||||
"authors": [
|
||||
"4drian3d"
|
||||
],
|
||||
@@ -22,8 +22,10 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.19",
|
||||
"fabric": "*",
|
||||
"java": ">=17",
|
||||
"minecraft": ">=1.20.2",
|
||||
"java": ">=21",
|
||||
"cloud": "*",
|
||||
"adventure-platform-fabric": "*",
|
||||
"minecraft": ">=1.21.4",
|
||||
"fabric-permissions-api-v0": "*"
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
group = io.github.miniplaceholders
|
||||
version = 2.2.3
|
||||
version = 2.3.0
|
||||
description = MiniMessage Component-based Placeholders for Paper, Fabric, Sponge, Folia and Velocity platforms
|
||||
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
|
||||
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
|
||||
+28
-39
@@ -2,27 +2,25 @@ metadata.format.version = "1.1"
|
||||
|
||||
[versions]
|
||||
|
||||
velocity = "3.2.0-SNAPSHOT"
|
||||
paper = "1.20.2-R0.1-SNAPSHOT"
|
||||
minecraft = "1.20.2"
|
||||
velocity = "3.4.0-SNAPSHOT"
|
||||
paper = "1.21.4-R0.1-SNAPSHOT"
|
||||
minecraft = "1.21.4"
|
||||
|
||||
runtask = "2.2.2"
|
||||
pluginyml = "0.6.0"
|
||||
userdev = "1.5.9"
|
||||
runtask = "2.3.1"
|
||||
blossom = "2.1.0"
|
||||
indra = "3.1.3"
|
||||
shadow = "8.1.1"
|
||||
jmh = "0.7.2"
|
||||
dokka = "1.9.10"
|
||||
shadow = "9.0.0-beta4"
|
||||
jmh = "0.7.3"
|
||||
dokka = "2.0.0"
|
||||
|
||||
cloud = "1.8.4"
|
||||
adventure = "4.14.0"
|
||||
adventurefabric = "5.10.1"
|
||||
brigadier = "1.0.500"
|
||||
kotlin="1.9.20"
|
||||
cloud = "2.0.0"
|
||||
cloud-minecraft = "2.0.0-SNAPSHOT"
|
||||
cloud-minecraft-modded = "2.0.0-beta.10"
|
||||
adventure = "4.19.0"
|
||||
adventureModded = "6.2.0"
|
||||
kotlin = "2.1.10"
|
||||
|
||||
fabric-api = "0.90.1+1.20.3"
|
||||
fabric-loader = "0.14.24"
|
||||
fabric-api = "0.114.3+1.21.5"
|
||||
fabric-loader = "0.16.10"
|
||||
|
||||
desertwell = "2.0.4"
|
||||
|
||||
@@ -34,42 +32,33 @@ minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft
|
||||
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
|
||||
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
|
||||
luckopermissionsapi = { group = "me.lucko", name = "fabric-permissions-api", version = "0.2-SNAPSHOT" }
|
||||
luckopermissionsapi = { group = "me.lucko", name = "fabric-permissions-api", version = "0.3.3" }
|
||||
|
||||
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
|
||||
adventure-minimesssage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
|
||||
adventure-platform-fabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurefabric" }
|
||||
adventure-minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
|
||||
adventure-platform-fabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventureModded" }
|
||||
adventure-serializer-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
|
||||
adventure-serializer-plain = { group = "net.kyori", name = "adventure-text-serializer-plain", version.ref = "adventure" }
|
||||
|
||||
cloud-core = { group = "cloud.commandframework", name = "cloud-core", version.ref = "cloud" }
|
||||
cloud-annotations = { group = "cloud.commandframework", name = "cloud-annotations", version.ref = "cloud" }
|
||||
cloud-velocity = { group = "cloud.commandframework", name = "cloud-velocity", version.ref = "cloud" }
|
||||
cloud-paper = { group = "cloud.commandframework", name = "cloud-paper", version.ref = "cloud" }
|
||||
cloud-fabric = { group = "cloud.commandframework", name = "cloud-fabric", version.ref = "cloud" }
|
||||
cloud-sponge = { group = "cloud.commandframework", name = "cloud-sponge", version = "1.8.0-SNAPSHOT" }
|
||||
cloud-extras = { group = "cloud.commandframework", name = "cloud-minecraft-extras", version.ref = "cloud" }
|
||||
cloud-core = { group = "org.incendo", name = "cloud-core", version.ref = "cloud" }
|
||||
cloud-velocity = { group = "org.incendo", name = "cloud-velocity", version.ref = "cloud-minecraft" }
|
||||
cloud-paper = { group = "org.incendo", name = "cloud-paper", version.ref = "cloud-minecraft" }
|
||||
cloud-fabric = { group = "org.incendo", name = "cloud-fabric", version.ref = "cloud-minecraft-modded" }
|
||||
cloud-extras = { group = "org.incendo", name = "cloud-minecraft-extras", version.ref = "cloud-minecraft" }
|
||||
|
||||
brigadier = { group = "com.mojang", name = "brigadier", version.ref = "brigadier" }
|
||||
|
||||
plugin-shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" }
|
||||
plugin-shadow = { module = "com.gradleup.shadow:shadow-gradle-plugin", version.ref = "shadow" }
|
||||
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
plugin-indra-common = { module = "net.kyori:indra-common", version.ref = "indra" }
|
||||
plugin-indra-spotless = { module = "net.kyori:indra-licenser-spotless", version.ref = "indra" }
|
||||
plugin-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.9.10"
|
||||
plugin-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
|
||||
|
||||
desertwell = { group = "net.william278", name = "DesertWell", version.ref = "desertwell" }
|
||||
|
||||
junit-bom = "org.junit:junit-bom:5.10.1"
|
||||
junit-bom = "org.junit:junit-bom:5.12.0"
|
||||
|
||||
[plugins]
|
||||
|
||||
pluginyml = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }
|
||||
userdev = { id = "io.papermc.paperweight.userdev", version.ref = "userdev" }
|
||||
runpaper = { id = "xyz.jpenilla.run-paper", version.ref = "runtask" }
|
||||
runvelocity = { id = "xyz.jpenilla.run-velocity", version.ref = "runtask" }
|
||||
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" }
|
||||
jmh = { id = "me.champeau.jmh", version.ref = "jmh" }
|
||||
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
|
||||
idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version = "1.1.7" }
|
||||
idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version = "1.1.10" }
|
||||
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.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
Vendored
+12
-10
@@ -13,6 +13,8 @@
|
||||
@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 ##########################################################################
|
||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# Package io.github.miniplaceholders.kotlin
|
||||
@@ -6,14 +6,14 @@ plugins {
|
||||
dependencies {
|
||||
compileOnly(kotlin("stdlib"))
|
||||
compileOnly(libs.adventure.api)
|
||||
compileOnly(libs.adventure.minimesssage)
|
||||
compileOnly(libs.adventure.minimessage)
|
||||
compileOnlyApi(projects.miniplaceholdersApi)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
explicitApi()
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
kotlin("kapt")
|
||||
alias(libs.plugins.shadow)
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://repo.kryptonmc.org/releases")
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
maven("https://repo.kryptonmc.org/snapshots")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.krypton.server)
|
||||
compileOnly(kotlin("stdlib"))
|
||||
kapt(libs.krypton.annotation)
|
||||
implementation(projects.miniplaceholdersCommon)
|
||||
implementation(projects.miniplaceholdersApi)
|
||||
implementation(projects.miniplaceholdersConnect)
|
||||
implementation(projects.miniplaceholdersKotlinExt)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package io.github.miniplaceholders.krypton
|
||||
|
||||
import com.google.inject.Inject
|
||||
import io.github.miniplaceholders.api.utils.TagsUtils
|
||||
import io.github.miniplaceholders.common.PlaceholdersCommand
|
||||
import io.github.miniplaceholders.common.PlaceholdersPlugin
|
||||
import io.github.miniplaceholders.common.PluginConstants
|
||||
import io.github.miniplaceholders.connect.InternalPlatform
|
||||
import io.github.miniplaceholders.kotlin.asClosingTag
|
||||
import io.github.miniplaceholders.kotlin.expansion
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.apache.logging.log4j.Logger
|
||||
import org.kryptonmc.api.command.BrigadierCommand
|
||||
import org.kryptonmc.api.command.CommandExecutionContext
|
||||
import org.kryptonmc.api.event.Listener
|
||||
import org.kryptonmc.api.event.server.ServerStartEvent
|
||||
import org.kryptonmc.api.plugin.annotation.Plugin
|
||||
import org.kryptonmc.krypton.KryptonServer
|
||||
import org.kryptonmc.krypton.command.KryptonCommandMeta
|
||||
|
||||
@Plugin(
|
||||
name = "MiniPlaceholders",
|
||||
id = "miniplaceholders",
|
||||
version = PluginConstants.VERSION,
|
||||
authors = ["4drian3d"]
|
||||
)
|
||||
class KotlinKryptonPlugin @Inject constructor(
|
||||
private val server: KryptonServer,
|
||||
private val logger: Logger
|
||||
) : PlaceholdersPlugin {
|
||||
|
||||
init {
|
||||
InternalPlatform.platform(InternalPlatform.KRYPTON)
|
||||
}
|
||||
|
||||
@Listener
|
||||
@Suppress("UNUSED")
|
||||
fun onServerStart(event: ServerStartEvent) {
|
||||
logger.info("Starting MiniPlaceholders Krypton")
|
||||
this.loadDefaultExpansions()
|
||||
this.registerPlatformCommand()
|
||||
}
|
||||
|
||||
override fun loadDefaultExpansions() {
|
||||
expansion("server") {
|
||||
globalPlaceholder("total_entities") { _, _ ->
|
||||
var entityCount = 0
|
||||
for ((_, value) in server.worldManager.worlds) {
|
||||
entityCount += value.entities.size
|
||||
}
|
||||
Component.text(entityCount).asClosingTag()
|
||||
}
|
||||
globalPlaceholder("total_chunks") { _, _ ->
|
||||
var chunkCount = 0
|
||||
for ((_, value) in server.worldManager.worlds) {
|
||||
chunkCount += value.chunks.size
|
||||
}
|
||||
Component.text(chunkCount).asClosingTag()
|
||||
}
|
||||
globalPlaceholder("name", TagsUtils.staticTag(server.platform.name))
|
||||
globalPlaceholder("online") { queue, _ ->
|
||||
if (queue.hasNext()) {
|
||||
val worldName = queue.pop().value()
|
||||
val players = server.players.filter { it.world.name == worldName }
|
||||
|
||||
return@globalPlaceholder Component.text(players.joinToString(", ")).asClosingTag()
|
||||
}
|
||||
Component.text(server.players.size).asClosingTag()
|
||||
}
|
||||
globalPlaceholder("version", TagsUtils.staticTag(server.platform.version))
|
||||
globalPlaceholder("max_players", Component.text(server.config.maxPlayers).asClosingTag())
|
||||
}.register()
|
||||
}
|
||||
|
||||
override fun registerPlatformCommand() {
|
||||
/*val command = PlaceholdersCommand.builder<CommandExecutionContext>()
|
||||
.fromSourceToAudience { it.sender }
|
||||
.playerSuggestions { server.players.map { it.name } }
|
||||
.toAudience { server.getPlayer(it) }
|
||||
.build()
|
||||
val brigadierCMD = BrigadierCommand.of(command.asNode("miniplaceholders"))
|
||||
val meta = KryptonCommandMeta.Builder("miniplaceholders").build()
|
||||
server.commandManager.register(brigadierCMD, meta)*/
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ dependencies {
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.20.2")
|
||||
minecraftVersion(libs.versions.minecraft.get())
|
||||
}
|
||||
processResources {
|
||||
filesMatching("paper-plugin.yml") {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package io.github.miniplaceholders.paper;
|
||||
|
||||
import io.github.miniplaceholders.common.command.PlaceholdersCommand;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.incendo.cloud.SenderMapper;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.paper.PaperCommandManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings({"unused", "UnstableApiUsage"})
|
||||
public final class PaperBootstrap implements PluginBootstrap {
|
||||
@Override
|
||||
public void bootstrap(@NotNull BootstrapContext bootstrapContext) {
|
||||
PaperCommandManager<SourceWrapper> commandManager = PaperCommandManager
|
||||
.builder(SenderMapper.create(SourceWrapper::new, SourceWrapper::stack))
|
||||
.executionCoordinator(ExecutionCoordinator.simpleCoordinator())
|
||||
.buildBootstrapped(bootstrapContext);
|
||||
|
||||
PlaceholdersCommand.<SourceWrapper>builder()
|
||||
.playerSuggestions(() -> Bukkit.getServer().getOnlinePlayers()
|
||||
.stream()
|
||||
.map(Player::getName)
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.toAudience(st -> Bukkit.getServer().getPlayer(st))
|
||||
.hasPermissionCheck((aud, p) -> aud.stack.getSender().hasPermission(p))
|
||||
.manager(commandManager)
|
||||
.command("miniplaceholders")
|
||||
.build()
|
||||
.register();
|
||||
|
||||
}
|
||||
|
||||
public record SourceWrapper(CommandSourceStack stack) implements ForwardingAudience.Single {
|
||||
|
||||
@Override
|
||||
public @NotNull Audience audience() {
|
||||
return this.stack.getSender();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,18 @@
|
||||
package io.github.miniplaceholders.paper;
|
||||
|
||||
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
|
||||
import cloud.commandframework.paper.PaperCommandManager;
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.common.PlaceholdersCommand;
|
||||
import io.github.miniplaceholders.common.PlaceholdersPlugin;
|
||||
import io.github.miniplaceholders.common.PluginConstants;
|
||||
import io.github.miniplaceholders.connect.InternalPlatform;
|
||||
import io.papermc.paper.datapack.Datapack;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin {
|
||||
@@ -37,12 +29,13 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin
|
||||
public void onEnable(){
|
||||
this.getSLF4JLogger().info("Starting MiniPlaceholders Paper");
|
||||
this.loadDefaultExpansions();
|
||||
this.registerPlatformCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultExpansions() {
|
||||
Expansion.builder("server")
|
||||
.version(PluginConstants.VERSION)
|
||||
.author("MiniPlaceholders Contributors")
|
||||
.globalPlaceholder("name", Tag.preProcessParsed(this.getServer().getName()))
|
||||
.globalPlaceholder("online", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(this.getServer().getOnlinePlayers().size())))
|
||||
.globalPlaceholder("version", Tag.preProcessParsed(this.getServer().getVersion()))
|
||||
@@ -80,30 +73,6 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"sonarlint(java:s1874)"})
|
||||
public void registerPlatformCommand() {
|
||||
try {
|
||||
PaperCommandManager<CommandSender> commandManager = new PaperCommandManager<>(
|
||||
this,
|
||||
AsynchronousCommandExecutionCoordinator.simpleCoordinator(),
|
||||
Function.identity(),
|
||||
Function.identity()
|
||||
);
|
||||
commandManager.registerBrigadier();
|
||||
|
||||
PlaceholdersCommand.<CommandSender>builder()
|
||||
.playerSuggestions(() -> getServer().getOnlinePlayers()
|
||||
.stream()
|
||||
.map(Player::getName)
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.toAudience(st -> getServer().getPlayer(st))
|
||||
.hasPermissionCheck(Permissible::hasPermission)
|
||||
.manager(commandManager)
|
||||
.command("miniplaceholders")
|
||||
.build()
|
||||
.register();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
name: MiniPlaceholders
|
||||
authors:
|
||||
- MiniPlaceholders Contributors
|
||||
version: '${version}'
|
||||
main: io.github.miniplaceholders.paper.PaperPlugin
|
||||
description: MiniMessage Component-based Placeholders for PaperMC, Krypton and Velocity platforms
|
||||
api-version: '1.19'
|
||||
bootstrapper: io.github.miniplaceholders.paper.PaperBootstrap
|
||||
description: MiniMessage Component-based Placeholders for Paper, Fabric, Sponge, Folia and Velocity platforms
|
||||
api-version: '1.21'
|
||||
folia-supported: true
|
||||
+1
-2
@@ -2,6 +2,5 @@
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"ignoreDeps": ["krypton", "krypton-api", "krypton-annotation-processor", "krypton-server"]
|
||||
]
|
||||
}
|
||||
+5
-5
@@ -11,13 +11,14 @@ pluginManagement {
|
||||
mavenCentral()
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://maven.quiltmc.org/repository/release/")
|
||||
maven("https://repo.jpenilla.xyz/snapshots/")
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://repo.maven.apache.org/maven2/")
|
||||
maven("https://jitpack.io") {
|
||||
mavenContent {
|
||||
@@ -30,9 +31,9 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("fabric-loom") version "1.4.4"
|
||||
id("org.spongepowered.gradle.plugin") version "2.2.0"
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
||||
id("quiet-fabric-loom") version "1.10.316"
|
||||
id("org.spongepowered.gradle.plugin") version "2.3.0" // sponge is disabled
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
|
||||
}
|
||||
|
||||
arrayOf(
|
||||
@@ -42,7 +43,6 @@ arrayOf(
|
||||
"common",
|
||||
"paper",
|
||||
"velocity",
|
||||
//"krypton",
|
||||
"fabric",
|
||||
"sponge"
|
||||
).forEach {
|
||||
|
||||
@@ -8,10 +8,12 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.miniplaceholdersCommon)
|
||||
implementation(projects.miniplaceholdersCommon) {
|
||||
exclude(group = "org.incendo")
|
||||
}
|
||||
implementation(projects.miniplaceholdersApi)
|
||||
implementation(projects.miniplaceholdersConnect)
|
||||
implementation(libs.cloud.sponge)
|
||||
//implementation(libs.cloud.sponge)
|
||||
}
|
||||
|
||||
sponge {
|
||||
@@ -40,8 +42,8 @@ sponge {
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
exclude("io/leangen/geantyref/**")
|
||||
}
|
||||
}
|
||||
//tasks {
|
||||
// shadowJar {
|
||||
// exclude("io/leangen/geantyref/**")
|
||||
// }
|
||||
//}
|
||||
@@ -1,37 +1,37 @@
|
||||
package io.github.miniplaceholders.sponge;
|
||||
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.sponge.SpongeCommandManager;
|
||||
import com.google.inject.Inject;
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.common.PlaceholdersCommand;
|
||||
//import io.github.miniplaceholders.common.command.PlaceholdersCommand;
|
||||
import io.github.miniplaceholders.common.PlaceholdersPlugin;
|
||||
import io.github.miniplaceholders.common.PluginConstants;
|
||||
import io.github.miniplaceholders.connect.InternalPlatform;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
//import net.kyori.adventure.audience.Audience;
|
||||
//import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
//import org.incendo.cloud.sponge7.SpongeCommandManager;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.command.Command;
|
||||
import org.spongepowered.api.command.CommandCause;
|
||||
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||
//import org.spongepowered.api.command.CommandCause;
|
||||
//import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
|
||||
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
|
||||
import org.spongepowered.api.world.server.ServerWorld;
|
||||
import org.spongepowered.plugin.PluginContainer;
|
||||
//import org.spongepowered.plugin.PluginContainer;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
//import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
//import java.util.stream.Collectors;
|
||||
|
||||
@Plugin("miniplaceholders")
|
||||
public class SpongePlugin implements PlaceholdersPlugin {
|
||||
|
||||
@Inject
|
||||
private PluginContainer pluginContainer;
|
||||
// @Inject
|
||||
// private PluginContainer pluginContainer;
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
@@ -58,6 +58,8 @@ public class SpongePlugin implements PlaceholdersPlugin {
|
||||
@Override
|
||||
public void loadDefaultExpansions() {
|
||||
Expansion.builder("server")
|
||||
.version(PluginConstants.VERSION)
|
||||
.author("MiniPlaceholders Contributors")
|
||||
.globalPlaceholder("name", Tag.preProcessParsed("Sponge"))
|
||||
.globalPlaceholder("online", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(server.onlinePlayers().size())))
|
||||
.globalPlaceholder("max_players", (queue, ctx) -> Tag.preProcessParsed(Integer.toString(server.maxPlayers())))
|
||||
@@ -85,31 +87,27 @@ public class SpongePlugin implements PlaceholdersPlugin {
|
||||
|
||||
@Override
|
||||
public void registerPlatformCommand() {
|
||||
final SpongeCommandManager<AudienceHolder> commandManager = new SpongeCommandManager<>(
|
||||
pluginContainer,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
AudienceHolder::cause,
|
||||
AudienceHolder::new
|
||||
);
|
||||
|
||||
PlaceholdersCommand.<AudienceHolder>builder()
|
||||
.manager(commandManager)
|
||||
.command("miniplaceholders")
|
||||
.playerSuggestions(() -> server.onlinePlayers()
|
||||
.stream()
|
||||
.map(ServerPlayer::name)
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.toAudience(st -> server.player(st).orElse(null))
|
||||
.hasPermissionCheck((holder, permission) -> holder.cause.hasPermission(permission))
|
||||
.build()
|
||||
.register();
|
||||
// Cloud 2 doesn't support Sponge 8 yet?
|
||||
// final SpongeCommandManager<AudienceHolder> commandManager = null;
|
||||
//
|
||||
// PlaceholdersCommand.<AudienceHolder>builder()
|
||||
// .manager(commandManager)
|
||||
// .command("miniplaceholders")
|
||||
// .playerSuggestions(() -> server.onlinePlayers()
|
||||
// .stream()
|
||||
// .map(ServerPlayer::name)
|
||||
// .collect(Collectors.toCollection(ArrayList::new)))
|
||||
// .toAudience(st -> server.player(st).orElse(null))
|
||||
// .hasPermissionCheck((holder, permission) -> holder.cause.hasPermission(permission))
|
||||
// .build()
|
||||
// .register();
|
||||
}
|
||||
|
||||
record AudienceHolder(@NotNull CommandCause cause) implements ForwardingAudience.Single {
|
||||
|
||||
@Override
|
||||
public @NotNull Audience audience() {
|
||||
return cause.audience();
|
||||
}
|
||||
}
|
||||
// record AudienceHolder(@NotNull CommandCause cause) implements ForwardingAudience.Single {
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull Audience audience() {
|
||||
// return cause.audience();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package io.github.miniplaceholders.velocity;
|
||||
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.velocity.CloudInjectionModule;
|
||||
import cloud.commandframework.velocity.VelocityCommandManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
@@ -15,22 +12,25 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.utils.Components;
|
||||
import io.github.miniplaceholders.common.PlaceholdersCommand;
|
||||
import io.github.miniplaceholders.common.command.PlaceholdersCommand;
|
||||
import io.github.miniplaceholders.common.PlaceholdersPlugin;
|
||||
import io.github.miniplaceholders.common.PluginConstants;
|
||||
import io.github.miniplaceholders.connect.InternalPlatform;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import org.incendo.cloud.SenderMapper;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.velocity.CloudInjectionModule;
|
||||
import org.incendo.cloud.velocity.VelocityCommandManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Plugin(
|
||||
name = "MiniPlaceholders",
|
||||
id = "miniplaceholders",
|
||||
version = PluginConstants.VERSION,
|
||||
authors = {"4drian3d"}
|
||||
authors = {"MiniPlaceholders Contributors", "4drian3d"}
|
||||
)
|
||||
public final class VelocityPlugin implements PlaceholdersPlugin {
|
||||
private final Logger logger;
|
||||
@@ -57,6 +57,8 @@ public final class VelocityPlugin implements PlaceholdersPlugin {
|
||||
@Override
|
||||
public void loadDefaultExpansions() {
|
||||
Expansion.builder("proxy")
|
||||
.author("MiniPlaceholders Contributors")
|
||||
.version(PluginConstants.VERSION)
|
||||
.globalPlaceholder("online_players", (queue, ctx) -> {
|
||||
if (queue.hasNext()) {
|
||||
String server = queue.pop().value();
|
||||
@@ -82,9 +84,8 @@ public final class VelocityPlugin implements PlaceholdersPlugin {
|
||||
injector = injector.createChildInjector(
|
||||
new CloudInjectionModule<>(
|
||||
CommandSource.class,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
Function.identity(),
|
||||
Function.identity()
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
SenderMapper.identity()
|
||||
)
|
||||
);
|
||||
final VelocityCommandManager<CommandSource> commandManager = injector.getInstance(
|
||||
|
||||
Reference in new issue
Block a user