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