From 43037f8c13dcb4b68d55a7e36f51ccee5aa85ec5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 3 Apr 2019 19:25:14 -0700 Subject: [PATCH] Code Cleanup Pt 2 --- Changelog.txt | 2 + .../java/com/gmail/nossr50/api/PartyAPI.java | 2 +- .../java/com/gmail/nossr50/api/SkillAPI.java | 2 +- .../nossr50/chat/ChatManagerFactory.java | 4 +- .../nossr50/commands/McImportCommand.java | 34 +++++------- .../nossr50/commands/McconvertCommand.java | 10 ++-- .../nossr50/commands/McscoreboardCommand.java | 2 +- .../gmail/nossr50/commands/ToggleCommand.java | 2 +- .../gmail/nossr50/commands/XprateCommand.java | 4 +- .../nossr50/commands/chat/ChatCommand.java | 2 +- .../commands/database/McremoveCommand.java | 2 +- .../experience/ExperienceCommand.java | 4 +- .../experience/SkillresetCommand.java | 4 +- .../nossr50/commands/party/PartyCommand.java | 20 +++---- .../commands/party/PartyInfoCommand.java | 12 ++--- .../party/alliance/PartyAllianceCommand.java | 4 +- .../commands/party/teleport/PtpCommand.java | 4 +- .../commands/player/InspectCommand.java | 2 +- .../commands/player/McrankCommand.java | 2 +- .../nossr50/commands/player/MctopCommand.java | 2 +- .../commands/skills/AcrobaticsCommand.java | 4 +- .../commands/skills/AlchemyCommand.java | 2 +- .../commands/skills/ArcheryCommand.java | 2 +- .../nossr50/commands/skills/AxesCommand.java | 2 +- .../commands/skills/ExcavationCommand.java | 4 +- .../commands/skills/FishingCommand.java | 2 +- .../commands/skills/HerbalismCommand.java | 4 +- .../commands/skills/MiningCommand.java | 2 +- .../commands/skills/MmoInfoCommand.java | 2 +- .../commands/skills/RepairCommand.java | 2 +- .../commands/skills/SalvageCommand.java | 2 +- .../nossr50/commands/skills/SkillCommand.java | 16 +++--- .../commands/skills/SkillGuideCommand.java | 4 +- .../commands/skills/SmeltingCommand.java | 2 +- .../commands/skills/SwordsCommand.java | 2 +- .../commands/skills/TamingCommand.java | 2 +- .../commands/skills/UnarmedCommand.java | 6 +-- .../commands/skills/WoodcuttingCommand.java | 4 +- .../gmail/nossr50/config/AdvancedConfig.java | 2 +- .../com/gmail/nossr50/config/MainConfig.java | 2 +- .../com/gmail/nossr50/config/RankConfig.java | 2 +- .../config/experience/ExperienceConfig.java | 5 +- .../gmail/nossr50/config/hocon/HOCONUtil.java | 16 +++--- .../config/skills/alchemy/PotionConfig.java | 12 ++--- .../treasure/ExcavationTreasureConfig.java | 5 +- .../treasure/FishingTreasureConfig.java | 15 +++--- .../treasure/HerbalismTreasureConfig.java | 4 +- .../config/treasure/TreasureFactory.java | 2 +- .../database/FlatfileDatabaseManager.java | 52 +++++++++--------- .../nossr50/database/SQLDatabaseManager.java | 18 +++---- .../nossr50/datatypes/chat/ChatMode.java | 2 +- .../datatypes/database/PlayerStat.java | 2 +- .../datatypes/database/PoolIdentifier.java | 3 ++ .../gmail/nossr50/datatypes/party/Party.java | 8 +-- .../nossr50/datatypes/player/McMMOPlayer.java | 8 +-- .../datatypes/player/PlayerProfile.java | 10 ++-- .../nossr50/datatypes/skills/ItemType.java | 2 +- .../datatypes/skills/PrimarySkillType.java | 10 ++-- .../datatypes/skills/SubSkillType.java | 24 ++++----- .../datatypes/skills/SuperAbilityType.java | 2 +- .../nossr50/datatypes/skills/ToolType.java | 2 +- .../datatypes/skills/alchemy/PotionStage.java | 2 +- .../fake/FakeEntityDamageByEntityEvent.java | 2 +- .../events/fake/FakeEntityDamageEvent.java | 2 +- .../party/McMMOPartyAllianceChangeEvent.java | 2 +- .../events/party/McMMOPartyChangeEvent.java | 2 +- .../nossr50/listeners/BlockListener.java | 2 +- .../nossr50/listeners/InteractionManager.java | 6 +-- .../gmail/nossr50/locale/LocaleLoader.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 2 +- .../com/gmail/nossr50/party/PartyManager.java | 14 ++--- .../nossr50/runnables/CheckDateTask.java | 46 ++++++++-------- .../runnables/backups/CleanBackupsTask.java | 6 +-- .../database/DatabaseConversionTask.java | 7 +-- .../runnables/party/PartyAutoKickTask.java | 4 +- .../player/PlayerProfileLoadingTask.java | 2 +- .../runnables/skills/BleedTimerTask.java | 2 +- .../gmail/nossr50/skills/alchemy/Alchemy.java | 4 +- .../skills/alchemy/AlchemyPotionBrewer.java | 2 +- .../gmail/nossr50/skills/archery/Archery.java | 2 +- .../nossr50/skills/excavation/Excavation.java | 2 +- .../gmail/nossr50/skills/fishing/Fishing.java | 2 +- .../skills/fishing/FishingManager.java | 15 +++--- .../skills/herbalism/HerbalismManager.java | 2 +- .../nossr50/skills/mining/MiningManager.java | 6 +-- .../skills/repair/repairables/Repairable.java | 3 +- .../repair/repairables/RepairableManager.java | 2 +- .../skills/salvage/SalvageManager.java | 2 +- .../salvageables/SalvageableManager.java | 2 +- .../nossr50/skills/taming/TamingManager.java | 4 +- .../skills/woodcutting/Woodcutting.java | 2 +- .../woodcutting/WoodcuttingManager.java | 2 +- .../com/gmail/nossr50/util/BlockUtils.java | 2 +- .../com/gmail/nossr50/util/ChimaeraWing.java | 2 +- .../gmail/nossr50/util/EnchantmentUtils.java | 2 +- .../gmail/nossr50/util/HardcoreManager.java | 8 +-- .../java/com/gmail/nossr50/util/Misc.java | 2 +- .../gmail/nossr50/util/MobHealthbarUtils.java | 10 ++-- .../nossr50/util/adapter/BiomeAdapter.java | 4 +- .../util/blockmeta/ChunkletManager.java | 36 ++++++------- .../nossr50/util/blockmeta/ChunkletStore.java | 10 ++-- .../util/blockmeta/HashChunkletManager.java | 2 +- .../blockmeta/chunkmeta/ChunkManager.java | 54 +++++++++---------- .../util/blockmeta/chunkmeta/ChunkStore.java | 18 +++---- .../blockmeta/chunkmeta/HashChunkManager.java | 30 ++++------- .../chunkmeta/McMMOSimpleRegionFile.java | 2 +- .../commands/CommandRegistrationManager.java | 4 +- .../nossr50/util/commands/CommandUtils.java | 6 +-- .../util/experience/FormulaManager.java | 4 +- .../nossr50/util/player/UserManager.java | 2 +- .../util/scoreboards/ScoreboardManager.java | 6 +-- .../nossr50/util/skills/CombatUtils.java | 6 +-- .../util/skills/ParticleEffectUtils.java | 2 +- .../gmail/nossr50/util/skills/PerksUtils.java | 2 +- .../gmail/nossr50/util/skills/RankUtils.java | 3 +- .../gmail/nossr50/util/skills/SkillUtils.java | 2 +- .../gmail/nossr50/util/uuid/UUIDFetcher.java | 4 +- .../shatt/backup/ZipLibrary.java | 2 +- 118 files changed, 372 insertions(+), 400 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 602db5d0f..1167a7a8f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -29,6 +29,7 @@ Version 2.2.0 Note: Admins are players who are op or have adminchat permission. Bug Fixes + Fixed a bug where Blast Minings cooldown was not being displayed correctly Fixed a bug where players who started at level 1 would not be purged from the DB for being "powerless" Fixed a potential bug where players could be awarded XP for cancelled tame events Fixed a bug where party size limits were only counting online players @@ -117,6 +118,7 @@ Version 2.2.0 Scoreboard.Misc.Ability locale entry renamed from "Ability" to "Super Ability", this is used only if scoreboards are enabled and super ability names are disabled in scoreboard.conf MySQL and FlatFile Settings can now be found in "database_settings.conf" + Added new config setting for the update interval of FlatFile scoreboards Added new config toggle for purging power-less users Added new config toggle for purging inactive users Database Purging's "Purge_Interval" renamed -> "Purge-Interval-In-Hours" diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index 681bbb366..0b3f28105 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -176,7 +176,7 @@ public final class PartyAPI { */ @Deprecated public static List getOnlineAndOfflineMembers(Player player) { - List members = new ArrayList(); + List members = new ArrayList<>(); for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) { OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); diff --git a/src/main/java/com/gmail/nossr50/api/SkillAPI.java b/src/main/java/com/gmail/nossr50/api/SkillAPI.java index ee230bc72..cdb686af8 100644 --- a/src/main/java/com/gmail/nossr50/api/SkillAPI.java +++ b/src/main/java/com/gmail/nossr50/api/SkillAPI.java @@ -82,7 +82,7 @@ public final class SkillAPI { } private static List getListFromEnum(List skillsTypes) { - List skills = new ArrayList(); + List skills = new ArrayList<>(); for (PrimarySkillType primarySkillType : skillsTypes) { skills.add(primarySkillType.name()); diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java b/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java index 308e736df..4146d26c7 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java @@ -6,8 +6,8 @@ import org.bukkit.plugin.Plugin; import java.util.HashMap; public class ChatManagerFactory { - private static final HashMap adminChatManagers = new HashMap(); - private static final HashMap partyChatManagers = new HashMap(); + private static final HashMap adminChatManagers = new HashMap<>(); + private static final HashMap partyChatManagers = new HashMap<>(); public static ChatManager getChatManager(Plugin plugin, ChatMode mode) { switch (mode) { diff --git a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java index 1eac84979..42b3d4cf5 100644 --- a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java @@ -33,7 +33,7 @@ public class McImportCommand implements CommandExecutor { mcMMO.p.getLogger().info("Starting import of mod materials..."); fileAmount = 0; - HashMap> materialNames = new HashMap>(); + HashMap> materialNames = new HashMap<>(); BufferedReader in = null; @@ -65,7 +65,7 @@ public class McImportCommand implements CommandExecutor { ModConfigType type = ModConfigType.getModConfigType(materialName); if (!materialNames.containsKey(type)) { - materialNames.put(type, new ArrayList()); + materialNames.put(type, new ArrayList<>()); } materialNames.get(type).add(materialName); @@ -93,13 +93,13 @@ public class McImportCommand implements CommandExecutor { private void createOutput(HashMap> materialNames) { for (ModConfigType modConfigType : materialNames.keySet()) { - HashMap> materialNamesType = new HashMap>(); + HashMap> materialNamesType = new HashMap<>(); for (String materialName : materialNames.get(modConfigType)) { String modName = Misc.getModName(materialName); if (!materialNamesType.containsKey(modName)) { - materialNamesType.put(modName, new ArrayList()); + materialNamesType.put(modName, new ArrayList<>()); } materialNamesType.get(modName).add(materialName); @@ -169,16 +169,10 @@ public class McImportCommand implements CommandExecutor { out = new FileWriter(outputFile); out.write(writer.toString()); - } - catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); return; - } - catch (Exception e) { - e.printStackTrace(); - return; - } - finally { + } finally { tryClose(out); fileAmount++; } @@ -201,7 +195,7 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsBlocks(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and categorise them under a skill for (String materialName : materialNames.get(modName)) { @@ -220,7 +214,7 @@ public class McImportCommand implements CommandExecutor { } if (!configSections.containsKey(skillName)) { - configSections.put(skillName, new ArrayList()); + configSections.put(skillName, new ArrayList<>()); } ArrayList skillContents = configSections.get(skillName); @@ -240,7 +234,7 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsTools(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and categorise them under a tool type for (String materialName : materialNames.get(modName)) { @@ -265,7 +259,7 @@ public class McImportCommand implements CommandExecutor { } if (!configSections.containsKey(toolType)) { - configSections.put(toolType, new ArrayList()); + configSections.put(toolType, new ArrayList<>()); } ArrayList skillContents = configSections.get(toolType); @@ -280,7 +274,7 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsArmor(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and categorise them under an armor type for (String materialName : materialNames.get(modName)) { @@ -299,7 +293,7 @@ public class McImportCommand implements CommandExecutor { } if (!configSections.containsKey(toolType)) { - configSections.put(toolType, new ArrayList()); + configSections.put(toolType, new ArrayList<>()); } ArrayList skillContents = configSections.get(toolType); @@ -325,14 +319,14 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsUnknown(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and print them for (String materialName : materialNames.get(modName)) { String configKey = "UNIDENTIFIED"; if (!configSections.containsKey(configKey)) { - configSections.put(configKey, new ArrayList()); + configSections.put(configKey, new ArrayList<>()); } ArrayList skillContents = configSections.get(configKey); diff --git a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java index e104b61d2..4202fda4c 100644 --- a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java @@ -26,8 +26,8 @@ public class McconvertCommand implements TabExecutor { private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); static { - ArrayList formulaTypes = new ArrayList(); - ArrayList databaseTypes = new ArrayList(); + ArrayList formulaTypes = new ArrayList<>(); + ArrayList databaseTypes = new ArrayList<>(); for (FormulaType type : FormulaType.values()) { formulaTypes.add(type.toString()); @@ -73,14 +73,14 @@ public class McconvertCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList(SUBCOMMANDS.size())); + return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<>(SUBCOMMANDS.size())); case 2: if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { - return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList(DATABASE_TYPES.size())); + return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<>(DATABASE_TYPES.size())); } if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) { - return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList(FORMULA_TYPES.size())); + return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<>(FORMULA_TYPES.size())); } return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java index f722bef8d..01d4ebe91 100644 --- a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java @@ -72,7 +72,7 @@ public class McscoreboardCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList(FIRST_ARGS.size())); + return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<>(FIRST_ARGS.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java index 11256ecbd..802fb4021 100644 --- a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java @@ -64,7 +64,7 @@ public abstract class ToggleCommand implements TabExecutor { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index 93746e97a..f3e714644 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -113,9 +113,9 @@ public class XprateCommand implements TabExecutor { return ImmutableList.of(); } - return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList(CommandUtils.RESET_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); case 2: - return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 11a83d367..884010e31 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -89,7 +89,7 @@ public abstract class ChatCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index 5fe1ca89a..957cbbc99 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -43,7 +43,7 @@ public class McremoveCommand implements TabExecutor { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java index 120cbb853..b13cd4b8d 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -113,9 +113,9 @@ public abstract class ExperienceCommand implements TabExecutor { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); case 2: - return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index 16a28d720..4e8a0bcfc 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -107,9 +107,9 @@ public class SkillresetCommand implements TabExecutor { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); case 2: - return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 0d32da932..1b90615d1 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -29,7 +29,7 @@ public class PartyCommand implements TabExecutor { private static final List ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); static { - ArrayList subcommands = new ArrayList(); + ArrayList subcommands = new ArrayList<>(); for (PartySubcommandType subcommand : PartySubcommandType.values()) { subcommands.add(subcommand.toString()); @@ -173,7 +173,7 @@ public class PartyCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList(PARTY_SUBCOMMANDS.size())); + return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<>(PARTY_SUBCOMMANDS.size())); case 2: PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); @@ -187,25 +187,25 @@ public class PartyCommand implements TabExecutor { case KICK: case OWNER: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); case XPSHARE: - return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList(XPSHARE_COMPLETIONS.size())); + return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size())); case ITEMSHARE: - return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList(ITEMSHARE_COMPLETIONS.size())); + return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<>(ITEMSHARE_COMPLETIONS.size())); case LOCK: case CHAT: - return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); case PASSWORD: - return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList(CommandUtils.RESET_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); case TELEPORT: - List matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList(PtpCommand.TELEPORT_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { Player player = (Player) sender; Party party = UserManager.getPlayer(player).getParty(); playerNames = party.getOnlinePlayerNames(player); - return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); } return matches; @@ -214,7 +214,7 @@ public class PartyCommand implements TabExecutor { } case 3: if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) { - return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); } return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 5a421f81e..250d1b922 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -41,21 +41,21 @@ public class PartyInfoCommand implements CommandExecutor { private void displayPartyHeader(Player player, Party party) { player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); - StringBuilder status = new StringBuilder(); - status.append(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel())); - /*if (!party.hasReachedLevelCap()) { status.append(" (").append(party.getXpToLevelPercentage()).append(")"); }*/ - player.sendMessage(status.toString()); + player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel()) + /*if (!party.hasReachedLevelCap()) { + status.append(" (").append(party.getXpToLevelPercentage()).append(")"); + }*/); } private void displayPartyFeatures(Player player, Party party) { player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header")); - List unlockedPartyFeatures = new ArrayList(); - List lockedPartyFeatures = new ArrayList(); + List unlockedPartyFeatures = new ArrayList<>(); + List lockedPartyFeatures = new ArrayList<>(); for (PartyFeature partyFeature : PartyFeature.values()) { if (!partyFeature.hasPermission(player)) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java index 41bd361e5..45ee67872 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java @@ -104,11 +104,11 @@ public class PartyAllianceCommand implements TabExecutor { public List onTabComplete(CommandSender commandSender, Command command, String label, String[] args) { switch (args.length) { case 1: - List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList(ALLIANCE_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size())); if (matches.size() == 0) { List playerNames = CommandUtils.getOnlinePlayerNames(commandSender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return matches; diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index a510af078..c516f10ac 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -127,7 +127,7 @@ public class PtpCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList(TELEPORT_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { Player player = (Player) sender; @@ -138,7 +138,7 @@ public class PtpCommand implements TabExecutor { } List playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return matches; diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index ceba2e0a9..b1d47ed7e 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -106,7 +106,7 @@ public class InspectCommand implements TabExecutor { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 076c5abee..e8efdebef 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -80,7 +80,7 @@ public class McrankCommand implements TabExecutor { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index 5683499e6..8e163f161 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -70,7 +70,7 @@ public class MctopCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 1588cbd77..91e86ef0f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -44,7 +44,7 @@ public class AcrobaticsCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDodge) { messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance) @@ -71,7 +71,7 @@ public class AcrobaticsCommand extends SkillCommand { graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs); //damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); - String rollStrings[] = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); + String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); //Format double rollChanceLucky = rollChance * 1.333D; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java index c896ac9c4..4bfff993b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java @@ -67,7 +67,7 @@ public class AlchemyCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canCatalysis) { messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index 5b9359da7..4a8063b28 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -59,7 +59,7 @@ public class ArcheryCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canRetrieve) { messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index 857b07f03..8c75d24a5 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -72,7 +72,7 @@ public class AxesCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canImpact) { messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index 0274c03fd..d32bb8c66 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -27,7 +27,7 @@ public class ExcavationCommand extends SkillCommand { protected void dataCalculations(Player player, float skillValue) { // GIGA DRILL BREAKER if (canGigaDrill) { - String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue); + String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue); gigaDrillBreakerLength = gigaDrillStrings[0]; gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; } @@ -41,7 +41,7 @@ public class ExcavationCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canGigaDrill) { messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index f8c57346c..694c79a21 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -128,7 +128,7 @@ public class FishingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canFishermansDiet) { messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index babe8d640..87f18e413 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -45,7 +45,7 @@ public class HerbalismCommand extends SkillCommand { // DOUBLE DROPS if (canDoubleDrop) { - String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);; + String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS); doubleDropChance = doubleDropStrings[0]; doubleDropChanceLucky = doubleDropStrings[1]; } @@ -99,7 +99,7 @@ public class HerbalismCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index b1639e17b..c3a9b25ac 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -78,7 +78,7 @@ public class MiningCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canBiggerBombs) { messages.add(getStatMessage(true, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastRadiusIncrease))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java index 95dc29458..d8ae0aa89 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java @@ -64,7 +64,7 @@ public class MmoInfoCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList(PrimarySkillType.SUBSKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList<>(PrimarySkillType.SUBSKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 16da3857e..349d18e8e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -90,7 +90,7 @@ public class RepairCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canArcaneForge) { RepairManager repairManager = UserManager.getPlayer(player).getRepairManager(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java index 7577c4c54..0c248a5f1 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java @@ -36,7 +36,7 @@ public class SalvageCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); if (canAdvancedSalvage) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index f13295b15..946548b8b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -162,28 +162,26 @@ public abstract class SkillCommand implements TabExecutor { ArrayList parentList = new ArrayList<>(); //TODO: Add JSON here - for (PrimarySkillType parent : parents) { - parentList.add(parent); - /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/; - } + /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ + parentList.addAll(parents); - String parentMessage = ""; + StringBuilder parentMessage = new StringBuilder(); for(int i = 0; i < parentList.size(); i++) { if(i+1 < parentList.size()) { - parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))); - parentMessage += ChatColor.GRAY+", "; + parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); + parentMessage.append(ChatColor.GRAY + ", "); } else { - parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))); + parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); } } //XP GAIN METHOD player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain.Child"))); - player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage)); + player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage.toString())); //LEVEL //player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, skillValue)); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java index 6f34f77b1..9d9af016a 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java @@ -67,7 +67,7 @@ public class SkillGuideCommand implements CommandExecutor { private ArrayList grabPageContents(int page) { int pageIndexStart = 8 * (page - 1); // Determine what string to start at - ArrayList allStrings = new ArrayList(); + ArrayList allStrings = new ArrayList<>(); allStrings.add(header); @@ -86,7 +86,7 @@ public class SkillGuideCommand implements CommandExecutor { } private ArrayList getGuide(PrimarySkillType skill) { - ArrayList guide = new ArrayList(); + ArrayList guide = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n"); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java index b688691c6..a3a5f5805 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -62,7 +62,7 @@ public class SmeltingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); /*if (canFluxMine) { messages.add(getStatMessage(SubSkillType.SMELTING_FLUX_MINING, str_fluxMiningChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 3b46b7b9a..98a0d3b57 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -68,7 +68,7 @@ public class SwordsCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks(); double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index fb613544e..e54ce1505 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -56,7 +56,7 @@ public class TamingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canEnvironmentallyAware) { messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index 64952dca4..f653d0c76 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -40,7 +40,7 @@ public class UnarmedCommand extends SkillCommand { protected void dataCalculations(Player player, float skillValue) { // UNARMED_ARROW_DEFLECT if (canDeflect) { - String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);; + String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT); deflectChance = deflectStrings[0]; deflectChanceLucky = deflectStrings[1]; } @@ -54,7 +54,7 @@ public class UnarmedCommand extends SkillCommand { // UNARMED_DISARM if (canDisarm) { - String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);; + String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM); disarmChance = disarmStrings[0]; disarmChanceLucky = disarmStrings[1]; } @@ -84,7 +84,7 @@ public class UnarmedCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDeflect) { messages.add(getStatMessage(SubSkillType.UNARMED_ARROW_DEFLECT, deflectChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index 7c6f6207b..c0f7ae4cb 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -46,7 +46,7 @@ public class WoodcuttingCommand extends SkillCommand { } private void setDoubleDropClassicChanceStrings(Player player) { - String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);; + String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER); doubleDropChance = doubleDropStrings[0]; doubleDropChanceLucky = doubleDropStrings[1]; } @@ -63,7 +63,7 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.WOODCUTTING_HARVEST_LUMBER, doubleDropChance) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index e0829baf5..7a432ea2d 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -160,7 +160,7 @@ public class AdvancedConfig extends ConfigValidated { @Override public List validateKeys() { // Validate all the settings! - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* GENERAL */ if (getAbilityLength() < 1) { diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 8a7055a3c..a7c7735c0 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -235,7 +235,7 @@ public class MainConfig extends ConfigValidated { @Override public List validateKeys() { // Validate all the settings! - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* General Settings */ /*if (getSaveInterval() <= 0) { diff --git a/src/main/java/com/gmail/nossr50/config/RankConfig.java b/src/main/java/com/gmail/nossr50/config/RankConfig.java index dbd16511e..3dc4a302d 100644 --- a/src/main/java/com/gmail/nossr50/config/RankConfig.java +++ b/src/main/java/com/gmail/nossr50/config/RankConfig.java @@ -49,7 +49,7 @@ public class RankConfig extends ConfigValidated { @Override public List validateKeys() { - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* * In the future this method will check keys for all skills, but for now it only checks overhauled skills diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index 764f4007a..ec4f3e24d 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -77,7 +77,6 @@ public class ExperienceConfig extends ConfigValidated { public static final String OCELOT = "Ocelot"; public static final String WOLF = "Wolf"; public static final String FEATHER_FALL_MULTIPLIER = "FeatherFall_Multiplier"; - private static ExperienceConfig instance; //TODO: Should merge be false? Seems okay to leave it as true.. public ExperienceConfig() { @@ -109,12 +108,12 @@ public class ExperienceConfig extends ConfigValidated { @Override public void unload() { - instance = null; //TODO: this might be a bit problematic + } @Override public List validateKeys() { - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* * FORMULA SETTINGS diff --git a/src/main/java/com/gmail/nossr50/config/hocon/HOCONUtil.java b/src/main/java/com/gmail/nossr50/config/hocon/HOCONUtil.java index b9e96cf11..6e9d3780f 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/HOCONUtil.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/HOCONUtil.java @@ -7,32 +7,32 @@ public final class HOCONUtil { public static String serializeENUMName(String hyphenedString) { String[] split = hyphenedString.split("_"); - String formattedString = ""; + StringBuilder formattedString = new StringBuilder(); for(int x = 0; x < split.length; x++) { if(x + 1 >= split.length) - formattedString += StringUtils.getCapitalized(split[x]); + formattedString.append(StringUtils.getCapitalized(split[x])); else - formattedString+= (StringUtils.getCapitalized(split[x]) + '-'); + formattedString.append(StringUtils.getCapitalized(split[x])).append('-'); } - return formattedString; + return formattedString.toString(); } public static String deserializeENUMName(String serializedName) { String[] split = serializedName.split("-"); - String formattedString = ""; + StringBuilder formattedString = new StringBuilder(); for(int x = 0; x < split.length; x++) { if(x + 1 >= split.length) - formattedString += split[x].toUpperCase(); + formattedString.append(split[x].toUpperCase()); else - formattedString+= (split[x] + '_'); + formattedString.append(split[x]).append('_'); } - return formattedString; + return formattedString.toString(); } } diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java index 4a79d3c31..3efeb7e46 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java @@ -63,7 +63,7 @@ public class PotionConfig extends ConfigCollection { private List concoctionsIngredientsTierSeven; private List concoctionsIngredientsTierEight; - private Map potionMap = new HashMap(); + private Map potionMap = new HashMap<>(); public PotionConfig() { super("skillranks", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true); @@ -211,14 +211,14 @@ public class PotionConfig extends ConfigCollection { material = Material.valueOf(materialTypeString); } - List lore = new ArrayList(); + List lore = new ArrayList<>(); if (potion_section.getNode(LORE) != null) { for (String line : potion_section.getNode(LORE).getList(TypeToken.of(String.class))) { lore.add(ChatColor.translateAlternateColorCodes('&', line)); } } - List effects = new ArrayList(); + List effects = new ArrayList<>(); if (potion_section.getNode(EFFECTS) != null) { for (String effect : potion_section.getNode(EFFECTS).getList(TypeToken.of(String.class))) { String[] parts = effect.split(" "); @@ -235,14 +235,14 @@ public class PotionConfig extends ConfigCollection { } } - Color color = null; + Color color; if (potion_section.getNode(COLOR) != null) { color = Color.fromRGB(potion_section.getNode(COLOR).getInt()); } else { color = this.generateColor(effects); } - Map children = new HashMap(); + Map children = new HashMap<>(); if (potion_section.getNode(CHILDREN) != null) { for (String child : potion_section.getNode(CHILDREN).getList(TypeToken.of(String.class))) { ItemStack ingredient = loadIngredient(child); @@ -324,7 +324,7 @@ public class PotionConfig extends ConfigCollection { public Color generateColor(List effects) { if (effects != null && !effects.isEmpty()) { - List colors = new ArrayList(); + List colors = new ArrayList<>(); for (PotionEffect effect : effects) { if (effect.getType().getColor() != null) { colors.add(effect.getType().getColor()); diff --git a/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java index 7e1c30362..baa501c11 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java @@ -23,7 +23,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid public static final String DROP_LEVEL = "Drop_Level"; public static final String CUSTOM_NAME = "Custom_Name"; public static final String LORE = "Lore"; - public HashMap> excavationMap = new HashMap>(); + public HashMap> excavationMap = new HashMap<>(); public ExcavationTreasureConfig() { super("excavation_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); @@ -141,8 +141,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid */ for(String dropBlock : dropsFrom) { - if(excavationMap.get(dropBlock) == null) - excavationMap.put(dropBlock, new ArrayList<>()); + excavationMap.computeIfAbsent(dropBlock, k -> new ArrayList<>()); excavationMap.get(dropBlock).add(excavationTreasure); } diff --git a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java index 21251aac9..169f95f4e 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java @@ -40,9 +40,9 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati public static final String RARITY = "Rarity"; public static final String DROPS_FROM = "Drops_From"; - public HashMap> shakeMap = new HashMap>(); - public HashMap> fishingRewards = new HashMap>(); - public HashMap> fishingEnchantments = new HashMap>(); + public HashMap> shakeMap = new HashMap<>(); + public HashMap> fishingRewards = new HashMap<>(); + public HashMap> fishingEnchantments = new HashMap<>(); /** * This grabs an instance of this config class from the Config Manager @@ -81,7 +81,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati // Initialize fishing HashMap for (Rarity rarity : Rarity.values()) { if (!fishingRewards.containsKey(rarity)) { - fishingRewards.put(rarity, (new ArrayList())); + fishingRewards.put(rarity, (new ArrayList<>())); } } @@ -276,8 +276,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati /* * Add to map */ - if(shakeMap.get(entityType) == null) - shakeMap.put(entityType, new ArrayList<>()); + shakeMap.computeIfAbsent(entityType, k -> new ArrayList<>()); shakeMap.get(entityType).add(shakeTreasure); @@ -297,7 +296,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati } if (!fishingEnchantments.containsKey(rarity)) { - fishingEnchantments.put(rarity, (new ArrayList())); + fishingEnchantments.put(rarity, (new ArrayList<>())); } ConfigurationNode enchantmentSection = getUserRootNode().getNode(ENCHANTMENTS_RARITY, rarity.toString()); @@ -334,7 +333,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati @Override public List validateKeys() { // Validate all the settings! - List errorMessages = new ArrayList(); + List errorMessages = new ArrayList<>(); try { for (String tier : getUserRootNode().getNode(ENCHANTMENT_DROP_RATES).getList(TypeToken.of(String.class))) { /*double totalEnchantDropRate = 0; diff --git a/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java index 39c426b7c..b5c113b11 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java @@ -26,7 +26,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida public static final String CUSTOM_NAME = "Custom_Name"; public static final String LORE = "Lore"; - public HashMap> hylianMap = new HashMap>(); + public HashMap> hylianMap = new HashMap<>(); public HerbalismTreasureConfig() { super("hylian_luck_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); @@ -206,7 +206,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida private void addHylianTreasure(String dropper, HylianTreasure treasure) { if (!hylianMap.containsKey(dropper)) - hylianMap.put(dropper, new ArrayList()); + hylianMap.put(dropper, new ArrayList<>()); hylianMap.get(dropper).add(treasure); } diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java index aa36ed4d9..18772e78b 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java @@ -81,7 +81,7 @@ public class TreasureFactory { if(customLore != null && !customLore.getString().equalsIgnoreCase(CHANGE_ME)) { ItemMeta itemMeta = treasure.getItemMeta(); - List lore = new ArrayList(); + List lore = new ArrayList<>(); try { //TODO: Not sure how this will be handled by Configurate diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 57b0651db..938f30256 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -16,8 +16,8 @@ import java.io.*; import java.util.*; public final class FlatfileDatabaseManager implements DatabaseManager { - private final HashMap> playerStatHash = new HashMap>(); - private final List powerLevels = new ArrayList(); + private final HashMap> playerStatHash = new HashMap<>(); + private final List powerLevels = new ArrayList<>(); private long lastUpdate = 0; private long updateWaitTime; private final File usersFile; @@ -364,7 +364,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public Map readRank(String playerName) { updateLeaderboards(); - Map skills = new HashMap(); + Map skills = new HashMap<>(); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill))); @@ -652,7 +652,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME]).toString(); - line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); + line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; } i++; @@ -690,7 +690,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } public List getStoredUsers() { - ArrayList users = new ArrayList(); + ArrayList users = new ArrayList<>(); BufferedReader in = null; String usersFilePath = mcMMO.getUsersFilePath(); @@ -736,19 +736,19 @@ public final class FlatfileDatabaseManager implements DatabaseManager { powerLevels.clear(); // Clear old values from the power levels // Initialize lists - List mining = new ArrayList(); - List woodcutting = new ArrayList(); - List herbalism = new ArrayList(); - List excavation = new ArrayList(); - List acrobatics = new ArrayList(); - List repair = new ArrayList(); - List swords = new ArrayList(); - List axes = new ArrayList(); - List archery = new ArrayList(); - List unarmed = new ArrayList(); - List taming = new ArrayList(); - List fishing = new ArrayList(); - List alchemy = new ArrayList(); + List mining = new ArrayList<>(); + List woodcutting = new ArrayList<>(); + List herbalism = new ArrayList<>(); + List excavation = new ArrayList<>(); + List acrobatics = new ArrayList<>(); + List repair = new ArrayList<>(); + List swords = new ArrayList<>(); + List axes = new ArrayList<>(); + List archery = new ArrayList<>(); + List unarmed = new ArrayList<>(); + List taming = new ArrayList<>(); + List fishing = new ArrayList<>(); + List alchemy = new ArrayList<>(); BufferedReader in = null; String playerName = null; @@ -843,8 +843,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { in = new BufferedReader(new FileReader(usersFilePath)); StringBuilder writer = new StringBuilder(); String line; - HashSet usernames = new HashSet(); - HashSet players = new HashSet(); + HashSet usernames = new HashSet<>(); + HashSet players = new HashSet<>(); while ((line = in.readLine()) != null) { // Remove empty lines from the file @@ -1047,7 +1047,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } if (updated) { - line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); + line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; } writer.append(line).append("\r\n"); @@ -1133,9 +1133,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager { private PlayerProfile loadFromLine(String[] character) { Map skills = getSkillMapFromLine(character); // Skill levels - Map skillsXp = new EnumMap(PrimarySkillType.class); // Skill & XP - Map skillsDATS = new EnumMap(SuperAbilityType.class); // Ability & Cooldown - Map uniquePlayerDataMap = new EnumMap(UniqueDataType.class); + Map skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP + Map skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown + Map uniquePlayerDataMap = new EnumMap<>(UniqueDataType.class); MobHealthbarType mobHealthbarType; int scoreboardTipsShown; @@ -1201,7 +1201,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } private Map getSkillMapFromLine(String[] character) { - Map skills = new EnumMap(PrimarySkillType.class); // Skill & Level + Map skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level skills.put(PrimarySkillType.TAMING, Integer.valueOf(character[SKILLS_TAMING])); skills.put(PrimarySkillType.MINING, Integer.valueOf(character[SKILLS_MINING])); @@ -1322,7 +1322,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { character[HEALTHBAR] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); - line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); + line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; writer.append(line).append("\r\n"); } diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 297e9d0fc..5c9481516 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -23,7 +23,7 @@ public final class SQLDatabaseManager implements DatabaseManager { public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver"; private String tablePrefix = mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix(); - private final Map cachedUserIDs = new HashMap(); + private final Map cachedUserIDs = new HashMap<>(); private DataSource miscPool; private DataSource loadPool; @@ -344,7 +344,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public List readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) { - List stats = new ArrayList(); + List stats = new ArrayList<>(); String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(); ResultSet resultSet = null; @@ -359,7 +359,7 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet = statement.executeQuery(); while (resultSet.next()) { - ArrayList column = new ArrayList(); + ArrayList column = new ArrayList<>(); for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { column.add(resultSet.getString(i)); @@ -381,7 +381,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public Map readRank(String playerName) { - Map skills = new HashMap(); + Map skills = new HashMap<>(); ResultSet resultSet = null; PreparedStatement statement = null; @@ -751,7 +751,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public List getStoredUsers() { - ArrayList users = new ArrayList(); + ArrayList users = new ArrayList<>(); Statement statement = null; Connection connection = null; @@ -1077,10 +1077,10 @@ public final class SQLDatabaseManager implements DatabaseManager { } private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException { - Map skills = new EnumMap(PrimarySkillType.class); // Skill & Level - Map skillsXp = new EnumMap(PrimarySkillType.class); // Skill & XP - Map skillsDATS = new EnumMap(SuperAbilityType.class); // Ability & Cooldown - Map uniqueData = new EnumMap(UniqueDataType.class); //Chimaera wing cooldown and other misc info + Map skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level + Map skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP + Map skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown + Map uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info MobHealthbarType mobHealthbarType; UUID uuid; int scoreboardTipsShown; diff --git a/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java b/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java index 1596faf2a..e2210739f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java +++ b/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java @@ -9,7 +9,7 @@ public enum ChatMode { private String enabledMessage; private String disabledMessage; - private ChatMode(String enabledMessage, String disabledMessage) { + ChatMode(String enabledMessage, String disabledMessage) { this.enabledMessage = enabledMessage; this.disabledMessage = disabledMessage; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java b/src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java index 825be52ba..2e2233d32 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java +++ b/src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.datatypes.database; public class PlayerStat { public String name; - public int statVal = 0; + public int statVal; public PlayerStat(String name, int value) { this.name = name; diff --git a/src/main/java/com/gmail/nossr50/datatypes/database/PoolIdentifier.java b/src/main/java/com/gmail/nossr50/datatypes/database/PoolIdentifier.java index 9d7b27377..d93091942 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/database/PoolIdentifier.java +++ b/src/main/java/com/gmail/nossr50/datatypes/database/PoolIdentifier.java @@ -1,4 +1,7 @@ package com.gmail.nossr50.datatypes.database; public enum PoolIdentifier { + MISC, + LOAD, + SAVE } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index d747e252a..c751fc221 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.UUID; public class Party { - private final LinkedHashMap members = new LinkedHashMap(); - private final List onlineMembers = new ArrayList(); + private final LinkedHashMap members = new LinkedHashMap<>(); + private final List onlineMembers = new ArrayList<>(); private PartyLeader leader; private String name; @@ -90,7 +90,7 @@ public class Party { public List getOnlinePlayerNames(CommandSender sender) { Player player = sender instanceof Player ? (Player) sender : null; - List onlinePlayerNames = new ArrayList(); + List onlinePlayerNames = new ArrayList<>(); for (Player onlinePlayer : getOnlineMembers()) { if (player != null && player.canSee(onlinePlayer)) { @@ -130,7 +130,7 @@ public class Party { } public List getItemShareCategories() { - List shareCategories = new ArrayList(); + List shareCategories = new ArrayList<>(); for (ItemShareType shareType : ItemShareType.values()) { if (sharingDrops(shareType)) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index dd0d432ef..676aa66b7 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -67,7 +67,7 @@ public class McMMOPlayer { private Player player; private PlayerProfile profile; - private final Map skillManagers = new HashMap(); + private final Map skillManagers = new HashMap<>(); private ExperienceBarManager experienceBarManager; private Party party; @@ -85,10 +85,10 @@ public class McMMOPlayer { private boolean godMode; private boolean chatSpy = false; //Off by default - private final Map abilityMode = new HashMap(); - private final Map abilityInformed = new HashMap(); + private final Map abilityMode = new HashMap<>(); + private final Map abilityInformed = new HashMap<>(); - private final Map toolMode = new HashMap(); + private final Map toolMode = new HashMap<>(); private int recentlyHurt; private int respawnATS; diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 8ea8e5b09..4f87c2766 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -29,14 +29,14 @@ public class PlayerProfile { private int scoreboardTipsShown; /* Skill Data */ - private final Map skills = new HashMap(); // Skill & Level - private final Map skillsXp = new HashMap(); // Skill & XP - private final Map abilityDATS = new HashMap(); // Ability & Cooldown + private final Map skills = new HashMap<>(); // Skill & Level + private final Map skillsXp = new HashMap<>(); // Skill & XP + private final Map abilityDATS = new HashMap<>(); // Ability & Cooldown private final Map uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..) // Store previous XP gains for deminished returns - private DelayQueue gainedSkillsXp = new DelayQueue(); - private HashMap rollingSkillsXp = new HashMap(); + private DelayQueue gainedSkillsXp = new DelayQueue<>(); + private HashMap rollingSkillsXp = new HashMap<>(); @Deprecated public PlayerProfile(String playerName) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java index f0d786d73..b6f99cc4f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java @@ -3,5 +3,5 @@ package com.gmail.nossr50.datatypes.skills; public enum ItemType { ARMOR, TOOL, - OTHER; + OTHER } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index 1623e226f..31d2b7750 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -82,9 +82,9 @@ public enum PrimarySkillType { public static final List MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SALVAGE, SMELTING); static { - List childSkills = new ArrayList(); - List nonChildSkills = new ArrayList(); - ArrayList names = new ArrayList(); + List childSkills = new ArrayList<>(); + List nonChildSkills = new ArrayList<>(); + ArrayList names = new ArrayList<>(); ArrayList subSkillNames = new ArrayList<>(); for (PrimarySkillType skill : values()) { @@ -110,11 +110,11 @@ public enum PrimarySkillType { NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills); } - private PrimarySkillType(Class managerClass, Color runescapeColor, List subSkillTypes) { + PrimarySkillType(Class managerClass, Color runescapeColor, List subSkillTypes) { this(managerClass, runescapeColor, null, null, subSkillTypes); } - private PrimarySkillType(Class managerClass, Color runescapeColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { + PrimarySkillType(Class managerClass, Color runescapeColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { this.managerClass = managerClass; this.runescapeColor = runescapeColor; this.ability = ability; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index 39111a8ba..9154e88a8 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -182,7 +182,7 @@ public enum SubSkillType { /* * Find where to begin our substring (after the prefix) */ - String endResult = ""; + StringBuilder endResult = new StringBuilder(); int subStringIndex = getSubStringIndex(subSkillName); /* @@ -191,24 +191,24 @@ public enum SubSkillType { String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex); if(subskillNameWithoutPrefix.contains("_")) { - String splitStrings[] = subskillNameWithoutPrefix.split("_"); + String[] splitStrings = subskillNameWithoutPrefix.split("_"); for(String string : splitStrings) { - endResult += StringUtils.getCapitalized(string); + endResult.append(StringUtils.getCapitalized(string)); } } else { - endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix); + endResult.append(StringUtils.getCapitalized(subskillNameWithoutPrefix)); } - return endResult; + return endResult.toString(); } public String getWikiName(String subSkillName) { /* * Find where to begin our substring (after the prefix) */ - String endResult = ""; + StringBuilder endResult = new StringBuilder(); int subStringIndex = getSubStringIndex(subSkillName); /* @@ -217,22 +217,22 @@ public enum SubSkillType { String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex); if(subskillNameWithoutPrefix.contains("_")) { - String splitStrings[] = subskillNameWithoutPrefix.split("_"); + String[] splitStrings = subskillNameWithoutPrefix.split("_"); for(int i = 0; i < splitStrings.length; i++) { if(i+1 >= splitStrings.length) - endResult+=StringUtils.getCapitalized(splitStrings[i]); + endResult.append(StringUtils.getCapitalized(splitStrings[i])); else { - endResult += StringUtils.getCapitalized(splitStrings[i]); - endResult += "_"; + endResult.append(StringUtils.getCapitalized(splitStrings[i])); + endResult.append("_"); } } } else { - endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix); + endResult.append(StringUtils.getCapitalized(subskillNameWithoutPrefix)); } - return endResult; + return endResult.toString(); } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index 71d332c02..ad2d17dc7 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -91,7 +91,7 @@ public enum SuperAbilityType { private String abilityPlayerOff; private SubSkillType subSkillTypeDefinition; - private SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { + SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { this.abilityOn = abilityOn; this.abilityOff = abilityOff; this.abilityPlayer = abilityPlayer; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java index 2d50ebac4..5d6b798dc 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java @@ -15,7 +15,7 @@ public enum ToolType { private String lowerTool; private String raiseTool; - private ToolType(String lowerTool, String raiseTool) { + ToolType(String lowerTool, String raiseTool) { this.lowerTool = lowerTool; this.raiseTool = raiseTool; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java index 70da6d529..fe2778eed 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java @@ -16,7 +16,7 @@ public enum PotionStage { int numerical; - private PotionStage(int numerical) { + PotionStage(int numerical) { this.numerical = numerical; } diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java index 840f039f6..3458ab5c8 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java @@ -23,7 +23,7 @@ public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent { } public static EnumMap> getFunctionModifiers(Map modifiers) { - EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); + EnumMap> modifierFunctions = new EnumMap<>(DamageModifier.class); Function ZERO = Functions.constant(-0.0); for (DamageModifier modifier : modifiers.keySet()) { diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java index 0ec008672..34eab80bd 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java @@ -23,7 +23,7 @@ public class FakeEntityDamageEvent extends EntityDamageEvent { } public static EnumMap> getFunctionModifiers(Map modifiers) { - EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); + EnumMap> modifierFunctions = new EnumMap<>(DamageModifier.class); Function ZERO = Functions.constant(-0.0); for (DamageModifier modifier : modifiers.keySet()) { diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java index 1e126e501..98a8d4e2a 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java @@ -62,7 +62,7 @@ public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancel /** * Any reason that doesn't fit elsewhere. */ - CUSTOM; + CUSTOM } /** Following are required for Cancellable **/ diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java index f2d3f537e..584564b5f 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java @@ -75,7 +75,7 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { /** * Any reason that doesn't fit elsewhere. */ - CUSTOM; + CUSTOM } /** Following are required for Cancellable **/ diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 440ed37ac..ecd56e6dc 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -172,7 +172,7 @@ public class BlockListener implements Listener { BlockFace direction = event.getDirection(); Block movedBlock = event.getBlock(); - movedBlock = movedBlock.getRelative(direction, 2); +// movedBlock = movedBlock.getRelative(direction, 2); for (Block b : event.getBlocks()) { if (BlockUtils.shouldBeWatched(b.getState())) { diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java index a2b1dd01d..a12f8ae18 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java +++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java @@ -36,8 +36,7 @@ public class InteractionManager { subSkillList.add(abstractSubSkill); //Init ArrayList - if(interactRegister.get(abstractSubSkill.getInteractType()) == null) - interactRegister.put(abstractSubSkill.getInteractType(), new ArrayList<>()); + interactRegister.computeIfAbsent(abstractSubSkill.getInteractType(), k -> new ArrayList<>()); //Registration array reference ArrayList arrayRef = interactRegister.get(abstractSubSkill.getInteractType()); @@ -48,8 +47,7 @@ public class InteractionManager { String lowerCaseName = abstractSubSkill.getConfigKeyName().toLowerCase(); //Register in name map - if(subSkillNameMap.get(lowerCaseName) == null) - subSkillNameMap.put(lowerCaseName, abstractSubSkill); + subSkillNameMap.putIfAbsent(lowerCaseName, abstractSubSkill); System.out.println("[mcMMO] registered subskill: "+ abstractSubSkill.getConfigKeyName()); } diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java index 88d7c08d1..1a0d0b72b 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java @@ -13,7 +13,7 @@ public final class LocaleLoader { private static ResourceBundle bundle = null; private static ResourceBundle enBundle = null; - private LocaleLoader() {}; + private LocaleLoader() {} public static String getString(String key) { return getString(key, (Object[]) null); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 28f77b6ba..8114681bd 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -554,7 +554,7 @@ public class mcMMO extends JavaPlugin { new CleanBackupsTask().runTaskAsynchronously(mcMMO.p); // Bleed timer (Runs every 0.5 seconds) - new BleedTimerTask().runTaskTimer(this, 1 * Misc.TICK_CONVERSION_FACTOR, 1 * (Misc.TICK_CONVERSION_FACTOR / 2)); + new BleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2)); // Old & Powerless User remover long purgeIntervalTicks = getConfigManager().getConfigDatabase().getConfigSectionCleaning().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 3c38a657e..ac07cdac5 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -29,7 +29,7 @@ import java.util.UUID; public final class PartyManager { private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; - private static List parties = new ArrayList(); + private static List parties = new ArrayList<>(); private static File partyFile = new File(partiesFilePath); private PartyManager() {} @@ -145,7 +145,7 @@ public final class PartyManager { * @return the near party members */ public static List getNearMembers(McMMOPlayer mcMMOPlayer) { - List nearMembers = new ArrayList(); + List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { @@ -163,7 +163,7 @@ public final class PartyManager { } public static List getNearVisibleMembers(McMMOPlayer mcMMOPlayer) { - List nearMembers = new ArrayList(); + List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { @@ -192,7 +192,7 @@ public final class PartyManager { public static LinkedHashMap getAllMembers(Player player) { Party party = getParty(player); - return party == null ? new LinkedHashMap() : party.getMembers(); + return party == null ? new LinkedHashMap<>() : party.getMembers(); } /** @@ -216,7 +216,7 @@ public final class PartyManager { } private static List getOnlineMembers(Party party) { - return party == null ? new ArrayList() : party.getOnlineMembers(); + return party == null ? new ArrayList<>() : party.getOnlineMembers(); } /** @@ -589,7 +589,7 @@ public final class PartyManager { YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile); - ArrayList hasAlly = new ArrayList(); + ArrayList hasAlly = new ArrayList<>(); for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { Party party = new Party(partyName); @@ -659,7 +659,7 @@ public final class PartyManager { partiesFile.set(partyName + ".ItemShareType." + itemShareType.toString(), party.sharingDrops(itemShareType)); } - List members = new ArrayList(); + List members = new ArrayList<>(); for (Entry memberEntry : party.getMembers().entrySet()) { String memberUniqueId = memberEntry.getKey() == null ? "" : memberEntry.getKey().toString(); diff --git a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java index 0b296b4bd..7ad3371ff 100644 --- a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java @@ -1,23 +1,23 @@ -package com.gmail.nossr50.runnables; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.runnables.skills.AprilTask; -import com.gmail.nossr50.util.Misc; -import org.bukkit.scheduler.BukkitRunnable; - -public class CheckDateTask extends BukkitRunnable { - - @Override - public void run() { - if (!mcMMO.getHolidayManager().isAprilFirst()) { - return; - } - - // Set up jokes - new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR); - mcMMO.getHolidayManager().registerAprilCommand(); - - // Jokes deployed. - this.cancel(); - } -} +//package com.gmail.nossr50.runnables; +// +//import com.gmail.nossr50.mcMMO; +//import com.gmail.nossr50.runnables.skills.AprilTask; +//import com.gmail.nossr50.util.Misc; +//import org.bukkit.scheduler.BukkitRunnable; +// +//public class CheckDateTask extends BukkitRunnable { +// +// @Override +// public void run() { +// if (!mcMMO.getHolidayManager().isAprilFirst()) { +// return; +// } +// +// // Set up jokes +// new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR); +// mcMMO.getHolidayManager().registerAprilCommand(); +// +// // Jokes deployed. +// this.cancel(); +// } +//} 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 a72e922ae..e8f68b447 100644 --- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java @@ -18,9 +18,9 @@ public class CleanBackupsTask extends BukkitRunnable { @Override public void run() { - List savedDays = new ArrayList(); - HashMap> savedYearsWeeks = new HashMap>(); - List toDelete = new ArrayList(); + List savedDays = new ArrayList<>(); + HashMap> savedYearsWeeks = new HashMap<>(); + List toDelete = new ArrayList<>(); int amountTotal = 0; int amountDeleted = 0; int oldFileAgeLimit = mcMMO.getConfigManager().getConfigAutomatedBackups().getBackupDayLimit(); diff --git a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java index eaf30befe..0089ee677 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java @@ -21,11 +21,6 @@ public class DatabaseConversionTask extends BukkitRunnable { public void run() { sourceDatabase.convertUsers(mcMMO.getDatabaseManager()); - mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new Runnable() { - @Override - public void run() { - sender.sendMessage(message); - } - }); + mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message)); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index 861a9a7d8..48db5eccd 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -17,8 +17,8 @@ public class PartyAutoKickTask extends BukkitRunnable { @Override public void run() { - HashMap toRemove = new HashMap(); - List processedPlayers = new ArrayList(); + HashMap toRemove = new HashMap<>(); + List processedPlayers = new ArrayList<>(); long currentTime = System.currentTimeMillis(); diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index 5e1fe7750..f5593db4a 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java @@ -82,7 +82,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { if (mcMMO.getScoreboardSettings().getShowStatsAfterLogin()) { ScoreboardManager.enablePlayerStatsScoreboard(player); - new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR); + new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index 2290c241b..4d731fb1a 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.Map.Entry; public class BleedTimerTask extends BukkitRunnable { - private static Map bleedList = new HashMap(); + private static Map bleedList = new HashMap<>(); @Override public void run() { diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java index 478957de6..2553854d5 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java @@ -54,7 +54,7 @@ public final class Alchemy { public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed(); public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed(); - public static Map brewingStandMap = new HashMap(); + public static Map brewingStandMap = new HashMap<>(); private Alchemy() {} @@ -64,7 +64,7 @@ public final class Alchemy { public static void finishAllBrews() { mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews."); - List toFinish = new ArrayList(); + List toFinish = new ArrayList<>(); toFinish.addAll(brewingStandMap.values()); diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index 9d1f902ca..5577b51c4 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -108,7 +108,7 @@ public final class AlchemyPotionBrewer { return; } - List inputList = new ArrayList(); + List inputList = new ArrayList<>(); for (int i = 0; i < 3; i++) { ItemStack item = inventory.getItem(i); diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index e8180c8b7..1c1adb380 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -25,7 +25,7 @@ public class Archery { public Archery() { - List trackedEntities = new ArrayList(); + List trackedEntities = new ArrayList<>(); skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax(); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 3a647019c..6ddf253b2 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -21,7 +21,7 @@ public class Excavation { String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly)) return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly); - return new ArrayList(); + return new ArrayList<>(); } protected static int getBlockXP(BlockState blockState) { diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index c7f03a249..3b4c99ed2 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -16,7 +16,7 @@ import java.util.Set; public final class Fishing { - protected static final HashMap> ENCHANTABLE_CACHE = new HashMap>(); + protected static final HashMap> ENCHANTABLE_CACHE = new HashMap<>(); /*public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange(); public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 601d50ccd..a2dcc4518 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -53,7 +53,6 @@ public class FishingManager extends SkillManager { private long lastWarned = 0L; private long lastWarnedExhaust = 0L; private BoundingBox lastFishingBoundingBox; - private Item fishingCatch; private Location hookLocation; private int fishCaughtCounter = 1; private final float boundingBoxSize; @@ -87,7 +86,7 @@ public class FishingManager extends SkillManager { getPlayer().getInventory().getItemInMainHand().setDurability((short) (getPlayer().getInventory().getItemInMainHand().getDurability() + 5)); getPlayer().updateInventory(); - if(lastWarnedExhaust + (1000 * 1) < currentTime) + if(lastWarnedExhaust + (1000) < currentTime) { getPlayer().sendMessage(LocaleLoader.getString("Fishing.Exhausting")); lastWarnedExhaust = currentTime; @@ -114,7 +113,7 @@ public class FishingManager extends SkillManager { long fishHookSpawnCD = fishHookSpawnTimestamp + 1000; boolean hasFished = (currentTime < fishHookSpawnCD); - if(hasFished && (lastWarned + (1000 * 1) < currentTime)) + if(hasFished && (lastWarned + (1000) < currentTime)) { getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scared")); lastWarned = System.currentTimeMillis(); @@ -286,7 +285,6 @@ public class FishingManager extends SkillManager { * @param fishingCatch The {@link Item} initially caught */ public void handleFishing(Item fishingCatch) { - this.fishingCatch = fishingCatch; int fishXp = ExperienceConfig.getInstance().getXp(PrimarySkillType.FISHING, fishingCatch.getItemStack().getType()); int treasureXp = 0; Player player = getPlayer(); @@ -294,12 +292,11 @@ public class FishingManager extends SkillManager { if (MainConfig.getInstance().getFishingDropsEnabled() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) { treasure = getFishingTreasure(); - this.fishingCatch = null; } if (treasure != null) { ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay? - Map enchants = new HashMap(); + Map enchants = new HashMap<>(); if (isMagicHunterEnabled() && ItemUtils.isEnchantable(treasureDrop)) { @@ -517,7 +514,7 @@ public class FishingManager extends SkillManager { * @return true if the item has been enchanted */ private Map handleMagicHunter(ItemStack treasureDrop) { - Map enchants = new HashMap(); + Map enchants = new HashMap<>(); List fishingEnchantments = null; double diceRoll = Misc.getRandom().nextDouble() * 100; @@ -547,7 +544,7 @@ public class FishingManager extends SkillManager { } List validEnchantments = getPossibleEnchantments(treasureDrop); - List possibleEnchants = new ArrayList(); + List possibleEnchants = new ArrayList<>(); for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) { if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) { @@ -586,7 +583,7 @@ public class FishingManager extends SkillManager { return Fishing.ENCHANTABLE_CACHE.get(dropType); } - List possibleEnchantments = new ArrayList(); + List possibleEnchantments = new ArrayList<>(); for (Enchantment enchantment : Enchantment.values()) { if (enchantment.canEnchantItem(treasureDrop)) { diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 9b2687368..270e32d11 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -282,7 +282,7 @@ public class HerbalismManager extends SkillManager { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); - Material seed = null; + Material seed; switch (blockState.getType()) { case CARROTS: diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 404da88c2..6ee85818a 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -130,8 +130,8 @@ public class MiningManager extends SkillManager { * @param blockList The list of blocks to drop */ public void blastMiningDropProcessing(float yield, List blockList) { - List ores = new ArrayList(); - List debris = new ArrayList(); + List ores = new ArrayList<>(); + List debris = new ArrayList<>(); int xp = 0; float oreBonus = (float) (getOreBonus() / 100); @@ -263,7 +263,7 @@ public class MiningManager extends SkillManager { if (timeRemaining > 0) { //getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); - NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf("timeRemaining")); + NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index 652090840..c486c95cb 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.util.ItemUtils; import org.bukkit.Material; import java.util.Arrays; +import java.util.Collections; import java.util.List; @@ -19,7 +20,7 @@ public class Repairable { private final double xpMultiplier; public Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) { - this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Arrays.asList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier); + this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Collections.singletonList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier); } public Repairable(Material itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java index 3963cc50e..b4aa43c06 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java @@ -16,7 +16,7 @@ public class RepairableManager implements Unload { } public RepairableManager(List repairablesCollection) { - this.repairables = new HashMap(repairablesCollection.size()); + this.repairables = new HashMap<>(repairablesCollection.size()); registerRepairables(repairablesCollection); } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 221a71231..e2197dab4 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -143,7 +143,7 @@ public class SalvageManager extends SkillManager { }*/ public int getSalvageableAmount() { - return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE) * 1); + return (RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE)); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java index bd3e944f3..7554dad27 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java @@ -21,7 +21,7 @@ public class SalvageableManager implements Unload { } public SalvageableManager(List salvageablesCollection) { - this.salvageables = new HashMap(salvageablesCollection.size()); + this.salvageables = new HashMap<>(salvageablesCollection.size()); registerSalvageables(salvageablesCollection); } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 7b0007b89..f3ccc25de 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -37,7 +37,7 @@ public class TamingManager extends SkillManager { super(mcMMOPlayer, PrimarySkillType.TAMING); } - private static HashMap> summonedEntities = new HashMap>(); + private static HashMap> summonedEntities = new HashMap<>(); public boolean canUseThickFur() { return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.TAMING_THICK_FUR) @@ -384,7 +384,7 @@ public class TamingManager extends SkillManager { TrackedTamingEntity trackedEntity = new TrackedTamingEntity(livingEntity); if (!summonedEntities.containsKey(livingEntity.getType())) { - summonedEntities.put(livingEntity.getType(), new ArrayList()); + summonedEntities.put(livingEntity.getType(), new ArrayList<>()); } summonedEntities.get(livingEntity.getType()).add(trackedEntity); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index ac0cd0209..7f72765c0 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -99,7 +99,7 @@ public final class Woodcutting { * before taking measurements). */ protected static void processTree(BlockState blockState, Set treeFellerBlocks) { - List futureCenterBlocks = new ArrayList(); + List futureCenterBlocks = new ArrayList<>(); // Check the block up and take different behavior (smaller search) if it's a log if (handleBlock(blockState.getBlock().getRelative(BlockFace.UP).getState(), futureCenterBlocks, treeFellerBlocks)) { diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index a7518e090..86ab76874 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -75,7 +75,7 @@ public class WoodcuttingManager extends SkillManager { */ public void processTreeFeller(BlockState blockState) { Player player = getPlayer(); - Set treeFellerBlocks = new HashSet(); + Set treeFellerBlocks = new HashSet<>(); Woodcutting.treeFellerReachedThreshold = false; diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 0178e2006..40f3bef00 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -581,7 +581,7 @@ public final class BlockUtils { * @return HashSet with the IDs of every transparent block */ public static HashSet getTransparentBlocks() { - HashSet transparentBlocks = new HashSet(); + HashSet transparentBlocks = new HashSet<>(); for (Material material : Material.values()) { if (material.isTransparent()) { diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 141d2bf46..904b50e42 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -150,7 +150,7 @@ public final class ChimaeraWing { ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); - List itemLore = new ArrayList(); + List itemLore = new ArrayList<>(); itemLore.add("mcMMO Item"); itemLore.add(LocaleLoader.getString("Item.ChimaeraWing.Lore")); itemMeta.setLore(itemLore); diff --git a/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java b/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java index ad71ea747..6aab49b3d 100644 --- a/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java @@ -6,7 +6,7 @@ import java.util.HashMap; public class EnchantmentUtils { - private static final HashMap enchants = new HashMap(); + private static final HashMap enchants = new HashMap<>(); static { enchants.put("SHARPNESS", Enchantment.DAMAGE_ALL); diff --git a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java index 71760b196..c1aee7145 100644 --- a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -20,8 +20,8 @@ public final class HardcoreManager { PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); int totalLevelsLost = 0; - HashMap levelChanged = new HashMap(); - HashMap experienceChanged = new HashMap(); + HashMap levelChanged = new HashMap<>(); + HashMap experienceChanged = new HashMap<>(); for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { if (!primarySkillType.getHardcoreStatLossEnabled()) { @@ -63,8 +63,8 @@ public final class HardcoreManager { PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile(); int totalLevelsStolen = 0; - HashMap levelChanged = new HashMap(); - HashMap experienceChanged = new HashMap(); + HashMap levelChanged = new HashMap<>(); + HashMap experienceChanged = new HashMap<>(); for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { if (!primarySkillType.getHardcoreVampirismEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 141a80a41..2438b2bc7 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -40,7 +40,7 @@ public final class Misc { public static final Set modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION"); - private Misc() {}; + private Misc() {} public static boolean isNPCEntity(Entity entity) { return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake")); diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java index 2b94f2f4f..99d79346c 100644 --- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java @@ -127,19 +127,19 @@ public final class MobHealthbarUtils { int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D)); int grayDisplay = fullDisplay - coloredDisplay; - String healthbar = color + ""; + StringBuilder healthbar = new StringBuilder(color + ""); for (int i = 0; i < coloredDisplay; i++) { - healthbar += symbol; + healthbar.append(symbol); } - healthbar += ChatColor.GRAY; + healthbar.append(ChatColor.GRAY); for (int i = 0; i < grayDisplay; i++) { - healthbar += symbol; + healthbar.append(symbol); } - return healthbar; + return healthbar.toString(); } /** diff --git a/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java b/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java index 2de65c9fc..b9d19e6eb 100644 --- a/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java +++ b/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java @@ -10,8 +10,8 @@ public class BiomeAdapter { static { List allBiomes = Arrays.asList(Biome.values()); - List waterBiomes = new ArrayList(); - List iceBiomes = new ArrayList(); + List waterBiomes = new ArrayList<>(); + List iceBiomes = new ArrayList<>(); for (Biome biome : allBiomes) { if (isWater(biome.name()) && !isCold(biome.name())) { waterBiomes.add(biome); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java index e3e3d0b2e..feb54acd3 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java @@ -12,7 +12,7 @@ public interface ChunkletManager { * @param cz Chunklet Z coordinate that needs to be loaded * @param world World that the chunklet needs to be loaded in */ - public void loadChunklet(int cx, int cy, int cz, World world); + void loadChunklet(int cx, int cy, int cz, World world); /** * Unload a specific chunklet @@ -22,7 +22,7 @@ public interface ChunkletManager { * @param cz Chunklet Z coordinate that needs to be unloaded * @param world World that the chunklet needs to be unloaded from */ - public void unloadChunklet(int cx, int cy, int cz, World world); + void unloadChunklet(int cx, int cy, int cz, World world); /** * Load a given Chunk's Chunklet data @@ -31,7 +31,7 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is to be loaded * @param world World that the Chunk is in */ - public void loadChunk(int cx, int cz, World world); + void loadChunk(int cx, int cz, World world); /** * Unload a given Chunk's Chunklet data @@ -40,7 +40,7 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is to be unloaded * @param world World that the Chunk is in */ - public void unloadChunk(int cx, int cz, World world); + void unloadChunk(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is loaded @@ -49,7 +49,7 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is loaded * @param world World that the chunk was loaded in */ - public void chunkLoaded(int cx, int cz, World world); + void chunkLoaded(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is unloaded @@ -58,38 +58,38 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is unloaded * @param world World that the chunk was unloaded in */ - public void chunkUnloaded(int cx, int cz, World world); + void chunkUnloaded(int cx, int cz, World world); /** * Save all ChunkletStores related to the given world * * @param world World to save */ - public void saveWorld(World world); + void saveWorld(World world); /** * Unload all ChunkletStores from memory related to the given world after saving them * * @param world World to unload */ - public void unloadWorld(World world); + void unloadWorld(World world); /** * Load all ChunkletStores from all loaded chunks from this world into memory * * @param world World to load */ - public void loadWorld(World world); + void loadWorld(World world); /** * Save all ChunkletStores */ - public void saveAll(); + void saveAll(); /** * Unload all ChunkletStores after saving them */ - public void unloadAll(); + void unloadAll(); /** * Check to see if a given location is set to true @@ -100,7 +100,7 @@ public interface ChunkletManager { * @param world World to check in * @return true if the given location is set to true, false if otherwise */ - public boolean isTrue(int x, int y, int z, World world); + boolean isTrue(int x, int y, int z, World world); /** * Check to see if a given block location is set to true @@ -108,7 +108,7 @@ public interface ChunkletManager { * @param block Block location to check * @return true if the given block location is set to true, false if otherwise */ - public boolean isTrue(Block block); + boolean isTrue(Block block); /** * Set a given location to true, should create stores as necessary if the location does not exist @@ -118,14 +118,14 @@ public interface ChunkletManager { * @param z Z coordinate to set * @param world World to set in */ - public void setTrue(int x, int y, int z, World world); + void setTrue(int x, int y, int z, World world); /** * Set a given block location to true, should create stores as necessary if the location does not exist * * @param block Block location to set */ - public void setTrue(Block block); + void setTrue(Block block); /** * Set a given location to false, should not create stores if one does not exist for the given location @@ -135,17 +135,17 @@ public interface ChunkletManager { * @param z Z coordinate to set * @param world World to set in */ - public void setFalse(int x, int y, int z, World world); + void setFalse(int x, int y, int z, World world); /** * Set a given block location to false, should not create stores if one does not exist for the given location * * @param block Block location to set */ - public void setFalse(Block block); + void setFalse(Block block); /** * Delete any ChunkletStores that are empty */ - public void cleanUp(); + void cleanUp(); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java index 5514df13c..9b1537782 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java @@ -14,7 +14,7 @@ public interface ChunkletStore extends Serializable { * @param z z coordinate in current chunklet * @return true if the value is true at the given coordinates, false if otherwise */ - public boolean isTrue(int x, int y, int z); + boolean isTrue(int x, int y, int z); /** * Set the value to true at the given coordinates @@ -23,7 +23,7 @@ public interface ChunkletStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setTrue(int x, int y, int z); + void setTrue(int x, int y, int z); /** * Set the value to false at the given coordinates @@ -32,17 +32,17 @@ public interface ChunkletStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setFalse(int x, int y, int z); + void setFalse(int x, int y, int z); /** * @return true if all values in the chunklet are false, false if otherwise */ - public boolean isEmpty(); + boolean isEmpty(); /** * Set all values in this ChunkletStore to the values from another provided ChunkletStore * * @param otherStore Another ChunkletStore that this one should copy all data from */ - public void copyFrom(ChunkletStore otherStore); + void copyFrom(ChunkletStore otherStore); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index f591cdafa..e634eefa7 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -8,7 +8,7 @@ import java.io.*; import java.util.HashMap; public class HashChunkletManager implements ChunkletManager { - public HashMap store = new HashMap(); + public HashMap store = new HashMap<>(); @Override public void loadChunklet(int cx, int cy, int cz, World world) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java index 3cf9b1faa..d64824a0e 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java @@ -8,13 +8,13 @@ import org.bukkit.entity.Entity; import java.io.IOException; public interface ChunkManager { - public void closeAll(); + void closeAll(); - public ChunkStore readChunkStore(World world, int x, int z) throws IOException; + ChunkStore readChunkStore(World world, int x, int z) throws IOException; - public void writeChunkStore(World world, int x, int z, ChunkStore data); + void writeChunkStore(World world, int x, int z, ChunkStore data); - public void closeChunkStore(World world, int x, int z); + void closeChunkStore(World world, int x, int z); /** * Loads a specific chunklet @@ -24,7 +24,7 @@ public interface ChunkManager { * @param cz Chunklet Z coordinate that needs to be loaded * @param world World that the chunklet needs to be loaded in */ - public void loadChunklet(int cx, int cy, int cz, World world); + void loadChunklet(int cx, int cy, int cz, World world); /** * Unload a specific chunklet @@ -34,7 +34,7 @@ public interface ChunkManager { * @param cz Chunklet Z coordinate that needs to be unloaded * @param world World that the chunklet needs to be unloaded from */ - public void unloadChunklet(int cx, int cy, int cz, World world); + void unloadChunklet(int cx, int cy, int cz, World world); /** * Load a given Chunk's Chunklet data @@ -43,7 +43,7 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is to be loaded * @param world World that the Chunk is in */ - public void loadChunk(int cx, int cz, World world, Entity[] entities); + void loadChunk(int cx, int cz, World world, Entity[] entities); /** * Unload a given Chunk's Chunklet data @@ -52,7 +52,7 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is to be unloaded * @param world World that the Chunk is in */ - public void unloadChunk(int cx, int cz, World world); + void unloadChunk(int cx, int cz, World world); /** * Saves a given Chunk's Chunklet data @@ -61,9 +61,9 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is to be saved * @param world World that the Chunk is in */ - public void saveChunk(int cx, int cz, World world); + void saveChunk(int cx, int cz, World world); - public boolean isChunkLoaded(int cx, int cz, World world); + boolean isChunkLoaded(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is loaded @@ -72,7 +72,7 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is loaded * @param world World that the chunk was loaded in */ - public void chunkLoaded(int cx, int cz, World world); + void chunkLoaded(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is unloaded @@ -81,38 +81,38 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is unloaded * @param world World that the chunk was unloaded in */ - public void chunkUnloaded(int cx, int cz, World world); + void chunkUnloaded(int cx, int cz, World world); /** * Save all ChunkletStores related to the given world * * @param world World to save */ - public void saveWorld(World world); + void saveWorld(World world); /** * Unload all ChunkletStores from memory related to the given world after saving them * * @param world World to unload */ - public void unloadWorld(World world); + void unloadWorld(World world); /** * Load all ChunkletStores from all loaded chunks from this world into memory * * @param world World to load */ - public void loadWorld(World world); + void loadWorld(World world); /** * Save all ChunkletStores */ - public void saveAll(); + void saveAll(); /** * Unload all ChunkletStores after saving them */ - public void unloadAll(); + void unloadAll(); /** * Check to see if a given location is set to true @@ -123,7 +123,7 @@ public interface ChunkManager { * @param world World to check in * @return true if the given location is set to true, false if otherwise */ - public boolean isTrue(int x, int y, int z, World world); + boolean isTrue(int x, int y, int z, World world); /** * Check to see if a given block location is set to true @@ -131,7 +131,7 @@ public interface ChunkManager { * @param block Block location to check * @return true if the given block location is set to true, false if otherwise */ - public boolean isTrue(Block block); + boolean isTrue(Block block); /** * Check to see if a given BlockState location is set to true @@ -139,7 +139,7 @@ public interface ChunkManager { * @param blockState BlockState to check * @return true if the given BlockState location is set to true, false if otherwise */ - public boolean isTrue(BlockState blockState); + boolean isTrue(BlockState blockState); /** * Set a given location to true, should create stores as necessary if the location does not exist @@ -149,21 +149,21 @@ public interface ChunkManager { * @param z Z coordinate to set * @param world World to set in */ - public void setTrue(int x, int y, int z, World world); + void setTrue(int x, int y, int z, World world); /** * Set a given block location to true, should create stores as necessary if the location does not exist * * @param block Block location to set */ - public void setTrue(Block block); + void setTrue(Block block); /** * Set a given BlockState location to true, should create stores as necessary if the location does not exist * * @param blockState BlockState location to set */ - public void setTrue(BlockState blockState); + void setTrue(BlockState blockState); /** * Set a given location to false, should not create stores if one does not exist for the given location @@ -173,24 +173,24 @@ public interface ChunkManager { * @param z Z coordinate to set * @param world World to set in */ - public void setFalse(int x, int y, int z, World world); + void setFalse(int x, int y, int z, World world); /** * Set a given block location to false, should not create stores if one does not exist for the given location * * @param block Block location to set */ - public void setFalse(Block block); + void setFalse(Block block); /** * Set a given BlockState location to false, should not create stores if one does not exist for the given location * * @param blockState BlockState location to set */ - public void setFalse(BlockState blockState); + void setFalse(BlockState blockState); /** * Delete any ChunkletStores that are empty */ - public void cleanUp(); + void cleanUp(); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java index d4f585f9a..69b2acae1 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java @@ -13,28 +13,28 @@ public interface ChunkStore extends Serializable { * * @return true if the has been modified since it was last saved */ - public boolean isDirty(); + boolean isDirty(); /** * Checks the chunk's save state * * @param dirty the save state of the current chunk */ - public void setDirty(boolean dirty); + void setDirty(boolean dirty); /** * Checks the chunk's x coordinate * * @return the chunk's x coordinate. */ - public int getChunkX(); + int getChunkX(); /** * Checks the chunk's z coordinate * * @return the chunk's z coordinate. */ - public int getChunkZ(); + int getChunkZ(); /** * Checks the value at the given coordinates @@ -44,7 +44,7 @@ public interface ChunkStore extends Serializable { * @param z z coordinate in current chunklet * @return true if the value is true at the given coordinates, false if otherwise */ - public boolean isTrue(int x, int y, int z); + boolean isTrue(int x, int y, int z); /** * Set the value to true at the given coordinates @@ -53,7 +53,7 @@ public interface ChunkStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setTrue(int x, int y, int z); + void setTrue(int x, int y, int z); /** * Set the value to false at the given coordinates @@ -62,17 +62,17 @@ public interface ChunkStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setFalse(int x, int y, int z); + void setFalse(int x, int y, int z); /** * @return true if all values in the chunklet are false, false if otherwise */ - public boolean isEmpty(); + boolean isEmpty(); /** * Set all values in this ChunkletStore to the values from another provided ChunkletStore * * @param otherStore Another ChunkletStore that this one should copy all data from */ - public void copyFrom(ChunkletStore otherStore); + void copyFrom(ChunkletStore otherStore); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index be8f4191d..c4d4483b0 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -11,10 +11,10 @@ import java.io.*; import java.util.*; public class HashChunkManager implements ChunkManager { - private HashMap> regionFiles = new HashMap>(); - public HashMap store = new HashMap(); - public ArrayList converters = new ArrayList(); - private HashMap oldData = new HashMap(); + private HashMap> regionFiles = new HashMap<>(); + public HashMap store = new HashMap<>(); + public ArrayList converters = new ArrayList<>(); + private HashMap oldData = new HashMap<>(); @Override public synchronized void closeAll() { @@ -38,31 +38,19 @@ public class HashChunkManager implements ChunkManager { if (in == null) { return null; } - ObjectInputStream objectStream = new ObjectInputStream(in); - try { + try (ObjectInputStream objectStream = new ObjectInputStream(in)) { Object o = objectStream.readObject(); if (o instanceof ChunkStore) { return (ChunkStore) o; } throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z); - } - catch (IOException e) { + } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); // Assume the format changed return null; //throw new RuntimeException("Unable to process chunk meta data for " + x + ", " + z, e); } - catch (ClassNotFoundException e) { - e.printStackTrace(); - // Assume the format changed - //System.out.println("[SpoutPlugin] is Unable to find serialized class for " + x + ", " + z + ", " + e.getMessage()); - return null; - //throw new RuntimeException("Unable to find serialized class for " + x + ", " + z, e); - } - finally { - objectStream.close(); - } } @Override @@ -101,7 +89,7 @@ public class HashChunkManager implements ChunkManager { HashMap worldRegions = regionFiles.get(key); if (worldRegions == null) { - worldRegions = new HashMap(); + worldRegions = new HashMap<>(); regionFiles.put(key, worldRegions); } @@ -222,7 +210,7 @@ public class HashChunkManager implements ChunkManager { closeAll(); String worldName = world.getName(); - List keys = new ArrayList(store.keySet()); + List keys = new ArrayList<>(store.keySet()); for (String key : keys) { String[] info = key.split(","); if (worldName.equals(info[0])) { @@ -245,7 +233,7 @@ public class HashChunkManager implements ChunkManager { closeAll(); String worldName = world.getName(); - List keys = new ArrayList(store.keySet()); + List keys = new ArrayList<>(store.keySet()); for (String key : keys) { String[] info = key.split(","); if (worldName.equals(info[0])) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java index 6a506d2ef..a396a8060 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java @@ -29,7 +29,7 @@ public class McMMOSimpleRegionFile { private final int[] dataStart = new int[1024]; private final int[] dataActualLength = new int[1024]; private final int[] dataLength = new int[1024]; - private final ArrayList inuse = new ArrayList(); + private final ArrayList inuse = new ArrayList<>(); private int segmentSize; private int segmentMask; private final int rx; diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 2fb04c365..0f73efc90 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; public final class CommandRegistrationManager { - private CommandRegistrationManager() {}; + private CommandRegistrationManager() {} private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); @@ -183,7 +183,7 @@ public final class CommandRegistrationManager { } private static void registerXprateCommand() { - List aliasList = new ArrayList(); + List aliasList = new ArrayList<>(); aliasList.add("mcxprate"); PluginCommand command = mcMMO.p.getCommand("xprate"); diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index 982020903..d93ad9ffd 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -225,7 +225,7 @@ public final class CommandUtils { private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List skillGroup) { PlayerProfile profile = UserManager.getPlayer(inspect).getProfile(); - List displayData = new ArrayList(); + List displayData = new ArrayList<>(); displayData.add(header); for (PrimarySkillType skill : skillGroup) { @@ -243,7 +243,7 @@ public final class CommandUtils { public static List getOnlinePlayerNames(CommandSender sender) { Player player = sender instanceof Player ? (Player) sender : null; - List onlinePlayerNames = new ArrayList(); + List onlinePlayerNames = new ArrayList<>(); for (Player onlinePlayer : mcMMO.p.getServer().getOnlinePlayers()) { if (player != null && player.canSee(onlinePlayer)) { @@ -290,7 +290,7 @@ public final class CommandUtils { * @return List of all possible names */ private static List matchPlayer(String partialName) { - List matchedPlayers = new ArrayList(); + List matchedPlayers = new ArrayList<>(); for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) { String playerName = offlinePlayer.getName(); diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index 75843d215..a8383c687 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -14,8 +14,8 @@ public class FormulaManager { private static File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml"); // Experience needed to reach a level, cached values to improve conversion speed - private final Map experienceNeededLinear = new HashMap(); - private final Map experienceNeededExponential = new HashMap(); + private final Map experienceNeededLinear = new HashMap<>(); + private final Map experienceNeededExponential = new HashMap<>(); private FormulaType previousFormula; diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java index 3c5411bc9..8205f9aab 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -62,7 +62,7 @@ public final class UserManager { } public static Collection getPlayers() { - Collection playerCollection = new ArrayList(); + Collection playerCollection = new ArrayList<>(); for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { if (hasPlayerDataKey(player)) { 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 718b2a814..803010e5b 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -23,7 +23,7 @@ import java.util.*; * Manages the Scoreboards used to display a variety of mcMMO related information to the player */ public class ScoreboardManager { - static final Map PLAYER_SCOREBOARDS = new HashMap(); + static final Map PLAYER_SCOREBOARDS = new HashMap<>(); // do not localize; these are internal identifiers static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar"; @@ -128,7 +128,7 @@ public class ScoreboardManager { abilityLabelsSkill = abilityLabelSkillBuilder.build(); } - private static List dirtyPowerLevels = new ArrayList(); + private static List dirtyPowerLevels = new ArrayList<>(); public enum SidebarType { NONE, @@ -136,7 +136,7 @@ public class ScoreboardManager { STATS_BOARD, COOLDOWNS_BOARD, RANK_BOARD, - TOP_BOARD; + TOP_BOARD } private static String formatAbility(String abilityName) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 3ac1a8750..d69cf7cb3 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -701,7 +701,7 @@ public final class CombatUtils { @Deprecated public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) { - return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap(ImmutableMap.of(DamageModifier.BASE, damage))); + return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage))); } @Deprecated @@ -751,7 +751,7 @@ public final class CombatUtils { } private static Map getModifiers(EntityDamageEvent event) { - Map modifiers = new HashMap(); + Map modifiers = new HashMap<>(); for (DamageModifier modifier : DamageModifier.values()) { modifiers.put(modifier, event.getDamage(modifier)); } @@ -760,7 +760,7 @@ public final class CombatUtils { } private static Map getScaledModifiers(double damage, Map modifiers) { - Map scaledModifiers = new HashMap(); + Map scaledModifiers = new HashMap<>(); for (DamageModifier modifier : modifiers.keySet()) { if (modifier == DamageModifier.BASE) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java index e581d113b..a4ab565a0 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -12,7 +12,7 @@ import org.bukkit.entity.Player; public final class ParticleEffectUtils { - private ParticleEffectUtils() {}; + private ParticleEffectUtils() {} public static void playBleedEffect(LivingEntity livingEntity) { if (!MainConfig.getInstance().getBleedEffectEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java index 1247c8272..962b0922e 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java @@ -9,7 +9,7 @@ public final class PerksUtils { private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75; private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100; - private PerksUtils() {}; + private PerksUtils() {} public static int handleCooldownPerks(Player player, int cooldown) { if (Permissions.halvedCooldowns(player)) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index b5df535a0..24de72d0b 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -265,8 +265,7 @@ public class RankUtils { if (subSkillRanks == null) subSkillRanks = new HashMap<>(); - if (subSkillRanks.get(s) == null) - subSkillRanks.put(s, new HashMap<>()); + subSkillRanks.computeIfAbsent(s, k -> new HashMap<>()); } /* public static int getSubSkillUnlockRequirement(SubSkillType subSkillType) diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index 0b3853a29..95a5ea7d3 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -133,7 +133,7 @@ public class SkillUtils { int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED); ItemMeta itemMeta = heldItem.getItemMeta(); - List itemLore = new ArrayList(); + List itemLore = new ArrayList<>(); if (itemMeta.hasLore()) { itemLore = itemMeta.getLore(); diff --git a/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java b/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java index 90bef4122..aefc37520 100644 --- a/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java +++ b/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java @@ -31,7 +31,7 @@ public class UUIDFetcher implements Callable> { } public Map call() throws Exception { - Map uuidMap = new HashMap(); + Map uuidMap = new HashMap<>(); int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST); for (int i = 0; i < requests; i++) { HttpURLConnection connection = createConnection(); @@ -92,6 +92,6 @@ public class UUIDFetcher implements Callable> { } public static UUID getUUIDOf(String name) throws Exception { - return new UUIDFetcher(Arrays.asList(name)).call().get(name); + return new UUIDFetcher(Collections.singletonList(name)).call().get(name); } } diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java index f8f49c453..e254bd7c4 100644 --- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java +++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java @@ -46,7 +46,7 @@ public class ZipLibrary { File fileZip = new File(BACKUP_DIRECTORY + File.separator + dateFormat.format(date) + ".zip"); // Create the Source List, and add directories/etc to the file. - List sources = new ArrayList(); + List sources = new ArrayList<>(); sources.add(FLAT_FILE_DIRECTORY); sources.addAll(mcMMO.getConfigManager().getConfigFiles()); //Config File Backups