Simplify
This commit is contained in:
parent
07b12237b5
commit
919070df83
@ -1,6 +1,6 @@
|
|||||||
From fba3fb120161a1618a8991784bd0822087af733d Mon Sep 17 00:00:00 2001
|
From f6b9d470ca4aa3abddd5eaa0c3d50ca1db0802b5 Mon Sep 17 00:00:00 2001
|
||||||
From: md_5 <md_5@live.com.au>
|
From: md_5 <md_5@live.com.au>
|
||||||
Date: Thu, 20 Jun 2013 17:28:01 +1000
|
Date: Thu, 20 Jun 2013 17:35:57 +1000
|
||||||
Subject: [PATCH] Spigot Configuration
|
Subject: [PATCH] Spigot Configuration
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ index 3a4ddea..de052bd 100644
|
|||||||
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
||||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..7bb7712
|
index 0000000..80a76c1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||||
@@ -0,0 +1,91 @@
|
@@ -0,0 +1,91 @@
|
||||||
@ -80,7 +80,7 @@ index 0000000..7bb7712
|
|||||||
+ config.options().header( HEADER );
|
+ config.options().header( HEADER );
|
||||||
+ config.options().copyDefaults( true );
|
+ config.options().copyDefaults( true );
|
||||||
+
|
+
|
||||||
+ version = getInt( config, "config-version", 1 );
|
+ version = getInt( "config-version", 1 );
|
||||||
+ readConfig( SpigotConfig.class );
|
+ readConfig( SpigotConfig.class );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -90,11 +90,11 @@ index 0000000..7bb7712
|
|||||||
+ {
|
+ {
|
||||||
+ if ( Modifier.isPrivate( method.getModifiers() ) && Modifier.isStatic( method.getModifiers() ) )
|
+ if ( Modifier.isPrivate( method.getModifiers() ) && Modifier.isStatic( method.getModifiers() ) )
|
||||||
+ {
|
+ {
|
||||||
+ if ( method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == YamlConfiguration.class )
|
+ if ( method.getParameterTypes().length == 0 )
|
||||||
+ {
|
+ {
|
||||||
+ try
|
+ try
|
||||||
+ {
|
+ {
|
||||||
+ method.invoke( null, config );
|
+ method.invoke( null );
|
||||||
+ } catch ( InvocationTargetException ex )
|
+ } catch ( InvocationTargetException ex )
|
||||||
+ {
|
+ {
|
||||||
+ Throwables.propagate( ex.getCause() );
|
+ Throwables.propagate( ex.getCause() );
|
||||||
@ -115,19 +115,19 @@ index 0000000..7bb7712
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static boolean getBoolean(YamlConfiguration config, String path, boolean def)
|
+ private static boolean getBoolean(String path, boolean def)
|
||||||
+ {
|
+ {
|
||||||
+ config.addDefault( path, def );
|
+ config.addDefault( path, def );
|
||||||
+ return config.getBoolean( path, config.getBoolean( path ) );
|
+ return config.getBoolean( path, config.getBoolean( path ) );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static int getInt(YamlConfiguration config, String path, int def)
|
+ private static int getInt(String path, int def)
|
||||||
+ {
|
+ {
|
||||||
+ config.addDefault( path, def );
|
+ config.addDefault( path, def );
|
||||||
+ return config.getInt( path, config.getInt( path ) );
|
+ return config.getInt( path, config.getInt( path ) );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private static String getString(YamlConfiguration config, String path, String def)
|
+ private static String getString(String path, String def)
|
||||||
+ {
|
+ {
|
||||||
+ config.addDefault( path, def );
|
+ config.addDefault( path, def );
|
||||||
+ return config.getString( path, config.getString( path ) );
|
+ return config.getString( path, config.getString( path ) );
|
||||||
@ -135,10 +135,10 @@ index 0000000..7bb7712
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..9818836
|
index 0000000..b954278
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
@@ -0,0 +1,48 @@
|
@@ -0,0 +1,50 @@
|
||||||
+package org.spigotmc;
|
+package org.spigotmc;
|
||||||
+
|
+
|
||||||
+import org.bukkit.Bukkit;
|
+import org.bukkit.Bukkit;
|
||||||
@ -148,12 +148,14 @@ index 0000000..9818836
|
|||||||
+{
|
+{
|
||||||
+
|
+
|
||||||
+ private final String worldName;
|
+ private final String worldName;
|
||||||
|
+ private final YamlConfiguration config;
|
||||||
+ private final boolean verbose;
|
+ private final boolean verbose;
|
||||||
+
|
+
|
||||||
+ public SpigotWorldConfig(String worldName)
|
+ public SpigotWorldConfig(String worldName)
|
||||||
+ {
|
+ {
|
||||||
+ this.worldName = worldName;
|
+ this.worldName = worldName;
|
||||||
+ this.verbose = getBoolean( SpigotConfig.config, "verbose", true );
|
+ this.config = SpigotConfig.config;
|
||||||
|
+ this.verbose = getBoolean( "verbose", true );
|
||||||
+
|
+
|
||||||
+ log( "-------------- Spigot ----------------" );
|
+ log( "-------------- Spigot ----------------" );
|
||||||
+ log( "-------- World Settings For [" + worldName + "] --------" );
|
+ log( "-------- World Settings For [" + worldName + "] --------" );
|
||||||
@ -169,19 +171,19 @@ index 0000000..9818836
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private boolean getBoolean(YamlConfiguration config, String path, boolean def)
|
+ private boolean getBoolean(String path, boolean def)
|
||||||
+ {
|
+ {
|
||||||
+ config.addDefault( "world-settings.default." + path, def );
|
+ config.addDefault( "world-settings.default." + path, def );
|
||||||
+ return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) );
|
+ return config.getBoolean( "world-settings." + worldName + "." + path, config.getBoolean( "world-settings.default." + path ) );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private int getInt(YamlConfiguration config, String path, int def)
|
+ private int getInt(String path, int def)
|
||||||
+ {
|
+ {
|
||||||
+ config.addDefault( "world-settings.default." + path, def );
|
+ config.addDefault( "world-settings.default." + path, def );
|
||||||
+ return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) );
|
+ return config.getInt( "world-settings." + worldName + "." + path, config.getInt( "world-settings.default." + path ) );
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private String getString(YamlConfiguration config, String path, String def)
|
+ private String getString(String path, String def)
|
||||||
+ {
|
+ {
|
||||||
+ config.addDefault( "world-settings.default." + path, def );
|
+ config.addDefault( "world-settings.default." + path, def );
|
||||||
+ return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
|
+ return config.getString( "world-settings." + worldName + "." + path, config.getString( "world-settings.default." + path ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user