2018-07-22 12:00:00 +10:00
|
|
|
From 7f5e1cdcbdba8f6877b3edbb1e3276802167cae9 Mon Sep 17 00:00:00 2001
|
2013-05-14 12:08:11 +10:00
|
|
|
From: md_5 <md_5@live.com.au>
|
2013-07-07 09:33:34 +10:00
|
|
|
Date: Sun, 7 Jul 2013 09:32:53 +1000
|
2013-05-14 12:08:11 +10:00
|
|
|
Subject: [PATCH] Spigot Configuration
|
|
|
|
|
2014-07-05 20:34:22 +10:00
|
|
|
Provides the basic infrastructure to load and save the Spigot configuration file, spigot.yml
|
2013-05-14 12:08:11 +10:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2018-07-22 12:00:00 +10:00
|
|
|
index 2d6154bd3..b8a4b0bdd 100644
|
2013-05-14 12:08:11 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2018-07-15 10:00:00 +10:00
|
|
|
@@ -177,6 +177,11 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
|
|
if (this.H() < 0) {
|
2014-07-09 10:23:19 +10:00
|
|
|
this.setPort(this.propertyManager.getInt("server-port", 25565));
|
|
|
|
}
|
|
|
|
+ // Spigot start
|
|
|
|
+ this.a((PlayerList) (new DedicatedPlayerList(this)));
|
2015-05-25 20:09:58 +01:00
|
|
|
+ org.spigotmc.SpigotConfig.init((File) options.valueOf("spigot-settings"));
|
2014-07-09 10:23:19 +10:00
|
|
|
+ org.spigotmc.SpigotConfig.registerCommands();
|
|
|
|
+ // Spigot end
|
2013-06-21 19:08:32 +10:00
|
|
|
|
2014-11-26 08:27:08 +11:00
|
|
|
DedicatedServer.LOGGER.info("Generating keypair");
|
2014-07-09 10:23:19 +10:00
|
|
|
this.a(MinecraftEncryption.b());
|
2018-07-15 10:00:00 +10:00
|
|
|
@@ -192,7 +197,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
2014-07-09 10:23:19 +10:00
|
|
|
}
|
2013-06-21 19:08:32 +10:00
|
|
|
|
2017-07-26 13:22:16 +10:00
|
|
|
// CraftBukkit start
|
|
|
|
- this.a((PlayerList) (new DedicatedPlayerList(this)));
|
|
|
|
+ // this.a((PlayerList) (new DedicatedPlayerList(this))); // Spigot - moved up
|
|
|
|
server.loadPlugins();
|
|
|
|
server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
|
|
|
// CraftBukkit end
|
2013-06-15 22:01:15 +10:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2018-07-22 12:00:00 +10:00
|
|
|
index 000992db7..28cb33095 100644
|
2013-06-15 22:01:15 +10:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-07-15 10:00:00 +10:00
|
|
|
@@ -99,6 +99,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2014-11-26 08:27:08 +11:00
|
|
|
public long ticksPerMonsterSpawns;
|
|
|
|
public boolean populating;
|
|
|
|
private int tickPosition;
|
2013-06-20 17:31:40 +10:00
|
|
|
+ public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
|
|
|
|
|
|
|
|
public CraftWorld getWorld() {
|
|
|
|
return this.world;
|
2018-07-15 10:00:00 +10:00
|
|
|
@@ -113,6 +114,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2014-11-26 08:27:08 +11:00
|
|
|
}
|
2013-06-20 17:31:40 +10:00
|
|
|
|
2014-11-26 08:27:08 +11:00
|
|
|
protected World(IDataManager idatamanager, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) {
|
|
|
|
+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot
|
2013-06-15 22:01:15 +10:00
|
|
|
this.generator = gen;
|
2013-06-20 17:31:40 +10:00
|
|
|
this.world = new CraftWorld((WorldServer) this, gen, env);
|
2015-03-11 10:19:32 +00:00
|
|
|
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
2013-06-21 18:14:27 +10:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2018-07-22 12:00:00 +10:00
|
|
|
index 73e4cb4aa..6804b84fa 100644
|
2013-06-21 18:14:27 +10:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2018-07-16 12:16:51 +10:00
|
|
|
@@ -722,6 +722,7 @@ public final class CraftServer implements Server {
|
2014-04-17 19:03:00 +10:00
|
|
|
logger.log(Level.WARNING, "Failed to load banned-players.json, " + ex.getMessage());
|
|
|
|
}
|
2013-06-21 18:14:27 +10:00
|
|
|
|
2015-05-25 20:09:58 +01:00
|
|
|
+ org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
2013-06-21 18:14:27 +10:00
|
|
|
for (WorldServer world : console.worlds) {
|
2014-11-26 08:27:08 +11:00
|
|
|
world.worldData.setDifficulty(difficulty);
|
2013-06-21 18:14:27 +10:00
|
|
|
world.setSpawnFlags(monsters, animals);
|
2018-07-16 12:16:51 +10:00
|
|
|
@@ -736,12 +737,14 @@ public final class CraftServer implements Server {
|
2013-06-21 18:14:27 +10:00
|
|
|
} else {
|
|
|
|
world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns();
|
|
|
|
}
|
|
|
|
+ world.spigotConfig.init(); // Spigot
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginManager.clearPlugins();
|
2013-06-22 14:07:01 +10:00
|
|
|
commandMap.clearCommands();
|
|
|
|
resetRecipes();
|
2017-05-14 12:00:00 +10:00
|
|
|
reloadData();
|
2013-06-22 14:07:01 +10:00
|
|
|
+ org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
2014-02-12 13:48:26 +00:00
|
|
|
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
2018-07-16 12:16:51 +10:00
|
|
|
ignoreVanillaPermissions = commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
2013-06-22 14:07:01 +10:00
|
|
|
|
2015-05-25 20:09:58 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
2018-07-22 12:00:00 +10:00
|
|
|
index 3fecc796f..df07dc594 100644
|
2015-05-25 20:09:58 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
2018-07-22 12:00:00 +10:00
|
|
|
@@ -120,6 +120,14 @@ public class Main {
|
2015-05-25 20:09:58 +01:00
|
|
|
acceptsAll(asList("v", "version"), "Show the CraftBukkit Version");
|
|
|
|
|
|
|
|
acceptsAll(asList("demo"), "Demo mode");
|
|
|
|
+
|
|
|
|
+ // Spigot Start
|
|
|
|
+ acceptsAll(asList("S", "spigot-settings"), "File for spigot settings")
|
|
|
|
+ .withRequiredArg()
|
|
|
|
+ .ofType(File.class)
|
|
|
|
+ .defaultsTo(new File("spigot.yml"))
|
|
|
|
+ .describedAs("Yml file");
|
|
|
|
+ // Spigot End
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-20 16:04:02 +11:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotCommand.java b/src/main/java/org/spigotmc/SpigotCommand.java
|
|
|
|
new file mode 100644
|
2018-07-22 12:00:00 +10:00
|
|
|
index 000000000..fdb030c7a
|
2017-03-20 16:04:02 +11:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotCommand.java
|
|
|
|
@@ -0,0 +1,44 @@
|
|
|
|
+package org.spigotmc;
|
|
|
|
+
|
|
|
|
+import java.io.File;
|
|
|
|
+import net.minecraft.server.MinecraftServer;
|
|
|
|
+import net.minecraft.server.WorldServer;
|
|
|
|
+import org.bukkit.ChatColor;
|
|
|
|
+import org.bukkit.command.Command;
|
|
|
|
+import org.bukkit.command.CommandSender;
|
|
|
|
+
|
|
|
|
+public class SpigotCommand extends Command {
|
|
|
|
+
|
|
|
|
+ public SpigotCommand(String name) {
|
|
|
|
+ super(name);
|
|
|
|
+ this.description = "Spigot related commands";
|
|
|
|
+ this.usageMessage = "/spigot reload";
|
|
|
|
+ this.setPermission("bukkit.command.spigot");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
|
|
|
+ if (!testPermission(sender)) return true;
|
|
|
|
+
|
|
|
|
+ if (args.length != 1) {
|
|
|
|
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (args[0].equals("reload")) {
|
|
|
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
|
|
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
|
|
|
+
|
|
|
|
+ MinecraftServer console = MinecraftServer.getServer();
|
|
|
|
+ org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings"));
|
|
|
|
+ for (WorldServer world : console.worlds) {
|
|
|
|
+ world.spigotConfig.init();
|
|
|
|
+ }
|
|
|
|
+ console.server.reloadCount++;
|
|
|
|
+
|
|
|
|
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete.");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+}
|
2013-06-20 17:31:40 +10:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
|
|
new file mode 100644
|
2018-07-22 12:00:00 +10:00
|
|
|
index 000000000..132ab78ce
|
2013-06-20 17:31:40 +10:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
2017-03-20 16:04:02 +11:00
|
|
|
@@ -0,0 +1,140 @@
|
2013-06-20 17:31:40 +10:00
|
|
|
+package org.spigotmc;
|
|
|
|
+
|
|
|
|
+import com.google.common.base.Throwables;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
|
+import java.lang.reflect.Modifier;
|
2013-06-21 18:21:29 +10:00
|
|
|
+import java.util.HashMap;
|
2013-06-20 18:16:28 +10:00
|
|
|
+import java.util.List;
|
2013-06-21 18:21:29 +10:00
|
|
|
+import java.util.Map;
|
2013-06-20 17:31:40 +10:00
|
|
|
+import java.util.logging.Level;
|
2013-06-21 19:08:32 +10:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
2013-06-20 17:31:40 +10:00
|
|
|
+import org.bukkit.Bukkit;
|
2013-06-21 18:21:29 +10:00
|
|
|
+import org.bukkit.command.Command;
|
2014-07-12 11:27:09 +10:00
|
|
|
+import org.bukkit.configuration.InvalidConfigurationException;
|
2013-06-20 17:31:40 +10:00
|
|
|
+import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
+
|
|
|
|
+public class SpigotConfig
|
|
|
|
+{
|
|
|
|
+
|
2015-05-25 20:09:58 +01:00
|
|
|
+ private static File CONFIG_FILE;
|
2013-06-20 17:31:40 +10:00
|
|
|
+ private static final String HEADER = "This is the main configuration file for Spigot.\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"
|
|
|
|
+ + "For a reference for any variable inside this file, check out the Spigot wiki at\n"
|
|
|
|
+ + "http://www.spigotmc.org/wiki/spigot-configuration/\n"
|
|
|
|
+ + "\n"
|
|
|
|
+ + "If you need help with the configuration or have any questions related to Spigot,\n"
|
|
|
|
+ + "join us at the IRC or drop by our forums and leave a post.\n"
|
|
|
|
+ + "\n"
|
2014-08-23 14:14:57 +10:00
|
|
|
+ + "IRC: #spigot @ irc.spi.gt ( http://www.spigotmc.org/pages/irc/ )\n"
|
|
|
|
+ + "Forums: http://www.spigotmc.org/\n";
|
2013-06-20 17:31:40 +10:00
|
|
|
+ /*========================================================================*/
|
2014-08-25 20:09:32 +01:00
|
|
|
+ public static YamlConfiguration config;
|
2013-06-20 17:31:40 +10:00
|
|
|
+ static int version;
|
2013-06-21 18:21:29 +10:00
|
|
|
+ static Map<String, Command> commands;
|
2013-06-20 17:31:40 +10:00
|
|
|
+ /*========================================================================*/
|
|
|
|
+
|
2015-05-25 20:09:58 +01:00
|
|
|
+ public static void init(File configFile)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
2015-05-25 20:09:58 +01:00
|
|
|
+ CONFIG_FILE = configFile;
|
2014-07-12 11:27:09 +10:00
|
|
|
+ config = new YamlConfiguration();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ config.load( CONFIG_FILE );
|
|
|
|
+ } catch ( IOException ex )
|
|
|
|
+ {
|
|
|
|
+ } catch ( InvalidConfigurationException ex )
|
|
|
|
+ {
|
|
|
|
+ Bukkit.getLogger().log( Level.SEVERE, "Could not load spigot.yml, please correct your syntax errors", ex );
|
|
|
|
+ throw Throwables.propagate( ex );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:31:40 +10:00
|
|
|
+ config.options().header( HEADER );
|
|
|
|
+ config.options().copyDefaults( true );
|
|
|
|
+
|
2013-06-21 18:21:29 +10:00
|
|
|
+ commands = new HashMap<String, Command>();
|
2017-03-20 16:04:02 +11:00
|
|
|
+ commands.put( "spigot", new SpigotCommand( "spigot" ) );
|
2013-06-21 18:21:29 +10:00
|
|
|
+
|
2017-02-10 15:59:57 +11:00
|
|
|
+ version = getInt( "config-version", 11 );
|
|
|
|
+ set( "config-version", 11 );
|
2013-06-20 18:16:28 +10:00
|
|
|
+ readConfig( SpigotConfig.class, null );
|
2013-06-22 14:07:01 +10:00
|
|
|
+ }
|
2013-06-15 22:01:15 +10:00
|
|
|
+
|
2013-06-22 14:07:01 +10:00
|
|
|
+ public static void registerCommands()
|
|
|
|
+ {
|
2013-06-21 18:21:29 +10:00
|
|
|
+ for ( Map.Entry<String, Command> entry : commands.entrySet() )
|
|
|
|
+ {
|
2013-06-21 19:08:32 +10:00
|
|
|
+ MinecraftServer.getServer().server.getCommandMap().register( entry.getKey(), "Spigot", entry.getValue() );
|
2013-06-21 18:21:29 +10:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 18:16:28 +10:00
|
|
|
+ static void readConfig(Class<?> clazz, Object instance)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
2013-06-21 19:10:58 +10:00
|
|
|
+ for ( Method method : clazz.getDeclaredMethods() )
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
2013-06-20 18:16:28 +10:00
|
|
|
+ if ( Modifier.isPrivate( method.getModifiers() ) )
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
2013-06-21 19:17:26 +10:00
|
|
|
+ if ( method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE )
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
2013-06-21 19:17:26 +10:00
|
|
|
+ method.setAccessible( true );
|
2013-06-20 18:16:28 +10:00
|
|
|
+ method.invoke( instance );
|
2013-06-20 17:31:40 +10:00
|
|
|
+ } catch ( InvocationTargetException ex )
|
|
|
|
+ {
|
2014-07-12 11:27:09 +10:00
|
|
|
+ throw Throwables.propagate( ex.getCause() );
|
2013-06-25 18:12:27 +10:00
|
|
|
+ } catch ( Exception ex )
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ Bukkit.getLogger().log( Level.SEVERE, "Error invoking " + method, ex );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-06-11 12:56:24 +10:00
|
|
|
+
|
2013-06-20 17:31:40 +10:00
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ config.save( CONFIG_FILE );
|
|
|
|
+ } catch ( IOException ex )
|
|
|
|
+ {
|
|
|
|
+ Bukkit.getLogger().log( Level.SEVERE, "Could not save " + CONFIG_FILE, ex );
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-06-11 12:56:24 +10:00
|
|
|
+
|
2013-07-13 11:37:21 +10:00
|
|
|
+ private static void set(String path, Object val)
|
|
|
|
+ {
|
|
|
|
+ config.set( path, val );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private static boolean getBoolean(String path, boolean def)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( path, def );
|
|
|
|
+ return config.getBoolean( path, config.getBoolean( path ) );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private static int getInt(String path, int def)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( path, def );
|
|
|
|
+ return config.getInt( path, config.getInt( path ) );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-21 18:57:20 +10:00
|
|
|
+ private static <T> List getList(String path, T def)
|
2013-06-20 18:16:28 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( path, def );
|
|
|
|
+ return (List<T>) config.getList( path, config.getList( path ) );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private static String getString(String path, String def)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( path, def );
|
|
|
|
+ return config.getString( path, config.getString( path ) );
|
|
|
|
+ }
|
2014-07-26 18:03:45 +01:00
|
|
|
+
|
|
|
|
+ private static double getDouble(String path, double def)
|
|
|
|
+ {
|
|
|
|
+ config.addDefault( path, def );
|
|
|
|
+ return config.getDouble( path, config.getDouble( path ) );
|
|
|
|
+ }
|
2013-06-20 17:31:40 +10:00
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
new file mode 100644
|
2018-07-22 12:00:00 +10:00
|
|
|
index 000000000..961ddb428
|
2013-06-20 17:31:40 +10:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2013-07-13 11:37:21 +10:00
|
|
|
@@ -0,0 +1,71 @@
|
2013-06-20 17:31:40 +10:00
|
|
|
+package org.spigotmc;
|
2013-06-11 12:56:24 +10:00
|
|
|
+
|
2013-06-20 18:16:28 +10:00
|
|
|
+import java.util.List;
|
2013-06-20 17:31:40 +10:00
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
+
|
|
|
|
+public class SpigotWorldConfig
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ private final String worldName;
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private final YamlConfiguration config;
|
2013-06-21 18:14:27 +10:00
|
|
|
+ private boolean verbose;
|
2013-06-20 17:31:40 +10:00
|
|
|
+
|
|
|
|
+ public SpigotWorldConfig(String worldName)
|
|
|
|
+ {
|
|
|
|
+ this.worldName = worldName;
|
2013-06-20 17:36:06 +10:00
|
|
|
+ this.config = SpigotConfig.config;
|
2013-06-21 18:14:27 +10:00
|
|
|
+ init();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void init()
|
|
|
|
+ {
|
2013-06-20 17:36:06 +10:00
|
|
|
+ this.verbose = getBoolean( "verbose", true );
|
2013-06-20 17:31:40 +10:00
|
|
|
+
|
|
|
|
+ log( "-------- World Settings For [" + worldName + "] --------" );
|
2013-06-20 18:16:28 +10:00
|
|
|
+ SpigotConfig.readConfig( SpigotWorldConfig.class, this );
|
2013-06-20 17:31:40 +10:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void log(String s)
|
|
|
|
+ {
|
|
|
|
+ if ( verbose )
|
2013-06-11 12:56:24 +10:00
|
|
|
+ {
|
2013-06-20 17:31:40 +10:00
|
|
|
+ Bukkit.getLogger().info( s );
|
2013-06-11 12:56:24 +10:00
|
|
|
+ }
|
2013-06-20 17:31:40 +10:00
|
|
|
+ }
|
|
|
|
+
|
2013-07-13 11:37:21 +10:00
|
|
|
+ private void set(String path, Object val)
|
|
|
|
+ {
|
|
|
|
+ config.set( "world-settings.default." + path, val );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private boolean getBoolean(String path, boolean def)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( "world-settings.default." + path, def );
|
|
|
|
+ return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-21 17:00:01 +10:00
|
|
|
+ private double getDouble(String path, double def)
|
|
|
|
+ {
|
|
|
|
+ config.addDefault( "world-settings.default." + path, def );
|
2013-06-21 18:14:27 +10:00
|
|
|
+ return config.getDouble( "world-settings." + worldName + "." + path, config.getDouble( "world-settings.default." + path ) );
|
2013-06-21 17:00:01 +10:00
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private int getInt(String path, int def)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( "world-settings.default." + path, def );
|
|
|
|
+ return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-21 17:41:26 +10:00
|
|
|
+ private <T> List getList(String path, T def)
|
2013-06-20 18:16:28 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( "world-settings.default." + path, def );
|
|
|
|
+ return (List<T>) config.getList( "world-settings." + worldName + "." + path, config.getList( "world-settings.default." + path ) );
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-20 17:36:06 +10:00
|
|
|
+ private String getString(String path, String def)
|
2013-06-20 17:31:40 +10:00
|
|
|
+ {
|
|
|
|
+ config.addDefault( "world-settings.default." + path, def );
|
|
|
|
+ return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
|
|
|
|
+ }
|
|
|
|
+}
|
2013-05-14 12:08:11 +10:00
|
|
|
--
|
2018-07-15 10:00:00 +10:00
|
|
|
2.17.1
|
2013-05-14 12:08:11 +10:00
|
|
|
|