9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00

Configurable files and TPS bar improvment (#36)

* tps-bar-show-tps-of-server-option

* Configurable file locations for `banned-players.json`, `banned-ips.json`, `ops.json`, `whitelist.json`, `help.yml` and `.console_history` and option to see server tps instead of world tps with RCT and per world tpsbar
This commit is contained in:
dan28000
2025-10-06 23:32:31 +02:00
committed by GitHub
parent 24733bd827
commit 93763445fd
5 changed files with 186 additions and 53 deletions

View File

@@ -0,0 +1,62 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dan28000 <84990628+dan28000@users.noreply.github.com>
Date: Mon, 6 Oct 2025 14:17:59 +0200
Subject: [PATCH] Configurable-Files-Locations
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index a0d45f72e7c35883996214a2c5420d6a996a58aa..2c6aa5bac80e6383f935e368eb1aa69ca4b46d70 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -101,10 +101,12 @@ import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
public abstract class PlayerList {
- 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");
+ // DivineMC - make configurable location of files start
+ public static File USERBANLIST_FILE = new File("banned-players.json");
+ public static File IPBANLIST_FILE = new File("banned-ips.json");
+ public static File OPLIST_FILE = new File("ops.json");
+ public static File WHITELIST_FILE = new File("whitelist.json");
+ // DivineMC - make configurable location of files end
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();
@@ -113,10 +115,12 @@ public abstract class PlayerList {
private final MinecraftServer server;
public final List<ServerPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
private final Map<UUID, ServerPlayer> playersByUUID = Maps.newHashMap();
- private final UserBanList bans = new UserBanList(USERBANLIST_FILE);
- private final IpBanList ipBans = new IpBanList(IPBANLIST_FILE);
- private final ServerOpList ops = new ServerOpList(OPLIST_FILE);
- private final UserWhiteList whitelist = new UserWhiteList(WHITELIST_FILE);
+ // DivineMC - make configurable location of files start
+ private final UserBanList bans;
+ private final IpBanList ipBans;
+ private final ServerOpList ops;
+ private final UserWhiteList whitelist;
+ // DivineMC - make configurable location of files end
// CraftBukkit start
// private final Map<UUID, ServerStatsCounter> stats = Maps.newHashMap();
// private final Map<UUID, PlayerAdvancements> advancements = Maps.newHashMap();
@@ -144,6 +148,17 @@ public abstract class PlayerList {
this.registries = registries;
this.maxPlayers = maxPlayers;
this.playerIo = playerIo;
+ // DivineMC - make configurable location of files start
+ USERBANLIST_FILE = (File) server.options.valueOf("banned-players");
+ IPBANLIST_FILE = (File) server.options.valueOf("banned-ips");
+ OPLIST_FILE = (File) server.options.valueOf("ops");
+ WHITELIST_FILE = (File) server.options.valueOf("whitelist");
+
+ bans = new UserBanList(USERBANLIST_FILE);
+ ipBans = new IpBanList(IPBANLIST_FILE);
+ ops = new ServerOpList(OPLIST_FILE);
+ whitelist = new UserWhiteList(WHITELIST_FILE);
+ // DivineMC - make configurable location of files end
}
abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor

View File

@@ -0,0 +1,114 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dan28000 <pirkldan28@gmail.com>
Date: Thu, 12 Jun 2025 10:08:25 +0200
Subject: [PATCH] Configurable files locations and plugin loading
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
index 6567ff18cb1c21230565c2d92caf3a7f7f915c17..f5bc0eff886e9e3386467f40d4f329455d0b76e6 100644
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
@@ -21,7 +21,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
protected LineReader buildReader(LineReaderBuilder builder) {
builder
.appName("DivineMC") // DivineMC - Rebrand
- .variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
+ .variable(LineReader.HISTORY_FILE, ((java.io.File) server.options.valueOf("console-history")).toPath()) // DivineMC - make configurable location of files
.completer(new ConsoleCommandCompleter(this.server))
.option(LineReader.Option.COMPLETE_IN_WORD, true);
if (io.papermc.paper.configuration.GlobalConfiguration.get().console.enableBrigadierHighlighting) {
diff --git a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
index 70413fddd23ca1165cb5090cce4fddcb1bbca93f..ae70b84e6473fa2ed94416bf4bef88492de3e5f8 100644
--- a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
+++ b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
@@ -112,6 +112,20 @@ public class PluginInitializerManager {
// Register the default plugin directory
io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.DirectoryProviderSource.INSTANCE, pluginSystem.pluginDirectoryPath());
+ // DivineMC start - Register the plugin directory from flags
+ @SuppressWarnings("unchecked")
+ java.util.List<Path> pluginList = ((java.util.List<File>) optionSet.valuesOf("add-plugin-dir")).stream()
+ .filter(java.util.Objects::nonNull)
+ .map(f -> f.listFiles(file -> file.getName().endsWith(".jar")))
+ .filter(java.util.Objects::nonNull)
+ .flatMap(java.util.Arrays::stream)
+ .filter(File::isFile)
+ .map(File::toPath)
+ .toList();
+
+ io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.PluginFlagProviderSource.INSTANCE, pluginList);
+ // DivineMC end - Register the plugin directory from flags
+
// Register plugins from the flag
@SuppressWarnings("unchecked")
java.util.List<Path> files = ((java.util.List<File>) optionSet.valuesOf("add-plugin")).stream().map(File::toPath).toList();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index d8fbc4348951b4e9363b16ca00c1ba371503031e..0108422e8974d8091ba6ecee1f1897a142a02b67 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -180,6 +180,52 @@ public class Main {
.describedAs("Yml file");
// DivineMC end - Configuration
+ // DivineMC start - Implement loading plugins from external folder
+ acceptsAll(asList("add-plugin-dir", "add-extra-plugin-dir"), "Specify paths to directories containing 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 directory path.")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("extra"))
+ .describedAs("Directory");
+ // DivineMC end - Implement loading plugins from external folder
+
+ // DivineMC start - make configurable location of files start
+ accepts("help-location", "Location of the help file")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("help.yml"))
+ .describedAs("Help file location");
+
+ accepts("banned-players", "Location of banned players file")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("banned-players.json"))
+ .describedAs("Banned players file");
+
+ accepts("banned-ips", "Location of banned IPs file")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("banned-ips.json"))
+ .describedAs("Banned IPs file");
+
+ accepts("whitelist", "Location of whitelist file")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("whitelist.json"))
+ .describedAs("Whitelist file");
+
+ accepts("ops", "Location of operators file")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("ops.json"))
+ .describedAs("Operators file");
+
+ accepts("console-history", "Location of console history file")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File(".console_history"))
+ .describedAs("Console history file");
+ // DivineMC end - make configurable location of files end
+
this.accepts("server-name", "Name of the server")
.withRequiredArg()
.ofType(String.class)
diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
index b345a4973ea4aec58830e7d9aa5e1b5e78a2a4b7..f3d3b6e4caff9e16503cb04383876e84da7a30a3 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) net.minecraft.server.dedicated.DedicatedServer.getServer().options.valueOf("help-location"); // DivineMC - make configurable location of files
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), StandardCharsets.UTF_8));
try {

View File

@@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dan28000 <pirkldan28@gmail.com>
Date: Thu, 12 Jun 2025 10:08:25 +0200
Subject: [PATCH] Implement loading plugins from external folder
diff --git a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
index 70413fddd23ca1165cb5090cce4fddcb1bbca93f..ae70b84e6473fa2ed94416bf4bef88492de3e5f8 100644
--- a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
+++ b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
@@ -112,6 +112,20 @@ public class PluginInitializerManager {
// Register the default plugin directory
io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.DirectoryProviderSource.INSTANCE, pluginSystem.pluginDirectoryPath());
+ // DivineMC start - Register the plugin directory from flags
+ @SuppressWarnings("unchecked")
+ java.util.List<Path> pluginList = ((java.util.List<File>) optionSet.valuesOf("add-plugin-dir")).stream()
+ .filter(java.util.Objects::nonNull)
+ .map(f -> f.listFiles(file -> file.getName().endsWith(".jar")))
+ .filter(java.util.Objects::nonNull)
+ .flatMap(java.util.Arrays::stream)
+ .filter(File::isFile)
+ .map(File::toPath)
+ .toList();
+
+ io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.PluginFlagProviderSource.INSTANCE, pluginList);
+ // DivineMC end - Register the plugin directory from flags
+
// Register plugins from the flag
@SuppressWarnings("unchecked")
java.util.List<Path> files = ((java.util.List<File>) optionSet.valuesOf("add-plugin")).stream().map(File::toPath).toList();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 0838fcfaa950300f7a394295509be86cab824f99..d9bf383c9cb4fedcea84044f7db0da68b05fab76 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -180,6 +180,14 @@ public class Main {
.describedAs("Yml file");
// DivineMC end - Configuration
+ // DivineMC start - Implement loading plugins from external folder
+ acceptsAll(asList("add-plugin-dir", "add-extra-plugin-dir"), "Specify paths to directories containing 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 directory path.")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("extra"))
+ .describedAs("Directory");
+ // DivineMC end - Implement loading plugins from external folder
+
this.accepts("server-name", "Name of the server")
.withRequiredArg()
.ofType(String.class)

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] MSPT Tracking for each world
diff --git a/src/main/java/org/purpurmc/purpur/task/TPSBarTask.java b/src/main/java/org/purpurmc/purpur/task/TPSBarTask.java
index 8769993e7ca59da309087051a3cd38fc562c15d1..2eda6de8df6f8eb90bb84d12c3a88ca303664df4 100644
index 8769993e7ca59da309087051a3cd38fc562c15d1..b6ecadfb23bb4f694a3b0a138f927936267a02df 100644
--- a/src/main/java/org/purpurmc/purpur/task/TPSBarTask.java
+++ b/src/main/java/org/purpurmc/purpur/task/TPSBarTask.java
@@ -4,6 +4,8 @@ import net.kyori.adventure.bossbar.BossBar;
@@ -17,7 +17,7 @@ index 8769993e7ca59da309087051a3cd38fc562c15d1..2eda6de8df6f8eb90bb84d12c3a88ca3
import org.purpurmc.purpur.PurpurConfig;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -28,14 +30,64 @@ public class TPSBarTask extends BossBarTask {
@@ -28,14 +30,68 @@ public class TPSBarTask extends BossBarTask {
@Override
void updateBossBar(BossBar bossbar, Player player) {
@@ -29,7 +29,11 @@ index 8769993e7ca59da309087051a3cd38fc562c15d1..2eda6de8df6f8eb90bb84d12c3a88ca3
+ ServerLevel serverLevel = ((CraftWorld)player.getWorld()).getHandle();
+
+ double worldMspt = calculateWorldMSPT(serverLevel);
+ double worldTps = Math.min(20.0, 1000.0 / Math.max(worldMspt, 0.001));
+ double worldTps = this.tps;
+
+ if (!org.bxteam.divinemc.config.DivineConfig.AsyncCategory.showTPSOfServerInsteadOfWorld) {
+ worldTps = Math.min(20.0, 1000.0 / Math.max(worldMspt, 0.001));
+ }
+
+ double originalTps = this.tps;
+ double originalMspt = this.mspt;

View File

@@ -194,6 +194,7 @@ public class DivineConfig {
public static boolean disableHardThrow = false;
public static boolean pwtCompatabilityMode = false;
public static boolean usePerWorldTpsBar = true;
public static boolean showTPSOfServerInsteadOfWorld = true;
// Regionized chunk ticking
@Experimental("Regionized Chunk Ticking")
@@ -250,6 +251,8 @@ public class DivineConfig {
"Enables compatibility mode for plugins that are not compatible with Parallel World Ticking. This makes all async tasks run synchronously.");
usePerWorldTpsBar = getBoolean(ConfigCategory.ASYNC.key("parallel-world-ticking.use-per-world-tps-bar"), usePerWorldTpsBar,
"Enables per-world TPS bar, which shows the TPS of the world the player is currently in. TPS bar can be turned on/off with /tpsbar command.");
showTPSOfServerInsteadOfWorld = getBoolean(ConfigCategory.ASYNC.key("parallel-world-ticking.show-tps-of-server-instead-of-world"), showTPSOfServerInsteadOfWorld,
"Enables showing the TPS of the entire server instead of the world in the TPS bar.");
}
private static void regionizedChunkTicking() {