From 528965b5adb8000944495eb02df72766195fbff1 Mon Sep 17 00:00:00 2001 From: Morgan Date: Fri, 26 Aug 2011 10:45:59 -0400 Subject: [PATCH] Formatting --- src/net/milkbowl/autosave/AutoSave.java | 956 ++++++++++-------- src/net/milkbowl/autosave/AutoSaveConfig.java | 177 ++-- src/net/milkbowl/autosave/AutoSaveThread.java | 162 +-- src/net/milkbowl/autosave/Generic.java | 34 +- src/net/milkbowl/autosave/Mode.java | 3 +- src/net/milkbowl/autosave/ReportThread.java | 72 +- src/net/milkbowl/autosave/ThreadType.java | 3 +- 7 files changed, 770 insertions(+), 637 deletions(-) diff --git a/src/net/milkbowl/autosave/AutoSave.java b/src/net/milkbowl/autosave/AutoSave.java index 8774c16..8ea355c 100644 --- a/src/net/milkbowl/autosave/AutoSave.java +++ b/src/net/milkbowl/autosave/AutoSave.java @@ -39,449 +39,549 @@ public class AutoSave extends JavaPlugin { private static final Logger log = Logger.getLogger("Minecraft"); - private static final String CONFIG_FILE_NAME = "plugins/AutoSave/config.properties"; - - private AutoSaveThread saveThread = null; - private ReportThread reportThread = null; - private AutoSaveConfig config; - protected Date lastSave = null; - protected int numPlayers = 0; - protected boolean saveInProgress = false; - - @Override - public void onDisable() { - - // Perform a Save NOW! - performSave(); - - // Enable built-in world saving for ASynchronous Mode + private static final String CONFIG_FILE_NAME = "plugins/AutoSave/config.properties"; + + private AutoSaveThread saveThread = null; + private ReportThread reportThread = null; + private AutoSaveConfig config; + protected Date lastSave = null; + protected int numPlayers = 0; + protected boolean saveInProgress = false; + + @Override + public void onDisable() { + + // Perform a Save NOW! + performSave(); + + // Enable built-in world saving for ASynchronous Mode if (config.varMode == Mode.ASYNCHRONOUS) { for (World world : getServer().getWorlds()) { ((CraftWorld) world).getHandle().canSave = true; } } - - long timeA = 0; - if (config.varDebug) { - timeA = System.currentTimeMillis(); - } - // Stop thread - if (config.varDebug) { - log.info(String.format("[%s] Stopping Save Thread", getDescription().getName())); - } - stopThread(ThreadType.SAVE); - stopThread(ThreadType.REPORT); - - if (config.varDebug) { - long timeB = System.currentTimeMillis(); - long millis = timeB - timeA; - long durationSeconds = TimeUnit.MILLISECONDS.toSeconds(millis); - - log.info(String.format("[%s] Version %s was disabled in %d seconds", getDescription().getName(), getDescription().getVersion(), durationSeconds)); - } else { - log.info(String.format("[%s] Version %s is disabled!", getDescription().getName(), getDescription().getVersion())); - } - } - - @Override - public void onEnable() { - // Load Configuration - config = new AutoSaveConfig(getConfiguration()); - config.load(); - - // Ensure our folder exists... - File dir = new File("plugins/AutoSave"); - dir.mkdir(); - - // Load configuration - //loadConfigFile(); - - // Test the waters, make sure we are running a build that has the methods we NEED - try { - // Check Server - org.bukkit.Server.class.getMethod("savePlayers", new Class[] {}); - - // Check World - org.bukkit.World.class.getMethod("save", new Class[] {}); - } catch (NoSuchMethodException e) { - // Do error stuff - log.severe(String.format("[%s] ERROR: Server version is incompatible with %s!", getDescription().getName(), getDescription().getName())); - log.severe(String.format("[%s] Could not find method \"%s\", disabling!", getDescription().getName(), e.getMessage())); - - // Clean up - getPluginLoader().disablePlugin(this); - return; - } - - // Disable built-in world saving for ASynchronous Mode + + long timeA = 0; + if (config.varDebug) { + timeA = System.currentTimeMillis(); + } + // Stop thread + if (config.varDebug) { + log.info(String.format("[%s] Stopping Save Thread", + getDescription().getName())); + } + stopThread(ThreadType.SAVE); + stopThread(ThreadType.REPORT); + + if (config.varDebug) { + long timeB = System.currentTimeMillis(); + long millis = timeB - timeA; + long durationSeconds = TimeUnit.MILLISECONDS.toSeconds(millis); + + log.info(String.format( + "[%s] Version %s was disabled in %d seconds", + getDescription().getName(), getDescription().getVersion(), + durationSeconds)); + } else { + log.info(String.format("[%s] Version %s is disabled!", + getDescription().getName(), getDescription().getVersion())); + } + } + + @Override + public void onEnable() { + // Load Configuration + config = new AutoSaveConfig(getConfiguration()); + config.load(); + + // Ensure our folder exists... + File dir = new File("plugins/AutoSave"); + dir.mkdir(); + + // Load configuration + // loadConfigFile(); + + // Test the waters, make sure we are running a build that has the + // methods we NEED + try { + // Check Server + org.bukkit.Server.class.getMethod("savePlayers", new Class[] {}); + + // Check World + org.bukkit.World.class.getMethod("save", new Class[] {}); + } catch (NoSuchMethodException e) { + // Do error stuff + log.severe(String.format( + "[%s] ERROR: Server version is incompatible with %s!", + getDescription().getName(), getDescription().getName())); + log.severe(String.format( + "[%s] Could not find method \"%s\", disabling!", + getDescription().getName(), e.getMessage())); + + // Clean up + getPluginLoader().disablePlugin(this); + return; + } + + // Disable built-in world saving for ASynchronous Mode if (config.varMode == Mode.ASYNCHRONOUS) { for (World world : getServer().getWorlds()) { ((CraftWorld) world).getHandle().canSave = true; } } - // Make an HTTP request for anonymous statistic collection - startThread(ThreadType.REPORT); - - // Start AutoSave Thread - startThread(ThreadType.SAVE); - - // Notify on logger load - log.info(String.format("[%s] Version %s is enabled: %s", getDescription().getName(), getDescription().getVersion(), config.varUuid.toString())); - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - String commandName = command.getName().toLowerCase(); - Player player = null; - if ((sender instanceof Player)) { - // Player, lets check if player isOp() - player = (Player) sender; - // Check Permissions - if(!player.isOp()) { - sendMessage(sender, config.messageInsufficientPermissions); - return true; - } - } else if (sender instanceof ConsoleCommandSender) { - // Success, this was from the Console - } else { - // Unknown, ignore these people with a pretty message - sendMessage(sender, config.messageInsufficientPermissions); - return true; - } - - if (commandName.equals("autosave")) { - if (args.length == 0) { - performSave(); - return true; - } else if (args.length == 1 && args[0].equalsIgnoreCase("help")) { - // Shows help for allowed commands - - // /save - sendMessage(sender, "&f/save&7 - &3Saves all players & worlds"); - - // /save help - sendMessage(sender, "&f/save help&7 - &3Displays this dialogue"); - - // /save toggle - sendMessage(sender, "&f/save toggle&7 - &3Toggles the AutoSave system"); - - // /save status - sendMessage(sender, "&f/save status&7 - &3Reports thread status and last run time"); - - // /save interval - sendMessage(sender, "&f/save interval&7 [value] - &3Sets & retrieves the save interval"); - - // /save broadcast - sendMessage(sender, "&f/save broadcast&7 [on|off] - &3Sets & retrieves the broadcast value"); - - // /save report - sendMessage(sender, "&f/save report&7 [on|off] - &3Sets & retrieves the report value"); - - // /save warn - sendMessage(sender, "&f/save warn&7 [value] - &3Sets & retrieves the warn time in seconds"); - - // /save version - sendMessage(sender, "&f/save version&7 - &3Prints the version of AutoSave"); - } else if (args.length == 1 && args[0].equalsIgnoreCase("toggle")) { - // Start thread - if (saveThread == null) { - sendMessage(sender, config.messageStarting); - return startThread(ThreadType.SAVE); - } else { // Stop thread - sendMessage(sender, config.messageStopping); - return stopThread(ThreadType.SAVE); - } - } else if (args.length == 1 && args[0].equalsIgnoreCase("status")) { - // Get Thread Status - if (saveThread == null) { - sendMessage(sender, config.messageStatusOff); - } else { - if (saveThread.isAlive()) { - if (lastSave == null) { - sendMessage(sender, config.messageStatusNotRun); - return true; - } else { - sendMessage(sender, config.messageStatusSuccess.replaceAll("\\$\\{DATE\\}", lastSave.toString())); - return true; - } - } else { - sendMessage(sender, config.messageStatusFail); - return true; - } - } - } else if (args.length >= 1 && args[0].equalsIgnoreCase("interval")) { - if (args.length == 1) { - // Report interval! - sendMessage(sender, config.messageInfoLookup.replaceAll("\\$\\{VARIABLE\\}", "Interval").replaceAll("\\$\\{VALUE\\}", String.valueOf(config.varInterval))); - return true; - } else if (args.length == 2) { - // Change interval! - try { - int newInterval = Integer.parseInt(args[1]); - config.varInterval = newInterval; - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "Interval")); - return true; - } catch (NumberFormatException e) { - sendMessage(sender, config.messageInfoNaN); - return false; - } - } - } else if (args.length >= 1 && args[0].equalsIgnoreCase("warn")) { - if (args.length == 1) { - // Report interval! - sendMessage(sender, config.messageInfoListLookup.replaceAll("\\$\\{VARIABLE\\}", "Warn").replaceAll("\\$\\{VALUE\\}", Generic.join(", ", config.varWarnTimes))); - return true; - } else if (args.length == 2) { - // Change interval! - try { - ArrayList tmpWarn = new ArrayList(); - for (String s : args[1].split(",")) { - tmpWarn.add(Integer.parseInt(s)); - } - config.varWarnTimes = tmpWarn; - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "Warn")); - return true; - } catch (NumberFormatException e) { - sendMessage(sender, config.messageInfoNaN); - return false; - } - } - } else if (args.length >= 1 && args[0].equalsIgnoreCase("broadcast")) { - if (args.length == 1) { - // Report broadcast status! - sendMessage(sender, config.messageInfoLookup.replaceAll("\\$\\{VARIABLE\\}", "Broadcast").replaceAll("\\$\\{VALUE\\}", String.valueOf(config.varBroadcast ? config.valueOn : config.valueOff))); - return true; - } else if (args.length == 2) { - // Change broadcast status! - boolean newSetting = false; - if (args[1].equalsIgnoreCase(config.valueOn)) { - newSetting = true; - } else if (args[1].equalsIgnoreCase(config.valueOff)) { - newSetting = false; - } else { - sendMessage(sender, config.messageInfoInvalid.replaceAll("\\$\\{VALIDSETTINGS\\}", String.format("%s, %s", config.valueOn, config.valueOff))); - return false; - } - config.varBroadcast = newSetting; - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "AutoSave Broadcast")); - return true; - } - } else if (args.length >= 1 && args[0].equalsIgnoreCase("debug")) { - if (args.length == 1) { - // Report debug status! - sendMessage(sender, config.messageInfoLookup.replaceAll("\\$\\{VARIABLE\\}", "Debug").replaceAll("\\$\\{VALUE\\}", String.valueOf(config.varDebug ? config.valueOn : config.valueOff))); - return true; - } else if (args.length == 2) { - // Change debug status! - boolean newSetting = false; - if (args[1].equalsIgnoreCase(config.valueOn)) { - newSetting = true; - } else if (args[1].equalsIgnoreCase(config.valueOff)) { - newSetting = false; - } else { - sendMessage(sender, config.messageInfoInvalid.replaceAll("\\$\\{VALIDSETTINGS\\}", String.format("%s, %s", config.valueOn, config.valueOff))); - return false; - } - config.varDebug = newSetting; - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "Debug")); - return true; - } - } else if (args.length >= 1 && args[0].equalsIgnoreCase("report")) { - if (args.length == 1) { - // Report report status! - sendMessage(sender, config.messageInfoLookup.replaceAll("\\$\\{VARIABLE\\}", "Report").replaceAll("\\$\\{VALUE\\}", String.valueOf(config.varReport ? config.valueOn : config.valueOff))); - return true; - } else if (args.length == 2) { - // Change report status! - boolean newSetting = false; - if (args[1].equalsIgnoreCase(config.valueOn)) { - startThread(ThreadType.REPORT); - newSetting = true; - } else if (args[1].equalsIgnoreCase(config.valueOff)) { - stopThread(ThreadType.REPORT); - newSetting = false; - } else { - sendMessage(sender, config.messageInfoInvalid.replaceAll("\\$\\{VALIDSETTINGS\\}", String.format("%s, %s", config.valueOn, config.valueOff))); - return false; - } - config.varReport = newSetting; - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "Report")); - return true; - } - } else if (args.length == 2 && args[0].equalsIgnoreCase("addworld")) { - config.varWorlds.add(args[1]); - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "Worlds")); - return true; - } else if (args.length == 2 && args[0].equalsIgnoreCase("remworld")) { - config.varWorlds.remove(args[1]); - sendMessage(sender, config.messageInfoChangeSuccess.replaceAll("\\$\\{VARIABLE\\}", "Worlds")); - return true; - } else if (args.length == 1 && args[0].equalsIgnoreCase("world")) { - sendMessage(sender, config.messageInfoListLookup.replaceAll("\\$\\{VARIABLE\\}", "Worlds").replaceAll("\\$\\{VALUE\\}", Generic.join(", ", config.varWorlds))); - return true; - } else if (args.length == 1 && args[0].equalsIgnoreCase("version")) { - sendMessage(sender, String.format("%s%s", ChatColor.BLUE, config.messageVersion.replaceAll("\\$\\{VERSION\\}", getDescription().getVersion()).replaceAll("\\$\\{UUID\\}", config.varUuid.toString()))); - return true; - } - } else { - sendMessage(sender, String.format("Unknown command \"%s\" handled by %s", commandName, getDescription().getName())); - } - return false; - } - - protected boolean startThread(ThreadType type) { - switch(type) { - case REPORT: - if (reportThread == null || !reportThread.isAlive()) { - reportThread = new ReportThread(this, config.varUuid, config.varDebug); - reportThread.start(); - } - return true; - case SAVE: - if (saveThread == null || !saveThread.isAlive()) { - saveThread = new AutoSaveThread(this, config); - saveThread.start(); - } - return true; - default: - return false; - } - } - - protected boolean stopThread(ThreadType type) { + // Make an HTTP request for anonymous statistic collection + startThread(ThreadType.REPORT); + + // Start AutoSave Thread + startThread(ThreadType.SAVE); + + // Notify on logger load + log.info(String.format("[%s] Version %s is enabled: %s", + getDescription().getName(), getDescription().getVersion(), + config.varUuid.toString())); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, + String commandLabel, String[] args) { + String commandName = command.getName().toLowerCase(); + Player player = null; + if ((sender instanceof Player)) { + // Player, lets check if player isOp() + player = (Player) sender; + // Check Permissions + if (!player.isOp()) { + sendMessage(sender, config.messageInsufficientPermissions); + return true; + } + } else if (sender instanceof ConsoleCommandSender) { + // Success, this was from the Console + } else { + // Unknown, ignore these people with a pretty message + sendMessage(sender, config.messageInsufficientPermissions); + return true; + } + + if (commandName.equals("autosave")) { + if (args.length == 0) { + performSave(); + return true; + } else if (args.length == 1 && args[0].equalsIgnoreCase("help")) { + // Shows help for allowed commands + + // /save + sendMessage(sender, "&f/save&7 - &3Saves all players & worlds"); + + // /save help + sendMessage(sender, "&f/save help&7 - &3Displays this dialogue"); + + // /save toggle + sendMessage(sender, + "&f/save toggle&7 - &3Toggles the AutoSave system"); + + // /save status + sendMessage(sender, + "&f/save status&7 - &3Reports thread status and last run time"); + + // /save interval + sendMessage(sender, + "&f/save interval&7 [value] - &3Sets & retrieves the save interval"); + + // /save broadcast + sendMessage(sender, + "&f/save broadcast&7 [on|off] - &3Sets & retrieves the broadcast value"); + + // /save report + sendMessage(sender, + "&f/save report&7 [on|off] - &3Sets & retrieves the report value"); + + // /save warn + sendMessage(sender, + "&f/save warn&7 [value] - &3Sets & retrieves the warn time in seconds"); + + // /save version + sendMessage(sender, + "&f/save version&7 - &3Prints the version of AutoSave"); + } else if (args.length == 1 && args[0].equalsIgnoreCase("toggle")) { + // Start thread + if (saveThread == null) { + sendMessage(sender, config.messageStarting); + return startThread(ThreadType.SAVE); + } else { // Stop thread + sendMessage(sender, config.messageStopping); + return stopThread(ThreadType.SAVE); + } + } else if (args.length == 1 && args[0].equalsIgnoreCase("status")) { + // Get Thread Status + if (saveThread == null) { + sendMessage(sender, config.messageStatusOff); + } else { + if (saveThread.isAlive()) { + if (lastSave == null) { + sendMessage(sender, config.messageStatusNotRun); + return true; + } else { + sendMessage(sender, + config.messageStatusSuccess.replaceAll( + "\\$\\{DATE\\}", + lastSave.toString())); + return true; + } + } else { + sendMessage(sender, config.messageStatusFail); + return true; + } + } + } else if (args.length >= 1 && args[0].equalsIgnoreCase("interval")) { + if (args.length == 1) { + // Report interval! + sendMessage( + sender, + config.messageInfoLookup.replaceAll( + "\\$\\{VARIABLE\\}", "Interval") + .replaceAll("\\$\\{VALUE\\}", + String.valueOf(config.varInterval))); + return true; + } else if (args.length == 2) { + // Change interval! + try { + int newInterval = Integer.parseInt(args[1]); + config.varInterval = newInterval; + sendMessage(sender, + config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "Interval")); + return true; + } catch (NumberFormatException e) { + sendMessage(sender, config.messageInfoNaN); + return false; + } + } + } else if (args.length >= 1 && args[0].equalsIgnoreCase("warn")) { + if (args.length == 1) { + // Report interval! + sendMessage( + sender, + config.messageInfoListLookup.replaceAll( + "\\$\\{VARIABLE\\}", "Warn").replaceAll( + "\\$\\{VALUE\\}", + Generic.join(", ", config.varWarnTimes))); + return true; + } else if (args.length == 2) { + // Change interval! + try { + ArrayList tmpWarn = new ArrayList(); + for (String s : args[1].split(",")) { + tmpWarn.add(Integer.parseInt(s)); + } + config.varWarnTimes = tmpWarn; + sendMessage(sender, + config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "Warn")); + return true; + } catch (NumberFormatException e) { + sendMessage(sender, config.messageInfoNaN); + return false; + } + } + } else if (args.length >= 1 + && args[0].equalsIgnoreCase("broadcast")) { + if (args.length == 1) { + // Report broadcast status! + sendMessage( + sender, + config.messageInfoLookup + .replaceAll("\\$\\{VARIABLE\\}", + "Broadcast") + .replaceAll( + "\\$\\{VALUE\\}", + String.valueOf(config.varBroadcast ? config.valueOn + : config.valueOff))); + return true; + } else if (args.length == 2) { + // Change broadcast status! + boolean newSetting = false; + if (args[1].equalsIgnoreCase(config.valueOn)) { + newSetting = true; + } else if (args[1].equalsIgnoreCase(config.valueOff)) { + newSetting = false; + } else { + sendMessage(sender, + config.messageInfoInvalid.replaceAll( + "\\$\\{VALIDSETTINGS\\}", String + .format("%s, %s", + config.valueOn, + config.valueOff))); + return false; + } + config.varBroadcast = newSetting; + sendMessage(sender, + config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "AutoSave Broadcast")); + return true; + } + } else if (args.length >= 1 && args[0].equalsIgnoreCase("debug")) { + if (args.length == 1) { + // Report debug status! + sendMessage( + sender, + config.messageInfoLookup + .replaceAll("\\$\\{VARIABLE\\}", "Debug") + .replaceAll( + "\\$\\{VALUE\\}", + String.valueOf(config.varDebug ? config.valueOn + : config.valueOff))); + return true; + } else if (args.length == 2) { + // Change debug status! + boolean newSetting = false; + if (args[1].equalsIgnoreCase(config.valueOn)) { + newSetting = true; + } else if (args[1].equalsIgnoreCase(config.valueOff)) { + newSetting = false; + } else { + sendMessage(sender, + config.messageInfoInvalid.replaceAll( + "\\$\\{VALIDSETTINGS\\}", String + .format("%s, %s", + config.valueOn, + config.valueOff))); + return false; + } + config.varDebug = newSetting; + sendMessage(sender, + config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "Debug")); + return true; + } + } else if (args.length >= 1 && args[0].equalsIgnoreCase("report")) { + if (args.length == 1) { + // Report report status! + sendMessage( + sender, + config.messageInfoLookup + .replaceAll("\\$\\{VARIABLE\\}", "Report") + .replaceAll( + "\\$\\{VALUE\\}", + String.valueOf(config.varReport ? config.valueOn + : config.valueOff))); + return true; + } else if (args.length == 2) { + // Change report status! + boolean newSetting = false; + if (args[1].equalsIgnoreCase(config.valueOn)) { + startThread(ThreadType.REPORT); + newSetting = true; + } else if (args[1].equalsIgnoreCase(config.valueOff)) { + stopThread(ThreadType.REPORT); + newSetting = false; + } else { + sendMessage(sender, + config.messageInfoInvalid.replaceAll( + "\\$\\{VALIDSETTINGS\\}", String + .format("%s, %s", + config.valueOn, + config.valueOff))); + return false; + } + config.varReport = newSetting; + sendMessage(sender, + config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "Report")); + return true; + } + } else if (args.length == 2 && args[0].equalsIgnoreCase("addworld")) { + config.varWorlds.add(args[1]); + sendMessage(sender, config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "Worlds")); + return true; + } else if (args.length == 2 && args[0].equalsIgnoreCase("remworld")) { + config.varWorlds.remove(args[1]); + sendMessage(sender, config.messageInfoChangeSuccess.replaceAll( + "\\$\\{VARIABLE\\}", "Worlds")); + return true; + } else if (args.length == 1 && args[0].equalsIgnoreCase("world")) { + sendMessage( + sender, + config.messageInfoListLookup.replaceAll( + "\\$\\{VARIABLE\\}", "Worlds").replaceAll( + "\\$\\{VALUE\\}", + Generic.join(", ", config.varWorlds))); + return true; + } else if (args.length == 1 && args[0].equalsIgnoreCase("version")) { + sendMessage(sender, String.format( + "%s%s", + ChatColor.BLUE, + config.messageVersion.replaceAll("\\$\\{VERSION\\}", + getDescription().getVersion()).replaceAll( + "\\$\\{UUID\\}", config.varUuid.toString()))); + return true; + } + } else { + sendMessage(sender, String.format( + "Unknown command \"%s\" handled by %s", commandName, + getDescription().getName())); + } + return false; + } + + protected boolean startThread(ThreadType type) { + switch (type) { + case REPORT: + if (reportThread == null || !reportThread.isAlive()) { + reportThread = new ReportThread(this, config.varUuid, + config.varDebug); + reportThread.start(); + } + return true; + case SAVE: + if (saveThread == null || !saveThread.isAlive()) { + saveThread = new AutoSaveThread(this, config); + saveThread.start(); + } + return true; + default: + return false; + } + } + + protected boolean stopThread(ThreadType type) { switch (type) { - case REPORT: - if (reportThread == null) { - return true; - } else { - reportThread.setRun(false); - try { - reportThread.join(5000); - reportThread = null; - return true; - } catch (InterruptedException e) { - warn("Could not stop ReportThread", e); - return false; - } - } - case SAVE: - if (saveThread == null) { - return true; - } else { - saveThread.setRun(false); - try { - saveThread.join(5000); - saveThread = null; - return true; - } catch (InterruptedException e) { - warn("Could not stop AutoSaveThread", e); - return false; - } - } - default: - return false; + case REPORT: + if (reportThread == null) { + return true; + } else { + reportThread.setRun(false); + try { + reportThread.join(5000); + reportThread = null; + return true; + } catch (InterruptedException e) { + warn("Could not stop ReportThread", e); + return false; + } + } + case SAVE: + if (saveThread == null) { + return true; + } else { + saveThread.setRun(false); + try { + saveThread.join(5000); + saveThread = null; + return true; + } catch (InterruptedException e) { + warn("Could not stop AutoSaveThread", e); + return false; + } + } + default: + return false; + } + } + + private void savePlayers() { + // Save the players + debug("Saving players"); + this.getServer().savePlayers(); + } + + private int saveWorlds(List worldNames) { + // Save our worlds... + int i = 0; + List worlds = this.getServer().getWorlds(); + for (World world : worlds) { + if (worldNames.contains(world.getName())) { + debug(String.format("Saving world: %s", world.getName())); + world.save(); + i++; + } + } + return i; + } + + private int saveWorlds() { + // Save our worlds + int i = 0; + List worlds = this.getServer().getWorlds(); + for (World world : worlds) { + debug(String.format("Saving world: %s", world.getName())); + world.save(); + i++; } - } - - private void savePlayers() { - // Save the players - debug("Saving players"); - this.getServer().savePlayers(); - } - - private int saveWorlds(List worldNames) { - // Save our worlds... - int i = 0; - List worlds = this.getServer().getWorlds(); - for (World world : worlds) { - if (worldNames.contains(world.getName())) { - debug(String.format("Saving world: %s", world.getName())); - world.save(); - i++; - } - } - return i; - } - - private int saveWorlds() { - // Save our worlds - int i = 0; - List worlds = this.getServer().getWorlds(); - for (World world : worlds) { - debug(String.format("Saving world: %s", world.getName())); - world.save(); - i++; - } - return i; - } - - public void performSave() { - if(saveInProgress) { - warn("Multiple concurrent saves attempted! Save interval is likely too short!"); - return; - } - - if(getServer().getOnlinePlayers().length == 0) { - // No players online, don't bother saving. - return; - } - - // Lock - saveInProgress = true; - - broadcast(config.messageBroadcastPre); - - // Save the players - savePlayers(); - debug("Saved Players"); - - // Save the worlds - int saved = 0; - if (config.varWorlds.contains("*")) { - saved += saveWorlds(); - } else { - saved += saveWorlds(config.varWorlds); - } - + return i; + } + + public void performSave() { + if (saveInProgress) { + warn("Multiple concurrent saves attempted! Save interval is likely too short!"); + return; + } + + if (getServer().getOnlinePlayers().length == 0) { + // No players online, don't bother saving. + return; + } + + // Lock + saveInProgress = true; + + broadcast(config.messageBroadcastPre); + + // Save the players + savePlayers(); + debug("Saved Players"); + + // Save the worlds + int saved = 0; + if (config.varWorlds.contains("*")) { + saved += saveWorlds(); + } else { + saved += saveWorlds(config.varWorlds); + } + debug(String.format("Saved %d Worlds", saved)); - - lastSave = new Date(); - debug("messageBroadcastPost"); + lastSave = new Date(); + debug("messageBroadcastPost"); broadcast(config.messageBroadcastPost); - - // Release - saveInProgress = false; - } - - public void sendMessage(CommandSender sender, String message) { - if(!message.equals("")) { - sender.sendMessage(Generic.parseColor(message)); - } - } - - public void broadcast(String message) { - if(!message.equals("")) { - getServer().broadcastMessage(Generic.parseColor(message)); - log.info(message); - log.info(Generic.stripColor(message)); - log.info(String.format("[%s] %s", getDescription().getName(), Generic.stripColor(message))); - } - } - - public void debug(String message) { - if(config.varDebug) { - log.info(Generic.stripColor(String.format("[%s] %s", getDescription().getName(), message))); - } - } - - public void warn(String message) { - log.warning(String.format("[%s] %s", getDescription().getName(), Generic.stripColor(message))); - } - - public void warn(String message, Exception e) { - log.log(Level.WARNING, String.format("[%s] %s", getDescription().getName(), Generic.stripColor(message)), e); - } + + // Release + saveInProgress = false; + } + + public void sendMessage(CommandSender sender, String message) { + if (!message.equals("")) { + sender.sendMessage(Generic.parseColor(message)); + } + } + + public void broadcast(String message) { + if (!message.equals("")) { + getServer().broadcastMessage(Generic.parseColor(message)); + log.info(message); + log.info(Generic.stripColor(message)); + log.info(String.format("[%s] %s", getDescription().getName(), + Generic.stripColor(message))); + } + } + + public void debug(String message) { + if (config.varDebug) { + log.info(Generic.stripColor(String.format("[%s] %s", + getDescription().getName(), message))); + } + } + + public void warn(String message) { + log.warning(String.format("[%s] %s", getDescription().getName(), + Generic.stripColor(message))); + } + + public void warn(String message, Exception e) { + log.log(Level.WARNING, + String.format("[%s] %s", getDescription().getName(), + Generic.stripColor(message)), e); + } } diff --git a/src/net/milkbowl/autosave/AutoSaveConfig.java b/src/net/milkbowl/autosave/AutoSaveConfig.java index 728cbf6..ff5179f 100644 --- a/src/net/milkbowl/autosave/AutoSaveConfig.java +++ b/src/net/milkbowl/autosave/AutoSaveConfig.java @@ -27,90 +27,105 @@ import org.bukkit.util.config.Configuration; public class AutoSaveConfig { - + Configuration config; - + public AutoSaveConfig(Configuration config) { this.config = config; } - // Messages - protected String messageBroadcastPre = "&9AutoSaving"; - protected String messageBroadcastPost = "&9AutoSave Complete"; - protected String messageStatusFail = "&9AutoSave has stopped, check the server logs for more info"; - protected String messageStatusNotRun = "&9AutoSave is running but has not yet saved."; - protected String messageStatusSuccess = "&9AutoSave is running and last saved at ${DATE}."; - protected String messageStatusOff = "&9AutoSave is not running (disabled)"; - protected String messageInsufficientPermissions = "&cYou do not have access to that command."; - protected String messageStopping = "&9AutoSave Stopping"; - protected String messageStarting = "&9AutoSave Starting"; - protected String messageInfoNaN = "&cYou must enter a valid number, ex: 300"; - protected String messageInfoChangeSuccess = "&9${VARIABLE} has been updated."; - protected String messageInfoLookup = "&9${VARIABLE} is ${VALUE}"; - protected String messageInfoListLookup = "&9${VARIABLE} is set to [${VALUE}]"; - protected String messageInfoInvalid = "&cYou must enter a valid setting (${VALIDSETTINGS})"; - protected String messageVersion = "&9AutoSave v${VERSION}, Instance ${UUID}"; - protected String messageWarning = "&9Warning, AutoSave will commence soon."; - - // Values - protected String valueOn = "on"; - protected String valueOff = "off"; - - // Variables - protected UUID varUuid; - protected boolean varReport = true; - protected int varInterval = 300; - protected List varWarnTimes = null; - protected boolean varBroadcast = true; - protected boolean varDebug = false; - protected List varWorlds = null; - protected Mode varMode = Mode.SYNCHRONOUS; - - public void load() { - - // Messages - messageBroadcastPre = config.getString("messages.broadcast.pre", messageBroadcastPre); - messageBroadcastPost = config.getString("messages.broadcast.post", messageBroadcastPost); - messageStatusFail = config.getString("messages.status.fail", messageStatusFail); - messageStatusNotRun = config.getString("messages.status.notrun", messageStatusNotRun); - messageStatusSuccess = config.getString("messages.status.success", messageStatusSuccess); - messageStatusOff = config.getString("messages.status.off", messageStatusOff); - messageInsufficientPermissions = config.getString("messages.insufficentpermissions", messageInsufficientPermissions); - messageStopping = config.getString("messages.stopping", messageStopping); - messageStarting = config.getString("messages.starting", messageStarting); - messageInfoNaN = config.getString("messages.info.nan", messageInfoNaN); - messageInfoChangeSuccess = config.getString("messages.info.changesuccess", messageInfoChangeSuccess); - messageInfoLookup = config.getString("messages.info.lookup", messageInfoLookup); - messageInfoListLookup = config.getString("messages.info.listlookup", messageInfoListLookup); - messageInfoInvalid = config.getString("messages.info.invalid", messageInfoInvalid); - messageVersion = config.getString("messages.version", messageVersion); - messageWarning = config.getString("messages.warning", messageWarning); - - // Values - valueOn = config.getString("value.on", valueOn); - valueOff = config.getString("value.off", valueOff); - - // Variables - varDebug = config.getBoolean("var.debug", varDebug); - varBroadcast = config.getBoolean("var.broadcast", varBroadcast); - varInterval = config.getInt("var.interval", varInterval); - varMode = Mode.valueOf(config.getString("var.mode", varMode.name())); - - varWorlds = config.getStringList("var.worlds", null); - if(varWorlds.size() == 0) { - varWorlds.add("*"); - config.setProperty("var.worlds", varWorlds); - } - - varWarnTimes = config.getIntList("var.warntime", null); - if(varWarnTimes.size() == 0) { - varWarnTimes.add(0); - config.setProperty("var.warntime", varWarnTimes); - } - - varUuid = UUID.fromString(config.getString("var.uuid", UUID.randomUUID().toString())); - varReport = config.getBoolean("var.report", varReport); - - config.save(); - } + // Messages + protected String messageBroadcastPre = "&9AutoSaving"; + protected String messageBroadcastPost = "&9AutoSave Complete"; + protected String messageStatusFail = "&9AutoSave has stopped, check the server logs for more info"; + protected String messageStatusNotRun = "&9AutoSave is running but has not yet saved."; + protected String messageStatusSuccess = "&9AutoSave is running and last saved at ${DATE}."; + protected String messageStatusOff = "&9AutoSave is not running (disabled)"; + protected String messageInsufficientPermissions = "&cYou do not have access to that command."; + protected String messageStopping = "&9AutoSave Stopping"; + protected String messageStarting = "&9AutoSave Starting"; + protected String messageInfoNaN = "&cYou must enter a valid number, ex: 300"; + protected String messageInfoChangeSuccess = "&9${VARIABLE} has been updated."; + protected String messageInfoLookup = "&9${VARIABLE} is ${VALUE}"; + protected String messageInfoListLookup = "&9${VARIABLE} is set to [${VALUE}]"; + protected String messageInfoInvalid = "&cYou must enter a valid setting (${VALIDSETTINGS})"; + protected String messageVersion = "&9AutoSave v${VERSION}, Instance ${UUID}"; + protected String messageWarning = "&9Warning, AutoSave will commence soon."; + + // Values + protected String valueOn = "on"; + protected String valueOff = "off"; + + // Variables + protected UUID varUuid; + protected boolean varReport = true; + protected int varInterval = 300; + protected List varWarnTimes = null; + protected boolean varBroadcast = true; + protected boolean varDebug = false; + protected List varWorlds = null; + protected Mode varMode = Mode.SYNCHRONOUS; + + public void load() { + + // Messages + messageBroadcastPre = config.getString("messages.broadcast.pre", + messageBroadcastPre); + messageBroadcastPost = config.getString("messages.broadcast.post", + messageBroadcastPost); + messageStatusFail = config.getString("messages.status.fail", + messageStatusFail); + messageStatusNotRun = config.getString("messages.status.notrun", + messageStatusNotRun); + messageStatusSuccess = config.getString("messages.status.success", + messageStatusSuccess); + messageStatusOff = config.getString("messages.status.off", + messageStatusOff); + messageInsufficientPermissions = config.getString( + "messages.insufficentpermissions", + messageInsufficientPermissions); + messageStopping = config + .getString("messages.stopping", messageStopping); + messageStarting = config + .getString("messages.starting", messageStarting); + messageInfoNaN = config.getString("messages.info.nan", messageInfoNaN); + messageInfoChangeSuccess = config.getString( + "messages.info.changesuccess", messageInfoChangeSuccess); + messageInfoLookup = config.getString("messages.info.lookup", + messageInfoLookup); + messageInfoListLookup = config.getString("messages.info.listlookup", + messageInfoListLookup); + messageInfoInvalid = config.getString("messages.info.invalid", + messageInfoInvalid); + messageVersion = config.getString("messages.version", messageVersion); + messageWarning = config.getString("messages.warning", messageWarning); + + // Values + valueOn = config.getString("value.on", valueOn); + valueOff = config.getString("value.off", valueOff); + + // Variables + varDebug = config.getBoolean("var.debug", varDebug); + varBroadcast = config.getBoolean("var.broadcast", varBroadcast); + varInterval = config.getInt("var.interval", varInterval); + varMode = Mode.valueOf(config.getString("var.mode", varMode.name())); + + varWorlds = config.getStringList("var.worlds", null); + if (varWorlds.size() == 0) { + varWorlds.add("*"); + config.setProperty("var.worlds", varWorlds); + } + + varWarnTimes = config.getIntList("var.warntime", null); + if (varWarnTimes.size() == 0) { + varWarnTimes.add(0); + config.setProperty("var.warntime", varWarnTimes); + } + + varUuid = UUID.fromString(config.getString("var.uuid", UUID + .randomUUID().toString())); + varReport = config.getBoolean("var.report", varReport); + + config.save(); + } } \ No newline at end of file diff --git a/src/net/milkbowl/autosave/AutoSaveThread.java b/src/net/milkbowl/autosave/AutoSaveThread.java index 4c47cd4..5122154 100644 --- a/src/net/milkbowl/autosave/AutoSaveThread.java +++ b/src/net/milkbowl/autosave/AutoSaveThread.java @@ -25,86 +25,98 @@ public class AutoSaveThread extends Thread { - protected final Logger log = Logger.getLogger("Minecraft"); - private boolean run = true; - private boolean saveInProgress = false; - private AutoSave plugin = null; - private AutoSaveConfig config = null; + protected final Logger log = Logger.getLogger("Minecraft"); + private boolean run = true; + private boolean saveInProgress = false; + private AutoSave plugin = null; + private AutoSaveConfig config = null; - // Constructor to define number of seconds to sleep - AutoSaveThread(AutoSave plugin, AutoSaveConfig config) { - this.plugin = plugin; - this.config = config; - } + // Constructor to define number of seconds to sleep + AutoSaveThread(AutoSave plugin, AutoSaveConfig config) { + this.plugin = plugin; + this.config = config; + } - // Allows for the thread to naturally exit if value is false - public void setRun(boolean run) { - this.run = run; - } + // Allows for the thread to naturally exit if value is false + public void setRun(boolean run) { + this.run = run; + } - // The code to run...weee - public void run() { - if (config == null) { - return; - } + // The code to run...weee + public void run() { + if (config == null) { + return; + } - log.info(String.format("[%s] AutoSaveThread Started: Interval is %d seconds, Warn Times are %s", plugin.getDescription().getName(), config.varInterval, Generic.join(",", config.varWarnTimes))); - while (run) { - // Do our Sleep stuff! - for (int i = 0; i < config.varInterval; i++) { - try { - if (!run) { - if (config.varDebug) { - log.info(String.format("[%s] Graceful quit of AutoSaveThread", plugin.getDescription().getName())); - } - return; - } - boolean warn = false; - for (int w : config.varWarnTimes) { - if (w != 0 && w + i == config.varInterval) { - warn = true; - } - } + log.info(String + .format("[%s] AutoSaveThread Started: Interval is %d seconds, Warn Times are %s", + plugin.getDescription().getName(), config.varInterval, + Generic.join(",", config.varWarnTimes))); + while (run) { + // Do our Sleep stuff! + for (int i = 0; i < config.varInterval; i++) { + try { + if (!run) { + if (config.varDebug) { + log.info(String.format( + "[%s] Graceful quit of AutoSaveThread", + plugin.getDescription().getName())); + } + return; + } + boolean warn = false; + for (int w : config.varWarnTimes) { + if (w != 0 && w + i == config.varInterval) { + warn = true; + } + } - if (warn) { - // Perform warning - if (config.varDebug) { - log.info(String.format("[%s] Warning Time Reached: %d seconds to go.", plugin.getDescription().getName(), config.varInterval - i)); - } - plugin.getServer().broadcastMessage(config.messageWarning); - log.info(String.format("[%s] %s", plugin.getDescription().getName(), config.messageWarning)); - } - Thread.sleep(1000); - } catch (InterruptedException e) { - log.info("Could not sleep!"); - } - } + if (warn) { + // Perform warning + if (config.varDebug) { + log.info(String + .format("[%s] Warning Time Reached: %d seconds to go.", + plugin.getDescription().getName(), + config.varInterval - i)); + } + plugin.getServer().broadcastMessage( + config.messageWarning); + log.info(String.format("[%s] %s", plugin + .getDescription().getName(), + config.messageWarning)); + } + Thread.sleep(1000); + } catch (InterruptedException e) { + log.info("Could not sleep!"); + } + } - switch(config.varMode) { - case ASYNCHRONOUS: - plugin.getServer().getScheduler() - .scheduleAsyncDelayedTask(plugin, new Runnable() { - - public void run() { - plugin.performSave(); - plugin.lastSave = new Date(); - } - }); - break; - case SYNCHRONOUS: - plugin.getServer().getScheduler() - .scheduleSyncDelayedTask(plugin, new Runnable() { - public void run() { - plugin.performSave(); - plugin.lastSave = new Date(); - } - }); - break; - default: - log.warning(String.format("[%s] Invalid configuration mode!", plugin.getDescription().getName())); - break; - } - } - } + switch (config.varMode) { + case ASYNCHRONOUS: + plugin.getServer().getScheduler() + .scheduleAsyncDelayedTask(plugin, new Runnable() { + + public void run() { + plugin.performSave(); + plugin.lastSave = new Date(); + } + }); + break; + case SYNCHRONOUS: + plugin.getServer().getScheduler() + .scheduleSyncDelayedTask(plugin, new Runnable() { + public void run() { + plugin.performSave(); + plugin.lastSave = new Date(); + } + }); + break; + default: + log.warning(String.format("[%s] Invalid configuration mode!", + plugin.getDescription().getName())); + break; + } + } + } } diff --git a/src/net/milkbowl/autosave/Generic.java b/src/net/milkbowl/autosave/Generic.java index caace7e..90e7615 100644 --- a/src/net/milkbowl/autosave/Generic.java +++ b/src/net/milkbowl/autosave/Generic.java @@ -25,27 +25,27 @@ import org.bukkit.ChatColor; public class Generic { - public static boolean stringArrayContains(String base, String[] comparesWith) { + public static boolean stringArrayContains(String base, String[] comparesWith) { - for (int i = 0; i < comparesWith.length; i++) { - try { - if (base.compareTo(comparesWith[i]) == 0) { - return true; - } - } catch (NullPointerException npe) { - return false; - } - } + for (int i = 0; i < comparesWith.length; i++) { + try { + if (base.compareTo(comparesWith[i]) == 0) { + return true; + } + } catch (NullPointerException npe) { + return false; + } + } + + return false; + } - return false; - } - public static String join(String glue, List s) { try { - if(s == null) { + if (s == null) { return ""; } - + int k = s.size(); if (k == 0) { return null; @@ -60,7 +60,7 @@ public static String join(String glue, List s) { return ""; } } - + // Parse Colors public static String parseColor(String message) { message = message.replaceAll("&0", ChatColor.BLACK + ""); @@ -81,7 +81,7 @@ public static String parseColor(String message) { message = message.replaceAll("(?i)&f", ChatColor.WHITE + ""); return message; } - + // Parse Colors public static String stripColor(String message) { message = message.replaceAll("&0", ""); diff --git a/src/net/milkbowl/autosave/Mode.java b/src/net/milkbowl/autosave/Mode.java index f96f0a2..02bb16b 100644 --- a/src/net/milkbowl/autosave/Mode.java +++ b/src/net/milkbowl/autosave/Mode.java @@ -21,6 +21,5 @@ package net.milkbowl.autosave; public enum Mode { - ASYNCHRONOUS, - SYNCHRONOUS; + ASYNCHRONOUS, SYNCHRONOUS; } diff --git a/src/net/milkbowl/autosave/ReportThread.java b/src/net/milkbowl/autosave/ReportThread.java index f0bb289..d8e11b3 100644 --- a/src/net/milkbowl/autosave/ReportThread.java +++ b/src/net/milkbowl/autosave/ReportThread.java @@ -34,80 +34,88 @@ public class ReportThread extends Thread { private String statsBaseUrl; protected final Logger log = Logger.getLogger("Minecraft"); private static final int REPORT_DELAY = 21600; - + private JavaPlugin plugin = null; private UUID uuid = null; private boolean debug = false; private boolean run = true; - + public ReportThread(JavaPlugin plugin, UUID uuid, boolean debug) { this.plugin = plugin; this.uuid = uuid; this.debug = debug; this.statsBaseUrl = "http://stats.cereal.sh/"; } - - public ReportThread(JavaPlugin plugin, UUID uuid, boolean debug, String statsBaseUrl) { + + public ReportThread(JavaPlugin plugin, UUID uuid, boolean debug, + String statsBaseUrl) { this(plugin, uuid, debug); this.statsBaseUrl = statsBaseUrl; } - + public void setRun(boolean run) { this.run = run; } - + public void run() { // Obtain values String osName = System.getProperty("os.name"); String osArch = System.getProperty("os.arch"); String osVersion = System.getProperty("os.version"); - String java = System.getProperty("java.vendor") + " " + System.getProperty("java.version"); + String java = System.getProperty("java.vendor") + " " + + System.getProperty("java.version"); String pluginName = plugin.getDescription().getName(); String pluginVersion = plugin.getDescription().getVersion(); String bukkitVersion = plugin.getServer().getVersion(); - - if(debug) { + + if (debug) { log.info(String.format("[%s] Start of ReportThread", pluginName)); } - + while (true) { try { - URL statsUrl = new URL( String.format( - "%s?uuid=%s&plugin=%s&version=%s&bVersion=%s&osName=%s&osArch=%s&osVersion=%s&java=%s", - statsBaseUrl, - URLEncoder.encode(uuid.toString(), "ISO-8859-1"), - URLEncoder.encode(pluginName, "ISO-8859-1"), - URLEncoder.encode(pluginVersion, "ISO-8859-1"), - URLEncoder.encode(bukkitVersion, "ISO-8859-1"), - URLEncoder.encode(osName, "ISO-8859-1"), - URLEncoder.encode(osArch, "ISO-8859-1"), - URLEncoder.encode(osVersion, "ISO-8859-1"), - URLEncoder.encode(java, "ISO-8859-1") - )); + URL statsUrl = new URL( + String.format( + "%s?uuid=%s&plugin=%s&version=%s&bVersion=%s&osName=%s&osArch=%s&osVersion=%s&java=%s", + statsBaseUrl, URLEncoder.encode( + uuid.toString(), "ISO-8859-1"), + URLEncoder.encode(pluginName, "ISO-8859-1"), + URLEncoder.encode(pluginVersion, "ISO-8859-1"), + URLEncoder.encode(bukkitVersion, "ISO-8859-1"), + URLEncoder.encode(osName, "ISO-8859-1"), + URLEncoder.encode(osArch, "ISO-8859-1"), + URLEncoder.encode(osVersion, "ISO-8859-1"), + URLEncoder.encode(java, "ISO-8859-1"))); URLConnection conn = statsUrl.openConnection(); - conn.setRequestProperty("User-Agent", String.format("%s %s:%s", "BukkitReport", pluginName, pluginVersion)); + conn.setRequestProperty("User-Agent", String.format("%s %s:%s", + "BukkitReport", pluginName, pluginVersion)); String inputLine; - BufferedReader in = new BufferedReader( - new InputStreamReader(conn.getInputStream())); + BufferedReader in = new BufferedReader(new InputStreamReader( + conn.getInputStream())); if (debug) { // Output the contents -- wee - log.info(String.format("[%s] StatsURL: %s", pluginName, statsUrl.toString())); + log.info(String.format("[%s] StatsURL: %s", pluginName, + statsUrl.toString())); while ((inputLine = in.readLine()) != null) { - if (inputLine.equals("
") || inputLine.equals("
")) { + if (inputLine.equals("
")
+								|| inputLine.equals("
")) { continue; } - log.info(String.format("[%s] %s", pluginName, inputLine)); + log.info(String + .format("[%s] %s", pluginName, inputLine)); } } in.close(); - + // Sleep for 6 hours... for (int i = 0; i < REPORT_DELAY; i++) { - if(!run) { - if(debug) { - log.info(String.format("[%s] Graceful quit of ReportThread", pluginName)); + if (!run) { + if (debug) { + log.info(String.format( + "[%s] Graceful quit of ReportThread", + pluginName)); } return; } diff --git a/src/net/milkbowl/autosave/ThreadType.java b/src/net/milkbowl/autosave/ThreadType.java index 215471c..400e2ed 100644 --- a/src/net/milkbowl/autosave/ThreadType.java +++ b/src/net/milkbowl/autosave/ThreadType.java @@ -21,6 +21,5 @@ package net.milkbowl.autosave; public enum ThreadType { - REPORT, - SAVE; + REPORT, SAVE; }