Compare commits
8
Commits
feat/extensions
...
1.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e8a881b51 | ||
|
|
8bb9bafb8b | ||
|
|
74f14f139c | ||
|
|
45b2fbe977 | ||
|
|
df04f51d60 | ||
|
|
5b35094d27 | ||
|
|
927563f749 | ||
|
|
225bafeaaa |
No files matched your search
@@ -25,7 +25,7 @@ jobs:
|
||||
command: gradle build
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: MiniPlaceholders
|
||||
path: build/libs/MiniPlaceholders.jar
|
||||
path: build/libs/MiniPlaceholders-*.jar
|
||||
@@ -2,7 +2,6 @@ package me.dreamerzero.miniplaceholders.api;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -14,6 +13,8 @@ import me.dreamerzero.miniplaceholders.connect.InternalPlatform;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* MiniPlaceholders
|
||||
*
|
||||
@@ -36,9 +37,11 @@ public final class MiniPlaceholders {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static @NotNull Platform getPlatform() {
|
||||
return InternalPlatform.platform() == InternalPlatform.PAPER
|
||||
? Platform.PAPER
|
||||
: Platform.VELOCITY;
|
||||
switch (InternalPlatform.platform()) {
|
||||
case PAPER: return Platform.PAPER;
|
||||
case VELOCITY: return Platform.VELOCITY;
|
||||
default: return Platform.KRYPTON;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +76,7 @@ public final class MiniPlaceholders {
|
||||
*/
|
||||
@Contract("null -> fail, !null -> !null")
|
||||
public static @NotNull TagResolver getAudiencePlaceholders(final @NotNull Audience audience) {
|
||||
Objects.requireNonNull(audience, () -> "audience cannot be null");
|
||||
requireNonNull(audience, "audience cannot be null");
|
||||
|
||||
final TagResolver.Builder resolvers = TagResolver.builder();
|
||||
for (Expansion expansion : expansions) {
|
||||
@@ -97,8 +100,8 @@ public final class MiniPlaceholders {
|
||||
*/
|
||||
@Contract("_, null -> fail; null, _ -> fail; !null, !null -> !null")
|
||||
public static @NotNull TagResolver getRelationalPlaceholders(final @NotNull Audience audience, final @NotNull Audience otherAudience) {
|
||||
Objects.requireNonNull(audience, () -> "audience cannot be null");
|
||||
Objects.requireNonNull(otherAudience, () -> "otherAudience cannot be null");
|
||||
requireNonNull(audience, "audience cannot be null");
|
||||
requireNonNull(otherAudience, "otherAudience cannot be null");
|
||||
|
||||
final TagResolver.Builder builder = TagResolver.builder();
|
||||
for (final Expansion expansion : expansions) {
|
||||
@@ -131,7 +134,7 @@ public final class MiniPlaceholders {
|
||||
*/
|
||||
@Contract("_, null -> fail; null, _ -> fail; !null, !null -> !null")
|
||||
public static @NotNull TagResolver getAudienceGlobalPlaceholders(final @NotNull Audience audience) {
|
||||
Objects.requireNonNull(audience, () -> "audience cannot be null");
|
||||
requireNonNull(audience, "audience cannot be null");
|
||||
final TagResolver.Builder builder = TagResolver.builder();
|
||||
|
||||
for (final Expansion expansion : expansions) {
|
||||
@@ -165,8 +168,8 @@ public final class MiniPlaceholders {
|
||||
*/
|
||||
@Contract("_, null -> fail; null, _ -> fail; !null, !null -> !null")
|
||||
public static @NotNull TagResolver getRelationalGlobalPlaceholders(final @NotNull Audience audience, final @NotNull Audience otherAudience) {
|
||||
Objects.requireNonNull(audience, () -> "audience cannot be null");
|
||||
Objects.requireNonNull(otherAudience, () -> "otherAudience cannot be null");
|
||||
requireNonNull(audience, "audience cannot be null");
|
||||
requireNonNull(otherAudience, "otherAudience cannot be null");
|
||||
|
||||
final TagResolver.Builder builder = TagResolver.builder();
|
||||
for (final Expansion expansion : expansions) {
|
||||
|
||||
@@ -5,5 +5,7 @@ public enum Platform {
|
||||
/**Paper Platform */
|
||||
PAPER,
|
||||
/**Velocity Platform */
|
||||
VELOCITY
|
||||
VELOCITY,
|
||||
/**Krypton Platform */
|
||||
KRYPTON;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
module me.dreamerzero.miniplaceholders.api {
|
||||
/** MiniPlaceholdes API Module */
|
||||
open module me.dreamerzero.miniplaceholders.api {
|
||||
requires net.kyori.adventure;
|
||||
requires net.kyori.examination.api;
|
||||
requires net.kyori.adventure.text.minimessage;
|
||||
|
||||
+3
-5
@@ -6,10 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
group = "me.dreamerzero.miniplaceholders"
|
||||
version = "1.2.0"
|
||||
description = "MiniPlaceholders"
|
||||
apply<JavaPlugin>()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -18,6 +15,7 @@ dependencies {
|
||||
shadow(project(":miniplaceholders-common"))
|
||||
shadow(project(":miniplaceholders-velocity"))
|
||||
shadow(project(":miniplaceholders-paper", "reobf"))
|
||||
shadow(project(":miniplaceholders-krypton"))
|
||||
}
|
||||
|
||||
subprojects {
|
||||
@@ -30,7 +28,7 @@ subprojects {
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
archiveFileName.set("MiniPlaceholders.jar")
|
||||
archiveFileName.set("MiniPlaceholders-$version.jar")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
configurations = listOf(project.configurations.shadow.get())
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ dependencies {
|
||||
}
|
||||
|
||||
blossom{
|
||||
replaceToken("{version}", version)
|
||||
replaceToken("{version}", project.version)
|
||||
replaceTokenIn("src/main/java/me/dreamerzero/miniplaceholders/common/PluginConstants.java")
|
||||
}
|
||||
|
||||
@@ -24,4 +24,10 @@ tasks {
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to "me.dreamerzero.miniplaceholders.common")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package me.dreamerzero.miniplaceholders.connect;
|
||||
|
||||
public enum InternalPlatform {
|
||||
|
||||
PAPER, VELOCITY;
|
||||
PAPER, VELOCITY, KRYPTON;
|
||||
|
||||
private static InternalPlatform actualPlatform;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
module me.dreamerzero.miniplaceholders.connect {
|
||||
//TODO: exports to
|
||||
exports me.dreamerzero.miniplaceholders.connect;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
group = me.dreamerzero.miniplaceholders
|
||||
version = 1.3.0
|
||||
description = MiniPlaceholders
|
||||
@@ -0,0 +1,13 @@
|
||||
repositories {
|
||||
maven("https://repo.kryptonmc.org/releases")
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
maven("https://repo.kryptonmc.org/snapshots")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.kryptonmc:krypton-server:0.66.3")
|
||||
annotationProcessor("org.kryptonmc:annotation-processor:0.66.2")
|
||||
compileOnly(project(":miniplaceholders-common"))
|
||||
compileOnly(project(":miniplaceholders-api"))
|
||||
compileOnly(project(":miniplaceholders-connect"))
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package me.dreamerzero.miniplaceholders.krypton;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kryptonmc.api.Server;
|
||||
import org.kryptonmc.api.command.BrigadierCommand;
|
||||
import org.kryptonmc.api.command.Sender;
|
||||
import org.kryptonmc.api.entity.player.Player;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.dreamerzero.miniplaceholders.api.Expansion;
|
||||
import me.dreamerzero.miniplaceholders.api.utils.TagsUtils;
|
||||
import me.dreamerzero.miniplaceholders.common.PlaceholdersCommand;
|
||||
import me.dreamerzero.miniplaceholders.common.PlaceholdersPlugin;
|
||||
import me.dreamerzero.miniplaceholders.common.PluginConstants;
|
||||
import me.dreamerzero.miniplaceholders.connect.InternalPlatform;
|
||||
import me.lucko.spark.api.statistic.StatisticWindow;
|
||||
|
||||
@Plugin(
|
||||
name = "MiniPlaceholders",
|
||||
id = "miniplaceholders",
|
||||
version = PluginConstants.VERSION,
|
||||
authors = {"4drian3d"}
|
||||
)
|
||||
public class JavaKryptonPlugin implements PlaceholdersPlugin {
|
||||
private final KryptonServer server;
|
||||
private final Logger logger;
|
||||
|
||||
@Inject
|
||||
public JavaKryptonPlugin(Server server, Logger logger) {
|
||||
this.logger = logger;
|
||||
this.server = (KryptonServer)server;
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerStart(ServerStartEvent event) {
|
||||
logger.info("Starting MiniPlaceholders Krypton");
|
||||
|
||||
InternalPlatform.platform(InternalPlatform.KRYPTON);
|
||||
|
||||
this.loadDefaultExpansions();
|
||||
this.registerPlatformCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadDefaultExpansions() {
|
||||
Expansion.builder("server")
|
||||
.globalPlaceholder("total_entities", (queue, ctx) -> {
|
||||
int entityCount = 0;
|
||||
for (var entry : server.getWorldManager().getWorlds().entrySet()) {
|
||||
entityCount += entry.getValue().entities().size();
|
||||
}
|
||||
return TagsUtils.staticTag(Component.text(entityCount));
|
||||
})
|
||||
.globalPlaceholder("total_chunks", (queque, ctx) -> {
|
||||
int chunkCount = 0;
|
||||
for(var entry : server.getWorldManager().getWorlds().entrySet()) {
|
||||
chunkCount += entry.getValue().chunks().size();
|
||||
}
|
||||
return TagsUtils.staticTag(Component.text(chunkCount));
|
||||
})
|
||||
.globalPlaceholder("name", TagsUtils.staticTag(server.getPlatform().getName()))
|
||||
.globalPlaceholder("online", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getPlayers().size())))
|
||||
.globalPlaceholder("version", TagsUtils.staticTag(server.getPlatform().getVersion()))
|
||||
.globalPlaceholder("max_players", TagsUtils.staticTag(Component.text(server.getMaxPlayers())))
|
||||
.globalPlaceholder("has_whitelist", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getPlayerManager().getWhitelistEnabled())))
|
||||
.globalPlaceholder("tps_1", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().tps().poll(StatisticWindow.TicksPerSecond.MINUTES_1))))
|
||||
.globalPlaceholder("tps_5", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().tps().poll(StatisticWindow.TicksPerSecond.MINUTES_5))))
|
||||
.globalPlaceholder("tps_15", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().tps().poll(StatisticWindow.TicksPerSecond.MINUTES_15))))
|
||||
.globalPlaceholder("mspt", (queue, ctx) -> TagsUtils.staticTag(Component.text(server.getSpark().mspt().poll(StatisticWindow.MillisPerTick.SECONDS_10).mean())))
|
||||
.build()
|
||||
.register();
|
||||
}
|
||||
|
||||
private static final PlainTextComponentSerializer SERIALIZER = PlainTextComponentSerializer.plainText();
|
||||
|
||||
@Override
|
||||
public void registerPlatformCommand() {
|
||||
final PlaceholdersCommand<Sender> command = new PlaceholdersCommand<>(
|
||||
() -> server.getPlayers()
|
||||
.stream()
|
||||
.map(Player::name)
|
||||
.map(SERIALIZER::serialize)
|
||||
.toList(),
|
||||
server::player);
|
||||
final BrigadierCommand brigadierCMD = BrigadierCommand.of(command.placeholderTestCommand("miniplaceholders"));
|
||||
|
||||
server.getCommandManager().register(brigadierCMD);
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,13 @@ dependencies {
|
||||
paperDevBundle("1.19.1-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
val pluginVersion: String = version as String
|
||||
|
||||
bukkit {
|
||||
name = "MiniPlaceholders"
|
||||
main = "me.dreamerzero.miniplaceholders.paper.PaperPlugin"
|
||||
apiVersion = "1.18"
|
||||
website = "https://github.com/4drian3d/MiniPlaceholders"
|
||||
authors = listOf("4drian3d")
|
||||
version = pluginVersion
|
||||
version = project.version as String
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
@@ -36,5 +34,10 @@ tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.19.1")
|
||||
}
|
||||
jar {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to "me.dreamerzero.miniplaceholders.paper")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import io.papermc.paper.datapack.Datapack;
|
||||
@@ -20,7 +19,7 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin, Listener {
|
||||
public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin {
|
||||
private final DecimalFormat tpsFormat = new DecimalFormat("###.##");
|
||||
private final DecimalFormat msptFormat = new DecimalFormat("###.###");
|
||||
|
||||
@@ -28,7 +27,6 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin,
|
||||
public void onEnable(){
|
||||
this.getSLF4JLogger().info("Starting MiniPlaceholders Paper");
|
||||
InternalPlatform.platform(InternalPlatform.PAPER);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
tpsFormat.setRoundingMode(RoundingMode.HALF_UP);
|
||||
msptFormat.setRoundingMode(RoundingMode.HALF_UP);
|
||||
@@ -77,7 +75,7 @@ public final class PaperPlugin extends JavaPlugin implements PlaceholdersPlugin,
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"sonarlint(java:s1874)", "deprecation", /*TODO: replace with Java(536871800) */ "all"})
|
||||
@SuppressWarnings({"sonarlint(java:s1874)", /*TODO: replace with Java(536871800) */ "all"})
|
||||
public void registerPlatformCommand() {
|
||||
MinecraftServer.getServer()
|
||||
.vanillaCommandDispatcher
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ pluginManagement {
|
||||
|
||||
rootProject.name = "miniplaceholders-parent"
|
||||
|
||||
val modules = listOf("connect", "api", "common", "paper", "velocity")
|
||||
val modules = listOf("connect", "api", "common", "paper", "velocity", "krypton")
|
||||
|
||||
modules.forEach {
|
||||
include("miniplaceholders-$it")
|
||||
|
||||
@@ -8,8 +8,16 @@ dependencies {
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to "me.dreamerzero.miniplaceholders.velocity")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user