Added some startup crash prevention.

This commit is contained in:
Steven Lawson 2012-09-20 16:35:00 -04:00
parent 5785cc2164
commit 054ce678f4
2 changed files with 98 additions and 70 deletions

View File

@ -27,6 +27,8 @@ public class TFM_UserList
} }
private void primeList() private void primeList()
{
try
{ {
_userlist.clear(); _userlist.clear();
@ -45,6 +47,12 @@ public class TFM_UserList
exportList(); exportList();
} }
catch (Exception ex)
{
TFM_Log.severe("Error loading Userlist, resetting list: " + ex.getMessage());
purge();
}
}
private void exportList() private void exportList()
{ {

View File

@ -187,6 +187,8 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean adminOnlyMode = false; public static boolean adminOnlyMode = false;
public void loadMainConfig() public void loadMainConfig()
{
try
{ {
TFM_Util.createDefaultConfiguration(CONFIG_FILE, getFile()); TFM_Util.createDefaultConfiguration(CONFIG_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE)); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE));
@ -221,11 +223,18 @@ public class TotalFreedomMod extends JavaPlugin
allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread); allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread);
adminOnlyMode = config.getBoolean("admin_only_mode", adminOnlyMode); adminOnlyMode = config.getBoolean("admin_only_mode", adminOnlyMode);
} }
catch (Exception ex)
{
TFM_Log.severe("Error loading main config: " + ex.getMessage());
}
}
public static List<String> superadmins = new ArrayList<String>(); public static List<String> superadmins = new ArrayList<String>();
public static List<String> superadmin_ips = new ArrayList<String>(); public static List<String> superadmin_ips = new ArrayList<String>();
public void loadSuperadminConfig() public void loadSuperadminConfig()
{
try
{ {
TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, getFile()); TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), SUPERADMIN_FILE)); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), SUPERADMIN_FILE));
@ -248,11 +257,17 @@ public class TotalFreedomMod extends JavaPlugin
} }
} }
} }
catch (Exception ex)
{
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
}
}
public static List<String> permbanned_players = new ArrayList<String>(); public static List<String> permbanned_players = new ArrayList<String>();
public static List<String> permbanned_ips = new ArrayList<String>(); public static List<String> permbanned_ips = new ArrayList<String>();
public void loadPermbanConfig() public void loadPermbanConfig()
{
try
{ {
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, getFile()); TFM_Util.createDefaultConfiguration(PERMBAN_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), PERMBAN_FILE)); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), PERMBAN_FILE));
@ -275,6 +290,11 @@ public class TotalFreedomMod extends JavaPlugin
} }
} }
} }
catch (Exception ex)
{
TFM_Log.severe("Error loading permban list: " + ex.getMessage());
}
}
private void registerEventHandlers() private void registerEventHandlers()
{ {