mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-22 02:47:43 +01:00
Fix up some configuration shit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From 62e0511e12ddc2b636f8fc8934a1d16673c9dd49 Mon Sep 17 00:00:00 2001
|
||||
From e99b757757c6fa75be9da4b9cf7c66deeaf13b7a Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 9 May 2019 18:09:43 -0500
|
||||
Subject: [PATCH] Purpur config files
|
||||
@@ -9,11 +9,11 @@ Subject: [PATCH] Purpur config files
|
||||
src/main/java/net/minecraft/server/World.java | 3 +
|
||||
src/main/java/net/pl3x/purpur/Metrics.java | 598 ++++++++++++++++++
|
||||
.../java/net/pl3x/purpur/PurpurCommand.java | 66 ++
|
||||
.../java/net/pl3x/purpur/PurpurConfig.java | 133 ++++
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 60 ++
|
||||
.../java/net/pl3x/purpur/PurpurConfig.java | 135 ++++
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 67 ++
|
||||
.../org/bukkit/craftbukkit/CraftServer.java | 11 +
|
||||
.../java/org/bukkit/craftbukkit/Main.java | 8 +
|
||||
9 files changed, 890 insertions(+)
|
||||
9 files changed, 899 insertions(+)
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/Metrics.java
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/PurpurCommand.java
|
||||
create mode 100644 src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
@@ -57,7 +57,7 @@ index 349a0ea213..d70c8cab2b 100644
|
||||
// Paper end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 3c966b4ab6..4e8a53d104 100644
|
||||
index baad985178..89090b12d2 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -80,6 +80,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
@@ -755,10 +755,10 @@ index 0000000000..f8cf4ad234
|
||||
+}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000..8600a868fb
|
||||
index 0000000000..706d787579
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
||||
@@ -0,0 +1,133 @@
|
||||
@@ -0,0 +1,135 @@
|
||||
+package net.pl3x.purpur;
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
@@ -779,7 +779,6 @@ index 0000000000..8600a868fb
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public class PurpurConfig {
|
||||
+ private static final int CONFIG_VERSION = 3;
|
||||
+ private static final String HEADER = "This is the main configuration file for Purpur.\n"
|
||||
+ + "As you can see, there's tons to configure. Some options may impact gameplay, so use\n"
|
||||
+ + "with caution, and make sure you know what each option does before configuring.\n"
|
||||
@@ -791,11 +790,13 @@ index 0000000000..8600a868fb
|
||||
+ + "Docs: https://purpur.readthedocs.org/ \n";
|
||||
+ private static File CONFIG_FILE;
|
||||
+ public static YamlConfiguration config;
|
||||
+ static Map<String, Command> commands;
|
||||
+ private static int version;
|
||||
+ private static boolean verbose;
|
||||
+
|
||||
+ private static Map<String, Command> commands;
|
||||
+ private static boolean metricsStarted;
|
||||
+
|
||||
+ static int version;
|
||||
+ static boolean verbose;
|
||||
+
|
||||
+ public static void init(File configFile) {
|
||||
+ CONFIG_FILE = configFile;
|
||||
+ config = new YamlConfiguration();
|
||||
@@ -813,20 +814,20 @@ index 0000000000..8600a868fb
|
||||
+ commands = new HashMap<>();
|
||||
+ commands.put("purpur", new PurpurCommand("purpur"));
|
||||
+
|
||||
+ version = getInt("config-version", CONFIG_VERSION);
|
||||
+ set("config-version", version);
|
||||
+ version = getInt("config-version", 4);
|
||||
+ set("config-version", 4);
|
||||
+
|
||||
+ readConfig(PurpurConfig.class, null);
|
||||
+ }
|
||||
+
|
||||
+ protected static void log(String s) {
|
||||
+ log(Level.INFO, s);
|
||||
+ if (verbose) {
|
||||
+ log(Level.INFO, s);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ protected static void log(Level level, String s) {
|
||||
+ if (verbose) {
|
||||
+ Bukkit.getLogger().log(level, s);
|
||||
+ }
|
||||
+ Bukkit.getLogger().log(level, s);
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands() {
|
||||
@@ -864,6 +865,7 @@ index 0000000000..8600a868fb
|
||||
+ }
|
||||
+
|
||||
+ private static void set(String path, Object val) {
|
||||
+ config.addDefault(path, val);
|
||||
+ config.set(path, val);
|
||||
+ }
|
||||
+
|
||||
@@ -894,13 +896,14 @@ index 0000000000..8600a868fb
|
||||
+}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000..4985f21733
|
||||
index 0000000000..eda37fa43f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -0,0 +1,60 @@
|
||||
@@ -0,0 +1,67 @@
|
||||
+package net.pl3x.purpur;
|
||||
+
|
||||
+import com.destroystokyo.paper.PaperWorldConfig;
|
||||
+import org.bukkit.configuration.ConfigurationSection;
|
||||
+import org.spigotmc.SpigotWorldConfig;
|
||||
+
|
||||
+import java.util.List;
|
||||
@@ -912,7 +915,6 @@ index 0000000000..4985f21733
|
||||
+ private final String worldName;
|
||||
+ private final PaperWorldConfig paperConfig;
|
||||
+ private final SpigotWorldConfig spigotConfig;
|
||||
+ private boolean verbose;
|
||||
+
|
||||
+ public PurpurWorldConfig(String worldName, PaperWorldConfig paperConfig, SpigotWorldConfig spigotConfig) {
|
||||
+ this.worldName = worldName;
|
||||
@@ -927,12 +929,19 @@ index 0000000000..4985f21733
|
||||
+ }
|
||||
+
|
||||
+ private void set(String path, Object val) {
|
||||
+ PurpurConfig.config.addDefault("world-settings.default." + path, val);
|
||||
+ PurpurConfig.config.set("world-settings.default." + path, val);
|
||||
+ if (PurpurConfig.config.get("world-settings." + worldName + "." + path) != null) {
|
||||
+ PurpurConfig.config.addDefault("world-settings." + worldName + "." + path, val);
|
||||
+ PurpurConfig.config.set("world-settings." + worldName + "." + path, val);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private ConfigurationSection getConfigurationSection(String path) {
|
||||
+ ConfigurationSection section = PurpurConfig.config.getConfigurationSection("world-settings." + worldName + "." + path);
|
||||
+ return section != null ? section : PurpurConfig.config.getConfigurationSection("world-settings.default." + path);
|
||||
+ }
|
||||
+
|
||||
+ private boolean getBoolean(String path, boolean def) {
|
||||
+ PurpurConfig.config.addDefault("world-settings.default." + path, def);
|
||||
+ return PurpurConfig.config.getBoolean("world-settings." + worldName + "." + path, PurpurConfig.config.getBoolean("world-settings.default." + path));
|
||||
@@ -1002,7 +1011,7 @@ index fc074a66c9..df4fb5947a 100644
|
||||
public void restart() {
|
||||
org.spigotmc.RestartCommand.restart();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index af05f3c1e0..533cfe7386 100644
|
||||
index 374e0450a2..b5bc4e2097 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -138,6 +138,14 @@ public class Main {
|
||||
|
||||
Reference in New Issue
Block a user