From 3b644cd6c3ae0f1b3bce4140aabf6b9601c3939c Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Tue, 19 Dec 2017 02:18:13 -0800 Subject: [PATCH] Java 7 and make intellij happy --- pom.xml | 4 +- .../java/com/massivecraft/factions/Conf.java | 28 +++++----- .../com/massivecraft/factions/FLocation.java | 4 +- .../java/com/massivecraft/factions/P.java | 4 +- .../factions/cmd/CmdAutoHelp.java | 2 +- .../massivecraft/factions/cmd/CmdConfig.java | 48 ++++++++--------- .../massivecraft/factions/cmd/CmdDisband.java | 2 +- .../massivecraft/factions/cmd/CmdHelp.java | 26 +++++----- .../massivecraft/factions/cmd/CmdHome.java | 2 +- .../massivecraft/factions/cmd/CmdList.java | 2 +- .../factions/cmd/CmdSetMaxVaults.java | 1 - .../massivecraft/factions/cmd/CmdShow.java | 2 +- .../massivecraft/factions/cmd/CmdStatus.java | 2 +- .../com/massivecraft/factions/cmd/CmdTop.java | 2 +- .../massivecraft/factions/cmd/CmdVault.java | 2 - .../factions/event/FPlayerLeaveEvent.java | 7 +-- .../factions/integration/Econ.java | 4 +- .../factions/integration/Essentials.java | 5 +- .../factions/integration/Worldguard.java | 13 ++--- .../integration/dynmap/EngineDynmap.java | 44 ++++++++-------- .../listeners/FactionsBlockListener.java | 23 ++------- .../listeners/FactionsEntityListener.java | 15 ++---- .../listeners/FactionsPlayerListener.java | 6 +-- .../scoreboards/BufferedObjective.java | 6 +-- .../factions/scoreboards/FScoreboard.java | 2 +- .../factions/scoreboards/FTeamWrapper.java | 12 ++--- .../scoreboards/sidebar/FDefaultSidebar.java | 2 +- .../factions/struct/ChatMode.java | 2 +- .../factions/struct/Relation.java | 2 +- .../massivecraft/factions/struct/Role.java | 2 +- .../factions/util/AsciiCompass.java | 4 +- .../factions/util/EnumTypeAdapter.java | 4 +- .../util/MapFLocToStringSetTypeAdapter.java | 4 +- .../massivecraft/factions/util/MiscUtil.java | 18 +++---- .../factions/util/VisualizeUtil.java | 4 +- .../massivecraft/factions/zcore/MCommand.java | 18 +++---- .../massivecraft/factions/zcore/MPlugin.java | 10 ++-- .../factions/zcore/persist/MemoryBoard.java | 36 ++++++------- .../factions/zcore/persist/MemoryFPlayer.java | 7 +-- .../zcore/persist/MemoryFPlayers.java | 6 +-- .../factions/zcore/persist/MemoryFaction.java | 51 ++++++++----------- .../zcore/persist/MemoryFactions.java | 6 +-- .../zcore/persist/json/JSONBoard.java | 2 +- .../zcore/persist/json/JSONFPlayer.java | 5 +- .../zcore/persist/json/JSONFPlayers.java | 16 +++--- .../zcore/persist/json/JSONFactions.java | 17 +++---- .../factions/zcore/util/DiscUtil.java | 2 +- .../factions/zcore/util/PermUtil.java | 2 +- .../factions/zcore/util/Persist.java | 3 +- .../factions/zcore/util/TagReplacer.java | 2 +- .../factions/zcore/util/TagUtil.java | 6 +-- .../factions/zcore/util/TextUtil.java | 4 +- .../factions/zcore/util/UUIDFetcher.java | 4 +- 53 files changed, 222 insertions(+), 285 deletions(-) diff --git a/pom.xml b/pom.xml index 547f4d82..dceadff9 100644 --- a/pom.xml +++ b/pom.xml @@ -28,8 +28,8 @@ maven-compiler-plugin 3.5.1 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 1592f007..359cad41 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -10,7 +10,7 @@ import java.util.*; public class Conf { - public static List baseCommandAliases = new ArrayList(); + public static List baseCommandAliases = new ArrayList<>(); public static boolean allowNoSlashCommand = true; // Colors @@ -145,14 +145,14 @@ public class Conf { public static int actionDeniedPainAmount = 1; // commands which will be prevented if the player is a member of a permanent faction - public static Set permanentFactionMemberDenyCommands = new LinkedHashSet(); + public static Set permanentFactionMemberDenyCommands = new LinkedHashSet<>(); // commands which will be prevented when in claimed territory of another faction - public static Set territoryNeutralDenyCommands = new LinkedHashSet(); - public static Set territoryEnemyDenyCommands = new LinkedHashSet(); - public static Set territoryAllyDenyCommands = new LinkedHashSet(); - public static Set warzoneDenyCommands = new LinkedHashSet(); - public static Set wildernessDenyCommands = new LinkedHashSet(); + public static Set territoryNeutralDenyCommands = new LinkedHashSet<>(); + public static Set territoryEnemyDenyCommands = new LinkedHashSet<>(); + public static Set territoryAllyDenyCommands = new LinkedHashSet<>(); + public static Set warzoneDenyCommands = new LinkedHashSet<>(); + public static Set wildernessDenyCommands = new LinkedHashSet<>(); public static boolean territoryDenyBuild = true; public static boolean territoryDenyBuildWhenOffline = true; @@ -309,12 +309,12 @@ public class Conf { // If empty all regions are shown. // Specify Faction either by name or UUID. // To show all regions on a given world, add 'world:' to the list. - public static Set dynmapVisibleFactions = new HashSet(); + public static Set dynmapVisibleFactions = new HashSet<>(); // Optional setting to hide specific Factions. // Specify Faction either by name or UUID. // To hide all regions on a given world, add 'world:' to the list. - public static Set dynmapHiddenFactions = new HashSet(); + public static Set dynmapHiddenFactions = new HashSet<>(); // Region Style public static final transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00"; @@ -349,12 +349,12 @@ public class Conf { public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections - public static Set playersWhoBypassAllProtection = new LinkedHashSet(); + public static Set playersWhoBypassAllProtection = new LinkedHashSet<>(); - public static Set worldsNoClaiming = new LinkedHashSet(); - public static Set worldsNoPowerLoss = new LinkedHashSet(); - public static Set worldsIgnorePvP = new LinkedHashSet(); - public static Set worldsNoWildernessProtection = new LinkedHashSet(); + public static Set worldsNoClaiming = new LinkedHashSet<>(); + public static Set worldsNoPowerLoss = new LinkedHashSet<>(); + public static Set worldsIgnorePvP = new LinkedHashSet<>(); + public static Set worldsNoWildernessProtection = new LinkedHashSet<>(); // faction- public static String vaultPrefix = "faction-%s"; diff --git a/src/main/java/com/massivecraft/factions/FLocation.java b/src/main/java/com/massivecraft/factions/FLocation.java index 790ddac8..cfc3c55a 100644 --- a/src/main/java/com/massivecraft/factions/FLocation.java +++ b/src/main/java/com/massivecraft/factions/FLocation.java @@ -192,7 +192,7 @@ public class FLocation implements Serializable { public Set getCircle(double radius) { double radiusSquared = radius * radius; - Set ret = new LinkedHashSet(); + Set ret = new LinkedHashSet<>(); if (radius <= 0) { return ret; } @@ -215,7 +215,7 @@ public class FLocation implements Serializable { } public static HashSet getArea(FLocation from, FLocation to) { - HashSet ret = new HashSet(); + HashSet ret = new HashSet<>(); for (long x : MiscUtil.range(from.getX(), to.getX())) { for (long z : MiscUtil.range(from.getZ(), to.getZ())) { diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index 17a879cb..fbeb8c31 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -299,7 +299,7 @@ public class P extends MPlugin { // Get a list of all players in the specified faction public Set getPlayersInFaction(String factionTag) { - Set players = new HashSet(); + Set players = new HashSet<>(); Faction faction = Factions.getInstance().getByTag(factionTag); if (faction != null) { for (FPlayer fplayer : faction.getFPlayers()) { @@ -311,7 +311,7 @@ public class P extends MPlugin { // Get a list of all online players in the specified faction public Set getOnlinePlayersInFaction(String factionTag) { - Set players = new HashSet(); + Set players = new HashSet<>(); Faction faction = Factions.getInstance().getByTag(factionTag); if (faction != null) { for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java index b422401b..833bde37 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java @@ -27,7 +27,7 @@ public class CmdAutoHelp extends MCommand

{ } MCommand pcmd = this.commandChain.get(this.commandChain.size() - 1); - ArrayList lines = new ArrayList(); + ArrayList lines = new ArrayList<>(); lines.addAll(pcmd.helpLong); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java index 956b6b4e..aa1639c2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java @@ -16,7 +16,7 @@ import java.util.Set; public class CmdConfig extends FCommand { - private static HashMap properFieldNames = new HashMap(); + private static HashMap properFieldNames = new HashMap<>(); public CmdConfig() { super(); @@ -41,8 +41,8 @@ public class CmdConfig extends FCommand { // that way, if the person using this command messes up the capitalization, we can fix that if (properFieldNames.isEmpty()) { Field[] fields = Conf.class.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName()); + for (Field field : fields) { + properFieldNames.put(field.getName().toLowerCase(), field.getName()); } } @@ -59,9 +59,9 @@ public class CmdConfig extends FCommand { String success; - String value = args.get(1); + StringBuilder value = new StringBuilder(args.get(1)); for (int i = 2; i < args.size(); i++) { - value += ' ' + args.get(i); + value.append(' ').append(args.get(i)); } try { @@ -69,7 +69,7 @@ public class CmdConfig extends FCommand { // boolean if (target.getType() == boolean.class) { - boolean targetValue = this.strAsBool(value); + boolean targetValue = this.strAsBool(value.toString()); target.setBoolean(null, targetValue); if (targetValue) { @@ -82,7 +82,7 @@ public class CmdConfig extends FCommand { // int else if (target.getType() == int.class) { try { - int intVal = Integer.parseInt(value); + int intVal = Integer.parseInt(value.toString()); target.setInt(null, intVal); success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + "."; } catch (NumberFormatException ex) { @@ -94,7 +94,7 @@ public class CmdConfig extends FCommand { // long else if (target.getType() == long.class) { try { - long longVal = Long.parseLong(value); + long longVal = Long.parseLong(value.toString()); target.setLong(null, longVal); success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + "."; } catch (NumberFormatException ex) { @@ -106,7 +106,7 @@ public class CmdConfig extends FCommand { // double else if (target.getType() == double.class) { try { - double doubleVal = Double.parseDouble(value); + double doubleVal = Double.parseDouble(value.toString()); target.setDouble(null, doubleVal); success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + "."; } catch (NumberFormatException ex) { @@ -118,7 +118,7 @@ public class CmdConfig extends FCommand { // float else if (target.getType() == float.class) { try { - float floatVal = Float.parseFloat(value); + float floatVal = Float.parseFloat(value.toString()); target.setFloat(null, floatVal); success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + "."; } catch (NumberFormatException ex) { @@ -129,7 +129,7 @@ public class CmdConfig extends FCommand { // String else if (target.getType() == String.class) { - target.set(null, value); + target.set(null, value.toString()); success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\"."; } @@ -137,16 +137,16 @@ public class CmdConfig extends FCommand { else if (target.getType() == ChatColor.class) { ChatColor newColor = null; try { - newColor = ChatColor.valueOf(value.toUpperCase()); + newColor = ChatColor.valueOf(value.toString().toUpperCase()); } catch (IllegalArgumentException ex) { } if (newColor == null) { - sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toUpperCase())); + sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase())); return; } target.set(null, newColor); - success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toUpperCase() + "\"."; + success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toString().toUpperCase() + "\"."; } // Set or other parameterized collection @@ -164,12 +164,12 @@ public class CmdConfig extends FCommand { else if (innerType == Material.class) { Material newMat = null; try { - newMat = Material.valueOf(value.toUpperCase()); + newMat = Material.valueOf(value.toString().toUpperCase()); } catch (IllegalArgumentException ex) { } if (newMat == null) { - sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toUpperCase())); + sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase())); return; } @@ -179,13 +179,13 @@ public class CmdConfig extends FCommand { if (matSet.contains(newMat)) { matSet.remove(newMat); target.set(null, matSet); - success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toUpperCase()); + success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase()); } // Material not present yet, add it else { matSet.add(newMat); target.set(null, matSet); - success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toUpperCase()); + success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase()); } } @@ -194,16 +194,16 @@ public class CmdConfig extends FCommand { @SuppressWarnings("unchecked") Set stringSet = (Set) target.get(null); // String already present, so remove it - if (stringSet.contains(value)) { - stringSet.remove(value); + if (stringSet.contains(value.toString())) { + stringSet.remove(value.toString()); target.set(null, stringSet); - success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value); + success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value.toString()); } // String not present yet, add it else { - stringSet.add(value); + stringSet.add(value.toString()); target.set(null, stringSet); - success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value); + success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value.toString()); } } @@ -223,7 +223,7 @@ public class CmdConfig extends FCommand { sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName)); return; } catch (IllegalAccessException ex) { - sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value)); + sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString())); return; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index bb72f340..429313ea 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -37,7 +37,7 @@ public class CmdDisband extends FCommand { return; } - boolean isMyFaction = fme == null ? false : faction == myFaction; + boolean isMyFaction = fme != null && faction == myFaction; if (isMyFaction) { if (!assertMinRole(Role.ADMIN)) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java index 89929136..e239b831 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java @@ -53,7 +53,7 @@ public class CmdHelp extends FCommand { ConfigurationSection help = P.p.getConfig().getConfigurationSection("help"); if (help == null) { help = P.p.getConfig().createSection("help"); // create new help section - List error = new ArrayList(); + List error = new ArrayList<>(); error.add("&cUpdate help messages in config.yml!"); error.add("&cSet use-old-help for legacy help messages"); help.set("'1'", error); // add default error messages @@ -76,10 +76,10 @@ public class CmdHelp extends FCommand { public ArrayList> helpPages; public void updateHelp() { - helpPages = new ArrayList>(); + helpPages = new ArrayList<>(); ArrayList pageLines; - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true)); @@ -92,7 +92,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true)); @@ -105,7 +105,7 @@ public class CmdHelp extends FCommand { helpPages.add(pageLines); if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) { - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(""); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString())); @@ -118,7 +118,7 @@ public class CmdHelp extends FCommand { helpPages.add(pageLines); } - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true)); @@ -133,7 +133,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString())); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true)); @@ -143,7 +143,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString())); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true)); pageLines.add(""); pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true)); @@ -155,7 +155,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString())); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString())); @@ -167,7 +167,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString())); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString())); @@ -179,7 +179,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString())); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true)); pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); @@ -192,7 +192,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true)); @@ -201,7 +201,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); helpPages.add(pageLines); - pageLines = new ArrayList(); + pageLines = new ArrayList<>(); pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java index 4dfc1af6..ee2ece1d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java @@ -116,7 +116,7 @@ public class CmdHome extends FCommand { public void run() { // Create a smoke effect if (Conf.homesTeleportCommandSmokeEffectEnabled) { - List smokeLocations = new ArrayList(); + List smokeLocations = new ArrayList<>(); smokeLocations.add(loc); smokeLocations.add(loc.add(0, 1, 0)); smokeLocations.add(CmdHome.this.myFaction.getHome()); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdList.java b/src/main/java/com/massivecraft/factions/cmd/CmdList.java index 82e93d50..f9604512 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdList.java @@ -91,7 +91,7 @@ public class CmdList extends FCommand { } }); - ArrayList lines = new ArrayList(); + ArrayList lines = new ArrayList<>(); factionList.add(0, Factions.getInstance().getNone()); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java index b9847c07..564de0d8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetMaxVaults.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.ChatColor; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 0c19939b..6a292f6d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -14,7 +14,7 @@ import java.util.List; public class CmdShow extends FCommand { - List defaults = new ArrayList(); + List defaults = new ArrayList<>(); public CmdShow() { this.aliases.add("show"); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java index 7caea961..f9d448b0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStatus.java @@ -25,7 +25,7 @@ public class CmdStatus extends FCommand { @Override public void perform() { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); for (FPlayer fp : myFaction.getFPlayers()) { String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java index 667b80f4..1040557b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTop.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTop.java @@ -140,7 +140,7 @@ public class CmdTop extends FCommand { msg(TL.COMMAND_TOP_INVALID, criteria); } - ArrayList lines = new ArrayList(); + ArrayList lines = new ArrayList<>(); final int pageheight = 9; int pagenumber = this.argAsInt(1, 1); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java index 66432014..24125fbc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdVault.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdVault.java @@ -8,8 +8,6 @@ import com.drtshock.playervaults.vaultmanagement.VaultViewInfo; import com.massivecraft.factions.Conf; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; diff --git a/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java b/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java index 73afb5e4..b3b9e474 100644 --- a/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java @@ -34,10 +34,7 @@ public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable @Override public void setCancelled(boolean c) { - if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) { - cancelled = false; // Don't let them cancel factions disbanding. - } else { - cancelled = c; - } + // Don't let them cancel factions disbanding. + cancelled = reason != PlayerLeaveReason.DISBAND && reason != PlayerLeaveReason.RESET && c; } } \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/integration/Econ.java b/src/main/java/com/massivecraft/factions/integration/Econ.java index 395c5966..951496d4 100644 --- a/src/main/java/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -207,7 +207,7 @@ public class Econ { } public static Set getFplayers(EconomyParticipator ep) { - Set fplayers = new HashSet(); + Set fplayers = new HashSet<>(); if (ep != null) { if (ep instanceof FPlayer) { @@ -221,7 +221,7 @@ public class Econ { } public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { - Set recipients = new HashSet(); + Set recipients = new HashSet<>(); recipients.addAll(getFplayers(invoker)); recipients.addAll(getFplayers(from)); recipients.addAll(getFplayers(to)); diff --git a/src/main/java/com/massivecraft/factions/integration/Essentials.java b/src/main/java/com/massivecraft/factions/integration/Essentials.java index 7b67d565..0c9310ed 100644 --- a/src/main/java/com/massivecraft/factions/integration/Essentials.java +++ b/src/main/java/com/massivecraft/factions/integration/Essentials.java @@ -38,9 +38,6 @@ public class Essentials { } public static boolean isVanished(Player player) { - if (essentials == null) { - return false; - } - return essentials.getUser(player).isVanished(); + return essentials != null && essentials.getUser(player).isVanished(); } } diff --git a/src/main/java/com/massivecraft/factions/integration/Worldguard.java b/src/main/java/com/massivecraft/factions/integration/Worldguard.java index ef9787c6..fcace7a3 100644 --- a/src/main/java/com/massivecraft/factions/integration/Worldguard.java +++ b/src/main/java/com/massivecraft/factions/integration/Worldguard.java @@ -82,10 +82,7 @@ public class Worldguard { World world = loc.getWorld(); Vector pt = toVector(loc); - if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { - return wg.canBuild(player, loc); - } - return false; + return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, loc); } // Check for Regions in chunk the chunk @@ -125,17 +122,13 @@ public class Worldguard { RegionManager regionManager = wg.getRegionManager(world); ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk); Map allregions = regionManager.getRegions(); - Collection allregionslist = new ArrayList(allregions.values()); + Collection allregionslist = new ArrayList<>(allregions.values()); List overlaps; boolean foundregions = false; try { overlaps = region.getIntersectingRegions(allregionslist); - if (overlaps == null || overlaps.isEmpty()) { - foundregions = false; - } else { - foundregions = true; - } + foundregions = overlaps != null && !overlaps.isEmpty(); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java index 40faaced..fa24e17c 100644 --- a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java @@ -144,7 +144,7 @@ public class EngineDynmap { // Thread Safe / Asynchronous: Yes public Map createHomes() { - Map ret = new HashMap(); + Map ret = new HashMap<>(); // Loop current factions for (Faction faction : Factions.getInstance().getAllFactions()) { @@ -176,7 +176,7 @@ public class EngineDynmap { // This method places out the faction home markers into the factions markerset. public void updateHomes(Map homes) { // Put all current faction markers in a map - Map markers = new HashMap(); + Map markers = new HashMap<>(); for (Marker marker : this.markerset.getMarkers()) { markers.put(marker.getMarkerID(), marker); } @@ -220,7 +220,7 @@ public class EngineDynmap { // Thread Safe: YES public Map>> createWorldFactionChunks() { // Create map "world name --> faction --> set of chunk coords" - Map>> worldFactionChunks = new HashMap>>(); + Map>> worldFactionChunks = new HashMap<>(); // Note: The board is the world. The board id is the world name. MemoryBoard board = (MemoryBoard) Board.getInstance(); @@ -231,13 +231,13 @@ public class EngineDynmap { Map> factionChunks = worldFactionChunks.get(world); if (factionChunks == null) { - factionChunks = new HashMap>(); + factionChunks = new HashMap<>(); worldFactionChunks.put(world, factionChunks); } Set factionTerritory = factionChunks.get(chunkOwner); if (factionTerritory == null) { - factionTerritory = new HashSet(); + factionTerritory = new HashSet<>(); factionChunks.put(chunkOwner, factionTerritory); } @@ -249,7 +249,7 @@ public class EngineDynmap { // Thread Safe: YES public Map createAreas(Map>> worldFactionChunks) { - Map ret = new HashMap(); + Map ret = new HashMap<>(); // For each world for (Entry>> entry : worldFactionChunks.entrySet()) { @@ -272,7 +272,7 @@ public class EngineDynmap { // Handle specific faction on specific world // "handle faction on world" public Map createAreas(String world, Faction faction, Set chunks) { - Map ret = new HashMap(); + Map ret = new HashMap<>(); // If the faction is visible ... if (!isVisible(faction, world)) { @@ -295,7 +295,7 @@ public class EngineDynmap { // Loop through chunks: set flags on chunk map TileFlags allChunkFlags = new TileFlags(); - LinkedList allChunks = new LinkedList(); + LinkedList allChunks = new LinkedList<>(); for (FLocation chunk : chunks) { allChunkFlags.setFlag((int) chunk.getX(), (int) chunk.getZ(), true); // Set flag for chunk allChunks.addLast(chunk); @@ -316,7 +316,7 @@ public class EngineDynmap { // If we need to start shape, and this block is not part of one yet if (ourChunkFlags == null && allChunkFlags.getFlag(chunkX, chunkZ)) { ourChunkFlags = new TileFlags(); // Create map for shape - ourChunks = new LinkedList(); + ourChunks = new LinkedList<>(); floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape ourChunks.add(chunk); // Add it to our chunk list minimumX = chunkX; @@ -335,7 +335,7 @@ public class EngineDynmap { // Else, keep it in the list for the next polygon else { if (newChunks == null) { - newChunks = new LinkedList(); + newChunks = new LinkedList<>(); } newChunks.add(chunk); } @@ -354,7 +354,7 @@ public class EngineDynmap { int currentX = minimumX; int currentZ = minimumZ; Direction direction = Direction.XPLUS; - ArrayList linelist = new ArrayList(); + ArrayList linelist = new ArrayList<>(); linelist.add(new int[]{initialX, initialZ}); // Add start point while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) { switch (direction) { @@ -452,7 +452,7 @@ public class EngineDynmap { // Thread Safe: NO public void updateAreas(Map areas) { // Map Current - Map markers = new HashMap(); + Map markers = new HashMap<>(); for (AreaMarker marker : this.markerset.getAreaMarkers()) { markers.put(marker.getMarkerID(), marker); } @@ -510,7 +510,7 @@ public class EngineDynmap { return null; } - Set ret = new HashSet(); + Set ret = new HashSet<>(); for (FPlayer fplayer : faction.getFPlayers()) { // NOTE: We add both UUID and name. This might be a good idea for future proofing. @@ -527,7 +527,7 @@ public class EngineDynmap { return null; } - Map> ret = new HashMap>(); + Map> ret = new HashMap<>(); for (Faction faction : Factions.getInstance().getAllFactions()) { String playersetId = createPlayersetId(faction); @@ -654,14 +654,14 @@ public class EngineDynmap { } public static String getHtmlPlayerString(Collection playersOfficersList) { - String ret = ""; + StringBuilder ret = new StringBuilder(); for (FPlayer fplayer : playersOfficersList) { if (ret.length() > 0) { - ret += ", "; + ret.append(", "); } - ret += getHtmlPlayerName(fplayer); + ret.append(getHtmlPlayerName(fplayer)); } - return ret; + return ret.toString(); } public static String getHtmlPlayerName(FPlayer fplayer) { @@ -707,11 +707,7 @@ public class EngineDynmap { return false; } - if (hidden.contains(factionId) || hidden.contains(factionName) || hidden.contains("world:" + world)) { - return false; - } - - return true; + return !hidden.contains(factionId) && !hidden.contains(factionName) && !hidden.contains("world:" + world); } // Thread Safe / Asynchronous: Yes @@ -750,7 +746,7 @@ public class EngineDynmap { // Find all contiguous blocks, set in target and clear in source private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) { int cnt = 0; - ArrayDeque stack = new ArrayDeque(); + ArrayDeque stack = new ArrayDeque<>(); stack.push(new int[]{x, y}); while (!stack.isEmpty()) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index 8196d9c5..0bd8ba93 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -91,7 +91,6 @@ public class FactionsBlockListener implements Listener { // if potentially pushing into air/water/lava in another territory, we need to check it out if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) { event.setCancelled(true); - return; } /* @@ -126,7 +125,6 @@ public class FactionsBlockListener implements Listener { if (!canPistonMoveBlock(pistonFaction, targetLoc)) { event.setCancelled(true); - return; } } @@ -161,32 +159,19 @@ public class FactionsBlockListener implements Listener { } if (otherFaction.isWilderness()) { - if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) { - return true; - } + return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()); - return false; } else if (otherFaction.isSafeZone()) { - if (!Conf.safeZoneDenyBuild) { - return true; - } + return !Conf.safeZoneDenyBuild; - return false; } else if (otherFaction.isWarZone()) { - if (!Conf.warZoneDenyBuild) { - return true; - } + return !Conf.warZoneDenyBuild; - return false; } Relation rel = pistonFaction.getRelationTo(otherFaction); - if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) { - return false; - } - - return true; + return !rel.confDenyBuild(otherFaction.hasPlayersOnline()); } public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index 4fa5d5b5..a1c4a4b9 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -177,7 +177,7 @@ public class FactionsEntityListener implements Listener { Block center = loc.getBlock(); if (center.isLiquid()) { // a single surrounding block in all 6 directions is broken if the material is weak enough - List targets = new ArrayList(); + List targets = new ArrayList<>(); targets.add(center.getRelative(0, 0, 1)); targets.add(center.getRelative(0, 0, -1)); targets.add(center.getRelative(0, 1, 0)); @@ -202,10 +202,9 @@ public class FactionsEntityListener implements Listener { if (!this.canDamagerHurtDamagee(sub, false)) { event.setCancelled(true); } - sub = null; } - private static final Set badPotionEffects = new LinkedHashSet(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER)); + private static final Set badPotionEffects = new LinkedHashSet<>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER)); @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPotionSplashEvent(PotionSplashEvent event) { @@ -236,14 +235,11 @@ public class FactionsEntityListener implements Listener { } // scan through affected entities to make sure they're all valid targets - Iterator iter = event.getAffectedEntities().iterator(); - while (iter.hasNext()) { - LivingEntity target = iter.next(); + for (LivingEntity target : event.getAffectedEntities()) { EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0); if (!this.canDamagerHurtDamagee(sub, true)) { event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works } - sub = null; } } @@ -251,10 +247,7 @@ public class FactionsEntityListener implements Listener { if (!(damagee instanceof Player)) { return false; } - if (Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone()) { - return true; - } - return false; + return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone(); } public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 4609d640..01a7f3fa 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -135,7 +135,7 @@ public class FactionsPlayerListener implements Listener { } // Holds the next time a player can have a map shown. - private HashMap showTimes = new HashMap(); + private HashMap showTimes = new HashMap<>(); @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { @@ -270,7 +270,7 @@ public class FactionsPlayerListener implements Listener { // for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory - private Map interactSpammers = new HashMap(); + private Map interactSpammers = new HashMap<>(); private static class InteractAttemptSpam { private int attempts = 0; @@ -470,7 +470,6 @@ public class FactionsPlayerListener implements Listener { if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { event.setCancelled(true); - return; } } @@ -481,7 +480,6 @@ public class FactionsPlayerListener implements Listener { if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { event.setCancelled(true); - return; } } diff --git a/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java b/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java index 335b0bb5..dd4f6342 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/BufferedObjective.java @@ -18,7 +18,7 @@ public class BufferedObjective { private final String baseName; private Objective current; - private List currentTeams = new ArrayList(); + private List currentTeams = new ArrayList<>(); private String title; private DisplaySlot displaySlot; @@ -26,7 +26,7 @@ public class BufferedObjective { private int teamPtr; private boolean requiresUpdate = false; - private final Map contents = new HashMap(); + private final Map contents = new HashMap<>(); static { // Check for long line support. @@ -113,7 +113,7 @@ public class BufferedObjective { Objective buffer = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy"); buffer.setDisplayName(title); - List bufferTeams = new ArrayList(); + List bufferTeams = new ArrayList<>(); for (Map.Entry entry : contents.entrySet()) { if (entry.getValue().length() > 16) { diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java b/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java index 86bcd888..edeafe47 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java @@ -13,7 +13,7 @@ import java.util.HashMap; import java.util.Map; public class FScoreboard { - private static final Map fscoreboards = new HashMap(); + private static final Map fscoreboards = new HashMap<>(); private final Scoreboard scoreboard; private final FPlayer fplayer; diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java b/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java index 2d273174..120af283 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FTeamWrapper.java @@ -10,15 +10,15 @@ import org.bukkit.scoreboard.Team; import java.util.*; public class FTeamWrapper { - private static final Map wrappers = new HashMap(); - private static final List tracking = new ArrayList(); + private static final Map wrappers = new HashMap<>(); + private static final List tracking = new ArrayList<>(); private static int factionTeamPtr; - private static final Set updating = new HashSet(); + private static final Set updating = new HashSet<>(); - private final Map teams = new HashMap(); + private final Map teams = new HashMap<>(); private final String teamName; private final Faction faction; - private final Set members = new HashSet(); + private final Set members = new HashSet<>(); public static void applyUpdatesLater(final Faction faction) { if (!FScoreboard.isSupportedByServer()) { @@ -194,7 +194,7 @@ public class FTeamWrapper { } private Set getPlayers() { - return new HashSet(this.members); + return new HashSet<>(this.members); } private void unregister() { diff --git a/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java b/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java index af93921b..55e16938 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java @@ -29,7 +29,7 @@ public class FDefaultSidebar extends FSidebarProvider { List lines = P.p.getConfig().getStringList(list); if (lines == null || lines.isEmpty()) { - return new ArrayList(); + return new ArrayList<>(); } ListIterator it = lines.listIterator(); diff --git a/src/main/java/com/massivecraft/factions/struct/ChatMode.java b/src/main/java/com/massivecraft/factions/struct/ChatMode.java index 020dfb27..b83f3a20 100644 --- a/src/main/java/com/massivecraft/factions/struct/ChatMode.java +++ b/src/main/java/com/massivecraft/factions/struct/ChatMode.java @@ -11,7 +11,7 @@ public enum ChatMode { public final int value; public final TL nicename; - private ChatMode(final int value, final TL nicename) { + ChatMode(final int value, final TL nicename) { this.value = value; this.nicename = nicename; } diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index 2dd92c4e..29704273 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -15,7 +15,7 @@ public enum Relation { public final int value; public final String nicename; - private Relation(final int value, final String nicename) { + Relation(final int value, final String nicename) { this.value = value; this.nicename = nicename; } diff --git a/src/main/java/com/massivecraft/factions/struct/Role.java b/src/main/java/com/massivecraft/factions/struct/Role.java index cf81e8a2..1cdd505a 100644 --- a/src/main/java/com/massivecraft/factions/struct/Role.java +++ b/src/main/java/com/massivecraft/factions/struct/Role.java @@ -12,7 +12,7 @@ public enum Role { public final String nicename; public final TL translation; - private Role(final int value, final TL translation) { + Role(final int value, final TL translation) { this.value = value; this.nicename = translation.toString(); this.translation = translation; diff --git a/src/main/java/com/massivecraft/factions/util/AsciiCompass.java b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java index 7d52b360..348b0107 100644 --- a/src/main/java/com/massivecraft/factions/util/AsciiCompass.java +++ b/src/main/java/com/massivecraft/factions/util/AsciiCompass.java @@ -20,7 +20,7 @@ public class AsciiCompass { public final char asciiChar; - private Point(final char asciiChar) { + Point(final char asciiChar) { this.asciiChar = asciiChar; } @@ -80,7 +80,7 @@ public class AsciiCompass { } public static ArrayList getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); String row; row = ""; diff --git a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java index 6c975989..c1e918d8 100644 --- a/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/EnumTypeAdapter.java @@ -15,8 +15,8 @@ import java.util.Map; public final class EnumTypeAdapter> extends TypeAdapter { - private final Map nameToConstant = new HashMap(); - private final Map constantToName = new HashMap(); + private final Map nameToConstant = new HashMap<>(); + private final Map constantToName = new HashMap<>(); public EnumTypeAdapter(Class classOfT) { try { diff --git a/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java b/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java index eb9936a4..f74e7f19 100644 --- a/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java +++ b/src/main/java/com/massivecraft/factions/util/MapFLocToStringSetTypeAdapter.java @@ -24,7 +24,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer> locationMap = new ConcurrentHashMap>(); + Map> locationMap = new ConcurrentHashMap<>(); Set nameSet; Iterator iter; String worldName; @@ -38,7 +38,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer(); + nameSet = new HashSet<>(); iter = entry2.getValue().getAsJsonArray().iterator(); while (iter.hasNext()) { nameSet.add(iter.next().getAsString()); diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java index 03ccc951..7a300c4f 100644 --- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java +++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java @@ -45,24 +45,24 @@ public class MiscUtil { } /// TODO create tag whitelist!! - public static HashSet substanceChars = new HashSet(Arrays.asList(new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"})); + public static HashSet substanceChars = new HashSet<>(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")); public static String getComparisonString(String str) { - String ret = ""; + StringBuilder ret = new StringBuilder(); str = ChatColor.stripColor(str); str = str.toLowerCase(); for (char c : str.toCharArray()) { if (substanceChars.contains(String.valueOf(c))) { - ret += c; + ret.append(c); } } - return ret.toLowerCase(); + return ret.toString().toLowerCase(); } public static ArrayList validateTag(String str) { - ArrayList errors = new ArrayList(); + ArrayList errors = new ArrayList<>(); if (getComparisonString(str).length() < Conf.factionTagLengthMin) { errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin)); @@ -82,9 +82,9 @@ public class MiscUtil { } public static Iterable rankOrder(Iterable players) { - List admins = new ArrayList(); - List moderators = new ArrayList(); - List normal = new ArrayList(); + List admins = new ArrayList<>(); + List moderators = new ArrayList<>(); + List normal = new ArrayList<>(); for (FPlayer player : players) { switch (player.getRole()) { @@ -102,7 +102,7 @@ public class MiscUtil { } } - List ret = new ArrayList(); + List ret = new ArrayList<>(); ret.addAll(admins); ret.addAll(moderators); ret.addAll(normal); diff --git a/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java index 517fa07b..27cb9cba 100644 --- a/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java +++ b/src/main/java/com/massivecraft/factions/util/VisualizeUtil.java @@ -9,7 +9,7 @@ import java.util.Map.Entry; public class VisualizeUtil { - protected static Map> playerLocations = new HashMap>(); + protected static Map> playerLocations = new HashMap<>(); public static Set getPlayerLocations(Player player) { return getPlayerLocations(player.getUniqueId()); @@ -18,7 +18,7 @@ public class VisualizeUtil { public static Set getPlayerLocations(UUID uuid) { Set ret = playerLocations.get(uuid); if (ret == null) { - ret = new HashSet(); + ret = new HashSet<>(); playerLocations.put(uuid, ret); } return ret; diff --git a/src/main/java/com/massivecraft/factions/zcore/MCommand.java b/src/main/java/com/massivecraft/factions/zcore/MCommand.java index 527cb750..6e5d50ec 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MCommand.java +++ b/src/main/java/com/massivecraft/factions/zcore/MCommand.java @@ -73,7 +73,7 @@ public abstract class MCommand { public Player me; // Will only be set when the sender is a player public boolean senderIsConsole; public List args; // Will contain the arguments, or and empty list if there are none. - public List> commandChain = new ArrayList>(); // The command chain used to execute this command + public List> commandChain = new ArrayList<>(); // The command chain used to execute this command public MCommand(T p) { this.p = p; @@ -82,14 +82,14 @@ public abstract class MCommand { this.allowNoSlashAccess = false; - this.subCommands = new ArrayList>(); - this.aliases = new ArrayList(); + this.subCommands = new ArrayList<>(); + this.aliases = new ArrayList<>(); - this.requiredArgs = new ArrayList(); - this.optionalArgs = new LinkedHashMap(); + this.requiredArgs = new ArrayList<>(); + this.optionalArgs = new LinkedHashMap<>(); this.helpShort = null; - this.helpLong = new ArrayList(); + this.helpLong = new ArrayList<>(); this.visibility = CommandVisibility.VISIBLE; } @@ -210,7 +210,7 @@ public abstract class MCommand { ret.append(TextUtil.implode(this.aliases, ",")); - List args = new ArrayList(); + List args = new ArrayList<>(); for (String requiredArg : this.requiredArgs) { args.add("<" + requiredArg + ">"); @@ -280,7 +280,7 @@ public abstract class MCommand { } public List getToolTips(FPlayer player) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); for (String s : p.getConfig().getStringList("tooltips.show")) { lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); } @@ -288,7 +288,7 @@ public abstract class MCommand { } public List getToolTips(Faction faction) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); for (String s : p.getConfig().getStringList("tooltips.list")) { lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); } diff --git a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java index 8a0e7a32..9498df10 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java @@ -52,17 +52,17 @@ public abstract class MPlugin extends JavaPlugin { private MPluginSecretPlayerListener mPluginSecretPlayerListener; // Our stored base commands - private List> baseCommands = new ArrayList>(); + private List> baseCommands = new ArrayList<>(); public List> getBaseCommands() { return this.baseCommands; } // holds f stuck start times - private Map timers = new HashMap(); + private Map timers = new HashMap<>(); //holds f stuck taskids - public Map stuckMap = new HashMap(); + public Map stuckMap = new HashMap<>(); // -------------------------------------------- // // ENABLE @@ -214,7 +214,7 @@ public abstract class MPlugin extends JavaPlugin { // These are not supposed to be used directly. // They are loaded and used through the TextUtil instance for the plugin. - public Map rawTags = new LinkedHashMap(); + public Map rawTags = new LinkedHashMap<>(); public void addRawTags() { this.rawTags.put("l", ""); // logo @@ -277,7 +277,7 @@ public abstract class MPlugin extends JavaPlugin { } if (commandString.startsWith(alias + " ") || commandString.equals(alias)) { - final List args = new ArrayList(Arrays.asList(commandString.split("\\s+"))); + final List args = new ArrayList<>(Arrays.asList(commandString.split("\\s+"))); args.remove(0); if (testOnly) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java index 389ed3e6..2c91d245 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryBoard.java @@ -104,10 +104,8 @@ public abstract class MemoryBoard extends Board { } public Set getAllClaims(String factionId) { - Set locs = new HashSet(); - Iterator> iter = flocationIds.entrySet().iterator(); - while (iter.hasNext()) { - Entry entry = iter.next(); + Set locs = new HashSet<>(); + for (Entry entry : flocationIds.entrySet()) { if (entry.getValue().equals(factionId)) { locs.add(entry.getKey()); } @@ -227,9 +225,7 @@ public abstract class MemoryBoard extends Board { public int getFactionCoordCountInWorld(Faction faction, String worldName) { String factionId = faction.getId(); int ret = 0; - Iterator> iter = flocationIds.entrySet().iterator(); - while (iter.hasNext()) { - Entry entry = iter.next(); + for (Entry entry : flocationIds.entrySet()) { if (entry.getValue().equals(factionId) && entry.getKey().getWorldName().equals(worldName)) { ret += 1; } @@ -246,7 +242,7 @@ public abstract class MemoryBoard extends Board { * of decreasing z */ public ArrayList getMap(Faction faction, FLocation flocation, double inDegrees) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); Faction factionLoc = getFactionAt(flocation); ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction))); @@ -260,26 +256,26 @@ public abstract class MemoryBoard extends Board { height--; } - Map fList = new HashMap(); + Map fList = new HashMap<>(); int chrIdx = 0; // For each row for (int dz = 0; dz < height; dz++) { // Draw and add that row - String row = ""; + StringBuilder row = new StringBuilder(); for (int dx = 0; dx < width; dx++) { if (dx == halfWidth && dz == halfHeight) { - row += ChatColor.AQUA + "+"; + row.append(ChatColor.AQUA + "+"); } else { FLocation flocationHere = topLeft.getRelative(dx, dz); Faction factionHere = getFactionAt(flocationHere); Relation relation = faction.getRelationTo(factionHere); if (factionHere.isWilderness()) { - row += ChatColor.GRAY + "-"; + row.append(ChatColor.GRAY + "-"); } else if (factionHere.isSafeZone()) { - row += Conf.colorPeaceful + "+"; + row.append(Conf.colorPeaceful).append("+"); } else if (factionHere.isWarZone()) { - row += ChatColor.DARK_RED + "+"; + row.append(ChatColor.DARK_RED + "+"); } else if (factionHere == faction || factionHere == factionLoc || relation.isAtLeast(Relation.ALLY) || @@ -289,13 +285,13 @@ public abstract class MemoryBoard extends Board { fList.put(factionHere.getTag(), Conf.mapKeyChrs[Math.min(chrIdx++, Conf.mapKeyChrs.length - 1)]); } char tag = fList.get(factionHere.getTag()); - row += factionHere.getColorTo(faction) + "" + tag; + row.append(factionHere.getColorTo(faction)).append("").append(tag); } else { - row += ChatColor.GRAY + "-"; + row.append(ChatColor.GRAY + "-"); } } } - ret.add(row); + ret.add(row.toString()); } // Get the compass @@ -308,11 +304,11 @@ public abstract class MemoryBoard extends Board { // Add the faction key if (Conf.showMapFactionKey) { - String fRow = ""; + StringBuilder fRow = new StringBuilder(); for (String key : fList.keySet()) { - fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key); + fRow.append(String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key)); } - ret.add(fRow); + ret.add(fRow.toString()); } return ret; diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 9a0900c3..baaeee2c 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -819,7 +819,7 @@ public abstract class MemoryFPlayer implements FPlayer { } // announce success - Set informTheseFPlayers = new HashSet(); + Set informTheseFPlayers = new HashSet<>(); informTheseFPlayers.add(this); informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true)); for (FPlayer fp : informTheseFPlayers) { @@ -836,10 +836,7 @@ public abstract class MemoryFPlayer implements FPlayer { } public boolean shouldBeSaved() { - if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) { - return false; - } - return true; + return this.hasFaction() || (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(Conf.powerPlayerStarting)); } public void msg(String str, Object... args) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayers.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayers.java index 196c473c..708baf32 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayers.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayers.java @@ -12,7 +12,7 @@ import java.util.*; import java.util.concurrent.ConcurrentSkipListMap; public abstract class MemoryFPlayers extends FPlayers { - public Map fPlayers = new ConcurrentSkipListMap(String.CASE_INSENSITIVE_ORDER); + public Map fPlayers = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER); public void clean() { for (FPlayer fplayer : this.fPlayers.values()) { @@ -24,7 +24,7 @@ public abstract class MemoryFPlayers extends FPlayers { } public Collection getOnlinePlayers() { - Set entities = new HashSet(); + Set entities = new HashSet<>(); for (Player player : Bukkit.getServer().getOnlinePlayers()) { entities.add(this.getByPlayer(player)); } @@ -38,7 +38,7 @@ public abstract class MemoryFPlayers extends FPlayers { @Override public List getAllFPlayers() { - return new ArrayList(fPlayers.values()); + return new ArrayList<>(fPlayers.values()); } @Override diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 3f9ca6e9..8613ee37 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -35,13 +35,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { protected transient long lastPlayerLoggedOffTime; protected double money; protected double powerBoost; - protected Map relationWish = new HashMap(); - protected Map> claimOwnership = new ConcurrentHashMap>(); - protected transient Set fplayers = new HashSet(); - protected Set invites = new HashSet(); - protected HashMap> announcements = new HashMap>(); - protected ConcurrentHashMap warps = new ConcurrentHashMap(); - protected ConcurrentHashMap warpPasswords = new ConcurrentHashMap(); + protected Map relationWish = new HashMap<>(); + protected Map> claimOwnership = new ConcurrentHashMap<>(); + protected transient Set fplayers = new HashSet<>(); + protected Set invites = new HashSet<>(); + protected HashMap> announcements = new HashMap<>(); + protected ConcurrentHashMap warps = new ConcurrentHashMap<>(); + protected ConcurrentHashMap warpPasswords = new ConcurrentHashMap<>(); private long lastDeath; protected int maxVaults; @@ -284,11 +284,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { public boolean isPowerFrozen() { int freezeSeconds = P.p.getConfig().getInt("hcf.powerfreeze", 0); - if (freezeSeconds == 0) { - return false; - } + return freezeSeconds != 0 && System.currentTimeMillis() - lastDeath < freezeSeconds * 1000; - return System.currentTimeMillis() - lastDeath < freezeSeconds * 1000; } public void setLastDeath(long time) { @@ -354,7 +351,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { powerBoost = old.powerBoost; relationWish = old.relationWish; claimOwnership = old.claimOwnership; - fplayers = new HashSet(); + fplayers = new HashSet<>(); invites = old.invites; announcements = old.announcements; } @@ -540,11 +537,11 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { public Set getFPlayers() { // return a shallow copy of the FPlayer list, to prevent tampering and // concurrency issues - return new HashSet(fplayers); + return new HashSet<>(fplayers); } public Set getFPlayersWhereOnline(boolean online) { - Set ret = new HashSet(); + Set ret = new HashSet<>(); if (!this.isNormal()) { return ret; } @@ -572,7 +569,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { } public ArrayList getFPlayersWhereRole(Role role) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); if (!this.isNormal()) { return ret; } @@ -587,7 +584,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { } public ArrayList getOnlinePlayers() { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); if (this.isPlayerFreeType()) { return ret; } @@ -763,16 +760,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return false; } Set ownerData = claimOwnership.get(loc); - if (ownerData == null) { - return false; - } - return ownerData.contains(player.getId()); + return ownerData != null && ownerData.contains(player.getId()); } public void setPlayerAsOwner(FPlayer player, FLocation loc) { Set ownerData = claimOwnership.get(loc); if (ownerData == null) { - ownerData = new HashSet(); + ownerData = new HashSet<>(); } ownerData.add(player.getId()); claimOwnership.put(loc, ownerData); @@ -797,18 +791,17 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return ""; } - String ownerList = ""; + StringBuilder ownerList = new StringBuilder(); - Iterator iter = ownerData.iterator(); - while (iter.hasNext()) { - if (!ownerList.isEmpty()) { - ownerList += ", "; + for (String anOwnerData : ownerData) { + if (ownerList.length() > 0) { + ownerList.append(", "); } - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(iter.next())); + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData)); //TODO:TL - ownerList += offlinePlayer != null ? offlinePlayer.getName() : "null player"; + ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : "null player"); } - return ownerList; + return ownerList.toString(); } public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java index f9f884c1..76d1caee 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java @@ -13,7 +13,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public abstract class MemoryFactions extends Factions { - public final Map factions = new ConcurrentHashMap(); + public final Map factions = new ConcurrentHashMap<>(); public int nextId = 1; public void load() { @@ -134,7 +134,7 @@ public abstract class MemoryFactions extends Factions { } public Set getFactionTags() { - Set tags = new HashSet(); + Set tags = new HashSet<>(); for (Faction faction : factions.values()) { tags.add(faction.getTag()); } @@ -149,7 +149,7 @@ public abstract class MemoryFactions extends Factions { @Override public ArrayList getAllFactions() { - return new ArrayList(factions.values()); + return new ArrayList<>(factions.values()); } @Override diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONBoard.java b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONBoard.java index d81afb45..53b40aad 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONBoard.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONBoard.java @@ -23,7 +23,7 @@ public class JSONBoard extends MemoryBoard { // -------------------------------------------- // public Map> dumpAsSaveFormat() { - Map> worldCoordIds = new HashMap>(); + Map> worldCoordIds = new HashMap<>(); String worldName, coords; String id; diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayer.java index 71d451d2..ade236a0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayer.java @@ -20,9 +20,6 @@ public class JSONFPlayer extends MemoryFPlayer { } public boolean shouldBeSaved() { - if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) { - return false; - } - return true; + return this.hasFaction() || (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(Conf.powerPlayerStarting)); } } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayers.java b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayers.java index c5a2ec6c..302c9294 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayers.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFPlayers.java @@ -55,7 +55,7 @@ public class JSONFPlayers extends MemoryFPlayers { } public void forceSave(boolean sync) { - final Map entitiesThatShouldBeSaved = new HashMap(); + final Map entitiesThatShouldBeSaved = new HashMap<>(); for (FPlayer entity : this.fPlayers.values()) { if (((MemoryFPlayer) entity).shouldBeSaved()) { entitiesThatShouldBeSaved.put(entity.getId(), (JSONFPlayer) entity); @@ -81,7 +81,7 @@ public class JSONFPlayers extends MemoryFPlayers { private Map loadCore() { if (!this.file.exists()) { - return new HashMap(); + return new HashMap<>(); } String content = DiscUtil.readCatch(this.file); @@ -91,8 +91,8 @@ public class JSONFPlayers extends MemoryFPlayers { Map data = this.gson.fromJson(content, new TypeToken>() { }.getType()); - Set list = new HashSet(); - Set invalidList = new HashSet(); + Set list = new HashSet<>(); + Set invalidList = new HashSet<>(); for (Entry entry : data.entrySet()) { String key = entry.getKey(); entry.getValue().setId(key); @@ -117,12 +117,12 @@ public class JSONFPlayers extends MemoryFPlayers { } catch (IOException e) { e.printStackTrace(); } - saveCore(file, (Map) data, true); + saveCore(file, data, true); Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath()); // Start fetching those UUIDs Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + list.size() + " old player names to UUID. This may take a while."); - UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list)); + UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list)); try { Map response = fetcher.call(); for (String s : list) { @@ -161,11 +161,11 @@ public class JSONFPlayers extends MemoryFPlayers { Bukkit.getLogger().log(Level.INFO, "While converting we found names that either don't have a UUID or aren't players and removed them from storage."); Bukkit.getLogger().log(Level.INFO, "The following names were detected as being invalid: " + StringUtils.join(invalidList, ", ")); } - saveCore(this.file, (Map) data, true); // Update the + saveCore(this.file, data, true); // Update the // flatfile Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID."); } - return (Map) data; + return data; } private boolean doesKeyNeedMigration(String key) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java index ecd33c4f..a157e485 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java @@ -49,7 +49,7 @@ public class JSONFactions extends MemoryFactions { } public void forceSave(boolean sync) { - final Map entitiesThatShouldBeSaved = new HashMap(); + final Map entitiesThatShouldBeSaved = new HashMap<>(); for (Faction entity : this.factions.values()) { entitiesThatShouldBeSaved.put(entity.getId(), (JSONFaction) entity); } @@ -74,7 +74,7 @@ public class JSONFactions extends MemoryFactions { private Map loadCore() { if (!this.file.exists()) { - return new HashMap(); + return new HashMap<>(); } String content = DiscUtil.readCatch(this.file); @@ -112,7 +112,7 @@ public class JSONFactions extends MemoryFactions { } catch (IOException e) { e.printStackTrace(); } - saveCore(file, (Map) data, true); + saveCore(file, data, true); Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath()); Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + needsUpdate + " old player names to UUID. This may take a while."); @@ -128,7 +128,7 @@ public class JSONFactions extends MemoryFactions { Set list = whichKeysNeedMigration(set); if (list.size() > 0) { - UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list)); + UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list)); try { Map response = fetcher.call(); for (String value : response.keySet()) { @@ -155,7 +155,7 @@ public class JSONFactions extends MemoryFactions { Set list = whichKeysNeedMigration(invites); if (list.size() > 0) { - UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list)); + UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list)); try { Map response = fetcher.call(); for (String value : response.keySet()) { @@ -172,14 +172,14 @@ public class JSONFactions extends MemoryFactions { } } - saveCore(this.file, (Map) data, true); // Update the flatfile + saveCore(this.file, data, true); // Update the flatfile Bukkit.getLogger().log(Level.INFO, "Done converting factions.json to UUID."); } return data; } private Set whichKeysNeedMigration(Set keys) { - HashSet list = new HashSet(); + HashSet list = new HashSet<>(); for (String value : keys) { if (!value.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")) { // Not a valid UUID.. @@ -236,8 +236,7 @@ public class JSONFactions extends MemoryFactions { @Override public Faction generateFactionObject(String id) { - Faction faction = new JSONFaction(id); - return faction; + return new JSONFaction(id); } @Override diff --git a/src/main/java/com/massivecraft/factions/zcore/util/DiscUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/DiscUtil.java index a4c44e7d..f9aeb648 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/DiscUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/DiscUtil.java @@ -56,7 +56,7 @@ public class DiscUtil { // CATCH // -------------------------------------------- // - private static HashMap locks = new HashMap(); + private static HashMap locks = new HashMap<>(); public static boolean writeCatch(final File file, final String content, boolean sync) { String name = file.getName(); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java index e3b6830d..7acfc1db 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/PermUtil.java @@ -12,7 +12,7 @@ import java.util.Map.Entry; public class PermUtil { - public Map permissionDescriptions = new HashMap(); + public Map permissionDescriptions = new HashMap<>(); protected MPlugin p; diff --git a/src/main/java/com/massivecraft/factions/zcore/util/Persist.java b/src/main/java/com/massivecraft/factions/zcore/util/Persist.java index 839e842f..9513b2d8 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/Persist.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/Persist.java @@ -120,8 +120,7 @@ public class Persist { } try { - T instance = p.gson.fromJson(content, clazz); - return instance; + return p.gson.fromJson(content, clazz); } catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely p.log(Level.WARNING, ex.getMessage()); } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java index 0a9260e9..a05c9244 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java @@ -236,7 +236,7 @@ public enum TagReplacer { * @return a list of all the variables with this type */ protected static List getByType(TagType type) { - List tagReplacers = new ArrayList(); + List tagReplacers = new ArrayList<>(); for (TagReplacer tagReplacer : TagReplacer.values()) { if (type == TagType.FANCY) { if (tagReplacer.type == TagType.FANCY) { diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java index b89165d3..45d7c13e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TagUtil.java @@ -124,7 +124,7 @@ public class TagUtil { * @return list of fancy messages to send */ protected static List getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) { - List fancyMessages = new ArrayList(); + List fancyMessages = new ArrayList<>(); boolean minimal = P.p.getConfig().getBoolean("minimal-show", false); switch (type) { @@ -212,7 +212,7 @@ public class TagUtil { * @return list of tooltips for a fancy message */ private static List tipFaction(Faction faction) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); for (String line : P.p.getConfig().getStringList("tooltips.list")) { lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(faction, line))); } @@ -227,7 +227,7 @@ public class TagUtil { * @return list of tooltips for a fancy message */ private static List tipPlayer(FPlayer fplayer) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); for (String line : P.p.getConfig().getStringList("tooltips.show")) { lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(fplayer, line))); } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java index 76c32802..7c053913 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java @@ -13,7 +13,7 @@ public class TextUtil { public Map tags; public TextUtil() { - this.tags = new HashMap(); + this.tags = new HashMap<>(); } // -------------------------------------------- // @@ -187,7 +187,7 @@ public class TextUtil { } public ArrayList getPage(List lines, int pageHumanBased, String title) { - ArrayList ret = new ArrayList(); + ArrayList ret = new ArrayList<>(); int pageZeroBased = pageHumanBased - 1; int pageheight = 9; int pagecount = (lines.size() / pageheight) + 1; diff --git a/src/main/java/com/massivecraft/factions/zcore/util/UUIDFetcher.java b/src/main/java/com/massivecraft/factions/zcore/util/UUIDFetcher.java index e41da56c..6970128b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/UUIDFetcher.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/UUIDFetcher.java @@ -34,7 +34,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(); @@ -95,6 +95,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); } }