Changed config methods, missing config.yml

This commit is contained in:
Steven Lawson 2011-10-12 15:33:31 -04:00
parent b8d5e2f974
commit cd5bba842b
2 changed files with 29 additions and 24 deletions

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -13,6 +14,8 @@ import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -337,11 +340,11 @@ public class TFM_Cmds_Admin implements CommandExecutor
sender.sendMessage("Nuke monitor is disabled."); sender.sendMessage("Nuke monitor is disabled.");
} }
plugin.reloadConfig(); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml"));
plugin.getConfig().set("nuke_monitor", plugin.nukeMonitor); config.set("nuke_monitor", plugin.nukeMonitor);
plugin.getConfig().set("nuke_monitor_range", plugin.nukeMonitorRange); config.set("nuke_monitor_range", plugin.nukeMonitorRange);
plugin.getConfig().set("nuke_monitor_count", plugin.nukeMonitorCountBreak); config.set("nuke_monitor_count", plugin.nukeMonitorCountBreak);
plugin.saveConfig(); config.save(new File(plugin.getDataFolder(), "config.yml"));
} }
else else
{ {
@ -370,9 +373,9 @@ public class TFM_Cmds_Admin implements CommandExecutor
sender.sendMessage("Command preprocess logging is now disabled."); sender.sendMessage("Command preprocess logging is now disabled.");
} }
plugin.reloadConfig(); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml"));
plugin.getConfig().set("preprocess_log", plugin.preprocessLogEnabled); config.set("preprocess_log", plugin.preprocessLogEnabled);
plugin.saveConfig(); config.save(new File(plugin.getDataFolder(), "config.yml"));
} }
else else
{ {

View File

@ -20,6 +20,8 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -221,23 +223,23 @@ public class TotalFreedomMod extends JavaPlugin
{ {
createDefaultConfiguration("config.yml"); createDefaultConfiguration("config.yml");
reloadConfig(); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
allowExplosions = getConfig().getBoolean("allow_explosions", false); allowExplosions = config.getBoolean("allow_explosions", false);
allowFirePlace = getConfig().getBoolean("allow_fire_place", false); allowFirePlace = config.getBoolean("allow_fire_place", false);
allowFireSpread = getConfig().getBoolean("allow_fire_spread", false); allowFireSpread = config.getBoolean("allow_fire_spread", false);
allowLavaDamage = getConfig().getBoolean("allow_lava_damage", false); allowLavaDamage = config.getBoolean("allow_lava_damage", false);
allowLavaPlace = getConfig().getBoolean("allow_lava_place", false); allowLavaPlace = config.getBoolean("allow_lava_place", false);
allowWaterPlace = getConfig().getBoolean("allow_water_place", false); allowWaterPlace = config.getBoolean("allow_water_place", false);
autoEntityWipe = getConfig().getBoolean("auto_wipe", true); autoEntityWipe = config.getBoolean("auto_wipe", true);
explosiveRadius = getConfig().getDouble("explosiveRadius", 4.0D); explosiveRadius = config.getDouble("explosiveRadius", 4.0D);
nukeMonitor = getConfig().getBoolean("nuke_monitor", true); nukeMonitor = config.getBoolean("nuke_monitor", true);
nukeMonitorCountBreak = getConfig().getInt("nuke_monitor_count", 100); nukeMonitorCountBreak = config.getInt("nuke_monitor_count", 100);
nukeMonitorRange = getConfig().getDouble("nuke_monitor_range", 10.0D); nukeMonitorRange = config.getDouble("nuke_monitor_range", 10.0D);
preprocessLogEnabled = getConfig().getBoolean("preprocess_log", true); preprocessLogEnabled = config.getBoolean("preprocess_log", true);
freecamTriggerCount = getConfig().getInt("freecam_trigger_count", 10); freecamTriggerCount = config.getInt("freecam_trigger_count", 10);
superadmins = (List<String>) getConfig().getList("superadmins", null); superadmins = (List<String>) config.getList("superadmins", null);
if (superadmins == null) if (superadmins == null)
{ {
superadmins = new ArrayList<String>(); superadmins = new ArrayList<String>();
@ -245,7 +247,7 @@ public class TotalFreedomMod extends JavaPlugin
superadmins.add("markbyron"); superadmins.add("markbyron");
} }
superadmin_ips = (List<String>) getConfig().getList("superadmin_ips", null); superadmin_ips = (List<String>) config.getList("superadmin_ips", null);
if (superadmin_ips == null) if (superadmin_ips == null)
{ {
superadmin_ips = new ArrayList<String>(); superadmin_ips = new ArrayList<String>();