diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java index 6aba0b364..85d18e9f8 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java @@ -61,7 +61,6 @@ public final class LocaleLoader { string = formatter.format(messageArguments); } - string.replaceAll("\'", "''"); string = addColors(string); return string; diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 1fef76fe1..d6eacbea0 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -328,11 +328,15 @@ public class mcMMO extends JavaPlugin { File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator); if (oldFlatfilePath.exists()) { - oldFlatfilePath.renameTo(new File(flatFileDirectory)); + if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) { + getLogger().warning("Failed to rename FlatFileStuff to flatfile !"); + } } if (oldModPath.exists()) { - oldModPath.renameTo(new File(modDirectory)); + if (!oldModPath.renameTo(new File(modDirectory))) { + getLogger().warning("Failed to rename ModConfigs to mods !"); + } } } @@ -422,7 +426,7 @@ public class mcMMO extends JavaPlugin { new BleedTimerTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR); // Old & Powerless User remover - long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60 * 60 * Misc.TICK_CONVERSION_FACTOR; + long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; if (purgeIntervalTicks == 0) { new UserPurgeTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. @@ -432,7 +436,7 @@ public class mcMMO extends JavaPlugin { } // Automatically remove old members from parties - long kickIntervalTicks = Config.getInstance().getAutoPartyKickInterval() * 60 * 60 * Misc.TICK_CONVERSION_FACTOR; + long kickIntervalTicks = Config.getInstance().getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; if (kickIntervalTicks == 0) { new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 4ca927335..c6953afa8 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -521,7 +521,10 @@ public final class PartyManager { */ public static void saveParties() { if (partyFile.exists()) { - partyFile.delete(); + if (!partyFile.delete()) { + mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!"); + return; + } } YamlConfiguration partiesFile = new YamlConfiguration(); diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java index 2c6fcb0b8..63401caf4 100644 --- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java @@ -87,8 +87,9 @@ public class CleanBackupsTask extends BukkitRunnable { mcMMO.p.getLogger().info("Cleaned backup files. Deleted " + amountDeleted + " of " + amountTotal + " files."); for (File file : toDelete) { - mcMMO.p.debug("Deleted: " + file.getName()); - file.delete(); + if (file.delete()) { + mcMMO.p.debug("Deleted: " + file.getName()); + } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java index 642de0941..8bf8fa938 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -18,8 +18,8 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; public class AlchemyBrewTask extends BukkitRunnable { - private final double DEFAULT_BREW_SPEED = 1.0; - private final int DEFAULT_BREW_TICKS = 400; + private static double DEFAULT_BREW_SPEED = 1.0; + private static int DEFAULT_BREW_TICKS = 400; private Block brewingStand; private double brewSpeed; diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java index e28b24d8d..b2915b73f 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyManager.java @@ -69,7 +69,8 @@ public class AlchemyManager extends SkillManager { } public String getIngredientList() { - String list = ""; + StringBuilder list = new StringBuilder(); + for (ItemStack ingredient : getIngredients()) { String string = StringUtils.getPrettyItemString(ingredient.getType()) + (ingredient.getDurability() != 0 ? ":" + ingredient.getDurability() : ""); if (string.equals("Long Grass:2")) { @@ -79,7 +80,7 @@ public class AlchemyManager extends SkillManager { string = "Pufferfish"; } - list += ", " + string; + list.append(", " + string); } return list.substring(2); } diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index ec7b97638..a5dae6824 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -30,9 +30,9 @@ import com.gmail.nossr50.mcMMO; import com.google.common.collect.ImmutableList; public final class HolidayManager { - private static ArrayList hasCelebrated; - private static int CURRENT_YEAR; - private static int START_YEAR = 2011; + private ArrayList hasCelebrated; + private int currentYear; + private final int startYear = 2011; private static final List ALL_COLORS; private static final List ALL_CHAT_COLORS; @@ -67,9 +67,9 @@ public final class HolidayManager { // This gets called onEnable public HolidayManager() { - CURRENT_YEAR = Calendar.getInstance().get(Calendar.YEAR); + currentYear = Calendar.getInstance().get(Calendar.YEAR); - File anniversaryFile = new File(mcMMO.getFlatFileDirectory(), "anniversary." + CURRENT_YEAR + ".yml"); + File anniversaryFile = new File(mcMMO.getFlatFileDirectory(), "anniversary." + currentYear + ".yml"); if (!anniversaryFile.exists()) { try { @@ -113,7 +113,7 @@ public final class HolidayManager { Pattern pattern = Pattern.compile("anniversary\\.(?:.+)\\.yml"); for (String fileName : FlatFileDir.list()) { - if (!pattern.matcher(fileName).matches() || fileName.equals("anniversary." + CURRENT_YEAR + ".yml")) { + if (!pattern.matcher(fileName).matches() || fileName.equals("anniversary." + currentYear + ".yml")) { continue; } @@ -127,15 +127,16 @@ public final class HolidayManager { } for (File file : toDelete) { - mcMMO.p.debug("Deleted: " + file.getName()); - file.delete(); + if (file.delete()) { + mcMMO.p.debug("Deleted: " + file.getName()); + } } } // This gets called onDisable public void saveAnniversaryFiles() { mcMMO.p.debug("Saving anniversary files..."); - String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + CURRENT_YEAR + ".yml"; + String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml"; try { BufferedWriter writer = new BufferedWriter(new FileWriter(anniversaryFilePath)); @@ -152,8 +153,8 @@ public final class HolidayManager { // This gets called from /mcmmo command public void anniversaryCheck(final CommandSender sender) { - GregorianCalendar anniversaryStart = new GregorianCalendar(CURRENT_YEAR, Calendar.FEBRUARY, 3); - GregorianCalendar anniversaryEnd = new GregorianCalendar(CURRENT_YEAR, Calendar.FEBRUARY, 6); + GregorianCalendar anniversaryStart = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 3); + GregorianCalendar anniversaryEnd = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 6); GregorianCalendar day = new GregorianCalendar(); if (hasCelebrated.contains(sender.getName())) { @@ -164,7 +165,7 @@ public final class HolidayManager { return; } - sender.sendMessage(ChatColor.BLUE + "Happy " + (CURRENT_YEAR - START_YEAR) + " Year Anniversary! In honor of all of"); + sender.sendMessage(ChatColor.BLUE + "Happy " + (currentYear - startYear) + " Year Anniversary! In honor of all of"); sender.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, here's a firework show!"); if (sender instanceof Player) { final int firework_amount = 10; @@ -225,7 +226,7 @@ public final class HolidayManager { } private void spawnFireworks(Player player) { - int power = (int) (Misc.getRandom().nextDouble() * 3) + 1; + int power = Misc.getRandom().nextInt(3) + 1; Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)]; double varX = Misc.getRandom().nextGaussian() * 3; double varZ = Misc.getRandom().nextGaussian() * 3; diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 380a41718..155952705 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -172,7 +172,7 @@ public class ScoreboardManager { public static void cleanup(ScoreboardWrapper wrapper) { PLAYER_SCOREBOARDS.remove(wrapper.playerName); - if (wrapper != null && wrapper.revertTask != null) { + if (wrapper.revertTask != null) { wrapper.revertTask.cancel(); } }