Upstream has released updates that appears to apply and compile correctly Tuinity Changes: db8a861 Updated Upstream (Paper) cb75b52 Updated Upstream (Paper) 98e9d5b Updated Upstream (Paper) 1aa9097 Updated Upstream (Paper) 126d3cc Fix abnormally high cpu usage caused by lighting 9a88f39 Fix skull NPE eedc3fc Updated Upstream (Paper) d0e617d Updated Upstream (Paper) 15c661b Updated Upstream (Paper)
295 lines
14 KiB
Diff
295 lines
14 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?=
|
|
<tsao-chi@the-lingo.org>
|
|
Date: Fri, 3 Apr 2020 14:59:22 +0800
|
|
Subject: [PATCH] Akarin configuration
|
|
|
|
|
|
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
index b09981e9bd2d24a0f0e291fabfbbbf0b3887a80b..501dacb4584412dd84e36421e113a1f068693e47 100644
|
|
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
|
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
@@ -231,6 +231,7 @@ public class TimingsExport extends Thread {
|
|
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
|
pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), // Tuinity - add config to timings report
|
|
pair("tuinity", mapAsJSON(Bukkit.spigot().getTuinityConfig(), null)) // Tuinity - add config to timings report
|
|
+ , pair("akarin", mapAsJSON(Bukkit.spigot().getAkarinConfig(), null)) // Akarin - Server config
|
|
));
|
|
|
|
new TimingsExport(listeners, parent, history).start();
|
|
diff --git a/src/main/java/io/akarin/server/Config.java b/src/main/java/io/akarin/server/Config.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..2ac8f02a97429f04f3e5c9206ec228edccaf24c9
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/akarin/server/Config.java
|
|
@@ -0,0 +1,183 @@
|
|
+package io.akarin.server;
|
|
+
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.configuration.ConfigurationSection;
|
|
+import org.bukkit.configuration.file.YamlConfiguration;
|
|
+
|
|
+import java.io.File;
|
|
+import java.lang.reflect.Method;
|
|
+import java.lang.reflect.Modifier;
|
|
+import java.util.List;
|
|
+import java.util.logging.Level;
|
|
+
|
|
+public final class Config {
|
|
+
|
|
+ public static final String CONFIG_HEADER = "Configuration file for Akarin.";
|
|
+ public static final int CURRENT_CONFIG_VERSION = 1;
|
|
+
|
|
+ private static final Object[] EMPTY = new Object[0];
|
|
+
|
|
+ private static File configFile;
|
|
+ public static YamlConfiguration config;
|
|
+ private static int configVersion;
|
|
+
|
|
+ public static void init(final File file) {
|
|
+ Config.configFile = file;
|
|
+ final YamlConfiguration config = new YamlConfiguration();
|
|
+ config.options().header(CONFIG_HEADER);
|
|
+ config.options().copyDefaults(true);
|
|
+
|
|
+ if (!file.exists()) {
|
|
+ try {
|
|
+ file.createNewFile();
|
|
+ } catch (final Exception ex) {
|
|
+ Bukkit.getLogger().log(Level.SEVERE, "Failure to create Akarin config", ex);
|
|
+ }
|
|
+ } else {
|
|
+ try {
|
|
+ config.load(file);
|
|
+ } catch (final Exception ex) {
|
|
+ Bukkit.getLogger().log(Level.SEVERE, "Failure to load Akarin config", ex);
|
|
+ throw new RuntimeException(ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ Config.load(config);
|
|
+ }
|
|
+
|
|
+ public static void load(final YamlConfiguration config) {
|
|
+ Config.config = config;
|
|
+ Config.configVersion = Config.getInt("config-version-please-do-not-modify-me", CURRENT_CONFIG_VERSION);
|
|
+ Config.set("config-version-please-do-not-modify-me", CURRENT_CONFIG_VERSION);
|
|
+
|
|
+ for (final Method method : Config.class.getDeclaredMethods()) {
|
|
+ if (method.getReturnType() != void.class || method.getParameterCount() != 0 ||
|
|
+ !Modifier.isPrivate(method.getModifiers()) || !Modifier.isStatic(method.getModifiers())) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ method.setAccessible(true);
|
|
+ method.invoke(null, EMPTY);
|
|
+ } catch (final Exception ex) {
|
|
+ throw new RuntimeException(ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /* We re-save to add new options */
|
|
+ try {
|
|
+ config.save(Config.configFile);
|
|
+ } catch (final Exception ex) {
|
|
+ Bukkit.getLogger().log(Level.SEVERE, "Unable to save Akarin config", ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ static void set(final String path, final Object value) {
|
|
+ Config.config.set(path, value);
|
|
+ }
|
|
+
|
|
+ static boolean getBoolean(final String path, final boolean dfl) {
|
|
+ Config.config.addDefault(path, Boolean.valueOf(dfl));
|
|
+ return Config.config.getBoolean(path, dfl);
|
|
+ }
|
|
+
|
|
+ static int getInt(final String path, final int dfl) {
|
|
+ Config.config.addDefault(path, Integer.valueOf(dfl));
|
|
+ return Config.config.getInt(path, dfl);
|
|
+ }
|
|
+
|
|
+ static long getLong(final String path, final long dfl) {
|
|
+ Config.config.addDefault(path, Long.valueOf(dfl));
|
|
+ return Config.config.getLong(path, dfl);
|
|
+ }
|
|
+
|
|
+ static double getDouble(final String path, final double dfl) {
|
|
+ Config.config.addDefault(path, Double.valueOf(dfl));
|
|
+ return Config.config.getDouble(path, dfl);
|
|
+ }
|
|
+
|
|
+ public static final class WorldConfig {
|
|
+
|
|
+ public final String worldName;
|
|
+ public ConfigurationSection config;
|
|
+ ConfigurationSection worldDefaults;
|
|
+
|
|
+ public WorldConfig(final String worldName) {
|
|
+ this.worldName = worldName;
|
|
+ this.init();
|
|
+ }
|
|
+
|
|
+ public void init() {
|
|
+ this.worldDefaults = Config.config.getConfigurationSection("world-settings.default");
|
|
+ if (this.worldDefaults == null) {
|
|
+ this.worldDefaults = Config.config.createSection("world-settings.default");
|
|
+ }
|
|
+
|
|
+ String worldSectionPath = "world-settings.".concat(this.worldName);
|
|
+ ConfigurationSection section = Config.config.getConfigurationSection(worldSectionPath);
|
|
+ if (section == null) {
|
|
+ section = Config.config.createSection(worldSectionPath);
|
|
+ }
|
|
+ Config.config.set(worldSectionPath, section);
|
|
+
|
|
+ this.load(section);
|
|
+ }
|
|
+
|
|
+ public void load(final ConfigurationSection config) {
|
|
+ this.config = config;
|
|
+
|
|
+ for (final Method method : Config.WorldConfig.class.getDeclaredMethods()) {
|
|
+ if (method.getReturnType() != void.class || method.getParameterCount() != 0 ||
|
|
+ !Modifier.isPrivate(method.getModifiers()) || Modifier.isStatic(method.getModifiers())) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ method.setAccessible(true);
|
|
+ method.invoke(this, EMPTY);
|
|
+ } catch (final Exception ex) {
|
|
+ throw new RuntimeException(ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /* We re-save to add new options */
|
|
+ try {
|
|
+ Config.config.save(Config.configFile);
|
|
+ } catch (final Exception ex) {
|
|
+ Bukkit.getLogger().log(Level.SEVERE, "Unable to save Akarin config", ex);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * update world defaults for the specified path, but also sets this world's config value for the path
|
|
+ * if it exists
|
|
+ */
|
|
+ void set(final String path, final Object val) {
|
|
+ this.worldDefaults.set(path, val);
|
|
+ if (this.config.get(path) != null) {
|
|
+ this.config.set(path, val);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ boolean getBoolean(final String path, final boolean dfl) {
|
|
+ this.worldDefaults.addDefault(path, Boolean.valueOf(dfl));
|
|
+ return this.config.getBoolean(path, this.worldDefaults.getBoolean(path));
|
|
+ }
|
|
+
|
|
+ int getInt(final String path, final int dfl) {
|
|
+ this.worldDefaults.addDefault(path, Integer.valueOf(dfl));
|
|
+ return this.config.getInt(path, this.worldDefaults.getInt(path));
|
|
+ }
|
|
+
|
|
+ long getLong(final String path, final long dfl) {
|
|
+ this.worldDefaults.addDefault(path, Long.valueOf(dfl));
|
|
+ return this.config.getLong(path, this.worldDefaults.getLong(path));
|
|
+ }
|
|
+
|
|
+ double getDouble(final String path, final double dfl) {
|
|
+ this.worldDefaults.addDefault(path, Double.valueOf(dfl));
|
|
+ return this.config.getDouble(path, this.worldDefaults.getDouble(path));
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
index 1f1243ae8371a3e76ebfdee91b327db832767c4a..201ce4a0411f9ddc775053130a7ca62f7412d5f3 100644
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
@@ -195,6 +195,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
|
|
// Paper end
|
|
com.tuinity.tuinity.config.TuinityConfig.init((File) options.valueOf("tuinity-settings")); // Tuinity - Server Config
|
|
+ io.akarin.server.Config.init((File) options.valueOf("akarin-settings")); // Akarin - Server Config
|
|
|
|
this.setSpawnAnimals(dedicatedserverproperties.spawnAnimals);
|
|
this.setSpawnNPCs(dedicatedserverproperties.spawnNpcs);
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 6ae9ec627e0cf2b3b464a8d86e08a6deba713675..655e0b5e52e22a1ac1ff3718ad5ab3ab61ef7e41 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -89,6 +89,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
public final ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
|
|
|
public final com.tuinity.tuinity.config.TuinityConfig.WorldConfig tuinityConfig; // Tuinity - Server Config
|
|
+ public final io.akarin.server.Config.WorldConfig akarinConfig; // Akarin - Server Config
|
|
|
|
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
|
public static BlockPosition lastPhysicsProblem; // Spigot
|
|
@@ -140,6 +141,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(worlddata.getName(), this.spigotConfig); // Paper
|
|
this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this.paperConfig, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
|
|
this.tuinityConfig = new com.tuinity.tuinity.config.TuinityConfig.WorldConfig(worlddata.getName()); // Tuinity - Server Config
|
|
+ this.akarinConfig = new io.akarin.server.Config.WorldConfig(worlddata.getName()); // Akarin - Server Config
|
|
this.generator = gen;
|
|
if (dimensionmanager.world == null) dimensionmanager.world = (WorldServer) this; // Paper
|
|
this.world = new CraftWorld((WorldServer) this, gen, env);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 760752eaeb07af551cd3cfd36be064c048a05d5b..8863a778a8c34513bc02e42376ebce295d515393 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -816,6 +816,7 @@ public final class CraftServer implements Server {
|
|
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
|
com.destroystokyo.paper.PaperConfig.init((File) console.options.valueOf("paper-settings")); // Paper
|
|
com.tuinity.tuinity.config.TuinityConfig.init((File) console.options.valueOf("tuinity-settings")); // Tuinity - Server Config
|
|
+ io.akarin.server.Config.init((File) console.options.valueOf("akarin-settings")); // Akarin - Server Config
|
|
for (WorldServer world : console.getWorlds()) {
|
|
world.worldData.setDifficulty(config.difficulty);
|
|
world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals);
|
|
@@ -845,6 +846,7 @@ public final class CraftServer implements Server {
|
|
world.spigotConfig.init(); // Spigot
|
|
world.paperConfig.init(); // Paper
|
|
world.tuinityConfig.init(); // Tuinity - Server Config
|
|
+ world.akarinConfig.init(); // Akarin - Server Config
|
|
}
|
|
|
|
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
|
@@ -2147,6 +2149,14 @@ public final class CraftServer implements Server {
|
|
}
|
|
// Tuinity end - add config to timings report
|
|
|
|
+ // Akarin Start - Server Config
|
|
+ @Override
|
|
+ public YamlConfiguration getAkarinConfig()
|
|
+ {
|
|
+ return io.akarin.server.Config.config;
|
|
+ }
|
|
+ // Akarin End - Server Config
|
|
+
|
|
@Override
|
|
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 cce21aaf3ba8c5049334e17b238aaf44d64db5fe..6464c181bbe35c4621b3b7eac6da47dc50de4e87 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
@@ -146,6 +146,14 @@ public class Main {
|
|
.describedAs("Yml file");
|
|
/* Conctete End - Server Config */
|
|
|
|
+ // Akarin Start - Server Config
|
|
+ acceptsAll(asList("akarin", "akarin-settings"), "File for Akarin settings")
|
|
+ .withRequiredArg()
|
|
+ .ofType(File.class)
|
|
+ .defaultsTo(new File("akarin.yml"))
|
|
+ .describedAs("Yml file");
|
|
+ // Akarin End - Server Config
|
|
+
|
|
// Paper start
|
|
acceptsAll(asList("server-name"), "Name of the server")
|
|
.withRequiredArg()
|