Java 7 and make intellij happy

This commit is contained in:
Trent Hensler 2017-12-19 02:18:13 -08:00
parent ce132ed033
commit 3b644cd6c3
53 changed files with 222 additions and 285 deletions

View File

@ -28,8 +28,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version> <version>3.5.1</version>
<configuration> <configuration>
<source>1.6</source> <source>1.7</source>
<target>1.6</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -10,7 +10,7 @@ import java.util.*;
public class Conf { public class Conf {
public static List<String> baseCommandAliases = new ArrayList<String>(); public static List<String> baseCommandAliases = new ArrayList<>();
public static boolean allowNoSlashCommand = true; public static boolean allowNoSlashCommand = true;
// Colors // Colors
@ -145,14 +145,14 @@ public class Conf {
public static int actionDeniedPainAmount = 1; public static int actionDeniedPainAmount = 1;
// commands which will be prevented if the player is a member of a permanent faction // commands which will be prevented if the player is a member of a permanent faction
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<String>(); public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<>();
// commands which will be prevented when in claimed territory of another faction // commands which will be prevented when in claimed territory of another faction
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<String>(); public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<>();
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<String>(); public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<>();
public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<String>(); public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<>();
public static Set<String> warzoneDenyCommands = new LinkedHashSet<String>(); public static Set<String> warzoneDenyCommands = new LinkedHashSet<>();
public static Set<String> wildernessDenyCommands = new LinkedHashSet<String>(); public static Set<String> wildernessDenyCommands = new LinkedHashSet<>();
public static boolean territoryDenyBuild = true; public static boolean territoryDenyBuild = true;
public static boolean territoryDenyBuildWhenOffline = true; public static boolean territoryDenyBuildWhenOffline = true;
@ -309,12 +309,12 @@ public class Conf {
// If empty all regions are shown. // If empty all regions are shown.
// Specify Faction either by name or UUID. // Specify Faction either by name or UUID.
// To show all regions on a given world, add 'world:<worldname>' to the list. // To show all regions on a given world, add 'world:<worldname>' to the list.
public static Set<String> dynmapVisibleFactions = new HashSet<String>(); public static Set<String> dynmapVisibleFactions = new HashSet<>();
// Optional setting to hide specific Factions. // Optional setting to hide specific Factions.
// Specify Faction either by name or UUID. // Specify Faction either by name or UUID.
// To hide all regions on a given world, add 'world:<worldname>' to the list. // To hide all regions on a given world, add 'world:<worldname>' to the list.
public static Set<String> dynmapHiddenFactions = new HashSet<String>(); public static Set<String> dynmapHiddenFactions = new HashSet<>();
// Region Style // Region Style
public static final transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00"; 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. 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 // mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>(); public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<>();
public static Set<String> worldsNoClaiming = new LinkedHashSet<String>(); public static Set<String> worldsNoClaiming = new LinkedHashSet<>();
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>(); public static Set<String> worldsNoPowerLoss = new LinkedHashSet<>();
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>(); public static Set<String> worldsIgnorePvP = new LinkedHashSet<>();
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>(); public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<>();
// faction-<factionId> // faction-<factionId>
public static String vaultPrefix = "faction-%s"; public static String vaultPrefix = "faction-%s";

View File

@ -192,7 +192,7 @@ public class FLocation implements Serializable {
public Set<FLocation> getCircle(double radius) { public Set<FLocation> getCircle(double radius) {
double radiusSquared = radius * radius; double radiusSquared = radius * radius;
Set<FLocation> ret = new LinkedHashSet<FLocation>(); Set<FLocation> ret = new LinkedHashSet<>();
if (radius <= 0) { if (radius <= 0) {
return ret; return ret;
} }
@ -215,7 +215,7 @@ public class FLocation implements Serializable {
} }
public static HashSet<FLocation> getArea(FLocation from, FLocation to) { public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
HashSet<FLocation> ret = new HashSet<FLocation>(); HashSet<FLocation> ret = new HashSet<>();
for (long x : MiscUtil.range(from.getX(), to.getX())) { for (long x : MiscUtil.range(from.getX(), to.getX())) {
for (long z : MiscUtil.range(from.getZ(), to.getZ())) { for (long z : MiscUtil.range(from.getZ(), to.getZ())) {

View File

@ -299,7 +299,7 @@ public class P extends MPlugin {
// Get a list of all players in the specified faction // Get a list of all players in the specified faction
public Set<String> getPlayersInFaction(String factionTag) { public Set<String> getPlayersInFaction(String factionTag) {
Set<String> players = new HashSet<String>(); Set<String> players = new HashSet<>();
Faction faction = Factions.getInstance().getByTag(factionTag); Faction faction = Factions.getInstance().getByTag(factionTag);
if (faction != null) { if (faction != null) {
for (FPlayer fplayer : faction.getFPlayers()) { 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 // Get a list of all online players in the specified faction
public Set<String> getOnlinePlayersInFaction(String factionTag) { public Set<String> getOnlinePlayersInFaction(String factionTag) {
Set<String> players = new HashSet<String>(); Set<String> players = new HashSet<>();
Faction faction = Factions.getInstance().getByTag(factionTag); Faction faction = Factions.getInstance().getByTag(factionTag);
if (faction != null) { if (faction != null) {
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) { for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) {

View File

@ -27,7 +27,7 @@ public class CmdAutoHelp extends MCommand<P> {
} }
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1); MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
ArrayList<String> lines = new ArrayList<String>(); ArrayList<String> lines = new ArrayList<>();
lines.addAll(pcmd.helpLong); lines.addAll(pcmd.helpLong);

View File

@ -16,7 +16,7 @@ import java.util.Set;
public class CmdConfig extends FCommand { public class CmdConfig extends FCommand {
private static HashMap<String, String> properFieldNames = new HashMap<String, String>(); private static HashMap<String, String> properFieldNames = new HashMap<>();
public CmdConfig() { public CmdConfig() {
super(); 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 // that way, if the person using this command messes up the capitalization, we can fix that
if (properFieldNames.isEmpty()) { if (properFieldNames.isEmpty()) {
Field[] fields = Conf.class.getDeclaredFields(); Field[] fields = Conf.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) { for (Field field : fields) {
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName()); properFieldNames.put(field.getName().toLowerCase(), field.getName());
} }
} }
@ -59,9 +59,9 @@ public class CmdConfig extends FCommand {
String success; String success;
String value = args.get(1); StringBuilder value = new StringBuilder(args.get(1));
for (int i = 2; i < args.size(); i++) { for (int i = 2; i < args.size(); i++) {
value += ' ' + args.get(i); value.append(' ').append(args.get(i));
} }
try { try {
@ -69,7 +69,7 @@ public class CmdConfig extends FCommand {
// boolean // boolean
if (target.getType() == boolean.class) { if (target.getType() == boolean.class) {
boolean targetValue = this.strAsBool(value); boolean targetValue = this.strAsBool(value.toString());
target.setBoolean(null, targetValue); target.setBoolean(null, targetValue);
if (targetValue) { if (targetValue) {
@ -82,7 +82,7 @@ public class CmdConfig extends FCommand {
// int // int
else if (target.getType() == int.class) { else if (target.getType() == int.class) {
try { try {
int intVal = Integer.parseInt(value); int intVal = Integer.parseInt(value.toString());
target.setInt(null, intVal); target.setInt(null, intVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -94,7 +94,7 @@ public class CmdConfig extends FCommand {
// long // long
else if (target.getType() == long.class) { else if (target.getType() == long.class) {
try { try {
long longVal = Long.parseLong(value); long longVal = Long.parseLong(value.toString());
target.setLong(null, longVal); target.setLong(null, longVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -106,7 +106,7 @@ public class CmdConfig extends FCommand {
// double // double
else if (target.getType() == double.class) { else if (target.getType() == double.class) {
try { try {
double doubleVal = Double.parseDouble(value); double doubleVal = Double.parseDouble(value.toString());
target.setDouble(null, doubleVal); target.setDouble(null, doubleVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -118,7 +118,7 @@ public class CmdConfig extends FCommand {
// float // float
else if (target.getType() == float.class) { else if (target.getType() == float.class) {
try { try {
float floatVal = Float.parseFloat(value); float floatVal = Float.parseFloat(value.toString());
target.setFloat(null, floatVal); target.setFloat(null, floatVal);
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + "."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + ".";
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -129,7 +129,7 @@ public class CmdConfig extends FCommand {
// String // String
else if (target.getType() == String.class) { else if (target.getType() == String.class) {
target.set(null, value); target.set(null, value.toString());
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\"."; success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\".";
} }
@ -137,16 +137,16 @@ public class CmdConfig extends FCommand {
else if (target.getType() == ChatColor.class) { else if (target.getType() == ChatColor.class) {
ChatColor newColor = null; ChatColor newColor = null;
try { try {
newColor = ChatColor.valueOf(value.toUpperCase()); newColor = ChatColor.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
} }
if (newColor == null) { 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; return;
} }
target.set(null, newColor); 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 // Set<?> or other parameterized collection
@ -164,12 +164,12 @@ public class CmdConfig extends FCommand {
else if (innerType == Material.class) { else if (innerType == Material.class) {
Material newMat = null; Material newMat = null;
try { try {
newMat = Material.valueOf(value.toUpperCase()); newMat = Material.valueOf(value.toString().toUpperCase());
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
} }
if (newMat == null) { 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; return;
} }
@ -179,13 +179,13 @@ public class CmdConfig extends FCommand {
if (matSet.contains(newMat)) { if (matSet.contains(newMat)) {
matSet.remove(newMat); matSet.remove(newMat);
target.set(null, matSet); 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 // Material not present yet, add it
else { else {
matSet.add(newMat); matSet.add(newMat);
target.set(null, matSet); 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<String> stringSet = (Set<String>) target.get(null); @SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) target.get(null);
// String already present, so remove it // String already present, so remove it
if (stringSet.contains(value)) { if (stringSet.contains(value.toString())) {
stringSet.remove(value); stringSet.remove(value.toString());
target.set(null, stringSet); 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 // String not present yet, add it
else { else {
stringSet.add(value); stringSet.add(value.toString());
target.set(null, stringSet); 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)); sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName));
return; return;
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value)); sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString()));
return; return;
} }

View File

@ -37,7 +37,7 @@ public class CmdDisband extends FCommand {
return; return;
} }
boolean isMyFaction = fme == null ? false : faction == myFaction; boolean isMyFaction = fme != null && faction == myFaction;
if (isMyFaction) { if (isMyFaction) {
if (!assertMinRole(Role.ADMIN)) { if (!assertMinRole(Role.ADMIN)) {

View File

@ -53,7 +53,7 @@ public class CmdHelp extends FCommand {
ConfigurationSection help = P.p.getConfig().getConfigurationSection("help"); ConfigurationSection help = P.p.getConfig().getConfigurationSection("help");
if (help == null) { if (help == null) {
help = P.p.getConfig().createSection("help"); // create new help section help = P.p.getConfig().createSection("help"); // create new help section
List<String> error = new ArrayList<String>(); List<String> error = new ArrayList<>();
error.add("&cUpdate help messages in config.yml!"); error.add("&cUpdate help messages in config.yml!");
error.add("&cSet use-old-help for legacy help messages"); error.add("&cSet use-old-help for legacy help messages");
help.set("'1'", error); // add default error messages help.set("'1'", error); // add default error messages
@ -76,10 +76,10 @@ public class CmdHelp extends FCommand {
public ArrayList<ArrayList<String>> helpPages; public ArrayList<ArrayList<String>> helpPages;
public void updateHelp() { public void updateHelp() {
helpPages = new ArrayList<ArrayList<String>>(); helpPages = new ArrayList<>();
ArrayList<String> pageLines; ArrayList<String> pageLines;
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdShow.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())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
@ -105,7 +105,7 @@ public class CmdHelp extends FCommand {
helpPages.add(pageLines); helpPages.add(pageLines);
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) { if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(""); pageLines.add("");
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString()));
@ -118,7 +118,7 @@ public class CmdHelp extends FCommand {
helpPages.add(pageLines); helpPages.add(pageLines);
} }
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdUnclaim.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())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdOwner.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())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
pageLines.add(""); pageLines.add("");
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true)); 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())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString())); 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_6.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.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())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString())); 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_2.toString()));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.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())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString()));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(TL.COMMAND_HELP_MOAR_1.toString()); pageLines.add(TL.COMMAND_HELP_MOAR_1.toString());
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString())); 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)); pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString()));
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdPermanent.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)); pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true));
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<>();
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString())); pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString()));
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));

View File

@ -116,7 +116,7 @@ public class CmdHome extends FCommand {
public void run() { public void run() {
// Create a smoke effect // Create a smoke effect
if (Conf.homesTeleportCommandSmokeEffectEnabled) { if (Conf.homesTeleportCommandSmokeEffectEnabled) {
List<Location> smokeLocations = new ArrayList<Location>(); List<Location> smokeLocations = new ArrayList<>();
smokeLocations.add(loc); smokeLocations.add(loc);
smokeLocations.add(loc.add(0, 1, 0)); smokeLocations.add(loc.add(0, 1, 0));
smokeLocations.add(CmdHome.this.myFaction.getHome()); smokeLocations.add(CmdHome.this.myFaction.getHome());

View File

@ -91,7 +91,7 @@ public class CmdList extends FCommand {
} }
}); });
ArrayList<String> lines = new ArrayList<String>(); ArrayList<String> lines = new ArrayList<>();
factionList.add(0, Factions.getInstance().getNone()); factionList.add(0, Factions.getInstance().getNone());

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -14,7 +14,7 @@ import java.util.List;
public class CmdShow extends FCommand { public class CmdShow extends FCommand {
List<String> defaults = new ArrayList<String>(); List<String> defaults = new ArrayList<>();
public CmdShow() { public CmdShow() {
this.aliases.add("show"); this.aliases.add("show");

View File

@ -25,7 +25,7 @@ public class CmdStatus extends FCommand {
@Override @Override
public void perform() { public void perform() {
ArrayList<String> ret = new ArrayList<String>(); ArrayList<String> ret = new ArrayList<>();
for (FPlayer fp : myFaction.getFPlayers()) { for (FPlayer fp : myFaction.getFPlayers()) {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX; 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); String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);

View File

@ -140,7 +140,7 @@ public class CmdTop extends FCommand {
msg(TL.COMMAND_TOP_INVALID, criteria); msg(TL.COMMAND_TOP_INVALID, criteria);
} }
ArrayList<String> lines = new ArrayList<String>(); ArrayList<String> lines = new ArrayList<>();
final int pageheight = 9; final int pageheight = 9;
int pagenumber = this.argAsInt(1, 1); int pagenumber = this.argAsInt(1, 1);

View File

@ -8,8 +8,6 @@ import com.drtshock.playervaults.vaultmanagement.VaultViewInfo;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -34,10 +34,7 @@ public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable
@Override @Override
public void setCancelled(boolean c) { public void setCancelled(boolean c) {
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) { // Don't let them cancel factions disbanding.
cancelled = false; // Don't let them cancel factions disbanding. cancelled = reason != PlayerLeaveReason.DISBAND && reason != PlayerLeaveReason.RESET && c;
} else {
cancelled = c;
}
} }
} }

View File

@ -207,7 +207,7 @@ public class Econ {
} }
public static Set<FPlayer> getFplayers(EconomyParticipator ep) { public static Set<FPlayer> getFplayers(EconomyParticipator ep) {
Set<FPlayer> fplayers = new HashSet<FPlayer>(); Set<FPlayer> fplayers = new HashSet<>();
if (ep != null) { if (ep != null) {
if (ep instanceof FPlayer) { if (ep instanceof FPlayer) {
@ -221,7 +221,7 @@ public class Econ {
} }
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
Set<FPlayer> recipients = new HashSet<FPlayer>(); Set<FPlayer> recipients = new HashSet<>();
recipients.addAll(getFplayers(invoker)); recipients.addAll(getFplayers(invoker));
recipients.addAll(getFplayers(from)); recipients.addAll(getFplayers(from));
recipients.addAll(getFplayers(to)); recipients.addAll(getFplayers(to));

View File

@ -38,9 +38,6 @@ public class Essentials {
} }
public static boolean isVanished(Player player) { public static boolean isVanished(Player player) {
if (essentials == null) { return essentials != null && essentials.getUser(player).isVanished();
return false;
}
return essentials.getUser(player).isVanished();
} }
} }

View File

@ -82,10 +82,7 @@ public class Worldguard {
World world = loc.getWorld(); World world = loc.getWorld();
Vector pt = toVector(loc); Vector pt = toVector(loc);
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, loc);
return wg.canBuild(player, loc);
}
return false;
} }
// Check for Regions in chunk the chunk // Check for Regions in chunk the chunk
@ -125,17 +122,13 @@ public class Worldguard {
RegionManager regionManager = wg.getRegionManager(world); RegionManager regionManager = wg.getRegionManager(world);
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk); ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
Map<String, ProtectedRegion> allregions = regionManager.getRegions(); Map<String, ProtectedRegion> allregions = regionManager.getRegions();
Collection<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values()); Collection<ProtectedRegion> allregionslist = new ArrayList<>(allregions.values());
List<ProtectedRegion> overlaps; List<ProtectedRegion> overlaps;
boolean foundregions = false; boolean foundregions = false;
try { try {
overlaps = region.getIntersectingRegions(allregionslist); overlaps = region.getIntersectingRegions(allregionslist);
if (overlaps == null || overlaps.isEmpty()) { foundregions = overlaps != null && !overlaps.isEmpty();
foundregions = false;
} else {
foundregions = true;
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -144,7 +144,7 @@ public class EngineDynmap {
// Thread Safe / Asynchronous: Yes // Thread Safe / Asynchronous: Yes
public Map<String, TempMarker> createHomes() { public Map<String, TempMarker> createHomes() {
Map<String, TempMarker> ret = new HashMap<String, TempMarker>(); Map<String, TempMarker> ret = new HashMap<>();
// Loop current factions // Loop current factions
for (Faction faction : Factions.getInstance().getAllFactions()) { 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. // This method places out the faction home markers into the factions markerset.
public void updateHomes(Map<String, TempMarker> homes) { public void updateHomes(Map<String, TempMarker> homes) {
// Put all current faction markers in a map // Put all current faction markers in a map
Map<String, Marker> markers = new HashMap<String, Marker>(); Map<String, Marker> markers = new HashMap<>();
for (Marker marker : this.markerset.getMarkers()) { for (Marker marker : this.markerset.getMarkers()) {
markers.put(marker.getMarkerID(), marker); markers.put(marker.getMarkerID(), marker);
} }
@ -220,7 +220,7 @@ public class EngineDynmap {
// Thread Safe: YES // Thread Safe: YES
public Map<String, Map<Faction, Set<FLocation>>> createWorldFactionChunks() { public Map<String, Map<Faction, Set<FLocation>>> createWorldFactionChunks() {
// Create map "world name --> faction --> set of chunk coords" // Create map "world name --> faction --> set of chunk coords"
Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = new HashMap<String, Map<Faction, Set<FLocation>>>(); Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks = new HashMap<>();
// Note: The board is the world. The board id is the world name. // Note: The board is the world. The board id is the world name.
MemoryBoard board = (MemoryBoard) Board.getInstance(); MemoryBoard board = (MemoryBoard) Board.getInstance();
@ -231,13 +231,13 @@ public class EngineDynmap {
Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.get(world); Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.get(world);
if (factionChunks == null) { if (factionChunks == null) {
factionChunks = new HashMap<Faction, Set<FLocation>>(); factionChunks = new HashMap<>();
worldFactionChunks.put(world, factionChunks); worldFactionChunks.put(world, factionChunks);
} }
Set<FLocation> factionTerritory = factionChunks.get(chunkOwner); Set<FLocation> factionTerritory = factionChunks.get(chunkOwner);
if (factionTerritory == null) { if (factionTerritory == null) {
factionTerritory = new HashSet<FLocation>(); factionTerritory = new HashSet<>();
factionChunks.put(chunkOwner, factionTerritory); factionChunks.put(chunkOwner, factionTerritory);
} }
@ -249,7 +249,7 @@ public class EngineDynmap {
// Thread Safe: YES // Thread Safe: YES
public Map<String, TempAreaMarker> createAreas(Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks) { public Map<String, TempAreaMarker> createAreas(Map<String, Map<Faction, Set<FLocation>>> worldFactionChunks) {
Map<String, TempAreaMarker> ret = new HashMap<String, TempAreaMarker>(); Map<String, TempAreaMarker> ret = new HashMap<>();
// For each world // For each world
for (Entry<String, Map<Faction, Set<FLocation>>> entry : worldFactionChunks.entrySet()) { for (Entry<String, Map<Faction, Set<FLocation>>> entry : worldFactionChunks.entrySet()) {
@ -272,7 +272,7 @@ public class EngineDynmap {
// Handle specific faction on specific world // Handle specific faction on specific world
// "handle faction on world" // "handle faction on world"
public Map<String, TempAreaMarker> createAreas(String world, Faction faction, Set<FLocation> chunks) { public Map<String, TempAreaMarker> createAreas(String world, Faction faction, Set<FLocation> chunks) {
Map<String, TempAreaMarker> ret = new HashMap<String, TempAreaMarker>(); Map<String, TempAreaMarker> ret = new HashMap<>();
// If the faction is visible ... // If the faction is visible ...
if (!isVisible(faction, world)) { if (!isVisible(faction, world)) {
@ -295,7 +295,7 @@ public class EngineDynmap {
// Loop through chunks: set flags on chunk map // Loop through chunks: set flags on chunk map
TileFlags allChunkFlags = new TileFlags(); TileFlags allChunkFlags = new TileFlags();
LinkedList<FLocation> allChunks = new LinkedList<FLocation>(); LinkedList<FLocation> allChunks = new LinkedList<>();
for (FLocation chunk : chunks) { for (FLocation chunk : chunks) {
allChunkFlags.setFlag((int) chunk.getX(), (int) chunk.getZ(), true); // Set flag for chunk allChunkFlags.setFlag((int) chunk.getX(), (int) chunk.getZ(), true); // Set flag for chunk
allChunks.addLast(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 we need to start shape, and this block is not part of one yet
if (ourChunkFlags == null && allChunkFlags.getFlag(chunkX, chunkZ)) { if (ourChunkFlags == null && allChunkFlags.getFlag(chunkX, chunkZ)) {
ourChunkFlags = new TileFlags(); // Create map for shape ourChunkFlags = new TileFlags(); // Create map for shape
ourChunks = new LinkedList<FLocation>(); ourChunks = new LinkedList<>();
floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape
ourChunks.add(chunk); // Add it to our chunk list ourChunks.add(chunk); // Add it to our chunk list
minimumX = chunkX; minimumX = chunkX;
@ -335,7 +335,7 @@ public class EngineDynmap {
// Else, keep it in the list for the next polygon // Else, keep it in the list for the next polygon
else { else {
if (newChunks == null) { if (newChunks == null) {
newChunks = new LinkedList<FLocation>(); newChunks = new LinkedList<>();
} }
newChunks.add(chunk); newChunks.add(chunk);
} }
@ -354,7 +354,7 @@ public class EngineDynmap {
int currentX = minimumX; int currentX = minimumX;
int currentZ = minimumZ; int currentZ = minimumZ;
Direction direction = Direction.XPLUS; Direction direction = Direction.XPLUS;
ArrayList<int[]> linelist = new ArrayList<int[]>(); ArrayList<int[]> linelist = new ArrayList<>();
linelist.add(new int[]{initialX, initialZ}); // Add start point linelist.add(new int[]{initialX, initialZ}); // Add start point
while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) { while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) {
switch (direction) { switch (direction) {
@ -452,7 +452,7 @@ public class EngineDynmap {
// Thread Safe: NO // Thread Safe: NO
public void updateAreas(Map<String, TempAreaMarker> areas) { public void updateAreas(Map<String, TempAreaMarker> areas) {
// Map Current // Map Current
Map<String, AreaMarker> markers = new HashMap<String, AreaMarker>(); Map<String, AreaMarker> markers = new HashMap<>();
for (AreaMarker marker : this.markerset.getAreaMarkers()) { for (AreaMarker marker : this.markerset.getAreaMarkers()) {
markers.put(marker.getMarkerID(), marker); markers.put(marker.getMarkerID(), marker);
} }
@ -510,7 +510,7 @@ public class EngineDynmap {
return null; return null;
} }
Set<String> ret = new HashSet<String>(); Set<String> ret = new HashSet<>();
for (FPlayer fplayer : faction.getFPlayers()) { for (FPlayer fplayer : faction.getFPlayers()) {
// NOTE: We add both UUID and name. This might be a good idea for future proofing. // 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; return null;
} }
Map<String, Set<String>> ret = new HashMap<String, Set<String>>(); Map<String, Set<String>> ret = new HashMap<>();
for (Faction faction : Factions.getInstance().getAllFactions()) { for (Faction faction : Factions.getInstance().getAllFactions()) {
String playersetId = createPlayersetId(faction); String playersetId = createPlayersetId(faction);
@ -654,14 +654,14 @@ public class EngineDynmap {
} }
public static String getHtmlPlayerString(Collection<FPlayer> playersOfficersList) { public static String getHtmlPlayerString(Collection<FPlayer> playersOfficersList) {
String ret = ""; StringBuilder ret = new StringBuilder();
for (FPlayer fplayer : playersOfficersList) { for (FPlayer fplayer : playersOfficersList) {
if (ret.length() > 0) { 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) { public static String getHtmlPlayerName(FPlayer fplayer) {
@ -707,11 +707,7 @@ public class EngineDynmap {
return false; return false;
} }
if (hidden.contains(factionId) || hidden.contains(factionName) || hidden.contains("world:" + world)) { return !hidden.contains(factionId) && !hidden.contains(factionName) && !hidden.contains("world:" + world);
return false;
}
return true;
} }
// Thread Safe / Asynchronous: Yes // Thread Safe / Asynchronous: Yes
@ -750,7 +746,7 @@ public class EngineDynmap {
// Find all contiguous blocks, set in target and clear in source // Find all contiguous blocks, set in target and clear in source
private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) { private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
int cnt = 0; int cnt = 0;
ArrayDeque<int[]> stack = new ArrayDeque<int[]>(); ArrayDeque<int[]> stack = new ArrayDeque<>();
stack.push(new int[]{x, y}); stack.push(new int[]{x, y});
while (!stack.isEmpty()) { while (!stack.isEmpty()) {

View File

@ -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 potentially pushing into air/water/lava in another territory, we need to check it out
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) { if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
/* /*
@ -126,7 +125,6 @@ public class FactionsBlockListener implements Listener {
if (!canPistonMoveBlock(pistonFaction, targetLoc)) { if (!canPistonMoveBlock(pistonFaction, targetLoc)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
@ -161,32 +159,19 @@ public class FactionsBlockListener implements Listener {
} }
if (otherFaction.isWilderness()) { if (otherFaction.isWilderness()) {
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) { return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
return true;
}
return false;
} else if (otherFaction.isSafeZone()) { } else if (otherFaction.isSafeZone()) {
if (!Conf.safeZoneDenyBuild) { return !Conf.safeZoneDenyBuild;
return true;
}
return false;
} else if (otherFaction.isWarZone()) { } else if (otherFaction.isWarZone()) {
if (!Conf.warZoneDenyBuild) { return !Conf.warZoneDenyBuild;
return true;
}
return false;
} }
Relation rel = pistonFaction.getRelationTo(otherFaction); Relation rel = pistonFaction.getRelationTo(otherFaction);
if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) { return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
return false;
}
return true;
} }
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {

View File

@ -177,7 +177,7 @@ public class FactionsEntityListener implements Listener {
Block center = loc.getBlock(); Block center = loc.getBlock();
if (center.isLiquid()) { if (center.isLiquid()) {
// a single surrounding block in all 6 directions is broken if the material is weak enough // a single surrounding block in all 6 directions is broken if the material is weak enough
List<Block> targets = new ArrayList<Block>(); List<Block> targets = new ArrayList<>();
targets.add(center.getRelative(0, 0, 1)); targets.add(center.getRelative(0, 0, 1));
targets.add(center.getRelative(0, 0, -1)); targets.add(center.getRelative(0, 0, -1));
targets.add(center.getRelative(0, 1, 0)); targets.add(center.getRelative(0, 1, 0));
@ -202,10 +202,9 @@ public class FactionsEntityListener implements Listener {
if (!this.canDamagerHurtDamagee(sub, false)) { if (!this.canDamagerHurtDamagee(sub, false)) {
event.setCancelled(true); event.setCancelled(true);
} }
sub = null;
} }
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<PotionEffectType>(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<PotionEffectType> 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) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPotionSplashEvent(PotionSplashEvent event) { 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 // scan through affected entities to make sure they're all valid targets
Iterator<LivingEntity> iter = event.getAffectedEntities().iterator(); for (LivingEntity target : event.getAffectedEntities()) {
while (iter.hasNext()) {
LivingEntity target = iter.next();
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0); EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
if (!this.canDamagerHurtDamagee(sub, true)) { if (!this.canDamagerHurtDamagee(sub, true)) {
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works 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)) { if (!(damagee instanceof Player)) {
return false; return false;
} }
if (Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone()) { return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone();
return true;
}
return false;
} }
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) { public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {

View File

@ -135,7 +135,7 @@ public class FactionsPlayerListener implements Listener {
} }
// Holds the next time a player can have a map shown. // Holds the next time a player can have a map shown.
private HashMap<UUID, Long> showTimes = new HashMap<UUID, Long>(); private HashMap<UUID, Long> showTimes = new HashMap<>();
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) { 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 // for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<String, InteractAttemptSpam>(); private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();
private static class InteractAttemptSpam { private static class InteractAttemptSpam {
private int attempts = 0; private int attempts = 0;
@ -470,7 +470,6 @@ public class FactionsPlayerListener implements Listener {
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
@ -481,7 +480,6 @@ public class FactionsPlayerListener implements Listener {
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) { if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }

View File

@ -18,7 +18,7 @@ public class BufferedObjective {
private final String baseName; private final String baseName;
private Objective current; private Objective current;
private List<Team> currentTeams = new ArrayList<Team>(); private List<Team> currentTeams = new ArrayList<>();
private String title; private String title;
private DisplaySlot displaySlot; private DisplaySlot displaySlot;
@ -26,7 +26,7 @@ public class BufferedObjective {
private int teamPtr; private int teamPtr;
private boolean requiresUpdate = false; private boolean requiresUpdate = false;
private final Map<Integer, String> contents = new HashMap<Integer, String>(); private final Map<Integer, String> contents = new HashMap<>();
static { static {
// Check for long line support. // Check for long line support.
@ -113,7 +113,7 @@ public class BufferedObjective {
Objective buffer = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy"); Objective buffer = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy");
buffer.setDisplayName(title); buffer.setDisplayName(title);
List<Team> bufferTeams = new ArrayList<Team>(); List<Team> bufferTeams = new ArrayList<>();
for (Map.Entry<Integer, String> entry : contents.entrySet()) { for (Map.Entry<Integer, String> entry : contents.entrySet()) {
if (entry.getValue().length() > 16) { if (entry.getValue().length() > 16) {

View File

@ -13,7 +13,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class FScoreboard { public class FScoreboard {
private static final Map<FPlayer, FScoreboard> fscoreboards = new HashMap<FPlayer, FScoreboard>(); private static final Map<FPlayer, FScoreboard> fscoreboards = new HashMap<>();
private final Scoreboard scoreboard; private final Scoreboard scoreboard;
private final FPlayer fplayer; private final FPlayer fplayer;

View File

@ -10,15 +10,15 @@ import org.bukkit.scoreboard.Team;
import java.util.*; import java.util.*;
public class FTeamWrapper { public class FTeamWrapper {
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<Faction, FTeamWrapper>(); private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<>();
private static final List<FScoreboard> tracking = new ArrayList<FScoreboard>(); private static final List<FScoreboard> tracking = new ArrayList<>();
private static int factionTeamPtr; private static int factionTeamPtr;
private static final Set<Faction> updating = new HashSet<Faction>(); private static final Set<Faction> updating = new HashSet<>();
private final Map<FScoreboard, Team> teams = new HashMap<FScoreboard, Team>(); private final Map<FScoreboard, Team> teams = new HashMap<>();
private final String teamName; private final String teamName;
private final Faction faction; private final Faction faction;
private final Set<OfflinePlayer> members = new HashSet<OfflinePlayer>(); private final Set<OfflinePlayer> members = new HashSet<>();
public static void applyUpdatesLater(final Faction faction) { public static void applyUpdatesLater(final Faction faction) {
if (!FScoreboard.isSupportedByServer()) { if (!FScoreboard.isSupportedByServer()) {
@ -194,7 +194,7 @@ public class FTeamWrapper {
} }
private Set<OfflinePlayer> getPlayers() { private Set<OfflinePlayer> getPlayers() {
return new HashSet<OfflinePlayer>(this.members); return new HashSet<>(this.members);
} }
private void unregister() { private void unregister() {

View File

@ -29,7 +29,7 @@ public class FDefaultSidebar extends FSidebarProvider {
List<String> lines = P.p.getConfig().getStringList(list); List<String> lines = P.p.getConfig().getStringList(list);
if (lines == null || lines.isEmpty()) { if (lines == null || lines.isEmpty()) {
return new ArrayList<String>(); return new ArrayList<>();
} }
ListIterator<String> it = lines.listIterator(); ListIterator<String> it = lines.listIterator();

View File

@ -11,7 +11,7 @@ public enum ChatMode {
public final int value; public final int value;
public final TL nicename; public final TL nicename;
private ChatMode(final int value, final TL nicename) { ChatMode(final int value, final TL nicename) {
this.value = value; this.value = value;
this.nicename = nicename; this.nicename = nicename;
} }

View File

@ -15,7 +15,7 @@ public enum Relation {
public final int value; public final int value;
public final String nicename; public final String nicename;
private Relation(final int value, final String nicename) { Relation(final int value, final String nicename) {
this.value = value; this.value = value;
this.nicename = nicename; this.nicename = nicename;
} }

View File

@ -12,7 +12,7 @@ public enum Role {
public final String nicename; public final String nicename;
public final TL translation; public final TL translation;
private Role(final int value, final TL translation) { Role(final int value, final TL translation) {
this.value = value; this.value = value;
this.nicename = translation.toString(); this.nicename = translation.toString();
this.translation = translation; this.translation = translation;

View File

@ -20,7 +20,7 @@ public class AsciiCompass {
public final char asciiChar; public final char asciiChar;
private Point(final char asciiChar) { Point(final char asciiChar) {
this.asciiChar = asciiChar; this.asciiChar = asciiChar;
} }
@ -80,7 +80,7 @@ public class AsciiCompass {
} }
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) { public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) {
ArrayList<String> ret = new ArrayList<String>(); ArrayList<String> ret = new ArrayList<>();
String row; String row;
row = ""; row = "";

View File

@ -15,8 +15,8 @@ import java.util.Map;
public final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> { public final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
private final Map<String, T> nameToConstant = new HashMap<String, T>(); private final Map<String, T> nameToConstant = new HashMap<>();
private final Map<T, String> constantToName = new HashMap<T, String>(); private final Map<T, String> constantToName = new HashMap<>();
public EnumTypeAdapter(Class<T> classOfT) { public EnumTypeAdapter(Class<T> classOfT) {
try { try {

View File

@ -24,7 +24,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
return null; return null;
} }
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>(); Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<>();
Set<String> nameSet; Set<String> nameSet;
Iterator<JsonElement> iter; Iterator<JsonElement> iter;
String worldName; String worldName;
@ -38,7 +38,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
x = Integer.parseInt(coords[0]); x = Integer.parseInt(coords[0]);
z = Integer.parseInt(coords[1]); z = Integer.parseInt(coords[1]);
nameSet = new HashSet<String>(); nameSet = new HashSet<>();
iter = entry2.getValue().getAsJsonArray().iterator(); iter = entry2.getValue().getAsJsonArray().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
nameSet.add(iter.next().getAsString()); nameSet.add(iter.next().getAsString());

View File

@ -45,24 +45,24 @@ public class MiscUtil {
} }
/// TODO create tag whitelist!! /// TODO create tag whitelist!!
public static HashSet<String> substanceChars = new HashSet<String>(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<String> 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) { public static String getComparisonString(String str) {
String ret = ""; StringBuilder ret = new StringBuilder();
str = ChatColor.stripColor(str); str = ChatColor.stripColor(str);
str = str.toLowerCase(); str = str.toLowerCase();
for (char c : str.toCharArray()) { for (char c : str.toCharArray()) {
if (substanceChars.contains(String.valueOf(c))) { if (substanceChars.contains(String.valueOf(c))) {
ret += c; ret.append(c);
} }
} }
return ret.toLowerCase(); return ret.toString().toLowerCase();
} }
public static ArrayList<String> validateTag(String str) { public static ArrayList<String> validateTag(String str) {
ArrayList<String> errors = new ArrayList<String>(); ArrayList<String> errors = new ArrayList<>();
if (getComparisonString(str).length() < Conf.factionTagLengthMin) { if (getComparisonString(str).length() < Conf.factionTagLengthMin) {
errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), 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<FPlayer> rankOrder(Iterable<FPlayer> players) { public static Iterable<FPlayer> rankOrder(Iterable<FPlayer> players) {
List<FPlayer> admins = new ArrayList<FPlayer>(); List<FPlayer> admins = new ArrayList<>();
List<FPlayer> moderators = new ArrayList<FPlayer>(); List<FPlayer> moderators = new ArrayList<>();
List<FPlayer> normal = new ArrayList<FPlayer>(); List<FPlayer> normal = new ArrayList<>();
for (FPlayer player : players) { for (FPlayer player : players) {
switch (player.getRole()) { switch (player.getRole()) {
@ -102,7 +102,7 @@ public class MiscUtil {
} }
} }
List<FPlayer> ret = new ArrayList<FPlayer>(); List<FPlayer> ret = new ArrayList<>();
ret.addAll(admins); ret.addAll(admins);
ret.addAll(moderators); ret.addAll(moderators);
ret.addAll(normal); ret.addAll(normal);

View File

@ -9,7 +9,7 @@ import java.util.Map.Entry;
public class VisualizeUtil { public class VisualizeUtil {
protected static Map<UUID, Set<Location>> playerLocations = new HashMap<UUID, Set<Location>>(); protected static Map<UUID, Set<Location>> playerLocations = new HashMap<>();
public static Set<Location> getPlayerLocations(Player player) { public static Set<Location> getPlayerLocations(Player player) {
return getPlayerLocations(player.getUniqueId()); return getPlayerLocations(player.getUniqueId());
@ -18,7 +18,7 @@ public class VisualizeUtil {
public static Set<Location> getPlayerLocations(UUID uuid) { public static Set<Location> getPlayerLocations(UUID uuid) {
Set<Location> ret = playerLocations.get(uuid); Set<Location> ret = playerLocations.get(uuid);
if (ret == null) { if (ret == null) {
ret = new HashSet<Location>(); ret = new HashSet<>();
playerLocations.put(uuid, ret); playerLocations.put(uuid, ret);
} }
return ret; return ret;

View File

@ -73,7 +73,7 @@ public abstract class MCommand<T extends MPlugin> {
public Player me; // Will only be set when the sender is a player public Player me; // Will only be set when the sender is a player
public boolean senderIsConsole; public boolean senderIsConsole;
public List<String> args; // Will contain the arguments, or and empty list if there are none. public List<String> args; // Will contain the arguments, or and empty list if there are none.
public List<MCommand<?>> commandChain = new ArrayList<MCommand<?>>(); // The command chain used to execute this command public List<MCommand<?>> commandChain = new ArrayList<>(); // The command chain used to execute this command
public MCommand(T p) { public MCommand(T p) {
this.p = p; this.p = p;
@ -82,14 +82,14 @@ public abstract class MCommand<T extends MPlugin> {
this.allowNoSlashAccess = false; this.allowNoSlashAccess = false;
this.subCommands = new ArrayList<MCommand<?>>(); this.subCommands = new ArrayList<>();
this.aliases = new ArrayList<String>(); this.aliases = new ArrayList<>();
this.requiredArgs = new ArrayList<String>(); this.requiredArgs = new ArrayList<>();
this.optionalArgs = new LinkedHashMap<String, String>(); this.optionalArgs = new LinkedHashMap<>();
this.helpShort = null; this.helpShort = null;
this.helpLong = new ArrayList<String>(); this.helpLong = new ArrayList<>();
this.visibility = CommandVisibility.VISIBLE; this.visibility = CommandVisibility.VISIBLE;
} }
@ -210,7 +210,7 @@ public abstract class MCommand<T extends MPlugin> {
ret.append(TextUtil.implode(this.aliases, ",")); ret.append(TextUtil.implode(this.aliases, ","));
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<>();
for (String requiredArg : this.requiredArgs) { for (String requiredArg : this.requiredArgs) {
args.add("<" + requiredArg + ">"); args.add("<" + requiredArg + ">");
@ -280,7 +280,7 @@ public abstract class MCommand<T extends MPlugin> {
} }
public List<String> getToolTips(FPlayer player) { public List<String> getToolTips(FPlayer player) {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
for (String s : p.getConfig().getStringList("tooltips.show")) { for (String s : p.getConfig().getStringList("tooltips.show")) {
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player))); lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player)));
} }
@ -288,7 +288,7 @@ public abstract class MCommand<T extends MPlugin> {
} }
public List<String> getToolTips(Faction faction) { public List<String> getToolTips(Faction faction) {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
for (String s : p.getConfig().getStringList("tooltips.list")) { for (String s : p.getConfig().getStringList("tooltips.list")) {
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction))); lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction)));
} }

View File

@ -52,17 +52,17 @@ public abstract class MPlugin extends JavaPlugin {
private MPluginSecretPlayerListener mPluginSecretPlayerListener; private MPluginSecretPlayerListener mPluginSecretPlayerListener;
// Our stored base commands // Our stored base commands
private List<MCommand<?>> baseCommands = new ArrayList<MCommand<?>>(); private List<MCommand<?>> baseCommands = new ArrayList<>();
public List<MCommand<?>> getBaseCommands() { public List<MCommand<?>> getBaseCommands() {
return this.baseCommands; return this.baseCommands;
} }
// holds f stuck start times // holds f stuck start times
private Map<UUID, Long> timers = new HashMap<UUID, Long>(); private Map<UUID, Long> timers = new HashMap<>();
//holds f stuck taskids //holds f stuck taskids
public Map<UUID, Integer> stuckMap = new HashMap<UUID, Integer>(); public Map<UUID, Integer> stuckMap = new HashMap<>();
// -------------------------------------------- // // -------------------------------------------- //
// ENABLE // ENABLE
@ -214,7 +214,7 @@ public abstract class MPlugin extends JavaPlugin {
// These are not supposed to be used directly. // These are not supposed to be used directly.
// They are loaded and used through the TextUtil instance for the plugin. // They are loaded and used through the TextUtil instance for the plugin.
public Map<String, String> rawTags = new LinkedHashMap<String, String>(); public Map<String, String> rawTags = new LinkedHashMap<>();
public void addRawTags() { public void addRawTags() {
this.rawTags.put("l", "<green>"); // logo this.rawTags.put("l", "<green>"); // logo
@ -277,7 +277,7 @@ public abstract class MPlugin extends JavaPlugin {
} }
if (commandString.startsWith(alias + " ") || commandString.equals(alias)) { if (commandString.startsWith(alias + " ") || commandString.equals(alias)) {
final List<String> args = new ArrayList<String>(Arrays.asList(commandString.split("\\s+"))); final List<String> args = new ArrayList<>(Arrays.asList(commandString.split("\\s+")));
args.remove(0); args.remove(0);
if (testOnly) { if (testOnly) {

View File

@ -104,10 +104,8 @@ public abstract class MemoryBoard extends Board {
} }
public Set<FLocation> getAllClaims(String factionId) { public Set<FLocation> getAllClaims(String factionId) {
Set<FLocation> locs = new HashSet<FLocation>(); Set<FLocation> locs = new HashSet<>();
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator(); for (Entry<FLocation, String> entry : flocationIds.entrySet()) {
while (iter.hasNext()) {
Entry<FLocation, String> entry = iter.next();
if (entry.getValue().equals(factionId)) { if (entry.getValue().equals(factionId)) {
locs.add(entry.getKey()); locs.add(entry.getKey());
} }
@ -227,9 +225,7 @@ public abstract class MemoryBoard extends Board {
public int getFactionCoordCountInWorld(Faction faction, String worldName) { public int getFactionCoordCountInWorld(Faction faction, String worldName) {
String factionId = faction.getId(); String factionId = faction.getId();
int ret = 0; int ret = 0;
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator(); for (Entry<FLocation, String> entry : flocationIds.entrySet()) {
while (iter.hasNext()) {
Entry<FLocation, String> entry = iter.next();
if (entry.getValue().equals(factionId) && entry.getKey().getWorldName().equals(worldName)) { if (entry.getValue().equals(factionId) && entry.getKey().getWorldName().equals(worldName)) {
ret += 1; ret += 1;
} }
@ -246,7 +242,7 @@ public abstract class MemoryBoard extends Board {
* of decreasing z * of decreasing z
*/ */
public ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) { public ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) {
ArrayList<String> ret = new ArrayList<String>(); ArrayList<String> ret = new ArrayList<>();
Faction factionLoc = getFactionAt(flocation); Faction factionLoc = getFactionAt(flocation);
ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction))); ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction)));
@ -260,26 +256,26 @@ public abstract class MemoryBoard extends Board {
height--; height--;
} }
Map<String, Character> fList = new HashMap<String, Character>(); Map<String, Character> fList = new HashMap<>();
int chrIdx = 0; int chrIdx = 0;
// For each row // For each row
for (int dz = 0; dz < height; dz++) { for (int dz = 0; dz < height; dz++) {
// Draw and add that row // Draw and add that row
String row = ""; StringBuilder row = new StringBuilder();
for (int dx = 0; dx < width; dx++) { for (int dx = 0; dx < width; dx++) {
if (dx == halfWidth && dz == halfHeight) { if (dx == halfWidth && dz == halfHeight) {
row += ChatColor.AQUA + "+"; row.append(ChatColor.AQUA + "+");
} else { } else {
FLocation flocationHere = topLeft.getRelative(dx, dz); FLocation flocationHere = topLeft.getRelative(dx, dz);
Faction factionHere = getFactionAt(flocationHere); Faction factionHere = getFactionAt(flocationHere);
Relation relation = faction.getRelationTo(factionHere); Relation relation = faction.getRelationTo(factionHere);
if (factionHere.isWilderness()) { if (factionHere.isWilderness()) {
row += ChatColor.GRAY + "-"; row.append(ChatColor.GRAY + "-");
} else if (factionHere.isSafeZone()) { } else if (factionHere.isSafeZone()) {
row += Conf.colorPeaceful + "+"; row.append(Conf.colorPeaceful).append("+");
} else if (factionHere.isWarZone()) { } else if (factionHere.isWarZone()) {
row += ChatColor.DARK_RED + "+"; row.append(ChatColor.DARK_RED + "+");
} else if (factionHere == faction || } else if (factionHere == faction ||
factionHere == factionLoc || factionHere == factionLoc ||
relation.isAtLeast(Relation.ALLY) || 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)]); fList.put(factionHere.getTag(), Conf.mapKeyChrs[Math.min(chrIdx++, Conf.mapKeyChrs.length - 1)]);
} }
char tag = fList.get(factionHere.getTag()); char tag = fList.get(factionHere.getTag());
row += factionHere.getColorTo(faction) + "" + tag; row.append(factionHere.getColorTo(faction)).append("").append(tag);
} else { } else {
row += ChatColor.GRAY + "-"; row.append(ChatColor.GRAY + "-");
} }
} }
} }
ret.add(row); ret.add(row.toString());
} }
// Get the compass // Get the compass
@ -308,11 +304,11 @@ public abstract class MemoryBoard extends Board {
// Add the faction key // Add the faction key
if (Conf.showMapFactionKey) { if (Conf.showMapFactionKey) {
String fRow = ""; StringBuilder fRow = new StringBuilder();
for (String key : fList.keySet()) { 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; return ret;

View File

@ -819,7 +819,7 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
// announce success // announce success
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>(); Set<FPlayer> informTheseFPlayers = new HashSet<>();
informTheseFPlayers.add(this); informTheseFPlayers.add(this);
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true)); informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
for (FPlayer fp : informTheseFPlayers) { for (FPlayer fp : informTheseFPlayers) {
@ -836,10 +836,7 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public boolean shouldBeSaved() { public boolean shouldBeSaved() {
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) { return this.hasFaction() || (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(Conf.powerPlayerStarting));
return false;
}
return true;
} }
public void msg(String str, Object... args) { public void msg(String str, Object... args) {

View File

@ -12,7 +12,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
public abstract class MemoryFPlayers extends FPlayers { public abstract class MemoryFPlayers extends FPlayers {
public Map<String, FPlayer> fPlayers = new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER); public Map<String, FPlayer> fPlayers = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
public void clean() { public void clean() {
for (FPlayer fplayer : this.fPlayers.values()) { for (FPlayer fplayer : this.fPlayers.values()) {
@ -24,7 +24,7 @@ public abstract class MemoryFPlayers extends FPlayers {
} }
public Collection<FPlayer> getOnlinePlayers() { public Collection<FPlayer> getOnlinePlayers() {
Set<FPlayer> entities = new HashSet<FPlayer>(); Set<FPlayer> entities = new HashSet<>();
for (Player player : Bukkit.getServer().getOnlinePlayers()) { for (Player player : Bukkit.getServer().getOnlinePlayers()) {
entities.add(this.getByPlayer(player)); entities.add(this.getByPlayer(player));
} }
@ -38,7 +38,7 @@ public abstract class MemoryFPlayers extends FPlayers {
@Override @Override
public List<FPlayer> getAllFPlayers() { public List<FPlayer> getAllFPlayers() {
return new ArrayList<FPlayer>(fPlayers.values()); return new ArrayList<>(fPlayers.values());
} }
@Override @Override

View File

@ -35,13 +35,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
protected transient long lastPlayerLoggedOffTime; protected transient long lastPlayerLoggedOffTime;
protected double money; protected double money;
protected double powerBoost; protected double powerBoost;
protected Map<String, Relation> relationWish = new HashMap<String, Relation>(); protected Map<String, Relation> relationWish = new HashMap<>();
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<FLocation, Set<String>>(); protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>();
protected transient Set<FPlayer> fplayers = new HashSet<FPlayer>(); protected transient Set<FPlayer> fplayers = new HashSet<>();
protected Set<String> invites = new HashSet<String>(); protected Set<String> invites = new HashSet<>();
protected HashMap<String, List<String>> announcements = new HashMap<String, List<String>>(); protected HashMap<String, List<String>> announcements = new HashMap<>();
protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<String, LazyLocation>(); protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<>();
protected ConcurrentHashMap<String, String> warpPasswords = new ConcurrentHashMap<String, String>(); protected ConcurrentHashMap<String, String> warpPasswords = new ConcurrentHashMap<>();
private long lastDeath; private long lastDeath;
protected int maxVaults; protected int maxVaults;
@ -284,11 +284,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public boolean isPowerFrozen() { public boolean isPowerFrozen() {
int freezeSeconds = P.p.getConfig().getInt("hcf.powerfreeze", 0); int freezeSeconds = P.p.getConfig().getInt("hcf.powerfreeze", 0);
if (freezeSeconds == 0) { return freezeSeconds != 0 && System.currentTimeMillis() - lastDeath < freezeSeconds * 1000;
return false;
}
return System.currentTimeMillis() - lastDeath < freezeSeconds * 1000;
} }
public void setLastDeath(long time) { public void setLastDeath(long time) {
@ -354,7 +351,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
powerBoost = old.powerBoost; powerBoost = old.powerBoost;
relationWish = old.relationWish; relationWish = old.relationWish;
claimOwnership = old.claimOwnership; claimOwnership = old.claimOwnership;
fplayers = new HashSet<FPlayer>(); fplayers = new HashSet<>();
invites = old.invites; invites = old.invites;
announcements = old.announcements; announcements = old.announcements;
} }
@ -540,11 +537,11 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public Set<FPlayer> getFPlayers() { public Set<FPlayer> getFPlayers() {
// return a shallow copy of the FPlayer list, to prevent tampering and // return a shallow copy of the FPlayer list, to prevent tampering and
// concurrency issues // concurrency issues
return new HashSet<FPlayer>(fplayers); return new HashSet<>(fplayers);
} }
public Set<FPlayer> getFPlayersWhereOnline(boolean online) { public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
Set<FPlayer> ret = new HashSet<FPlayer>(); Set<FPlayer> ret = new HashSet<>();
if (!this.isNormal()) { if (!this.isNormal()) {
return ret; return ret;
} }
@ -572,7 +569,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public ArrayList<FPlayer> getFPlayersWhereRole(Role role) { public ArrayList<FPlayer> getFPlayersWhereRole(Role role) {
ArrayList<FPlayer> ret = new ArrayList<FPlayer>(); ArrayList<FPlayer> ret = new ArrayList<>();
if (!this.isNormal()) { if (!this.isNormal()) {
return ret; return ret;
} }
@ -587,7 +584,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public ArrayList<Player> getOnlinePlayers() { public ArrayList<Player> getOnlinePlayers() {
ArrayList<Player> ret = new ArrayList<Player>(); ArrayList<Player> ret = new ArrayList<>();
if (this.isPlayerFreeType()) { if (this.isPlayerFreeType()) {
return ret; return ret;
} }
@ -763,16 +760,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return false; return false;
} }
Set<String> ownerData = claimOwnership.get(loc); Set<String> ownerData = claimOwnership.get(loc);
if (ownerData == null) { return ownerData != null && ownerData.contains(player.getId());
return false;
}
return ownerData.contains(player.getId());
} }
public void setPlayerAsOwner(FPlayer player, FLocation loc) { public void setPlayerAsOwner(FPlayer player, FLocation loc) {
Set<String> ownerData = claimOwnership.get(loc); Set<String> ownerData = claimOwnership.get(loc);
if (ownerData == null) { if (ownerData == null) {
ownerData = new HashSet<String>(); ownerData = new HashSet<>();
} }
ownerData.add(player.getId()); ownerData.add(player.getId());
claimOwnership.put(loc, ownerData); claimOwnership.put(loc, ownerData);
@ -797,18 +791,17 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return ""; return "";
} }
String ownerList = ""; StringBuilder ownerList = new StringBuilder();
Iterator<String> iter = ownerData.iterator(); for (String anOwnerData : ownerData) {
while (iter.hasNext()) { if (ownerList.length() > 0) {
if (!ownerList.isEmpty()) { ownerList.append(", ");
ownerList += ", ";
} }
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(iter.next())); OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData));
//TODO:TL //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) { public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {

View File

@ -13,7 +13,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public abstract class MemoryFactions extends Factions { public abstract class MemoryFactions extends Factions {
public final Map<String, Faction> factions = new ConcurrentHashMap<String, Faction>(); public final Map<String, Faction> factions = new ConcurrentHashMap<>();
public int nextId = 1; public int nextId = 1;
public void load() { public void load() {
@ -134,7 +134,7 @@ public abstract class MemoryFactions extends Factions {
} }
public Set<String> getFactionTags() { public Set<String> getFactionTags() {
Set<String> tags = new HashSet<String>(); Set<String> tags = new HashSet<>();
for (Faction faction : factions.values()) { for (Faction faction : factions.values()) {
tags.add(faction.getTag()); tags.add(faction.getTag());
} }
@ -149,7 +149,7 @@ public abstract class MemoryFactions extends Factions {
@Override @Override
public ArrayList<Faction> getAllFactions() { public ArrayList<Faction> getAllFactions() {
return new ArrayList<Faction>(factions.values()); return new ArrayList<>(factions.values());
} }
@Override @Override

View File

@ -23,7 +23,7 @@ public class JSONBoard extends MemoryBoard {
// -------------------------------------------- // // -------------------------------------------- //
public Map<String, Map<String, String>> dumpAsSaveFormat() { public Map<String, Map<String, String>> dumpAsSaveFormat() {
Map<String, Map<String, String>> worldCoordIds = new HashMap<String, Map<String, String>>(); Map<String, Map<String, String>> worldCoordIds = new HashMap<>();
String worldName, coords; String worldName, coords;
String id; String id;

View File

@ -20,9 +20,6 @@ public class JSONFPlayer extends MemoryFPlayer {
} }
public boolean shouldBeSaved() { public boolean shouldBeSaved() {
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) { return this.hasFaction() || (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(Conf.powerPlayerStarting));
return false;
}
return true;
} }
} }

View File

@ -55,7 +55,7 @@ public class JSONFPlayers extends MemoryFPlayers {
} }
public void forceSave(boolean sync) { public void forceSave(boolean sync) {
final Map<String, JSONFPlayer> entitiesThatShouldBeSaved = new HashMap<String, JSONFPlayer>(); final Map<String, JSONFPlayer> entitiesThatShouldBeSaved = new HashMap<>();
for (FPlayer entity : this.fPlayers.values()) { for (FPlayer entity : this.fPlayers.values()) {
if (((MemoryFPlayer) entity).shouldBeSaved()) { if (((MemoryFPlayer) entity).shouldBeSaved()) {
entitiesThatShouldBeSaved.put(entity.getId(), (JSONFPlayer) entity); entitiesThatShouldBeSaved.put(entity.getId(), (JSONFPlayer) entity);
@ -81,7 +81,7 @@ public class JSONFPlayers extends MemoryFPlayers {
private Map<String, JSONFPlayer> loadCore() { private Map<String, JSONFPlayer> loadCore() {
if (!this.file.exists()) { if (!this.file.exists()) {
return new HashMap<String, JSONFPlayer>(); return new HashMap<>();
} }
String content = DiscUtil.readCatch(this.file); String content = DiscUtil.readCatch(this.file);
@ -91,8 +91,8 @@ public class JSONFPlayers extends MemoryFPlayers {
Map<String, JSONFPlayer> data = this.gson.fromJson(content, new TypeToken<Map<String, JSONFPlayer>>() { Map<String, JSONFPlayer> data = this.gson.fromJson(content, new TypeToken<Map<String, JSONFPlayer>>() {
}.getType()); }.getType());
Set<String> list = new HashSet<String>(); Set<String> list = new HashSet<>();
Set<String> invalidList = new HashSet<String>(); Set<String> invalidList = new HashSet<>();
for (Entry<String, JSONFPlayer> entry : data.entrySet()) { for (Entry<String, JSONFPlayer> entry : data.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
entry.getValue().setId(key); entry.getValue().setId(key);
@ -117,12 +117,12 @@ public class JSONFPlayers extends MemoryFPlayers {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
saveCore(file, (Map<String, JSONFPlayer>) data, true); saveCore(file, data, true);
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath()); Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath());
// Start fetching those UUIDs // 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."); 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<String>(list)); UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list));
try { try {
Map<String, UUID> response = fetcher.call(); Map<String, UUID> response = fetcher.call();
for (String s : list) { 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, "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, ", ")); Bukkit.getLogger().log(Level.INFO, "The following names were detected as being invalid: " + StringUtils.join(invalidList, ", "));
} }
saveCore(this.file, (Map<String, JSONFPlayer>) data, true); // Update the saveCore(this.file, data, true); // Update the
// flatfile // flatfile
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID."); Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
} }
return (Map<String, JSONFPlayer>) data; return data;
} }
private boolean doesKeyNeedMigration(String key) { private boolean doesKeyNeedMigration(String key) {

View File

@ -49,7 +49,7 @@ public class JSONFactions extends MemoryFactions {
} }
public void forceSave(boolean sync) { public void forceSave(boolean sync) {
final Map<String, JSONFaction> entitiesThatShouldBeSaved = new HashMap<String, JSONFaction>(); final Map<String, JSONFaction> entitiesThatShouldBeSaved = new HashMap<>();
for (Faction entity : this.factions.values()) { for (Faction entity : this.factions.values()) {
entitiesThatShouldBeSaved.put(entity.getId(), (JSONFaction) entity); entitiesThatShouldBeSaved.put(entity.getId(), (JSONFaction) entity);
} }
@ -74,7 +74,7 @@ public class JSONFactions extends MemoryFactions {
private Map<String, JSONFaction> loadCore() { private Map<String, JSONFaction> loadCore() {
if (!this.file.exists()) { if (!this.file.exists()) {
return new HashMap<String, JSONFaction>(); return new HashMap<>();
} }
String content = DiscUtil.readCatch(this.file); String content = DiscUtil.readCatch(this.file);
@ -112,7 +112,7 @@ public class JSONFactions extends MemoryFactions {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
saveCore(file, (Map<String, JSONFaction>) data, true); saveCore(file, data, true);
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath()); 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."); 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<String> list = whichKeysNeedMigration(set); Set<String> list = whichKeysNeedMigration(set);
if (list.size() > 0) { if (list.size() > 0) {
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<String>(list)); UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list));
try { try {
Map<String, UUID> response = fetcher.call(); Map<String, UUID> response = fetcher.call();
for (String value : response.keySet()) { for (String value : response.keySet()) {
@ -155,7 +155,7 @@ public class JSONFactions extends MemoryFactions {
Set<String> list = whichKeysNeedMigration(invites); Set<String> list = whichKeysNeedMigration(invites);
if (list.size() > 0) { if (list.size() > 0) {
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<String>(list)); UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list));
try { try {
Map<String, UUID> response = fetcher.call(); Map<String, UUID> response = fetcher.call();
for (String value : response.keySet()) { for (String value : response.keySet()) {
@ -172,14 +172,14 @@ public class JSONFactions extends MemoryFactions {
} }
} }
saveCore(this.file, (Map<String, JSONFaction>) data, true); // Update the flatfile saveCore(this.file, data, true); // Update the flatfile
Bukkit.getLogger().log(Level.INFO, "Done converting factions.json to UUID."); Bukkit.getLogger().log(Level.INFO, "Done converting factions.json to UUID.");
} }
return data; return data;
} }
private Set<String> whichKeysNeedMigration(Set<String> keys) { private Set<String> whichKeysNeedMigration(Set<String> keys) {
HashSet<String> list = new HashSet<String>(); HashSet<String> list = new HashSet<>();
for (String value : keys) { 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}")) { 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.. // Not a valid UUID..
@ -236,8 +236,7 @@ public class JSONFactions extends MemoryFactions {
@Override @Override
public Faction generateFactionObject(String id) { public Faction generateFactionObject(String id) {
Faction faction = new JSONFaction(id); return new JSONFaction(id);
return faction;
} }
@Override @Override

View File

@ -56,7 +56,7 @@ public class DiscUtil {
// CATCH // CATCH
// -------------------------------------------- // // -------------------------------------------- //
private static HashMap<String, Lock> locks = new HashMap<String, Lock>(); private static HashMap<String, Lock> locks = new HashMap<>();
public static boolean writeCatch(final File file, final String content, boolean sync) { public static boolean writeCatch(final File file, final String content, boolean sync) {
String name = file.getName(); String name = file.getName();

View File

@ -12,7 +12,7 @@ import java.util.Map.Entry;
public class PermUtil { public class PermUtil {
public Map<String, String> permissionDescriptions = new HashMap<String, String>(); public Map<String, String> permissionDescriptions = new HashMap<>();
protected MPlugin p; protected MPlugin p;

View File

@ -120,8 +120,7 @@ public class Persist {
} }
try { try {
T instance = p.gson.fromJson(content, clazz); return p.gson.fromJson(content, clazz);
return instance;
} catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely } catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely
p.log(Level.WARNING, ex.getMessage()); p.log(Level.WARNING, ex.getMessage());
} }

View File

@ -236,7 +236,7 @@ public enum TagReplacer {
* @return a list of all the variables with this type * @return a list of all the variables with this type
*/ */
protected static List<TagReplacer> getByType(TagType type) { protected static List<TagReplacer> getByType(TagType type) {
List<TagReplacer> tagReplacers = new ArrayList<TagReplacer>(); List<TagReplacer> tagReplacers = new ArrayList<>();
for (TagReplacer tagReplacer : TagReplacer.values()) { for (TagReplacer tagReplacer : TagReplacer.values()) {
if (type == TagType.FANCY) { if (type == TagType.FANCY) {
if (tagReplacer.type == TagType.FANCY) { if (tagReplacer.type == TagType.FANCY) {

View File

@ -124,7 +124,7 @@ public class TagUtil {
* @return list of fancy messages to send * @return list of fancy messages to send
*/ */
protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) { protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) {
List<FancyMessage> fancyMessages = new ArrayList<FancyMessage>(); List<FancyMessage> fancyMessages = new ArrayList<>();
boolean minimal = P.p.getConfig().getBoolean("minimal-show", false); boolean minimal = P.p.getConfig().getBoolean("minimal-show", false);
switch (type) { switch (type) {
@ -212,7 +212,7 @@ public class TagUtil {
* @return list of tooltips for a fancy message * @return list of tooltips for a fancy message
*/ */
private static List<String> tipFaction(Faction faction) { private static List<String> tipFaction(Faction faction) {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
for (String line : P.p.getConfig().getStringList("tooltips.list")) { for (String line : P.p.getConfig().getStringList("tooltips.list")) {
lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(faction, line))); lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(faction, line)));
} }
@ -227,7 +227,7 @@ public class TagUtil {
* @return list of tooltips for a fancy message * @return list of tooltips for a fancy message
*/ */
private static List<String> tipPlayer(FPlayer fplayer) { private static List<String> tipPlayer(FPlayer fplayer) {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
for (String line : P.p.getConfig().getStringList("tooltips.show")) { for (String line : P.p.getConfig().getStringList("tooltips.show")) {
lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(fplayer, line))); lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(fplayer, line)));
} }

View File

@ -13,7 +13,7 @@ public class TextUtil {
public Map<String, String> tags; public Map<String, String> tags;
public TextUtil() { public TextUtil() {
this.tags = new HashMap<String, String>(); this.tags = new HashMap<>();
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -187,7 +187,7 @@ public class TextUtil {
} }
public ArrayList<String> getPage(List<String> lines, int pageHumanBased, String title) { public ArrayList<String> getPage(List<String> lines, int pageHumanBased, String title) {
ArrayList<String> ret = new ArrayList<String>(); ArrayList<String> ret = new ArrayList<>();
int pageZeroBased = pageHumanBased - 1; int pageZeroBased = pageHumanBased - 1;
int pageheight = 9; int pageheight = 9;
int pagecount = (lines.size() / pageheight) + 1; int pagecount = (lines.size() / pageheight) + 1;

View File

@ -34,7 +34,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
} }
public Map<String, UUID> call() throws Exception { public Map<String, UUID> call() throws Exception {
Map<String, UUID> uuidMap = new HashMap<String, UUID>(); Map<String, UUID> uuidMap = new HashMap<>();
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST); int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) { for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection(); HttpURLConnection connection = createConnection();
@ -95,6 +95,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
} }
public static UUID getUUIDOf(String name) throws Exception { 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);
} }
} }