Kajetan Johannes Hammerle 4 år sedan
förälder
incheckning
af8a866c74

+ 3 - 3
src/main/java/me/km/Server.java

@@ -47,10 +47,10 @@ public class Server {
 
         SnuviConfig conf = new SnuviConfig("", "config");
         if(conf.exists()) {
-            conf.load();
+            conf.load(null);
         }
 
-        boolean debug = conf.getBoolean("debug", false);
+        boolean debug = conf.getBoolean(null, "debug", false);
 
         // permissions
         Permissions perms = new Permissions(debug);
@@ -82,7 +82,7 @@ public class Server {
         commands.registerCommand(new CommandScript(scripts, server));
 
         // data base connection
-        databank = new DataBank(logger, conf.getString("user", "root"), conf.getString("password", ""));
+        databank = new DataBank(logger, conf.getString(null, "user", "root"), conf.getString(null, "password", ""));
         if(!databank.openDataBankConnection()) {
             logger.print("------------------------------------------------");
             logger.print("Starting server with dummy databank");

+ 1 - 1
src/main/java/me/km/snuviscript/commands/Commands.java

@@ -38,7 +38,7 @@ public class Commands {
         });
         sm.registerConsumer("config.saveasync", (sc, in) -> {
             SnuviConfig config = (SnuviConfig) in[0].get(sc);
-            scheduler.scheduleAsyncTask(() -> config.save());
+            scheduler.scheduleAsyncTask(() -> config.save(sc));
         });
     }
 }

+ 42 - 43
src/main/java/me/km/world/ModWorldInfo.java

@@ -5,7 +5,6 @@ import net.minecraft.world.storage.DerivedWorldInfo;
 import net.minecraft.world.storage.WorldInfo;
 import me.hammerle.snuviscript.config.SnuviConfig;
 import me.km.ObjectRegistry;
-import me.km.Server;
 import me.km.utils.ReflectionUtils;
 import net.minecraft.nbt.CompoundNBT;
 import net.minecraft.nbt.ListNBT;
