Command related patches

This commit is contained in:
AlphaKR93
2025-02-24 01:53:56 +09:00
parent 637b0ef8cb
commit 55fbffae38
24 changed files with 1029 additions and 402 deletions

View File

@@ -1,36 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Sat, 14 Dec 2024 11:06:41 +0900
Subject: [PATCH] Tick toggle subcommand
diff --git a/src/main/java/net/minecraft/server/commands/TickCommand.java b/src/main/java/net/minecraft/server/commands/TickCommand.java
index 13d96b54f48d60b098b80e04ba6168762c335c75..5aab945085eb4ed2ea44832319c6daad96fe3a71 100644
--- a/src/main/java/net/minecraft/server/commands/TickCommand.java
+++ b/src/main/java/net/minecraft/server/commands/TickCommand.java
@@ -21,6 +21,10 @@ public class TickCommand {
dispatcher.register(
Commands.literal("tick")
.requires(source -> source.hasPermission(3))
+ // Plazma start - Tick toggle subcommand
+ .executes(context -> toggleFreeze(context.getSource()))
+ .then(Commands.literal("toggle").executes(context -> toggleFreeze(context.getSource())))
+ // Plazma end - Tick toggle subcommand
.then(Commands.literal("query").executes(context -> tickQuery(context.getSource())))
.then(
Commands.literal("rate")
@@ -108,6 +112,14 @@ public class TickCommand {
return 1;
}
+ // Plazma start - Tick toggle subcommand
+ private static int toggleFreeze(CommandSourceStack source) {
+ ServerTickRateManager serverTickRateManager = source.getServer().tickRateManager();
+ boolean frozen = !serverTickRateManager.isFrozen();
+ return setFreeze(source, frozen);
+ }
+ // Plazma end - Tick toggle subcommand
+
private static int setFreeze(CommandSourceStack source, boolean frozen) {
ServerTickRateManager serverTickRateManager = source.getServer().tickRateManager();
if (frozen) {

View File

@@ -1,263 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Wed, 25 Dec 2024 13:24:51 +0900
Subject: [PATCH] Add options to modify configurations path
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
index 21a3761f075ace896c981936b2810fccb0b5d610..d99adf4a0b430b8a1ae41d3f4f04ad0c7a6e7eaa 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -135,7 +135,7 @@ public class PaperVersionFetcher implements VersionFetcher {
}
private @Nullable Component getHistory() {
- final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
+ final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.getInstance().getVersionData(); // Plazma - Add options to modify the configuration files
if (data == null) {
return null;
}
diff --git a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
index 660b2ec6b63a4ceffee44ab11f54dfa7c0d0996f..aa936d21bd458deef5672ddd782897c41daa765e 100644
--- a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
+++ b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
@@ -19,8 +19,24 @@ import org.bukkit.Bukkit;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-public enum VersionHistoryManager {
- INSTANCE;
+// Plazma start - Add options to modify the configuration files
+public final class VersionHistoryManager {
+ private static VersionHistoryManager INSTANCE;
+
+ public static VersionHistoryManager getInstance() {
+ if (INSTANCE == null) {
+ throw new IllegalStateException("VersionHistoryManager has not been initialized yet");
+ }
+ return INSTANCE;
+ }
+
+ public static void initialize(final joptsimple.OptionSet options) {
+ if (INSTANCE != null) {
+ throw new IllegalStateException("VersionHistoryManager has already been initialized");
+ }
+ INSTANCE = new VersionHistoryManager((java.io.File) options.valueOf("version-history"));
+ }
+ // Plazma end - Add options to modify the configuration files
private final Gson gson = new Gson();
@@ -28,8 +44,10 @@ public enum VersionHistoryManager {
private VersionData currentData = null;
- VersionHistoryManager() {
- final Path path = Paths.get("version_history.json");
+ // Plazma start - Add options to modify the configuration files
+ private VersionHistoryManager(final @Nonnull java.io.File file) {
+ final Path path = file.toPath();
+ // Plazma end - Add options to modify the configuration files
if (Files.exists(path)) {
// Basic file santiy checks
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
index 06323dcc745aed16123980fc559d7b65c42f1e1c..ee37957264b7830c29a72f76ef4d7729bc66040c 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
@@ -117,7 +117,7 @@ public class PufferfishVersionFetcher implements VersionFetcher {
}
private @Nullable Component getHistory() {
- final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.getInstance().getVersionData(); // Plazma - Add options to modify the configuration files
if (data == null) {
return null;
}
@@ -129,4 +129,4 @@ public class PufferfishVersionFetcher implements VersionFetcher {
return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 3e211e6ea16c8110e662d6201e8325ecd3d6a93b..011cdc8dbef3e823bdccf1a1c7cf945cf0cf7005 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -256,7 +256,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
org.purpurmc.purpur.PurpurConfig.registerCommands();
// Purpur end - Purpur config files
- com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
+ com.destroystokyo.paper.VersionHistoryManager.initialize(this.options); // Paper - load version history now // Plazma - Add options to modify the configuration files
gg.pufferfish.pufferfish.PufferfishConfig.pufferfishFile = (java.io.File) options.valueOf("pufferfish-settings"); // Purpur - Fix pufferfish issues
gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish
gg.pufferfish.pufferfish.PufferfishCommand.init(); // Pufferfish
diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java
index 1f2958d21c279ecb377b7c90ba643ea83e217eca..6a411f609c48b28115b947494062f9f7bf5b2d93 100644
--- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java
+++ b/src/main/java/net/minecraft/server/players/OldUsersConverter.java
@@ -82,7 +82,7 @@ public class OldUsersConverter {
}
public static boolean convertUserBanlist(final MinecraftServer server) {
- final UserBanList gameprofilebanlist = new UserBanList(PlayerList.USERBANLIST_FILE);
+ final UserBanList gameprofilebanlist = new UserBanList((File) server.options.valueOf("banned-players")); // Plazma - Configurable player list file path
if (OldUsersConverter.OLD_USERBANLIST.exists() && OldUsersConverter.OLD_USERBANLIST.isFile()) {
if (gameprofilebanlist.getFile().exists()) {
@@ -140,7 +140,7 @@ public class OldUsersConverter {
}
public static boolean convertIpBanlist(MinecraftServer server) {
- IpBanList ipbanlist = new IpBanList(PlayerList.IPBANLIST_FILE);
+ IpBanList ipbanlist = new IpBanList((File) server.options.valueOf("banned-ips")); // Plazma - Configurable player list file path
if (OldUsersConverter.OLD_IPBANLIST.exists() && OldUsersConverter.OLD_IPBANLIST.isFile()) {
if (ipbanlist.getFile().exists()) {
@@ -181,7 +181,7 @@ public class OldUsersConverter {
}
public static boolean convertOpsList(final MinecraftServer server) {
- final ServerOpList oplist = new ServerOpList(PlayerList.OPLIST_FILE);
+ final ServerOpList oplist = new ServerOpList((File) server.options.valueOf("ops")); // Plazma - Configurable player list file path
if (OldUsersConverter.OLD_OPLIST.exists() && OldUsersConverter.OLD_OPLIST.isFile()) {
if (oplist.getFile().exists()) {
@@ -225,7 +225,7 @@ public class OldUsersConverter {
}
public static boolean convertWhiteList(final MinecraftServer server) {
- final UserWhiteList whitelist = new UserWhiteList(PlayerList.WHITELIST_FILE);
+ final UserWhiteList whitelist = new UserWhiteList((File) server.options.valueOf("whitelist")); // Plazma - Configurable player list file path
if (OldUsersConverter.OLD_WHITELIST.exists() && OldUsersConverter.OLD_WHITELIST.isFile()) {
if (whitelist.getFile().exists()) {
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index d5d09bf63f4b7fba73188f75d5fe9599b8da2844..8ab6df63d9a22ac76b2ba14bc8fef318e65484c8 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -126,10 +126,12 @@ import org.bukkit.event.player.PlayerSpawnChangeEvent;
public abstract class PlayerList {
+ /* // Plazma - Configurable player list file path
public static final File USERBANLIST_FILE = new File("banned-players.json");
public static final File IPBANLIST_FILE = new File("banned-ips.json");
public static final File OPLIST_FILE = new File("ops.json");
public static final File WHITELIST_FILE = new File("whitelist.json");
+ */ // Plazma - Configurable player list file path
public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full");
public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login");
private static final Logger LOGGER = LogUtils.getLogger();
@@ -167,14 +169,12 @@ public abstract class PlayerList {
server.console = new com.destroystokyo.paper.console.TerminalConsoleCommandSender(); // Paper
// CraftBukkit end
- this.bans = new UserBanList(PlayerList.USERBANLIST_FILE);
- this.ipBans = new IpBanList(PlayerList.IPBANLIST_FILE);
- this.ops = new ServerOpList(PlayerList.OPLIST_FILE);
- this.whitelist = new UserWhiteList(PlayerList.WHITELIST_FILE);
- // CraftBukkit start
- // this.stats = Maps.newHashMap();
- // this.advancements = Maps.newHashMap();
- // CraftBukkit end
+ // Plazma start - Configurable player list file path
+ this.bans = new UserBanList((File) server.options.valueOf("banned-players"));
+ this.ipBans = new IpBanList((File) server.options.valueOf("banned-ips"));
+ this.ops = new ServerOpList((File) server.options.valueOf("ops"));
+ this.whitelist = new UserWhiteList((File) server.options.valueOf("whitelist"));
+ // Plazma end - Configurable player list file path
this.server = server;
this.registries = registryManager;
this.maxPlayers = maxPlayers;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 15527e902484496a6804c879d1de589bed3f8713..b2f924d0236683dc0a994350efe9a9db54b2ab98 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -276,12 +276,12 @@ public final class CraftServer implements Server {
private final ServicesManager servicesManager = new SimpleServicesManager();
private final CraftScheduler scheduler = new CraftScheduler();
private final CraftCommandMap commandMap; // Paper - Move down
- private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
+ private final SimpleHelpMap helpMap;
private final StandardMessenger messenger = new StandardMessenger();
private final SimplePluginManager pluginManager; // Paper - Move down
public final io.papermc.paper.plugin.manager.PaperPluginManagerImpl paperPluginManager; // Paper
private final StructureManager structureManager;
- protected final DedicatedServer console;
+ public final DedicatedServer console; // Plazma - AT (protected -> public)
protected final DedicatedPlayerList playerList;
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
@@ -421,6 +421,7 @@ public final class CraftServer implements Server {
Bukkit.setServer(this);
// Paper start
+ this.helpMap = new SimpleHelpMap(this); // Plazma - Add options to modify the configuration files
this.commandMap = new CraftCommandMap(this);
this.pluginManager = new SimplePluginManager(this, commandMap);
this.paperPluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(this, this.commandMap, pluginManager);
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index a75f3328ba32466b6ceeddb0069c856524f19c0a..913213c77fa2cf8038768a34b38bb59d698e714b 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -205,6 +205,44 @@ public class Main {
.defaultsTo(new File(org.plazmamc.plazma.configurations.PlazmaConfigurations.CONFIG_DIR))
.describedAs("Configuration Directory");
// Plazma end - Configurable Plazma
+
+ // Plazma start - Configurable player data storage
+ acceptsAll(asList("banned-ips"), "File for banned IPs")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("banned-ips.json"))
+ .describedAs("JSON file");
+
+ acceptsAll(asList("banned-players"), "File for banned players")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("banned-players.json"))
+ .describedAs("JSON file");
+
+ acceptsAll(asList("ops"), "File for ops")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("ops.json"))
+ .describedAs("JSON file");
+
+ acceptsAll(asList("whitelist"), "File for whitelist")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("whitelist.json"))
+ .describedAs("JSON file");
+
+ acceptsAll(asList("version-history"), "File for version history")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("version_history.json"))
+ .describedAs("JSON file");
+
+ acceptsAll(asList("help"), "File for help command")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("help.yml"))
+ .describedAs("Yaml file");
+ // Plazma end - Configurable player data storage
}
};
diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
index 5923d3c17756c489fcb392044c0679fe52e2d58f..3ec5cf874dfd9d2e016daa9f7c7aee2646e67861 100644
--- a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
+++ b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
@@ -25,7 +25,7 @@ public class HelpYamlReader {
public HelpYamlReader(Server server) {
this.server = server;
- File helpYamlFile = new File("help.yml");
+ File helpYamlFile = (File) ((org.bukkit.craftbukkit.CraftServer) server).console.options.valueOf("help"); // Plazma - Add options to modify the configuration files
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), Charsets.UTF_8));
try {

View File

@@ -1,35 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Wed, 25 Dec 2024 19:10:40 +0900
Subject: [PATCH] Add missing argument place for /compass command
diff --git a/src/main/java/org/purpurmc/purpur/command/CompassCommand.java b/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
index 79b8490832d2a0cc7846ddcb091cb6bcac74ea45..bc4bdb86dc9a8f454058e0e9555e0af6f70d6b37 100644
--- a/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
+++ b/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
@@ -22,6 +22,24 @@ public class CompassCommand {
}
return 1;
})
+ // Plazma start - Add missing argument place for /compass command
+ .then(Commands.argument("targets", net.minecraft.commands.arguments.EntityArgument.players())
+ .requires(listener -> listener.hasPermission(2, "bukkit.command.compass.other"))
+ .executes(context -> {
+ for (ServerPlayer player : net.minecraft.commands.arguments.EntityArgument.getPlayers(context, "targets")) {
+ CompassTask task = CompassTask.instance();
+ if (player.compassBar()) {
+ task.removePlayer(player.getBukkitEntity());
+ player.compassBar(false);
+ } else {
+ task.addPlayer(player.getBukkitEntity());
+ player.compassBar(true);
+ }
+ }
+ return net.minecraft.commands.arguments.EntityArgument.getPlayers(context, "targets").size();
+ })
+ )
+ // Plazma end - Add missing argument place for /compass command
);
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Services.java
+++ b/net/minecraft/server/Services.java
@@ -6,26 +_,42 @@
@@ -6,35 +_,55 @@
import com.mojang.authlib.yggdrasil.ServicesKeyType;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import java.io.File;
@@ -47,11 +47,14 @@
public static Services create(YggdrasilAuthenticationService authenticationService, File profileRepository, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files; add userCacheFile parameter
MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService();
GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository();
@@ -34,7 +_,11 @@
final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath();
GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, userCacheFile); // Paper - use specified user cache file
// Paper start - load paper config files from cli options
- final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath();
+ //final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath(); // Plazma - Remove legacy paper config transformation
final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath();
io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, profileRepository.toPath(), (File) optionSet.valueOf("spigot-settings"));
- io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, profileRepository.toPath(), (File) optionSet.valueOf("spigot-settings"));
- return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations);
+ io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(configDirPath, profileRepository.toPath(), (File) optionSet.valueOf("spigot-settings")); // Plazma - Remove legacy paper config transformation
+
+ // Plazma start - Configurable Plazma
+ final org.plazmamc.plazma.configurations.PlazmaConfigurations plazmaConfigurations = org.plazmamc.plazma.configurations.PlazmaConfigurations.create(optionSet);

View File

@@ -0,0 +1,24 @@
--- a/net/minecraft/server/commands/TickCommand.java
+++ b/net/minecraft/server/commands/TickCommand.java
@@ -21,6 +_,8 @@
dispatcher.register(
Commands.literal("tick")
.requires(commandSourceStack -> commandSourceStack.hasPermission(3))
+ .executes(context -> toggleFreeze(context.getSource()))
+ .then(Commands.literal("toggle").executes(context -> toggleFreeze(context.getSource())))
.then(Commands.literal("query").executes(commandContext -> tickQuery(commandContext.getSource())))
.then(
Commands.literal("rate")
@@ -113,6 +_,12 @@
source.sendSuccess(() -> Component.translatable("commands.tick.status.sprinting"), true);
return 1;
}
+
+ // Plazma start - /tick toggle
+ private static int toggleFreeze(final CommandSourceStack source) {
+ return setFreeze(source, !source.getServer().tickRateManager().isFrozen());
+ }
+ // Plazma end - /tick toggle
private static int setFreeze(CommandSourceStack source, boolean frozen) {
ServerTickRateManager serverTickRateManager = source.getServer().tickRateManager();

View File

@@ -140,7 +140,7 @@
this.server.spark.enableEarlyIfRequested(); // Paper - spark
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
if (this.convertOldUsers()) {
@@ -234,15 +_,7 @@
@@ -234,16 +_,8 @@
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
@@ -153,10 +153,12 @@
- }
- org.purpurmc.purpur.PurpurConfig.registerCommands();
- */// Purpur end - Purpur config files // Purpur - Configurable void damage height and damage
- com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
+ // noinspection ResultOfMethodCallIgnored // Plazma - For preloading
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
+ com.destroystokyo.paper.VersionHistoryManager.initialize(options); // Paper - load version history now // Plazma - Add options to modify the configuration files
this.setPvpAllowed(properties.pvp);
this.setFlightAllowed(properties.allowFlight);
@@ -287,8 +_,7 @@
LOGGER.warn("**** FAILED TO BIND TO PORT!");
LOGGER.warn("The exception was: {}", var10.toString());

View File

@@ -65,3 +65,12 @@
}
// Contributed by Techcable <Techcable@outlook.com> in GH-65
@@ -131,7 +_,7 @@
}
private @Nullable Component getHistory() {
- final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
+ final VersionHistoryManager.@Nullable VersionData data = VersionHistoryManager.getInstance().getVersionData(); // Plazma - Add options to modify configuration paths
if (data == null) {
return null;
}

View File

@@ -0,0 +1,42 @@
--- a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
+++ b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
@@ -19,8 +_,26 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-public enum VersionHistoryManager {
- INSTANCE;
+public final class VersionHistoryManager { // Plazma - Add options to modify configuration paths
+
+ // Plazma start - Add options to modify configuration paths
+ private static VersionHistoryManager INSTANCE;
+
+ @org.jetbrains.annotations.Contract(pure = true)
+ public static @org.jspecify.annotations.NonNull VersionHistoryManager getInstance() {
+ if (INSTANCE == null) {
+ throw new IllegalStateException("VersionHistoryManager has not been initialized yet");
+ }
+ return INSTANCE;
+ }
+
+ public static void initialize(final joptsimple.@org.jspecify.annotations.NonNull OptionSet options) {
+ if (INSTANCE != null) {
+ throw new IllegalStateException("VersionHistoryManager has already been initialized");
+ }
+ INSTANCE = new VersionHistoryManager(((java.io.File) options.valueOf("version-history")).toPath());
+ }
+ // Plazma end - Add options to modify configuration paths
private final Gson gson = new Gson();
@@ -28,9 +_,7 @@
private VersionData currentData = null;
- VersionHistoryManager() {
- final Path path = Paths.get("version_history.json");
-
+ private VersionHistoryManager(final @org.jspecify.annotations.NonNull Path path) { // Plazma - Add options to modify configuration paths
if (Files.exists(path)) {
// Basic file santiy checks
if (!Files.isRegularFile(path)) {

View File

@@ -1,6 +1,19 @@
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -83,62 +_,6 @@
@@ -18,10 +_,10 @@
import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer;
import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer;
import io.papermc.paper.configuration.transformation.Transformations;
-import io.papermc.paper.configuration.transformation.global.LegacyPaperConfig;
+//import io.papermc.paper.configuration.transformation.global.LegacyPaperConfig; // Plazma - Remove legacy paper config transformations
import io.papermc.paper.configuration.transformation.global.versioned.V29_LogIPs;
import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration;
-import io.papermc.paper.configuration.transformation.world.LegacyPaperWorldConfig;
+//import io.papermc.paper.configuration.transformation.world.LegacyPaperWorldConfig; // Plazma - Remove legacy paper config transformations
import io.papermc.paper.configuration.transformation.world.versioned.V29_ZeroWorldHeight;
import io.papermc.paper.configuration.transformation.world.versioned.V30_RenameFilterNbtFromSpawnEgg;
import io.papermc.paper.configuration.transformation.world.versioned.V31_SpawnLoadedRangeToGameRule;
@@ -83,64 +_,8 @@
@SuppressWarnings("Convert2Diamond")
public class PaperConfigurations extends Configurations<GlobalConfiguration, WorldConfiguration> {
@@ -61,8 +74,11 @@
- """;
-
@VisibleForTesting
public static final Supplier<SpigotWorldConfig> SPIGOT_WORLD_DEFAULTS = Suppliers.memoize(() -> new SpigotWorldConfig(RandomStringUtils.randomAlphabetic(255)) {
- public static final Supplier<SpigotWorldConfig> SPIGOT_WORLD_DEFAULTS = Suppliers.memoize(() -> new SpigotWorldConfig(RandomStringUtils.randomAlphabetic(255)) {
+ public static final Supplier<SpigotWorldConfig> SPIGOT_WORLD_DEFAULTS = Suppliers.memoize(() -> new SpigotWorldConfig(java.util.UUID.randomUUID().toString()) { // Plazma - Use modern method
@Override // override to ensure "verbose" is false
public void init() {
SpigotConfig.readConfig(SpigotWorldConfig.class, this);
@@ -148,28 +_,71 @@
});
public static final ContextKey<Supplier<SpigotWorldConfig>> SPIGOT_WORLD_CONFIG_CONTEXT_KEY = new ContextKey<>(new TypeToken<Supplier<SpigotWorldConfig>>() {}, "spigot world config");
@@ -286,10 +302,11 @@
return createWorldContextMap(level.levelStorageAccess.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig, level.registryAccess(), level.getGameRules());
}
@@ -347,102 +_,10 @@
@@ -346,103 +_,8 @@
.build();
}
public static PaperConfigurations setup(final Path legacyConfig, final Path configDir, final Path worldFolder, final File spigotConfig) throws Exception {
- public static PaperConfigurations setup(final Path legacyConfig, final Path configDir, final Path worldFolder, final File spigotConfig) throws Exception {
- final Path legacy = Files.isSymbolicLink(legacyConfig) ? Files.readSymbolicLink(legacyConfig) : legacyConfig;
- if (needsConverting(legacyConfig)) {
- final String legacyFileName = legacyConfig.getFileName().toString();
@@ -386,9 +403,7 @@
- worlds.set(level.getWorld().getName(), YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile()));
- }
- return global;
+ if (Files.exists(legacyConfig) && Files.isRegularFile(legacyConfig)) {
+ throw new RuntimeException("Since Plazma 1.21.4, support for the conversion of legacy paper configuration has been terminated. Remove the legacy paper configuration file or use the previous version of Plazma and convert the configuration first.");
+ }
+ public static PaperConfigurations setup(/*final Path legacyConfig,*/ final Path configDir, final Path worldFolder, final File spigotConfig) throws Exception { // Plazma - Remove legacy paper config transformation
+ return new PaperConfigurations(configDir);
}

View File

@@ -0,0 +1,224 @@
--- a/src/main/java/io/papermc/paper/configuration/transformation/global/LegacyPaperConfig.java
+++ /dev/null
@@ -1,221 +_,0 @@
-package io.papermc.paper.configuration.transformation.global;
-
-import com.mojang.logging.LogUtils;
-import io.papermc.paper.configuration.Configuration;
-import java.util.function.Predicate;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.format.NamedTextColor;
-import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
-import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket;
-import org.bukkit.ChatColor;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.slf4j.Logger;
-import org.spongepowered.configurate.ConfigurationNode;
-import org.spongepowered.configurate.transformation.ConfigurationTransformation;
-import org.spongepowered.configurate.transformation.TransformAction;
-
-import static org.spongepowered.configurate.NodePath.path;
-
-public final class LegacyPaperConfig {
- private static final Logger LOGGER = LogUtils.getClassLogger();
-
- private LegacyPaperConfig() {
- }
-
- public static ConfigurationTransformation transformation(final YamlConfiguration spigotConfiguration) {
- return ConfigurationTransformation.chain(versioned(), notVersioned(spigotConfiguration));
- }
-
- // Represents version transforms lifted directly from the old PaperConfig class
- // must be run BEFORE the "settings" flatten
- private static ConfigurationTransformation.Versioned versioned() {
- return ConfigurationTransformation.versionedBuilder()
- .versionKey(Configuration.LEGACY_CONFIG_VERSION_FIELD)
- .addVersion(11, ConfigurationTransformation.builder().addAction(path("settings", "play-in-use-item-spam-threshold"), TransformAction.rename("incoming-packet-spam-threshold")).build())
- .addVersion(14, ConfigurationTransformation.builder().addAction(path("settings", "spam-limiter", "tab-spam-increment"), (path, value) -> {
- if (value.getInt() == 10) {
- value.set(2);
- }
- return null;
- }).build())
- .addVersion(15, ConfigurationTransformation.builder().addAction(path("settings"), (path, value) -> {
- value.node("async-chunks", "threads").set(-1);
- return null;
- }).build())
- .addVersion(21, ConfigurationTransformation.builder().addAction(path("use-display-name-in-quit-message"), (path, value) -> new Object[]{"settings", "use-display-name-in-quit-message"}).build())
- .addVersion(23, ConfigurationTransformation.builder().addAction(path("settings", "chunk-loading", "global-max-chunk-load-rate"), (path, value) -> {
- if (value.getDouble() == 300.0) {
- value.set(-1.0);
- }
- return null;
- }).build())
- .addVersion(25, ConfigurationTransformation.builder().addAction(path("settings", "chunk-loading", "player-max-concurrent-loads"), (path, value) -> {
- if (value.getDouble() == 4.0) {
- value.set(20.0);
- }
- return null;
- }).build())
- .build();
- }
-
- // other non-versioned transforms found in PaperConfig
- // must be run BEFORE the "settings" flatten
- private static ConfigurationTransformation notVersioned(final YamlConfiguration spigotConfiguration) {
- return ConfigurationTransformation.builder()
- .addAction(path("settings"), (path, value) -> {
- final ConfigurationNode node = value.node("async-chunks");
- if (node.hasChild("load-threads")) {
- if (!node.hasChild("threads")) {
- node.node("threads").set(node.node("load-threads").getInt());
- }
- node.removeChild("load-threads");
- }
- node.removeChild("generation");
- node.removeChild("enabled");
- node.removeChild("thread-per-world-generation");
- return null;
- })
- .addAction(path("allow-perm-block-break-exploits"), (path, value) -> new Object[]{"settings", "unsupported-settings", "allow-permanent-block-break-exploits"})
- .addAction(path("settings", "unsupported-settings", "allow-tnt-duplication"), TransformAction.rename("allow-piston-duplication"))
- .addAction(path("settings", "save-player-data"), (path, value) -> {
- final Object val = value.raw();
- if (val instanceof Boolean bool) {
- spigotConfiguration.set("players.disable-saving", !bool);
- }
- value.raw(null);
- return null;
- })
- .addAction(path("settings", "log-named-entity-deaths"), (path, value) -> {
- final Object val = value.raw();
- if (val instanceof Boolean bool && !bool) {
- spigotConfiguration.set("settings.log-named-deaths", false);
- }
- value.raw(null);
- return null;
- })
- .build();
- }
-
- // transforms to new format with configurate
- // must be run AFTER the "settings" flatten
- public static ConfigurationTransformation toNewFormat() {
- return ConfigurationTransformation.chain(
- ConfigurationTransformation.versionedBuilder().versionKey(Configuration.LEGACY_CONFIG_VERSION_FIELD).addVersion(Configuration.FINAL_LEGACY_VERSION + 1, newFormatTransformation()).build(),
- ConfigurationTransformation.builder().addAction(path(Configuration.LEGACY_CONFIG_VERSION_FIELD), TransformAction.rename(Configuration.VERSION_FIELD)).build() // rename to _version to place at the top
- );
- }
-
- private static ConfigurationTransformation newFormatTransformation() {
- final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder()
- .addAction(path("verbose"), TransformAction.remove()) // not needed
- .addAction(path("unsupported-settings", "allow-headless-pistons-readme"), TransformAction.remove())
- .addAction(path("unsupported-settings", "allow-permanent-block-break-exploits-readme"), TransformAction.remove())
- .addAction(path("unsupported-settings", "allow-piston-duplication-readme"), TransformAction.remove())
- .addAction(path("packet-limiter", "limits", "all"), (path, value) -> new Object[]{"packet-limiter", "all-packets"})
- .addAction(path("packet-limiter", "limits"), (path, value) -> new Object[]{"packet-limiter", "overrides"})
- .addAction(path("packet-limiter", "overrides", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> {
- final Object keyValue = value.key();
- if (keyValue != null && keyValue.toString().equals("PacketPlayInAutoRecipe")) { // add special cast to handle the default for moj-mapped servers that upgrade the config
- return path.with(path.size() - 1, ServerboundPlaceRecipePacket.class.getSimpleName()).array();
- }
- return null;
- }).addAction(path("loggers"), TransformAction.rename("logging"));
-
- moveFromRootAndRename(builder, "incoming-packet-spam-threshold", "incoming-packet-threshold", "spam-limiter");
-
- moveFromRoot(builder, "save-empty-scoreboard-teams", "scoreboards");
- moveFromRoot(builder, "track-plugin-scoreboards", "scoreboards");
-
- moveFromRoot(builder, "suggest-player-names-when-null-tab-completions", "commands");
- moveFromRoot(builder, "time-command-affects-all-worlds", "commands");
- moveFromRoot(builder, "fix-target-selector-tag-completion", "commands");
-
- moveFromRoot(builder, "log-player-ip-addresses", "loggers");
-
- moveFromRoot(builder, "use-display-name-in-quit-message", "messages");
-
- moveFromRootAndRename(builder, "console-has-all-permissions", "has-all-permissions", "console");
-
- moveFromRootAndRename(builder, "bungee-online-mode", "online-mode", "proxies", "bungee-cord");
- moveFromRootAndRename(builder, "velocity-support", "velocity", "proxies");
-
- moveFromRoot(builder, "book-size", "item-validation");
- moveFromRoot(builder, "resolve-selectors-in-books", "item-validation");
-
- moveFromRoot(builder, "enable-player-collisions", "collisions");
- moveFromRoot(builder, "send-full-pos-for-hard-colliding-entities", "collisions");
-
- moveFromRootAndRename(builder, "player-auto-save-rate", "rate", "player-auto-save");
- moveFromRootAndRename(builder, "max-player-auto-save-per-tick", "max-per-tick", "player-auto-save");
-
- moveFromRootToMisc(builder, "max-joins-per-tick");
- moveFromRootToMisc(builder, "fix-entity-position-desync");
- moveFromRootToMisc(builder, "load-permissions-yml-before-plugins");
- moveFromRootToMisc(builder, "region-file-cache-size");
- moveFromRootToMisc(builder, "use-alternative-luck-formula");
- moveFromRootToMisc(builder, "lag-compensate-block-breaking");
- moveFromRootToMisc(builder, "use-dimension-type-for-custom-spawners");
-
- moveFromRoot(builder, "proxy-protocol", "proxies");
-
- miniMessageWithTranslatable(builder, String::isBlank, "multiplayer.disconnect.authservers_down", "messages", "kick", "authentication-servers-down");
- miniMessageWithTranslatable(builder, Predicate.isEqual("Flying is not enabled on this server"), "multiplayer.disconnect.flying", "messages", "kick", "flying-player");
- miniMessageWithTranslatable(builder, Predicate.isEqual("Flying is not enabled on this server"), "multiplayer.disconnect.flying", "messages", "kick", "flying-vehicle");
- miniMessage(builder, "messages", "kick", "connection-throttle");
- miniMessage(builder, "messages", "no-permission");
- miniMessageWithTranslatable(builder, Predicate.isEqual("&cSent too many packets"), Component.translatable("disconnect.exceeded_packet_rate", NamedTextColor.RED), "packet-limiter", "kick-message");
-
- return builder.build();
- }
-
- private static void miniMessageWithTranslatable(final ConfigurationTransformation.Builder builder, final Predicate<String> englishCheck, final String i18nKey, final String... strPath) {
- miniMessageWithTranslatable(builder, englishCheck, Component.translatable(i18nKey), strPath);
- }
- private static void miniMessageWithTranslatable(final ConfigurationTransformation.Builder builder, final Predicate<String> englishCheck, final Component component, final String... strPath) {
- builder.addAction(path((Object[]) strPath), (path, value) -> {
- final Object val = value.raw();
- if (val != null) {
- final String strVal = val.toString();
- if (!englishCheck.test(strVal)) {
- value.set(miniMessage(strVal));
- return null;
- }
- }
- value.set(MiniMessage.miniMessage().serialize(component));
- return null;
- });
- }
-
- private static void miniMessage(final ConfigurationTransformation.Builder builder, final String... strPath) {
- builder.addAction(path((Object[]) strPath), (path, value) -> {
- final Object val = value.raw();
- if (val != null) {
- value.set(miniMessage(val.toString()));
- }
- return null;
- });
- }
-
- @SuppressWarnings("deprecation") // valid use to convert legacy string to mini-message in legacy migration
- private static String miniMessage(final String input) {
- return MiniMessage.miniMessage().serialize(LegacyComponentSerializer.legacySection().deserialize(ChatColor.translateAlternateColorCodes('&', input)));
- }
-
- private static void moveFromRootToMisc(final ConfigurationTransformation.Builder builder, final String key) {
- moveFromRoot(builder, key, "misc");
- }
-
- private static void moveFromRoot(final ConfigurationTransformation.Builder builder, final String key, final String... parents) {
- moveFromRootAndRename(builder, key, key, parents);
- }
-
- private static void moveFromRootAndRename(final ConfigurationTransformation.Builder builder, final String oldKey, final String newKey, final String... parents) {
- builder.addAction(path(oldKey), (path, value) -> {
- final Object[] newPath = new Object[parents.length + 1];
- newPath[parents.length] = newKey;
- System.arraycopy(parents, 0, newPath, 0, parents.length);
- return newPath;
- });
- }
-}

View File

@@ -0,0 +1,323 @@
--- a/src/main/java/io/papermc/paper/configuration/transformation/world/LegacyPaperWorldConfig.java
+++ /dev/null
@@ -1,320 +_,0 @@
-package io.papermc.paper.configuration.transformation.world;
-
-import io.papermc.paper.configuration.Configuration;
-import io.papermc.paper.configuration.WorldConfiguration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-import net.minecraft.core.Holder;
-import net.minecraft.core.registries.BuiltInRegistries;
-import net.minecraft.core.registries.Registries;
-import net.minecraft.resources.ResourceKey;
-import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.entity.MobCategory;
-import net.minecraft.world.item.Item;
-import org.bukkit.Material;
-import org.spongepowered.configurate.transformation.ConfigurationTransformation;
-import org.spongepowered.configurate.transformation.TransformAction;
-
-import static io.papermc.paper.configuration.transformation.Transformations.moveFromRoot;
-import static io.papermc.paper.configuration.transformation.Transformations.moveFromRootAndRename;
-import static org.spongepowered.configurate.NodePath.path;
-
-public final class LegacyPaperWorldConfig {
-
- private LegacyPaperWorldConfig() {
- }
-
- public static ConfigurationTransformation transformation() {
- return ConfigurationTransformation.chain(versioned(), notVersioned());
- }
-
- private static ConfigurationTransformation.Versioned versioned() {
- return ConfigurationTransformation.versionedBuilder().versionKey(Configuration.LEGACY_CONFIG_VERSION_FIELD)
- .addVersion(13, ConfigurationTransformation.builder().addAction(path("enable-old-tnt-cannon-behaviors"), TransformAction.rename("prevent-tnt-from-moving-in-water")).build())
- .addVersion(16, ConfigurationTransformation.builder().addAction(path("use-chunk-inhabited-timer"), (path, value) -> {
- if (!value.getBoolean(true)) {
- value.raw(0);
- } else {
- value.raw(-1);
- }
- final Object[] newPath = path.array();
- newPath[newPath.length - 1] = "fixed-chunk-inhabited-time";
- return newPath;
- }).build())
- .addVersion(18, ConfigurationTransformation.builder().addAction(path("nether-ceiling-void-damage"), (path, value) -> {
- if (value.getBoolean(false)) {
- value.raw(128);
- } else {
- value.raw(0);
- }
- final Object[] newPath = path.array();
- newPath[newPath.length - 1] = "nether-ceiling-void-damage-height";
- return newPath;
- }).build())
- .addVersion(19, ConfigurationTransformation.builder()
- .addAction(path("anti-xray", "hidden-blocks"), (path, value) -> {
- final List<String> hiddenBlocks = value.getList(String.class);
- if (hiddenBlocks != null) {
- hiddenBlocks.remove("lit_redstone_ore");
- }
- return null;
- })
- .addAction(path("anti-xray", "replacement-blocks"), (path, value) -> {
- final List<String> replacementBlocks = value.getList(String.class);
- if (replacementBlocks != null) {
- final int index = replacementBlocks.indexOf("planks");
- if (index != -1) {
- replacementBlocks.set(index, "oak_planks");
- }
- }
- value.raw(replacementBlocks);
- return null;
- }).build())
- .addVersion(20, ConfigurationTransformation.builder().addAction(path("baby-zombie-movement-speed"), TransformAction.rename("baby-zombie-movement-modifier")).build())
- .addVersion(22, ConfigurationTransformation.builder().addAction(path("per-player-mob-spawns"), (path, value) -> {
- value.raw(true);
- return null;
- }).build())
- .addVersion(24,
- ConfigurationTransformation.builder()
- .addAction(path("spawn-limits", "monsters"), TransformAction.rename("monster"))
- .addAction(path("spawn-limits", "animals"), TransformAction.rename("creature"))
- .addAction(path("spawn-limits", "water-animals"), TransformAction.rename("water_creature"))
- .addAction(path("spawn-limits", "water-ambient"), TransformAction.rename("water_ambient"))
- .build(),
- ConfigurationTransformation.builder().addAction(path("despawn-ranges"), (path, value) -> {
- final int softDistance = value.node("soft").getInt(32);
- final int hardDistance = value.node("hard").getInt(128);
- value.node("soft").raw(null);
- value.node("hard").raw(null);
- for (final MobCategory category : MobCategory.values()) {
- if (softDistance != 32) {
- value.node(category.getName(), "soft").raw(softDistance);
- }
- if (hardDistance != 128) {
- value.node(category.getName(), "hard").raw(hardDistance);
- }
- }
- return null;
- }).build()
- )
- .addVersion(26, ConfigurationTransformation.builder().addAction(path("alt-item-despawn-rate", "items", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> {
- String itemName = path.get(path.size() - 1).toString();
- final Optional<Holder.Reference<Item>> item = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT))));
- if (item.isEmpty()) {
- itemName = Material.valueOf(itemName).getKey().getKey();
- }
- final Object[] newPath = path.array();
- newPath[newPath.length - 1] = itemName;
- return newPath;
- }).build())
- .addVersion(27, ConfigurationTransformation.builder().addAction(path("use-faster-eigencraft-redstone"), (path, value) -> {
- final WorldConfiguration.Misc.RedstoneImplementation redstoneImplementation = value.getBoolean(false) ? WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT : WorldConfiguration.Misc.RedstoneImplementation.VANILLA;
- value.set(redstoneImplementation);
- final Object[] newPath = path.array();
- newPath[newPath.length - 1] = "redstone-implementation";
- return newPath;
- }).build())
- .build();
- }
-
- // other transformations found in PaperWorldConfig that aren't versioned
- private static ConfigurationTransformation notVersioned() {
- return ConfigurationTransformation.builder()
- .addAction(path("treasure-maps-return-already-discovered"), (path, value) -> {
- boolean prevValue = value.getBoolean(false);
- value.node("villager-trade").set(prevValue);
- value.node("loot-tables").set(prevValue);
- return path.with(path.size() - 1, "treasure-maps-find-already-discovered").array();
- })
- .addAction(path("alt-item-despawn-rate", "items"), (path, value) -> {
- if (value.isMap()) {
- Map<String, Integer> rebuild = new HashMap<>();
- value.childrenMap().forEach((key, node) -> {
- String itemName = key.toString();
- final Optional<Holder.Reference<Item>> itemHolder = BuiltInRegistries.ITEM.get(ResourceKey.create(Registries.ITEM, ResourceLocation.parse(itemName.toLowerCase(Locale.ROOT))));
- final String item;
- if (itemHolder.isEmpty()) {
- final Material bukkitMat = Material.matchMaterial(itemName);
- item = bukkitMat != null ? bukkitMat.getKey().getKey() : null;
- } else {
- item = itemHolder.get().unwrapKey().orElseThrow().location().getPath();
- }
- if (item != null) {
- rebuild.put(item, node.getInt());
- }
- });
- value.set(rebuild);
- }
- return null;
- })
- .build();
- }
-
- public static ConfigurationTransformation toNewFormat() {
- return ConfigurationTransformation.chain(ConfigurationTransformation.versionedBuilder().versionKey(Configuration.LEGACY_CONFIG_VERSION_FIELD).addVersion(Configuration.FINAL_LEGACY_VERSION + 1, newFormatTransformation()).build(), ConfigurationTransformation.builder().addAction(path(Configuration.LEGACY_CONFIG_VERSION_FIELD), TransformAction.rename(Configuration.VERSION_FIELD)).build());
- }
-
- private static ConfigurationTransformation newFormatTransformation() {
- final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder()
- .addAction(path("verbose"), TransformAction.remove()); // not needed
-
- moveFromRoot(builder, "anti-xray", "anticheat");
-
- moveFromRootAndRename(builder, "armor-stands-do-collision-entity-lookups", "do-collision-entity-lookups", "entities", "armor-stands");
- moveFromRootAndRename(builder, "armor-stands-tick", "tick", "entities", "armor-stands");
-
- moveFromRoot(builder, "auto-save-interval", "chunks");
- moveFromRoot(builder, "delay-chunk-unloads-by", "chunks");
- moveFromRoot(builder, "entity-per-chunk-save-limit", "chunks");
- moveFromRoot(builder, "fixed-chunk-inhabited-time", "chunks");
- moveFromRoot(builder, "max-auto-save-chunks-per-tick", "chunks");
- moveFromRoot(builder, "prevent-moving-into-unloaded-chunks", "chunks");
-
- moveFromRoot(builder, "entities-target-with-follow-range", "entities");
- moveFromRoot(builder, "mob-effects", "entities");
-
- moveFromRoot(builder, "filter-nbt-data-from-spawn-eggs-and-related", "entities", "spawning");
- moveFromGameMechanics(builder, "disable-mob-spawner-spawn-egg-transformation", "entities", "spawning");
- moveFromRoot(builder, "per-player-mob-spawns", "entities", "spawning");
- moveFromGameMechanics(builder, "scan-for-legacy-ender-dragon", "entities", "spawning");
- moveFromRoot(builder, "spawn-limits", "entities", "spawning");
- moveFromRoot(builder, "despawn-ranges", "entities", "spawning");
- moveFromRoot(builder, "wateranimal-spawn-height", "entities", "spawning");
- builder.addAction(path("slime-spawn-height", "swamp-biome"), TransformAction.rename("surface-biome"));
- moveFromRoot(builder, "slime-spawn-height", "entities", "spawning");
- moveFromRoot(builder, "wandering-trader", "entities", "spawning");
- moveFromRoot(builder, "all-chunks-are-slime-chunks", "entities", "spawning");
- moveFromRoot(builder, "skeleton-horse-thunder-spawn-chance", "entities", "spawning");
- moveFromRoot(builder, "iron-golems-can-spawn-in-air", "entities", "spawning");
- moveFromRoot(builder, "alt-item-despawn-rate", "entities", "spawning");
- moveFromRoot(builder, "count-all-mobs-for-spawning", "entities", "spawning");
- moveFromRoot(builder, "creative-arrow-despawn-rate", "entities", "spawning");
- moveFromRoot(builder, "non-player-arrow-despawn-rate", "entities", "spawning");
- moveFromRoot(builder, "monster-spawn-max-light-level", "entities", "spawning");
-
-
- moveFromRootAndRename(builder, "duplicate-uuid-saferegen-delete-range", "safe-regen-delete-range", "entities", "spawning", "duplicate-uuid");
-
- moveFromRoot(builder, "baby-zombie-movement-modifier", "entities", "behavior");
- moveFromRoot(builder, "disable-creeper-lingering-effect", "entities", "behavior");
- moveFromRoot(builder, "door-breaking-difficulty", "entities", "behavior");
- moveFromGameMechanics(builder, "disable-chest-cat-detection", "entities", "behavior");
- moveFromGameMechanics(builder, "disable-player-crits", "entities", "behavior");
- moveFromRoot(builder, "experience-merge-max-value", "entities", "behavior");
- moveFromRoot(builder, "mobs-can-always-pick-up-loot", "entities", "behavior");
- moveFromGameMechanics(builder, "nerf-pigmen-from-nether-portals", "entities", "behavior");
- moveFromRoot(builder, "parrots-are-unaffected-by-player-movement", "entities", "behavior");
- moveFromRoot(builder, "phantoms-do-not-spawn-on-creative-players", "entities", "behavior");
- moveFromRoot(builder, "phantoms-only-attack-insomniacs", "entities", "behavior");
- moveFromRoot(builder, "piglins-guard-chests", "entities", "behavior");
- moveFromRoot(builder, "spawner-nerfed-mobs-should-jump", "entities", "behavior");
- moveFromRoot(builder, "zombie-villager-infection-chance", "entities", "behavior");
- moveFromRoot(builder, "zombies-target-turtle-eggs", "entities", "behavior");
- moveFromRoot(builder, "ender-dragons-death-always-places-dragon-egg", "entities", "behavior");
- moveFromGameMechanicsAndRename(builder, "disable-pillager-patrols", "disable", "game-mechanics", "pillager-patrols");
- moveFromGameMechanics(builder, "pillager-patrols", "entities", "behavior");
- moveFromRoot(builder, "should-remove-dragon", "entities", "behavior");
-
- moveFromRootAndRename(builder, "map-item-frame-cursor-limit", "item-frame-cursor-limit", "maps");
- moveFromRootAndRename(builder, "map-item-frame-cursor-update-interval", "item-frame-cursor-update-interval", "maps");
-
- moveFromRootAndRename(builder, "mob-spawner-tick-rate", "mob-spawner", "tick-rates");
- moveFromRootAndRename(builder, "container-update-tick-rate", "container-update", "tick-rates");
- moveFromRootAndRename(builder, "grass-spread-tick-rate", "grass-spread", "tick-rates");
-
- moveFromRoot(builder, "allow-non-player-entities-on-scoreboards", "scoreboards");
- moveFromRoot(builder, "use-vanilla-world-scoreboard-name-coloring", "scoreboards");
-
- moveFromRoot(builder, "disable-thunder", "environment");
- moveFromRoot(builder, "disable-ice-and-snow", "environment");
- moveFromRoot(builder, "optimize-explosions", "environment");
- moveFromRoot(builder, "disable-explosion-knockback", "environment");
- moveFromRoot(builder, "frosted-ice", "environment");
- moveFromRoot(builder, "disable-teleportation-suffocation-check", "environment");
- moveFromRoot(builder, "portal-create-radius", "environment");
- moveFromRoot(builder, "portal-search-radius", "environment");
- moveFromRoot(builder, "portal-search-vanilla-dimension-scaling", "environment");
- moveFromRootAndRename(builder, "enable-treasure-maps", "enabled", "environment", "treasure-maps");
- moveFromRootAndRename(builder, "treasure-maps-find-already-discovered", "find-already-discovered", "environment", "treasure-maps");
- moveFromRoot(builder, "water-over-lava-flow-speed", "environment");
- moveFromRoot(builder, "nether-ceiling-void-damage-height", "environment");
-
- moveFromRoot(builder, "keep-spawn-loaded", "spawn");
- moveFromRoot(builder, "keep-spawn-loaded-range", "spawn");
- moveFromRoot(builder, "allow-using-signs-inside-spawn-protection", "spawn");
-
- moveFromRoot(builder, "max-entity-collisions", "collisions");
- moveFromRoot(builder, "allow-vehicle-collisions", "collisions");
- moveFromRoot(builder, "fix-climbing-bypassing-cramming-rule", "collisions");
- moveFromRoot(builder, "only-players-collide", "collisions");
- moveFromRoot(builder, "allow-player-cramming-damage", "collisions");
-
- moveFromRoot(builder, "falling-block-height-nerf", "fixes");
- moveFromRoot(builder, "fix-items-merging-through-walls", "fixes");
- moveFromRoot(builder, "prevent-tnt-from-moving-in-water", "fixes");
- moveFromRoot(builder, "remove-corrupt-tile-entities", "fixes");
- moveFromRoot(builder, "split-overstacked-loot", "fixes");
- moveFromRoot(builder, "tnt-entity-height-nerf", "fixes");
- moveFromRoot(builder, "fix-wither-targeting-bug", "fixes");
- moveFromGameMechanics(builder, "disable-unloaded-chunk-enderpearl-exploit", "fixes");
- moveFromGameMechanics(builder, "fix-curing-zombie-villager-discount-exploit", "fixes");
-
- builder.addAction(path("fishing-time-range", "MaximumTicks"), TransformAction.rename("maximum"));
- builder.addAction(path("fishing-time-range", "MinimumTicks"), TransformAction.rename("minimum"));
-
- builder.addAction(path("generator-settings", "flat-bedrock"), (path, value) -> new Object[]{"environment", "generate-flat-bedrock"});
- builder.addAction(path("generator-settings"), TransformAction.remove());
-
- builder.addAction(path("game-mechanics", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> new Object[]{"misc", path.array()[1]});
- builder.addAction(path("game-mechanics"), TransformAction.remove());
-
- builder.addAction(path("feature-seeds", ConfigurationTransformation.WILDCARD_OBJECT), (path, value) -> {
- final String key = path.array()[path.size() - 1].toString();
- if (!"generate-random-seeds-for-all".equals(key)) {
- return new Object[]{"feature-seeds", "features", key};
- }
- return null;
- });
-
- builder.addAction(path("duplicate-uuid-resolver"), (path, value) -> {
- final WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode duplicateUUIDMode = switch (value.require(String.class)) {
- case "regen", "regenerate", "saferegen", "saferegenerate" -> WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.SAFE_REGEN;
- case "remove", "delete" -> WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.DELETE;
- case "silent", "nothing" -> WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.NOTHING;
- default -> WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.WARN;
- };
- value.set(duplicateUUIDMode);
- return new Object[]{"entities", "spawning", "duplicate-uuid", "mode"};
- });
-
- builder.addAction(path("redstone-implementation"), (path, value) -> {
- if ("alternate-current".equalsIgnoreCase(value.require(String.class))) {
- value.set("alternate_current");
- }
- return new Object[]{"misc", "redstone-implementation"};
- });
-
- moveToMisc(builder, "light-queue-size");
- moveToMisc(builder, "update-pathfinding-on-block-update");
- moveToMisc(builder, "show-sign-click-command-failure-msgs-to-player");
- moveToMisc(builder, "max-leash-distance");
-
- return builder.build();
- }
-
- private static void moveToMisc(final ConfigurationTransformation.Builder builder, String... key) {
- moveFromRootAndRename(builder, path((Object[]) key), key[key.length - 1], "misc");
- }
-
- private static void moveFromGameMechanics(final ConfigurationTransformation.Builder builder, final String key, final String... parents) {
- moveFromGameMechanicsAndRename(builder, key, key, parents);
- }
-
- private static void moveFromGameMechanicsAndRename(final ConfigurationTransformation.Builder builder, final String oldKey, final String newKey, final String... parents) {
- moveFromRootAndRename(builder, path("game-mechanics", oldKey), newKey, parents);
- }
-}

View File

@@ -0,0 +1,39 @@
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -45,8 +_,7 @@
protected CraftOfflinePlayer(CraftServer server, GameProfile profile) {
this.server = server;
this.profile = profile;
- this.storage = server.console.playerDataStorage;
-
+ this.storage = server.getServer().playerDataStorage; // Plazma
}
@Override
@@ -415,7 +_,7 @@
if (data.contains("SpawnDimension")) {
com.mojang.serialization.DataResult<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>> result = net.minecraft.world.level.Level.RESOURCE_KEY_CODEC.parse(net.minecraft.nbt.NbtOps.INSTANCE, data.get("SpawnDimension"));
net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> levelKey = result.resultOrPartial(LOGGER::error).orElse(net.minecraft.world.level.Level.OVERWORLD);
- net.minecraft.server.level.ServerLevel level = this.server.console.getLevel(levelKey);
+ net.minecraft.server.level.ServerLevel level = this.server.getServer().getLevel(levelKey); // Plazma
spawnWorld = level != null ? level.getWorld() : spawnWorld;
}
if (spawnWorld == null) {
@@ -813,7 +_,7 @@
* @param compoundTag
*/
private void save(CompoundTag compoundTag) {
- File playerDir = server.console.playerDataStorage.getPlayerDir();
+ File playerDir = server.getServer().playerDataStorage.getPlayerDir(); // Plazma
try {
File tempFile = File.createTempFile(this.getUniqueId()+"-", ".dat", playerDir);
net.minecraft.nbt.NbtIo.writeCompressed(compoundTag, tempFile.toPath());
@@ -821,7 +_,7 @@
File playerDataFileOld = new File(playerDir, this.getUniqueId()+".dat_old");
net.minecraft.Util.safeReplaceFile(playerDataFile.toPath(), tempFile.toPath(), playerDataFileOld.toPath());
} catch (java.io.IOException e) {
- e.printStackTrace();
+ LOGGER.error("Failed to save player data for " + this.getUniqueId(), e);
}
}
// Purpur end - OfflinePlayer API

View File

@@ -1,5 +1,39 @@
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -278,13 +_,13 @@
private final ServicesManager servicesManager = new SimpleServicesManager();
private final CraftScheduler scheduler = new CraftScheduler();
private final CraftCommandMap commandMap; // Paper - Move down
- private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
+ private final SimpleHelpMap helpMap; // Plazma - Add options to modify configuration paths
private final StandardMessenger messenger = new StandardMessenger();
private final SimplePluginManager pluginManager; // Paper - Move down
public final io.papermc.paper.plugin.manager.PaperPluginManagerImpl paperPluginManager; // Paper
private final StructureManager structureManager;
- protected final DedicatedServer console;
- protected final DedicatedPlayerList playerList;
+ private final DedicatedServer console; // Plazma - AT (protected -> private)
+ private final DedicatedPlayerList playerList; // Plazma - AT (protected -> private)
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
private YamlConfiguration configuration;
@@ -295,7 +_,7 @@
private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore();
private final WorldMetadataStore worldMetadata = new WorldMetadataStore();
private final Object2IntOpenHashMap<SpawnCategory> spawnCategoryLimit = new Object2IntOpenHashMap<>();
- private File container;
+ //private File container; // Plazma - Remove unused variables
private WarningState warningState = WarningState.DEFAULT;
public ApiVersion minimumAPI;
public CraftScoreboardManager scoreboardManager;
@@ -408,6 +_,7 @@
public CraftServer(DedicatedServer console, PlayerList playerList) {
this.console = console;
+ this.helpMap = new SimpleHelpMap(this); // Plazma - Add options to modify configuration paths
this.playerList = (DedicatedPlayerList) playerList;
this.playerView = Collections.unmodifiableList(Lists.transform(playerList.players, new Function<ServerPlayer, CraftPlayer>() {
@Override
@@ -1102,6 +_,7 @@
org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -26,13 +_,6 @@
@@ -26,172 +_,126 @@
// Paper end - Reset loggers after shutdown
public static void main(String[] args) {
@@ -12,61 +12,242 @@
- // Paper end
- // Todo: Installation script
if (System.getProperty("jdk.nio.maxCachedBufferSize") == null) System.setProperty("jdk.nio.maxCachedBufferSize", "262144"); // Paper - cap per-thread NIO cache size; https://www.evanjones.ca/java-bytebuffer-leak.html
OptionParser parser = new OptionParser() {
{
@@ -143,7 +_,7 @@
this.acceptsAll(Main.asList("noconsole"), "Disables the console");
- this.acceptsAll(Main.asList("v", "version"), "Show the CraftBukkit Version");
+ this.acceptsAll(Main.asList("v", "version"), "Show the Plazma Version"); // Plazma - Rebrand
this.acceptsAll(Main.asList("demo"), "Demo mode");
@@ -159,16 +_,15 @@
// Paper start
acceptsAll(asList("paper-dir", "paper-settings-directory"), "Directory for Paper settings")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
- .describedAs("Config directory");
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
+ .describedAs("Config directory");
acceptsAll(asList("paper", "paper-settings"), "File for Paper settings")
.withRequiredArg()
.ofType(File.class)
.defaultsTo(new File("paper.yml"))
.describedAs("Yml file");
- OptionParser parser = new OptionParser() {
- {
- this.acceptsAll(Main.asList("?", "help"), "Show the help");
-
acceptsAll(asList("add-plugin", "add-extra-plugin-jar"), "Specify paths to extra plugin jars to be loaded in addition to those in the plugins folder. This argument can be specified multiple times, once for each extra plugin jar path.")
.withRequiredArg()
.ofType(File.class)
@@ -176,20 +_,21 @@
.describedAs("Jar file");
// Paper end
+ // Plazma start - Configurable Plazma
+ acceptsAll(asList("plazma-dir", "plazma-settings-dir", "plazma-settings-directory"), "Directory for Plazma settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
+ .describedAs("Config directory");
+ // Plazma end - Configurable Plazma
- this.acceptsAll(Main.asList("c", "config"), "Properties file to use")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("server.properties"))
- .describedAs("Properties file");
-
- this.acceptsAll(Main.asList("P", "plugins"), "Plugin directory to use")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("plugins"))
- .describedAs("Plugin directory");
-
- this.acceptsAll(Main.asList("h", "host", "server-ip"), "Host to listen on")
- .withRequiredArg()
- .ofType(String.class)
- .describedAs("Hostname or IP");
-
- this.acceptsAll(Main.asList("W", "world-dir", "universe", "world-container"), "World container")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("."))
- .describedAs("Directory containing worlds");
-
- this.acceptsAll(Main.asList("w", "world", "level-name"), "World name")
- .withRequiredArg()
- .ofType(String.class)
- .describedAs("World name");
-
- this.acceptsAll(Main.asList("p", "port", "server-port"), "Port to listen on")
- .withRequiredArg()
- .ofType(Integer.class)
- .describedAs("Port");
-
- this.accepts("serverId", "Server ID")
- .withRequiredArg();
-
- this.accepts("jfrProfile", "Enable JFR profiling");
-
- this.accepts("pidFile", "pid File")
- .withRequiredArg()
- .withValuesConvertedBy(new PathConverter());
-
- this.acceptsAll(Main.asList("o", "online-mode"), "Whether to use online authentication")
- .withRequiredArg()
- .ofType(Boolean.class)
- .describedAs("Authentication");
-
- this.acceptsAll(Main.asList("s", "size", "max-players"), "Maximum amount of players")
- .withRequiredArg()
- .ofType(Integer.class)
- .describedAs("Server size");
-
- this.acceptsAll(Main.asList("d", "date-format"), "Format of the date to display in the console (for log entries)")
- .withRequiredArg()
- .ofType(SimpleDateFormat.class)
- .describedAs("Log date format");
-
- this.acceptsAll(Main.asList("log-pattern"), "Specfies the log filename pattern")
- .withRequiredArg()
- .ofType(String.class)
- .defaultsTo("server.log")
- .describedAs("Log filename");
-
- this.acceptsAll(Main.asList("log-limit"), "Limits the maximum size of the log file (0 = unlimited)")
- .withRequiredArg()
- .ofType(Integer.class)
- .defaultsTo(0)
- .describedAs("Max log size");
-
- this.acceptsAll(Main.asList("log-count"), "Specified how many log files to cycle through")
- .withRequiredArg()
- .ofType(Integer.class)
- .defaultsTo(1)
- .describedAs("Log count");
-
- this.acceptsAll(Main.asList("log-append"), "Whether to append to the log file")
- .withRequiredArg()
- .ofType(Boolean.class)
- .defaultsTo(true)
- .describedAs("Log append");
-
- this.acceptsAll(Main.asList("log-strip-color"), "Strips color codes from log file");
-
- this.acceptsAll(Main.asList("b", "bukkit-settings"), "File for bukkit settings")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("bukkit.yml"))
- .describedAs("Yml file");
-
- this.acceptsAll(Main.asList("C", "commands-settings"), "File for command settings")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("commands.yml"))
- .describedAs("Yml file");
-
- this.acceptsAll(Main.asList("forceUpgrade"), "Whether to force a world upgrade");
- this.acceptsAll(Main.asList("eraseCache"), "Whether to force cache erase during world upgrade");
- this.acceptsAll(Main.asList("recreateRegionFiles"), "Whether to recreate region files during world upgrade");
- this.accepts("safeMode", "Loads level with vanilla datapack only"); // Paper
- this.acceptsAll(Main.asList("nogui"), "Disables the graphical console");
-
- this.acceptsAll(Main.asList("nojline"), "Disables jline and emulates the vanilla console");
-
- this.acceptsAll(Main.asList("noconsole"), "Disables the console");
-
- this.acceptsAll(Main.asList("v", "version"), "Show the CraftBukkit Version");
-
- this.acceptsAll(Main.asList("demo"), "Demo mode");
-
- this.acceptsAll(Main.asList("initSettings"), "Only create configuration files and then exit"); // SPIGOT-5761: Add initSettings option
-
- // Spigot start
- this.acceptsAll(Main.asList("S", "spigot-settings"), "File for spigot settings")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("spigot.yml"))
- .describedAs("Yml file");
- // Spigot end
-
- // Paper start
- acceptsAll(asList("paper-dir", "paper-settings-directory"), "Directory for Paper settings")
+ // Plazma start - Cleanup OptionSets
+ OptionParser parser = new OptionParser() {{
+ this.acceptsAll(Main.asList("v", "version"), "Show the Plazma Version"); // Plazma - Rebrand
+ this.acceptsAll(Main.asList("?", "help"), "Show the help");
+
// Purpur start - Purpur config files
acceptsAll(asList("purpur", "purpur-settings"), "File for purpur settings")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("purpur.yml"))
+ this.acceptsAll(Main.asList("c", "config"), "Properties file to use")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("server.properties"))
+ .describedAs("Properties file");
+
+ this.acceptsAll(Main.asList("P", "plugins"), "Plugin directory to use")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("plugins"))
+ .describedAs("Plugin directory");
+
+ this.acceptsAll(Main.asList("h", "host", "server-ip"), "Host to listen on")
+ .withRequiredArg()
+ .ofType(String.class)
+ .describedAs("Hostname or IP");
+
+ this.acceptsAll(Main.asList("W", "world-dir", "universe", "world-container"), "World container")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("."))
+ .describedAs("Directory containing worlds");
+
+ this.acceptsAll(Main.asList("w", "world", "level-name"), "World name")
+ .withRequiredArg()
+ .ofType(String.class)
+ .describedAs("World name");
+
+ this.acceptsAll(Main.asList("p", "port", "server-port"), "Port to listen on")
+ .withRequiredArg()
+ .ofType(Integer.class)
+ .describedAs("Port");
+
+ this.acceptsAll(Main.asList("b", "bukkit-settings"), "File for bukkit settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("bukkit.yml"))
+ .describedAs("Yml file");
+
+ this.acceptsAll(Main.asList("C", "commands-settings"), "File for command settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("commands.yml"))
+ .describedAs("Yml file");
+
+ this.accepts("serverId", "Server ID")
+ .withRequiredArg();
+
+ this.accepts("pidFile", "pid File")
+ .withRequiredArg()
+ .withValuesConvertedBy(new PathConverter());
+
+ this.accepts("jfrProfile", "Enable JFR profiling");
+ this.accepts("forceUpgrade", "Whether to force a world upgrade");
+ this.accepts("eraseCache", "Whether to force cache erase during world upgrade");
+ this.accepts("recreateRegionFiles", "Whether to recreate region files during world upgrade");
+ this.accepts("safeMode", "Loads level with vanilla datapack only"); // Paper
+ this.accepts("nogui", "Disables the graphical console");
+ this.accepts("nojline", "Disables jline and emulates the vanilla console");
+ this.accepts("noconsole", "Disables the console");
+ this.accepts("demo", "Demo mode");
+ this.accepts("initSettings", "Only create configuration files and then exit"); // SPIGOT-5761: Add initSettings option
+
+ // Spigot start
+ this.acceptsAll(Main.asList("S", "spigot-settings"), "File for spigot settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("spigot.yml"))
+ .describedAs("Yaml file"); // Plazma
+ // Spigot end
+
+ // Paper start
+ this.acceptsAll(asList("paper-dir", "paper-settings-directory"), "Directory for Paper settings")
.withRequiredArg()
.ofType(File.class)
.defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
.describedAs("Config directory");
- acceptsAll(asList("paper", "paper-settings"), "File for Paper settings")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File("paper.yml"))
- .describedAs("Yml file");
-
- acceptsAll(asList("add-plugin", "add-extra-plugin-jar"), "Specify paths to extra plugin jars to be loaded in addition to those in the plugins folder. This argument can be specified multiple times, once for each extra plugin jar path.")
- .withRequiredArg()
- .ofType(File.class)
- .defaultsTo(new File[] {})
- .describedAs("Jar file");
- // Paper end
-
- // Purpur start - Purpur config files
- acceptsAll(asList("purpur", "purpur-settings"), "File for purpur settings")
+ this.acceptsAll(asList("add-plugin", "add-extra-plugin-jar"), "Specify paths to extra plugin jars to be loaded in addition to those in the plugins folder. This argument can be specified multiple times, once for each extra plugin jar path.")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File[] {})
+ .describedAs("Jar file");
+ // Paper end
+
+ // Purpur start - Purpur config files
+ this.acceptsAll(asList("purpur", "purpur-settings"), "File for purpur settings")
.withRequiredArg()
.ofType(File.class)
.defaultsTo(new File("purpur.yml"))
- .describedAs("Yml file");
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("purpur.yml"))
+ .describedAs("Yml file");
// Purpur end - Purpur config files
- // Purpur end - Purpur config files
- // Paper start
- acceptsAll(asList("server-name"), "Name of the server")
- .withRequiredArg()
@@ -74,8 +255,35 @@
- .defaultsTo("Unknown Server")
- .describedAs("Name");
- // Paper end
}
};
- }
- };
+ .describedAs("Yaml file"); // Plazma
+ // Purpur end - Purpur config files
+
+ // Plazma start - Configurable Plazma
+ this.acceptsAll(asList("plazma-dir", "plazma-settings-dir", "plazma-settings-directory"), "Directory for Plazma settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
+ .describedAs("Config directory");
+ // Plazma end - Configurable Plazma
+
+ // Plazma start - Add options to modify configuration paths
+ this.accepts("version-history", "File for version history")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("version-history.yml"))
+ .describedAs("JSON file");
+ this.accepts("help", "File for help")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("help.yml"))
+ .describedAs("Yaml file");
+ // Plazma end - Add options to modify configuration paths
+ }};
+ // Plazma end - Cleanup OptionSets
OptionSet options = null;
@@ -234,26 +_,6 @@

View File

@@ -0,0 +1,11 @@
--- a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
+++ b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
@@ -25,7 +_,7 @@
public HelpYamlReader(Server server) {
this.server = server;
- File helpYamlFile = new File("help.yml");
+ File helpYamlFile = (File) ((org.bukkit.craftbukkit.CraftServer) server).getServer().options.valueOf("help"); // Plazma - Add options to modify configuration paths
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), Charsets.UTF_8));
try {

View File

@@ -0,0 +1,27 @@
--- a/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
+++ b/src/main/java/org/purpurmc/purpur/command/CompassCommand.java
@@ -22,6 +_,24 @@
}
return 1;
})
+ // Plazma start - Add missing argument place for /compass command
+ .then(Commands.argument("targets", net.minecraft.commands.arguments.EntityArgument.players())
+ .requires(listener -> listener.hasPermission(2, "bukkit.command.compass.other"))
+ .executes(context -> {
+ for (ServerPlayer player : net.minecraft.commands.arguments.EntityArgument.getPlayers(context, "targets")) {
+ CompassTask task = CompassTask.instance();
+ if (player.compassBar()) {
+ task.removePlayer(player.getBukkitEntity());
+ player.compassBar(false);
+ } else {
+ task.addPlayer(player.getBukkitEntity());
+ player.compassBar(true);
+ }
+ }
+ return net.minecraft.commands.arguments.EntityArgument.getPlayers(context, "targets").size();
+ })
+ )
+ // Plazma end - Add missing argument place for /compass command
);
}
}