@@ -55,7 +54,7 @@ public class ModWorldInfo extends DerivedWorldInfo {
 
         config = new SnuviConfig("worlddata", name);
         if(config.exists()) {
-            config.load();
+            config.load(null);
         }
         onLoad(info, server);
 
@@ -63,22 +62,22 @@ public class ModWorldInfo extends DerivedWorldInfo {
     }
 
     private void onLoad(WorldInfo info, MinecraftServer server) {
-        String configSeed = config.getString("seed", null);
+        String configSeed = config.getString(null, "seed", null);
         if(configSeed != null) {
             seed = configSeed.hashCode();
         }
-        spawnX = config.getInt("spawnX", info.getSpawnX());
-        spawnY = config.getInt("spawnY", info.getSpawnY());
-        spawnZ = config.getInt("spawnZ", info.getSpawnZ());
-        gameTime = config.getLong("gameTime", info.getGameTime());
-        dayTime = config.getLong("dayTime", info.getDayTime());
-        clearWeatherTime = config.getInt("clearWeatherTime", info.getClearWeatherTime());
-        raining = config.getBoolean("raining", info.isRaining());
-        rainTime = config.getInt("rainTime", info.getRainTime());
-        thundering = config.getBoolean("thundering", info.isThundering());
-        thunderTime = config.getInt("thunderTime", info.getThunderTime());
-
-        String diffi = config.getString("difficulty");
+        spawnX = config.getInt(null, "spawnX", info.getSpawnX());
+        spawnY = config.getInt(null, "spawnY", info.getSpawnY());
+        spawnZ = config.getInt(null, "spawnZ", info.getSpawnZ());
+        gameTime = config.getLong(null, "gameTime", info.getGameTime());
+        dayTime = config.getLong(null, "dayTime", info.getDayTime());
+        clearWeatherTime = config.getInt(null, "clearWeatherTime", info.getClearWeatherTime());
+        raining = config.getBoolean(null, "raining", info.isRaining());
+        rainTime = config.getInt(null, "rainTime", info.getRainTime());
+        thundering = config.getBoolean(null, "thundering", info.isThundering());
+        thunderTime = config.getInt(null, "thunderTime", info.getThunderTime());
+
+        String diffi = config.getString(null, "difficulty");
         if(diffi == null) {
             difficulty = info.getDifficulty();
         } else {
@@ -90,35 +89,35 @@ public class ModWorldInfo extends DerivedWorldInfo {
         }
 
         GameRules rules = info.getGameRulesInstance();
-        gameRules.get(DO_FIRE_TICK).set(config.getBoolean("doFireTick", rules.getBoolean(DO_FIRE_TICK)), server);
-        gameRules.get(MOB_GRIEFING).set(config.getBoolean("mobGriefing", rules.getBoolean(MOB_GRIEFING)), server);
-        gameRules.get(KEEP_INVENTORY).set(config.getBoolean("keepInventory", rules.getBoolean(KEEP_INVENTORY)), server);
-        gameRules.get(DO_MOB_SPAWNING).set(config.getBoolean("doMobSpawning", rules.getBoolean(DO_MOB_SPAWNING)), server);
-        gameRules.get(DO_MOB_LOOT).set(config.getBoolean("doMobLoot", rules.getBoolean(DO_MOB_LOOT)), server);
-        gameRules.get(DO_TILE_DROPS).set(config.getBoolean("doTileDrops", rules.getBoolean(DO_TILE_DROPS)), server);
-        gameRules.get(DO_ENTITY_DROPS).set(config.getBoolean("doEntityDrops", rules.getBoolean(DO_ENTITY_DROPS)), server);
-        gameRules.get(COMMAND_BLOCK_OUTPUT).set(config.getBoolean("commandBlockOutput", rules.getBoolean(COMMAND_BLOCK_OUTPUT)), server);
-        gameRules.get(NATURAL_REGENERATION).set(config.getBoolean("naturalRegeneration", rules.getBoolean(NATURAL_REGENERATION)), server);
-        gameRules.get(DO_DAYLIGHT_CYCLE).set(config.getBoolean("doDaylightCycle", rules.getBoolean(DO_DAYLIGHT_CYCLE)), server);
-        gameRules.get(LOG_ADMIN_COMMANDS).set(config.getBoolean("logAdminCommands", rules.getBoolean(LOG_ADMIN_COMMANDS)), server);
-        gameRules.get(SHOW_DEATH_MESSAGES).set(config.getBoolean("showDeathMessages", rules.getBoolean(SHOW_DEATH_MESSAGES)), server);
-        ReflectionUtils.setIntegerValue(gameRules.get(RANDOM_TICK_SPEED), config.getInt("randomTickSpeed", rules.getInt(RANDOM_TICK_SPEED)));
-        gameRules.get(SEND_COMMAND_FEEDBACK).set(config.getBoolean("sendCommandFeedback", rules.getBoolean(SEND_COMMAND_FEEDBACK)), server);
-        gameRules.get(REDUCED_DEBUG_INFO).set(config.getBoolean("reducedDebugInfo", rules.getBoolean(REDUCED_DEBUG_INFO)), server);
-        gameRules.get(SPECTATORS_GENERATE_CHUNKS).set(config.getBoolean("spectatorsGenerateChunks", rules.getBoolean(SPECTATORS_GENERATE_CHUNKS)), server);
-        ReflectionUtils.setIntegerValue(gameRules.get(SPAWN_RADIUS), config.getInt("spawnRadius", rules.getInt(SPAWN_RADIUS)));
-        gameRules.get(DISABLE_ELYTRA_MOVEMENT_CHECK).set(config.getBoolean("disableElytraMovementCheck", rules.getBoolean(DISABLE_ELYTRA_MOVEMENT_CHECK)), server);
-        ReflectionUtils.setIntegerValue(gameRules.get(MAX_ENTITY_CRAMMING), config.getInt("maxEntityCramming", rules.getInt(MAX_ENTITY_CRAMMING)));
-        gameRules.get(DO_WEATHER_CYCLE).set(config.getBoolean("doWeatherCycle", rules.getBoolean(DO_WEATHER_CYCLE)), server);
-        gameRules.get(DO_LIMITED_CRAFTING).set(config.getBoolean("doLimitedCrafting", rules.getBoolean(DO_LIMITED_CRAFTING)), server);
-        ReflectionUtils.setIntegerValue(gameRules.get(MAX_COMMAND_CHAIN_LENGTH), config.getInt("maxCommandChainLength", rules.getInt(MAX_COMMAND_CHAIN_LENGTH)));
-        gameRules.get(ANNOUNCE_ADVANCEMENTS).set(config.getBoolean("announceAdvancements", rules.getBoolean(ANNOUNCE_ADVANCEMENTS)), server);
-        gameRules.get(DISABLE_RAIDS).set(config.getBoolean("disableRaids", rules.getBoolean(DISABLE_RAIDS)), server);
-        gameRules.get(DO_INSOMNIA).set(config.getBoolean("doInsomnia", rules.getBoolean(DO_INSOMNIA)), server);
-        gameRules.get(DO_IMMEDIATE_RESPAWN).set(config.getBoolean("doImmediateRespawn", rules.getBoolean(DO_IMMEDIATE_RESPAWN)), server);
+        gameRules.get(DO_FIRE_TICK).set(config.getBoolean(null, "doFireTick", rules.getBoolean(DO_FIRE_TICK)), server);
+        gameRules.get(MOB_GRIEFING).set(config.getBoolean(null, "mobGriefing", rules.getBoolean(MOB_GRIEFING)), server);
+        gameRules.get(KEEP_INVENTORY).set(config.getBoolean(null, "keepInventory", rules.getBoolean(KEEP_INVENTORY)), server);
+        gameRules.get(DO_MOB_SPAWNING).set(config.getBoolean(null, "doMobSpawning", rules.getBoolean(DO_MOB_SPAWNING)), server);
+        gameRules.get(DO_MOB_LOOT).set(config.getBoolean(null, "doMobLoot", rules.getBoolean(DO_MOB_LOOT)), server);
+        gameRules.get(DO_TILE_DROPS).set(config.getBoolean(null, "doTileDrops", rules.getBoolean(DO_TILE_DROPS)), server);
+        gameRules.get(DO_ENTITY_DROPS).set(config.getBoolean(null, "doEntityDrops", rules.getBoolean(DO_ENTITY_DROPS)), server);
+        gameRules.get(COMMAND_BLOCK_OUTPUT).set(config.getBoolean(null, "commandBlockOutput", rules.getBoolean(COMMAND_BLOCK_OUTPUT)), server);
+        gameRules.get(NATURAL_REGENERATION).set(config.getBoolean(null, "naturalRegeneration", rules.getBoolean(NATURAL_REGENERATION)), server);
+        gameRules.get(DO_DAYLIGHT_CYCLE).set(config.getBoolean(null, "doDaylightCycle", rules.getBoolean(DO_DAYLIGHT_CYCLE)), server);
+        gameRules.get(LOG_ADMIN_COMMANDS).set(config.getBoolean(null, "logAdminCommands", rules.getBoolean(LOG_ADMIN_COMMANDS)), server);
+        gameRules.get(SHOW_DEATH_MESSAGES).set(config.getBoolean(null, "showDeathMessages", rules.getBoolean(SHOW_DEATH_MESSAGES)), server);
+        ReflectionUtils.setIntegerValue(gameRules.get(RANDOM_TICK_SPEED), config.getInt(null, "randomTickSpeed", rules.getInt(RANDOM_TICK_SPEED)));
+        gameRules.get(SEND_COMMAND_FEEDBACK).set(config.getBoolean(null, "sendCommandFeedback", rules.getBoolean(SEND_COMMAND_FEEDBACK)), server);
+        gameRules.get(REDUCED_DEBUG_INFO).set(config.getBoolean(null, "reducedDebugInfo", rules.getBoolean(REDUCED_DEBUG_INFO)), server);
+        gameRules.get(SPECTATORS_GENERATE_CHUNKS).set(config.getBoolean(null, "spectatorsGenerateChunks", rules.getBoolean(SPECTATORS_GENERATE_CHUNKS)), server);
+        ReflectionUtils.setIntegerValue(gameRules.get(SPAWN_RADIUS), config.getInt(null, "spawnRadius", rules.getInt(SPAWN_RADIUS)));
+        gameRules.get(DISABLE_ELYTRA_MOVEMENT_CHECK).set(config.getBoolean(null, "disableElytraMovementCheck", rules.getBoolean(DISABLE_ELYTRA_MOVEMENT_CHECK)), server);
+        ReflectionUtils.setIntegerValue(gameRules.get(MAX_ENTITY_CRAMMING), config.getInt(null, "maxEntityCramming", rules.getInt(MAX_ENTITY_CRAMMING)));
+        gameRules.get(DO_WEATHER_CYCLE).set(config.getBoolean(null, "doWeatherCycle", rules.getBoolean(DO_WEATHER_CYCLE)), server);
+        gameRules.get(DO_LIMITED_CRAFTING).set(config.getBoolean(null, "doLimitedCrafting", rules.getBoolean(DO_LIMITED_CRAFTING)), server);
+        ReflectionUtils.setIntegerValue(gameRules.get(MAX_COMMAND_CHAIN_LENGTH), config.getInt(null, "maxCommandChainLength", rules.getInt(MAX_COMMAND_CHAIN_LENGTH)));
+        gameRules.get(ANNOUNCE_ADVANCEMENTS).set(config.getBoolean(null, "announceAdvancements", rules.getBoolean(ANNOUNCE_ADVANCEMENTS)), server);
+        gameRules.get(DISABLE_RAIDS).set(config.getBoolean(null, "disableRaids", rules.getBoolean(DISABLE_RAIDS)), server);
+        gameRules.get(DO_INSOMNIA).set(config.getBoolean(null, "doInsomnia", rules.getBoolean(DO_INSOMNIA)), server);
+        gameRules.get(DO_IMMEDIATE_RESPAWN).set(config.getBoolean(null, "doImmediateRespawn", rules.getBoolean(DO_IMMEDIATE_RESPAWN)), server);
 
         try {
-            type = Type.valueOf(config.getString("type", ""));
+            type = Type.valueOf(config.getString(null, "type", ""));
         } catch(IllegalArgumentException ex) {
             type = Type.VOID;
         }
@@ -166,7 +165,7 @@ public class ModWorldInfo extends DerivedWorldInfo {
 
         config.set("type", type);
 
-        config.save();
+        config.save(null);
     }
 
     @Override