mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-24 01:27:51 +01:00
Java 7 and make intellij happy
This commit is contained in:
parent
ce132ed033
commit
3b644cd6c3
4
pom.xml
4
pom.xml
@ -28,8 +28,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -10,7 +10,7 @@ import java.util.*;
|
||||
|
||||
public class Conf {
|
||||
|
||||
public static List<String> baseCommandAliases = new ArrayList<String>();
|
||||
public static List<String> baseCommandAliases = new ArrayList<>();
|
||||
public static boolean allowNoSlashCommand = true;
|
||||
|
||||
// Colors
|
||||
@ -145,14 +145,14 @@ public class Conf {
|
||||
public static int actionDeniedPainAmount = 1;
|
||||
|
||||
// commands which will be prevented if the player is a member of a permanent faction
|
||||
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<String>();
|
||||
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<>();
|
||||
|
||||
// commands which will be prevented when in claimed territory of another faction
|
||||
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<String>();
|
||||
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<String>();
|
||||
public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<String>();
|
||||
public static Set<String> warzoneDenyCommands = new LinkedHashSet<String>();
|
||||
public static Set<String> wildernessDenyCommands = new LinkedHashSet<String>();
|
||||
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<>();
|
||||
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<>();
|
||||
public static Set<String> territoryAllyDenyCommands = new LinkedHashSet<>();
|
||||
public static Set<String> warzoneDenyCommands = new LinkedHashSet<>();
|
||||
public static Set<String> wildernessDenyCommands = new LinkedHashSet<>();
|
||||
|
||||
public static boolean territoryDenyBuild = true;
|
||||
public static boolean territoryDenyBuildWhenOffline = true;
|
||||
@ -309,12 +309,12 @@ public class Conf {
|
||||
// If empty all regions are shown.
|
||||
// Specify Faction either by name or UUID.
|
||||
// To show all regions on a given world, add 'world:<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.
|
||||
// Specify Faction either by name or UUID.
|
||||
// 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
|
||||
public static final transient String DYNMAP_STYLE_LINE_COLOR = "#00FF00";
|
||||
@ -349,12 +349,12 @@ public class Conf {
|
||||
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
||||
|
||||
// mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
|
||||
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
|
||||
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<>();
|
||||
|
||||
public static Set<String> worldsNoClaiming = new LinkedHashSet<String>();
|
||||
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
|
||||
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
|
||||
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
|
||||
public static Set<String> worldsNoClaiming = new LinkedHashSet<>();
|
||||
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<>();
|
||||
public static Set<String> worldsIgnorePvP = new LinkedHashSet<>();
|
||||
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<>();
|
||||
|
||||
// faction-<factionId>
|
||||
public static String vaultPrefix = "faction-%s";
|
||||
|
@ -192,7 +192,7 @@ public class FLocation implements Serializable {
|
||||
public Set<FLocation> getCircle(double radius) {
|
||||
double radiusSquared = radius * radius;
|
||||
|
||||
Set<FLocation> ret = new LinkedHashSet<FLocation>();
|
||||
Set<FLocation> ret = new LinkedHashSet<>();
|
||||
if (radius <= 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -215,7 +215,7 @@ public class FLocation implements Serializable {
|
||||
}
|
||||
|
||||
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 z : MiscUtil.range(from.getZ(), to.getZ())) {
|
||||
|
@ -299,7 +299,7 @@ public class P extends MPlugin {
|
||||
|
||||
// Get a list of all players in the specified faction
|
||||
public Set<String> getPlayersInFaction(String factionTag) {
|
||||
Set<String> players = new HashSet<String>();
|
||||
Set<String> players = new HashSet<>();
|
||||
Faction faction = Factions.getInstance().getByTag(factionTag);
|
||||
if (faction != null) {
|
||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||
@ -311,7 +311,7 @@ public class P extends MPlugin {
|
||||
|
||||
// Get a list of all online players in the specified faction
|
||||
public Set<String> getOnlinePlayersInFaction(String factionTag) {
|
||||
Set<String> players = new HashSet<String>();
|
||||
Set<String> players = new HashSet<>();
|
||||
Faction faction = Factions.getInstance().getByTag(factionTag);
|
||||
if (faction != null) {
|
||||
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) {
|
||||
|
@ -27,7 +27,7 @@ public class CmdAutoHelp extends MCommand<P> {
|
||||
}
|
||||
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
||||
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
|
||||
lines.addAll(pcmd.helpLong);
|
||||
|
||||
|
@ -16,7 +16,7 @@ import java.util.Set;
|
||||
|
||||
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() {
|
||||
super();
|
||||
@ -41,8 +41,8 @@ public class CmdConfig extends FCommand {
|
||||
// that way, if the person using this command messes up the capitalization, we can fix that
|
||||
if (properFieldNames.isEmpty()) {
|
||||
Field[] fields = Conf.class.getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
|
||||
for (Field field : fields) {
|
||||
properFieldNames.put(field.getName().toLowerCase(), field.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,9 +59,9 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
String success;
|
||||
|
||||
String value = args.get(1);
|
||||
StringBuilder value = new StringBuilder(args.get(1));
|
||||
for (int i = 2; i < args.size(); i++) {
|
||||
value += ' ' + args.get(i);
|
||||
value.append(' ').append(args.get(i));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -69,7 +69,7 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
// boolean
|
||||
if (target.getType() == boolean.class) {
|
||||
boolean targetValue = this.strAsBool(value);
|
||||
boolean targetValue = this.strAsBool(value.toString());
|
||||
target.setBoolean(null, targetValue);
|
||||
|
||||
if (targetValue) {
|
||||
@ -82,7 +82,7 @@ public class CmdConfig extends FCommand {
|
||||
// int
|
||||
else if (target.getType() == int.class) {
|
||||
try {
|
||||
int intVal = Integer.parseInt(value);
|
||||
int intVal = Integer.parseInt(value.toString());
|
||||
target.setInt(null, intVal);
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + intVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -94,7 +94,7 @@ public class CmdConfig extends FCommand {
|
||||
// long
|
||||
else if (target.getType() == long.class) {
|
||||
try {
|
||||
long longVal = Long.parseLong(value);
|
||||
long longVal = Long.parseLong(value.toString());
|
||||
target.setLong(null, longVal);
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + longVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -106,7 +106,7 @@ public class CmdConfig extends FCommand {
|
||||
// double
|
||||
else if (target.getType() == double.class) {
|
||||
try {
|
||||
double doubleVal = Double.parseDouble(value);
|
||||
double doubleVal = Double.parseDouble(value.toString());
|
||||
target.setDouble(null, doubleVal);
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + doubleVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -118,7 +118,7 @@ public class CmdConfig extends FCommand {
|
||||
// float
|
||||
else if (target.getType() == float.class) {
|
||||
try {
|
||||
float floatVal = Float.parseFloat(value);
|
||||
float floatVal = Float.parseFloat(value.toString());
|
||||
target.setFloat(null, floatVal);
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + floatVal + ".";
|
||||
} catch (NumberFormatException ex) {
|
||||
@ -129,7 +129,7 @@ public class CmdConfig extends FCommand {
|
||||
|
||||
// String
|
||||
else if (target.getType() == String.class) {
|
||||
target.set(null, value);
|
||||
target.set(null, value.toString());
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_OPTIONSET.toString() + value + "\".";
|
||||
}
|
||||
|
||||
@ -137,16 +137,16 @@ public class CmdConfig extends FCommand {
|
||||
else if (target.getType() == ChatColor.class) {
|
||||
ChatColor newColor = null;
|
||||
try {
|
||||
newColor = ChatColor.valueOf(value.toUpperCase());
|
||||
newColor = ChatColor.valueOf(value.toString().toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
}
|
||||
if (newColor == null) {
|
||||
sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toUpperCase()));
|
||||
sendMessage(TL.COMMAND_CONFIG_INVALID_COLOUR.format(fieldName, value.toString().toUpperCase()));
|
||||
return;
|
||||
}
|
||||
target.set(null, newColor);
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toUpperCase() + "\".";
|
||||
success = "\"" + fieldName + TL.COMMAND_CONFIG_COLOURSET.toString() + value.toString().toUpperCase() + "\".";
|
||||
}
|
||||
|
||||
// Set<?> or other parameterized collection
|
||||
@ -164,12 +164,12 @@ public class CmdConfig extends FCommand {
|
||||
else if (innerType == Material.class) {
|
||||
Material newMat = null;
|
||||
try {
|
||||
newMat = Material.valueOf(value.toUpperCase());
|
||||
newMat = Material.valueOf(value.toString().toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
}
|
||||
if (newMat == null) {
|
||||
sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toUpperCase()));
|
||||
sendMessage(TL.COMMAND_CONFIG_INVALID_MATERIAL.format(fieldName, value.toString().toUpperCase()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -179,13 +179,13 @@ public class CmdConfig extends FCommand {
|
||||
if (matSet.contains(newMat)) {
|
||||
matSet.remove(newMat);
|
||||
target.set(null, matSet);
|
||||
success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toUpperCase());
|
||||
success = TL.COMMAND_CONFIG_MATERIAL_REMOVED.format(fieldName, value.toString().toUpperCase());
|
||||
}
|
||||
// Material not present yet, add it
|
||||
else {
|
||||
matSet.add(newMat);
|
||||
target.set(null, matSet);
|
||||
success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toUpperCase());
|
||||
success = TL.COMMAND_CONFIG_MATERIAL_ADDED.format(fieldName, value.toString().toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,16 +194,16 @@ public class CmdConfig extends FCommand {
|
||||
@SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) target.get(null);
|
||||
|
||||
// String already present, so remove it
|
||||
if (stringSet.contains(value)) {
|
||||
stringSet.remove(value);
|
||||
if (stringSet.contains(value.toString())) {
|
||||
stringSet.remove(value.toString());
|
||||
target.set(null, stringSet);
|
||||
success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value);
|
||||
success = TL.COMMAND_CONFIG_SET_REMOVED.format(fieldName, value.toString());
|
||||
}
|
||||
// String not present yet, add it
|
||||
else {
|
||||
stringSet.add(value);
|
||||
stringSet.add(value.toString());
|
||||
target.set(null, stringSet);
|
||||
success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value);
|
||||
success = TL.COMMAND_CONFIG_SET_ADDED.format(fieldName, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ public class CmdConfig extends FCommand {
|
||||
sendMessage(TL.COMMAND_CONFIG_ERROR_MATCHING.format(fieldName));
|
||||
return;
|
||||
} catch (IllegalAccessException ex) {
|
||||
sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value));
|
||||
sendMessage(TL.COMMAND_CONFIG_ERROR_SETTING.format(fieldName, value.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class CmdDisband extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
||||
boolean isMyFaction = fme != null && faction == myFaction;
|
||||
|
||||
if (isMyFaction) {
|
||||
if (!assertMinRole(Role.ADMIN)) {
|
||||
|
@ -53,7 +53,7 @@ public class CmdHelp extends FCommand {
|
||||
ConfigurationSection help = P.p.getConfig().getConfigurationSection("help");
|
||||
if (help == null) {
|
||||
help = P.p.getConfig().createSection("help"); // create new help section
|
||||
List<String> error = new ArrayList<String>();
|
||||
List<String> error = new ArrayList<>();
|
||||
error.add("&cUpdate help messages in config.yml!");
|
||||
error.add("&cSet use-old-help for legacy help messages");
|
||||
help.set("'1'", error); // add default error messages
|
||||
@ -76,10 +76,10 @@ public class CmdHelp extends FCommand {
|
||||
public ArrayList<ArrayList<String>> helpPages;
|
||||
|
||||
public void updateHelp() {
|
||||
helpPages = new ArrayList<ArrayList<String>>();
|
||||
helpPages = new ArrayList<>();
|
||||
ArrayList<String> pageLines;
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true));
|
||||
@ -92,7 +92,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString()));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
|
||||
@ -105,7 +105,7 @@ public class CmdHelp extends FCommand {
|
||||
helpPages.add(pageLines);
|
||||
|
||||
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add("");
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_1.toString()));
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_BANK_2.toString()));
|
||||
@ -118,7 +118,7 @@ public class CmdHelp extends FCommand {
|
||||
helpPages.add(pageLines);
|
||||
}
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true));
|
||||
@ -133,7 +133,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PLAYERTITLES.toString()));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true));
|
||||
@ -143,7 +143,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_OWNERSHIP_3.toString()));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
|
||||
pageLines.add("");
|
||||
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
|
||||
@ -155,7 +155,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_4.toString()));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_5.toString()));
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_6.toString()));
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_7.toString()));
|
||||
@ -167,7 +167,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_RELATIONS_13.toString()));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_1.toString()));
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_2.toString()));
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_3.toString()));
|
||||
@ -179,7 +179,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_PERMISSIONS_9.toString()));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(TL.COMMAND_HELP_MOAR_1.toString());
|
||||
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_ADMIN_1.toString()));
|
||||
@ -192,7 +192,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_2.toString()));
|
||||
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true));
|
||||
@ -201,7 +201,7 @@ public class CmdHelp extends FCommand {
|
||||
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true));
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines = new ArrayList<>();
|
||||
pageLines.add(p.txt.parse(TL.COMMAND_HELP_MOAR_3.toString()));
|
||||
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
|
||||
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));
|
||||
|
@ -116,7 +116,7 @@ public class CmdHome extends FCommand {
|
||||
public void run() {
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<Location>();
|
||||
List<Location> smokeLocations = new ArrayList<>();
|
||||
smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0));
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome());
|
||||
|
@ -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());
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
public class CmdShow extends FCommand {
|
||||
|
||||
List<String> defaults = new ArrayList<String>();
|
||||
List<String> defaults = new ArrayList<>();
|
||||
|
||||
public CmdShow() {
|
||||
this.aliases.add("show");
|
||||
|
@ -25,7 +25,7 @@ public class CmdStatus extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
for (FPlayer fp : myFaction.getFPlayers()) {
|
||||
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
|
||||
String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
||||
|
@ -140,7 +140,7 @@ public class CmdTop extends FCommand {
|
||||
msg(TL.COMMAND_TOP_INVALID, criteria);
|
||||
}
|
||||
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
|
||||
final int pageheight = 9;
|
||||
int pagenumber = this.argAsInt(1, 1);
|
||||
|
@ -8,8 +8,6 @@ import com.drtshock.playervaults.vaultmanagement.VaultViewInfo;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -34,10 +34,7 @@ public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean c) {
|
||||
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
|
||||
cancelled = false; // Don't let them cancel factions disbanding.
|
||||
} else {
|
||||
cancelled = c;
|
||||
}
|
||||
// Don't let them cancel factions disbanding.
|
||||
cancelled = reason != PlayerLeaveReason.DISBAND && reason != PlayerLeaveReason.RESET && c;
|
||||
}
|
||||
}
|
@ -207,7 +207,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static Set<FPlayer> getFplayers(EconomyParticipator ep) {
|
||||
Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
||||
Set<FPlayer> fplayers = new HashSet<>();
|
||||
|
||||
if (ep != null) {
|
||||
if (ep instanceof FPlayer) {
|
||||
@ -221,7 +221,7 @@ public class Econ {
|
||||
}
|
||||
|
||||
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
|
||||
Set<FPlayer> recipients = new HashSet<FPlayer>();
|
||||
Set<FPlayer> recipients = new HashSet<>();
|
||||
recipients.addAll(getFplayers(invoker));
|
||||
recipients.addAll(getFplayers(from));
|
||||
recipients.addAll(getFplayers(to));
|
||||
|
@ -38,9 +38,6 @@ public class Essentials {
|
||||
}
|
||||
|
||||
public static boolean isVanished(Player player) {
|
||||
if (essentials == null) {
|
||||
return false;
|
||||
}
|
||||
return essentials.getUser(player).isVanished();
|
||||
return essentials != null && essentials.getUser(player).isVanished();
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,7 @@ public class Worldguard {
|
||||
World world = loc.getWorld();
|
||||
Vector pt = toVector(loc);
|
||||
|
||||
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) {
|
||||
return wg.canBuild(player, loc);
|
||||
}
|
||||
return false;
|
||||
return wg.getRegionManager(world).getApplicableRegions(pt).size() > 0 && wg.canBuild(player, loc);
|
||||
}
|
||||
|
||||
// Check for Regions in chunk the chunk
|
||||
@ -125,17 +122,13 @@ public class Worldguard {
|
||||
RegionManager regionManager = wg.getRegionManager(world);
|
||||
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
||||
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
||||
Collection<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
||||
Collection<ProtectedRegion> allregionslist = new ArrayList<>(allregions.values());
|
||||
List<ProtectedRegion> overlaps;
|
||||
boolean foundregions = false;
|
||||
|
||||
try {
|
||||
overlaps = region.getIntersectingRegions(allregionslist);
|
||||
if (overlaps == null || overlaps.isEmpty()) {
|
||||
foundregions = false;
|
||||
} else {
|
||||
foundregions = true;
|
||||
}
|
||||
foundregions = overlaps != null && !overlaps.isEmpty();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class EngineDynmap {
|
||||
|
||||
// Thread Safe / Asynchronous: Yes
|
||||
public Map<String, TempMarker> createHomes() {
|
||||
Map<String, TempMarker> ret = new HashMap<String, TempMarker>();
|
||||
Map<String, TempMarker> ret = new HashMap<>();
|
||||
|
||||
// Loop current factions
|
||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||
@ -176,7 +176,7 @@ public class EngineDynmap {
|
||||
// This method places out the faction home markers into the factions markerset.
|
||||
public void updateHomes(Map<String, TempMarker> homes) {
|
||||
// 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()) {
|
||||
markers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
@ -220,7 +220,7 @@ public class EngineDynmap {
|
||||
// Thread Safe: YES
|
||||
public Map<String, Map<Faction, Set<FLocation>>> createWorldFactionChunks() {
|
||||
// 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.
|
||||
MemoryBoard board = (MemoryBoard) Board.getInstance();
|
||||
@ -231,13 +231,13 @@ public class EngineDynmap {
|
||||
|
||||
Map<Faction, Set<FLocation>> factionChunks = worldFactionChunks.get(world);
|
||||
if (factionChunks == null) {
|
||||
factionChunks = new HashMap<Faction, Set<FLocation>>();
|
||||
factionChunks = new HashMap<>();
|
||||
worldFactionChunks.put(world, factionChunks);
|
||||
}
|
||||
|
||||
Set<FLocation> factionTerritory = factionChunks.get(chunkOwner);
|
||||
if (factionTerritory == null) {
|
||||
factionTerritory = new HashSet<FLocation>();
|
||||
factionTerritory = new HashSet<>();
|
||||
factionChunks.put(chunkOwner, factionTerritory);
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ public class EngineDynmap {
|
||||
|
||||
// Thread Safe: YES
|
||||
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 (Entry<String, Map<Faction, Set<FLocation>>> entry : worldFactionChunks.entrySet()) {
|
||||
@ -272,7 +272,7 @@ public class EngineDynmap {
|
||||
// Handle specific faction on specific world
|
||||
// "handle faction on world"
|
||||
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 (!isVisible(faction, world)) {
|
||||
@ -295,7 +295,7 @@ public class EngineDynmap {
|
||||
|
||||
// Loop through chunks: set flags on chunk map
|
||||
TileFlags allChunkFlags = new TileFlags();
|
||||
LinkedList<FLocation> allChunks = new LinkedList<FLocation>();
|
||||
LinkedList<FLocation> allChunks = new LinkedList<>();
|
||||
for (FLocation chunk : chunks) {
|
||||
allChunkFlags.setFlag((int) chunk.getX(), (int) chunk.getZ(), true); // Set flag for chunk
|
||||
allChunks.addLast(chunk);
|
||||
@ -316,7 +316,7 @@ public class EngineDynmap {
|
||||
// If we need to start shape, and this block is not part of one yet
|
||||
if (ourChunkFlags == null && allChunkFlags.getFlag(chunkX, chunkZ)) {
|
||||
ourChunkFlags = new TileFlags(); // Create map for shape
|
||||
ourChunks = new LinkedList<FLocation>();
|
||||
ourChunks = new LinkedList<>();
|
||||
floodFillTarget(allChunkFlags, ourChunkFlags, chunkX, chunkZ); // Copy shape
|
||||
ourChunks.add(chunk); // Add it to our chunk list
|
||||
minimumX = chunkX;
|
||||
@ -335,7 +335,7 @@ public class EngineDynmap {
|
||||
// Else, keep it in the list for the next polygon
|
||||
else {
|
||||
if (newChunks == null) {
|
||||
newChunks = new LinkedList<FLocation>();
|
||||
newChunks = new LinkedList<>();
|
||||
}
|
||||
newChunks.add(chunk);
|
||||
}
|
||||
@ -354,7 +354,7 @@ public class EngineDynmap {
|
||||
int currentX = minimumX;
|
||||
int currentZ = minimumZ;
|
||||
Direction direction = Direction.XPLUS;
|
||||
ArrayList<int[]> linelist = new ArrayList<int[]>();
|
||||
ArrayList<int[]> linelist = new ArrayList<>();
|
||||
linelist.add(new int[]{initialX, initialZ}); // Add start point
|
||||
while ((currentX != initialX) || (currentZ != initialZ) || (direction != Direction.ZMINUS)) {
|
||||
switch (direction) {
|
||||
@ -452,7 +452,7 @@ public class EngineDynmap {
|
||||
// Thread Safe: NO
|
||||
public void updateAreas(Map<String, TempAreaMarker> areas) {
|
||||
// Map Current
|
||||
Map<String, AreaMarker> markers = new HashMap<String, AreaMarker>();
|
||||
Map<String, AreaMarker> markers = new HashMap<>();
|
||||
for (AreaMarker marker : this.markerset.getAreaMarkers()) {
|
||||
markers.put(marker.getMarkerID(), marker);
|
||||
}
|
||||
@ -510,7 +510,7 @@ public class EngineDynmap {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<String> ret = new HashSet<String>();
|
||||
Set<String> ret = new HashSet<>();
|
||||
|
||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||
// NOTE: We add both UUID and name. This might be a good idea for future proofing.
|
||||
@ -527,7 +527,7 @@ public class EngineDynmap {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, Set<String>> ret = new HashMap<String, Set<String>>();
|
||||
Map<String, Set<String>> ret = new HashMap<>();
|
||||
|
||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||
String playersetId = createPlayersetId(faction);
|
||||
@ -654,14 +654,14 @@ public class EngineDynmap {
|
||||
}
|
||||
|
||||
public static String getHtmlPlayerString(Collection<FPlayer> playersOfficersList) {
|
||||
String ret = "";
|
||||
StringBuilder ret = new StringBuilder();
|
||||
for (FPlayer fplayer : playersOfficersList) {
|
||||
if (ret.length() > 0) {
|
||||
ret += ", ";
|
||||
ret.append(", ");
|
||||
}
|
||||
ret += getHtmlPlayerName(fplayer);
|
||||
ret.append(getHtmlPlayerName(fplayer));
|
||||
}
|
||||
return ret;
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public static String getHtmlPlayerName(FPlayer fplayer) {
|
||||
@ -707,11 +707,7 @@ public class EngineDynmap {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hidden.contains(factionId) || hidden.contains(factionName) || hidden.contains("world:" + world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !hidden.contains(factionId) && !hidden.contains(factionName) && !hidden.contains("world:" + world);
|
||||
}
|
||||
|
||||
// Thread Safe / Asynchronous: Yes
|
||||
@ -750,7 +746,7 @@ public class EngineDynmap {
|
||||
// Find all contiguous blocks, set in target and clear in source
|
||||
private int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
|
||||
int cnt = 0;
|
||||
ArrayDeque<int[]> stack = new ArrayDeque<int[]>();
|
||||
ArrayDeque<int[]> stack = new ArrayDeque<>();
|
||||
stack.push(new int[]{x, y});
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
|
@ -91,7 +91,6 @@ public class FactionsBlockListener implements Listener {
|
||||
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -126,7 +125,6 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
if (!canPistonMoveBlock(pistonFaction, targetLoc)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,32 +159,19 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
|
||||
if (otherFaction.isWilderness()) {
|
||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) {
|
||||
return true;
|
||||
}
|
||||
return !Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName());
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isSafeZone()) {
|
||||
if (!Conf.safeZoneDenyBuild) {
|
||||
return true;
|
||||
}
|
||||
return !Conf.safeZoneDenyBuild;
|
||||
|
||||
return false;
|
||||
} else if (otherFaction.isWarZone()) {
|
||||
if (!Conf.warZoneDenyBuild) {
|
||||
return true;
|
||||
}
|
||||
return !Conf.warZoneDenyBuild;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||
|
||||
if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
|
||||
}
|
||||
|
||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||
|
@ -177,7 +177,7 @@ public class FactionsEntityListener implements Listener {
|
||||
Block center = loc.getBlock();
|
||||
if (center.isLiquid()) {
|
||||
// a single surrounding block in all 6 directions is broken if the material is weak enough
|
||||
List<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, 1, 0));
|
||||
@ -202,10 +202,9 @@ public class FactionsEntityListener implements Listener {
|
||||
if (!this.canDamagerHurtDamagee(sub, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
sub = null;
|
||||
}
|
||||
|
||||
private static final Set<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)
|
||||
public void onPotionSplashEvent(PotionSplashEvent event) {
|
||||
@ -236,14 +235,11 @@ public class FactionsEntityListener implements Listener {
|
||||
}
|
||||
|
||||
// scan through affected entities to make sure they're all valid targets
|
||||
Iterator<LivingEntity> iter = event.getAffectedEntities().iterator();
|
||||
while (iter.hasNext()) {
|
||||
LivingEntity target = iter.next();
|
||||
for (LivingEntity target : event.getAffectedEntities()) {
|
||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works
|
||||
}
|
||||
sub = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,10 +247,7 @@ public class FactionsEntityListener implements Listener {
|
||||
if (!(damagee instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
if (Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Board.getInstance().getFactionAt(new FLocation(damagee.getLocation())).isSafeZone();
|
||||
}
|
||||
|
||||
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {
|
||||
|
@ -135,7 +135,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// 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)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
@ -270,7 +270,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
|
||||
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
|
||||
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<String, InteractAttemptSpam>();
|
||||
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<>();
|
||||
|
||||
private static class InteractAttemptSpam {
|
||||
private int attempts = 0;
|
||||
@ -470,7 +470,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,7 +480,6 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class BufferedObjective {
|
||||
private final String baseName;
|
||||
|
||||
private Objective current;
|
||||
private List<Team> currentTeams = new ArrayList<Team>();
|
||||
private List<Team> currentTeams = new ArrayList<>();
|
||||
private String title;
|
||||
private DisplaySlot displaySlot;
|
||||
|
||||
@ -26,7 +26,7 @@ public class BufferedObjective {
|
||||
private int teamPtr;
|
||||
private boolean requiresUpdate = false;
|
||||
|
||||
private final Map<Integer, String> contents = new HashMap<Integer, String>();
|
||||
private final Map<Integer, String> contents = new HashMap<>();
|
||||
|
||||
static {
|
||||
// Check for long line support.
|
||||
@ -113,7 +113,7 @@ public class BufferedObjective {
|
||||
Objective buffer = scoreboard.registerNewObjective(getNextObjectiveName(), "dummy");
|
||||
buffer.setDisplayName(title);
|
||||
|
||||
List<Team> bufferTeams = new ArrayList<Team>();
|
||||
List<Team> bufferTeams = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<Integer, String> entry : contents.entrySet()) {
|
||||
if (entry.getValue().length() > 16) {
|
||||
|
@ -13,7 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 FPlayer fplayer;
|
||||
|
@ -10,15 +10,15 @@ import org.bukkit.scoreboard.Team;
|
||||
import java.util.*;
|
||||
|
||||
public class FTeamWrapper {
|
||||
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<Faction, FTeamWrapper>();
|
||||
private static final List<FScoreboard> tracking = new ArrayList<FScoreboard>();
|
||||
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<>();
|
||||
private static final List<FScoreboard> tracking = new ArrayList<>();
|
||||
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 Faction faction;
|
||||
private final Set<OfflinePlayer> members = new HashSet<OfflinePlayer>();
|
||||
private final Set<OfflinePlayer> members = new HashSet<>();
|
||||
|
||||
public static void applyUpdatesLater(final Faction faction) {
|
||||
if (!FScoreboard.isSupportedByServer()) {
|
||||
@ -194,7 +194,7 @@ public class FTeamWrapper {
|
||||
}
|
||||
|
||||
private Set<OfflinePlayer> getPlayers() {
|
||||
return new HashSet<OfflinePlayer>(this.members);
|
||||
return new HashSet<>(this.members);
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
|
@ -29,7 +29,7 @@ public class FDefaultSidebar extends FSidebarProvider {
|
||||
List<String> lines = P.p.getConfig().getStringList(list);
|
||||
|
||||
if (lines == null || lines.isEmpty()) {
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
ListIterator<String> it = lines.listIterator();
|
||||
|
@ -11,7 +11,7 @@ public enum ChatMode {
|
||||
public final int value;
|
||||
public final TL nicename;
|
||||
|
||||
private ChatMode(final int value, final TL nicename) {
|
||||
ChatMode(final int value, final TL nicename) {
|
||||
this.value = value;
|
||||
this.nicename = nicename;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public enum Relation {
|
||||
public final int value;
|
||||
public final String nicename;
|
||||
|
||||
private Relation(final int value, final String nicename) {
|
||||
Relation(final int value, final String nicename) {
|
||||
this.value = value;
|
||||
this.nicename = nicename;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public enum Role {
|
||||
public final String nicename;
|
||||
public final TL translation;
|
||||
|
||||
private Role(final int value, final TL translation) {
|
||||
Role(final int value, final TL translation) {
|
||||
this.value = value;
|
||||
this.nicename = translation.toString();
|
||||
this.translation = translation;
|
||||
|
@ -20,7 +20,7 @@ public class AsciiCompass {
|
||||
|
||||
public final char asciiChar;
|
||||
|
||||
private Point(final char asciiChar) {
|
||||
Point(final char asciiChar) {
|
||||
this.asciiChar = asciiChar;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class AsciiCompass {
|
||||
}
|
||||
|
||||
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
String row;
|
||||
|
||||
row = "";
|
||||
|
@ -15,8 +15,8 @@ import java.util.Map;
|
||||
|
||||
public final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
|
||||
|
||||
private final Map<String, T> nameToConstant = new HashMap<String, T>();
|
||||
private final Map<T, String> constantToName = new HashMap<T, String>();
|
||||
private final Map<String, T> nameToConstant = new HashMap<>();
|
||||
private final Map<T, String> constantToName = new HashMap<>();
|
||||
|
||||
public EnumTypeAdapter(Class<T> classOfT) {
|
||||
try {
|
||||
|
@ -24,7 +24,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>();
|
||||
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<>();
|
||||
Set<String> nameSet;
|
||||
Iterator<JsonElement> iter;
|
||||
String worldName;
|
||||
@ -38,7 +38,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
||||
x = Integer.parseInt(coords[0]);
|
||||
z = Integer.parseInt(coords[1]);
|
||||
|
||||
nameSet = new HashSet<String>();
|
||||
nameSet = new HashSet<>();
|
||||
iter = entry2.getValue().getAsJsonArray().iterator();
|
||||
while (iter.hasNext()) {
|
||||
nameSet.add(iter.next().getAsString());
|
||||
|
@ -45,24 +45,24 @@ public class MiscUtil {
|
||||
}
|
||||
|
||||
/// 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) {
|
||||
String ret = "";
|
||||
StringBuilder ret = new StringBuilder();
|
||||
|
||||
str = ChatColor.stripColor(str);
|
||||
str = str.toLowerCase();
|
||||
|
||||
for (char c : str.toCharArray()) {
|
||||
if (substanceChars.contains(String.valueOf(c))) {
|
||||
ret += c;
|
||||
ret.append(c);
|
||||
}
|
||||
}
|
||||
return ret.toLowerCase();
|
||||
return ret.toString().toLowerCase();
|
||||
}
|
||||
|
||||
public static ArrayList<String> validateTag(String str) {
|
||||
ArrayList<String> errors = new ArrayList<String>();
|
||||
ArrayList<String> errors = new ArrayList<>();
|
||||
|
||||
if (getComparisonString(str).length() < Conf.factionTagLengthMin) {
|
||||
errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin));
|
||||
@ -82,9 +82,9 @@ public class MiscUtil {
|
||||
}
|
||||
|
||||
public static Iterable<FPlayer> rankOrder(Iterable<FPlayer> players) {
|
||||
List<FPlayer> admins = new ArrayList<FPlayer>();
|
||||
List<FPlayer> moderators = new ArrayList<FPlayer>();
|
||||
List<FPlayer> normal = new ArrayList<FPlayer>();
|
||||
List<FPlayer> admins = new ArrayList<>();
|
||||
List<FPlayer> moderators = new ArrayList<>();
|
||||
List<FPlayer> normal = new ArrayList<>();
|
||||
|
||||
for (FPlayer player : players) {
|
||||
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(moderators);
|
||||
ret.addAll(normal);
|
||||
|
@ -9,7 +9,7 @@ import java.util.Map.Entry;
|
||||
|
||||
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) {
|
||||
return getPlayerLocations(player.getUniqueId());
|
||||
@ -18,7 +18,7 @@ public class VisualizeUtil {
|
||||
public static Set<Location> getPlayerLocations(UUID uuid) {
|
||||
Set<Location> ret = playerLocations.get(uuid);
|
||||
if (ret == null) {
|
||||
ret = new HashSet<Location>();
|
||||
ret = new HashSet<>();
|
||||
playerLocations.put(uuid, ret);
|
||||
}
|
||||
return ret;
|
||||
|
@ -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 boolean senderIsConsole;
|
||||
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) {
|
||||
this.p = p;
|
||||
@ -82,14 +82,14 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
this.allowNoSlashAccess = false;
|
||||
|
||||
this.subCommands = new ArrayList<MCommand<?>>();
|
||||
this.aliases = new ArrayList<String>();
|
||||
this.subCommands = new ArrayList<>();
|
||||
this.aliases = new ArrayList<>();
|
||||
|
||||
this.requiredArgs = new ArrayList<String>();
|
||||
this.optionalArgs = new LinkedHashMap<String, String>();
|
||||
this.requiredArgs = new ArrayList<>();
|
||||
this.optionalArgs = new LinkedHashMap<>();
|
||||
|
||||
this.helpShort = null;
|
||||
this.helpLong = new ArrayList<String>();
|
||||
this.helpLong = new ArrayList<>();
|
||||
this.visibility = CommandVisibility.VISIBLE;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
|
||||
ret.append(TextUtil.implode(this.aliases, ","));
|
||||
|
||||
List<String> args = new ArrayList<String>();
|
||||
List<String> args = new ArrayList<>();
|
||||
|
||||
for (String requiredArg : this.requiredArgs) {
|
||||
args.add("<" + requiredArg + ">");
|
||||
@ -280,7 +280,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
}
|
||||
|
||||
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")) {
|
||||
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFPlayerTags(s, player)));
|
||||
}
|
||||
@ -288,7 +288,7 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
}
|
||||
|
||||
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")) {
|
||||
lines.add(ChatColor.translateAlternateColorCodes('&', replaceFactionTags(s, faction)));
|
||||
}
|
||||
|
@ -52,17 +52,17 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
private MPluginSecretPlayerListener mPluginSecretPlayerListener;
|
||||
|
||||
// Our stored base commands
|
||||
private List<MCommand<?>> baseCommands = new ArrayList<MCommand<?>>();
|
||||
private List<MCommand<?>> baseCommands = new ArrayList<>();
|
||||
|
||||
public List<MCommand<?>> getBaseCommands() {
|
||||
return this.baseCommands;
|
||||
}
|
||||
|
||||
// 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
|
||||
public Map<UUID, Integer> stuckMap = new HashMap<UUID, Integer>();
|
||||
public Map<UUID, Integer> stuckMap = new HashMap<>();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ENABLE
|
||||
@ -214,7 +214,7 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
|
||||
// These are not supposed to be used directly.
|
||||
// They are loaded and used through the TextUtil instance for the plugin.
|
||||
public Map<String, String> rawTags = new LinkedHashMap<String, String>();
|
||||
public Map<String, String> rawTags = new LinkedHashMap<>();
|
||||
|
||||
public void addRawTags() {
|
||||
this.rawTags.put("l", "<green>"); // logo
|
||||
@ -277,7 +277,7 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (testOnly) {
|
||||
|
@ -104,10 +104,8 @@ public abstract class MemoryBoard extends Board {
|
||||
}
|
||||
|
||||
public Set<FLocation> getAllClaims(String factionId) {
|
||||
Set<FLocation> locs = new HashSet<FLocation>();
|
||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<FLocation, String> entry = iter.next();
|
||||
Set<FLocation> locs = new HashSet<>();
|
||||
for (Entry<FLocation, String> entry : flocationIds.entrySet()) {
|
||||
if (entry.getValue().equals(factionId)) {
|
||||
locs.add(entry.getKey());
|
||||
}
|
||||
@ -227,9 +225,7 @@ public abstract class MemoryBoard extends Board {
|
||||
public int getFactionCoordCountInWorld(Faction faction, String worldName) {
|
||||
String factionId = faction.getId();
|
||||
int ret = 0;
|
||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<FLocation, String> entry = iter.next();
|
||||
for (Entry<FLocation, String> entry : flocationIds.entrySet()) {
|
||||
if (entry.getValue().equals(factionId) && entry.getKey().getWorldName().equals(worldName)) {
|
||||
ret += 1;
|
||||
}
|
||||
@ -246,7 +242,7 @@ public abstract class MemoryBoard extends Board {
|
||||
* of decreasing z
|
||||
*/
|
||||
public ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
Faction factionLoc = getFactionAt(flocation);
|
||||
ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction)));
|
||||
|
||||
@ -260,26 +256,26 @@ public abstract class MemoryBoard extends Board {
|
||||
height--;
|
||||
}
|
||||
|
||||
Map<String, Character> fList = new HashMap<String, Character>();
|
||||
Map<String, Character> fList = new HashMap<>();
|
||||
int chrIdx = 0;
|
||||
|
||||
// For each row
|
||||
for (int dz = 0; dz < height; dz++) {
|
||||
// Draw and add that row
|
||||
String row = "";
|
||||
StringBuilder row = new StringBuilder();
|
||||
for (int dx = 0; dx < width; dx++) {
|
||||
if (dx == halfWidth && dz == halfHeight) {
|
||||
row += ChatColor.AQUA + "+";
|
||||
row.append(ChatColor.AQUA + "+");
|
||||
} else {
|
||||
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
||||
Faction factionHere = getFactionAt(flocationHere);
|
||||
Relation relation = faction.getRelationTo(factionHere);
|
||||
if (factionHere.isWilderness()) {
|
||||
row += ChatColor.GRAY + "-";
|
||||
row.append(ChatColor.GRAY + "-");
|
||||
} else if (factionHere.isSafeZone()) {
|
||||
row += Conf.colorPeaceful + "+";
|
||||
row.append(Conf.colorPeaceful).append("+");
|
||||
} else if (factionHere.isWarZone()) {
|
||||
row += ChatColor.DARK_RED + "+";
|
||||
row.append(ChatColor.DARK_RED + "+");
|
||||
} else if (factionHere == faction ||
|
||||
factionHere == factionLoc ||
|
||||
relation.isAtLeast(Relation.ALLY) ||
|
||||
@ -289,13 +285,13 @@ public abstract class MemoryBoard extends Board {
|
||||
fList.put(factionHere.getTag(), Conf.mapKeyChrs[Math.min(chrIdx++, Conf.mapKeyChrs.length - 1)]);
|
||||
}
|
||||
char tag = fList.get(factionHere.getTag());
|
||||
row += factionHere.getColorTo(faction) + "" + tag;
|
||||
row.append(factionHere.getColorTo(faction)).append("").append(tag);
|
||||
} else {
|
||||
row += ChatColor.GRAY + "-";
|
||||
row.append(ChatColor.GRAY + "-");
|
||||
}
|
||||
}
|
||||
}
|
||||
ret.add(row);
|
||||
ret.add(row.toString());
|
||||
}
|
||||
|
||||
// Get the compass
|
||||
@ -308,11 +304,11 @@ public abstract class MemoryBoard extends Board {
|
||||
|
||||
// Add the faction key
|
||||
if (Conf.showMapFactionKey) {
|
||||
String fRow = "";
|
||||
StringBuilder fRow = new StringBuilder();
|
||||
for (String key : fList.keySet()) {
|
||||
fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key);
|
||||
fRow.append(String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key));
|
||||
}
|
||||
ret.add(fRow);
|
||||
ret.add(fRow.toString());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -819,7 +819,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
// announce success
|
||||
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>();
|
||||
Set<FPlayer> informTheseFPlayers = new HashSet<>();
|
||||
informTheseFPlayers.add(this);
|
||||
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
||||
for (FPlayer fp : informTheseFPlayers) {
|
||||
@ -836,10 +836,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
}
|
||||
|
||||
public boolean shouldBeSaved() {
|
||||
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.hasFaction() || (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(Conf.powerPlayerStarting));
|
||||
}
|
||||
|
||||
public void msg(String str, Object... args) {
|
||||
|
@ -12,7 +12,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
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() {
|
||||
for (FPlayer fplayer : this.fPlayers.values()) {
|
||||
@ -24,7 +24,7 @@ public abstract class MemoryFPlayers extends FPlayers {
|
||||
}
|
||||
|
||||
public Collection<FPlayer> getOnlinePlayers() {
|
||||
Set<FPlayer> entities = new HashSet<FPlayer>();
|
||||
Set<FPlayer> entities = new HashSet<>();
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
entities.add(this.getByPlayer(player));
|
||||
}
|
||||
@ -38,7 +38,7 @@ public abstract class MemoryFPlayers extends FPlayers {
|
||||
|
||||
@Override
|
||||
public List<FPlayer> getAllFPlayers() {
|
||||
return new ArrayList<FPlayer>(fPlayers.values());
|
||||
return new ArrayList<>(fPlayers.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,13 +35,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
protected transient long lastPlayerLoggedOffTime;
|
||||
protected double money;
|
||||
protected double powerBoost;
|
||||
protected Map<String, Relation> relationWish = new HashMap<String, Relation>();
|
||||
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<FLocation, Set<String>>();
|
||||
protected transient Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
||||
protected Set<String> invites = new HashSet<String>();
|
||||
protected HashMap<String, List<String>> announcements = new HashMap<String, List<String>>();
|
||||
protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<String, LazyLocation>();
|
||||
protected ConcurrentHashMap<String, String> warpPasswords = new ConcurrentHashMap<String, String>();
|
||||
protected Map<String, Relation> relationWish = new HashMap<>();
|
||||
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>();
|
||||
protected transient Set<FPlayer> fplayers = new HashSet<>();
|
||||
protected Set<String> invites = new HashSet<>();
|
||||
protected HashMap<String, List<String>> announcements = new HashMap<>();
|
||||
protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<>();
|
||||
protected ConcurrentHashMap<String, String> warpPasswords = new ConcurrentHashMap<>();
|
||||
private long lastDeath;
|
||||
protected int maxVaults;
|
||||
|
||||
@ -284,11 +284,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
|
||||
public boolean isPowerFrozen() {
|
||||
int freezeSeconds = P.p.getConfig().getInt("hcf.powerfreeze", 0);
|
||||
if (freezeSeconds == 0) {
|
||||
return false;
|
||||
}
|
||||
return freezeSeconds != 0 && System.currentTimeMillis() - lastDeath < freezeSeconds * 1000;
|
||||
|
||||
return System.currentTimeMillis() - lastDeath < freezeSeconds * 1000;
|
||||
}
|
||||
|
||||
public void setLastDeath(long time) {
|
||||
@ -354,7 +351,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
powerBoost = old.powerBoost;
|
||||
relationWish = old.relationWish;
|
||||
claimOwnership = old.claimOwnership;
|
||||
fplayers = new HashSet<FPlayer>();
|
||||
fplayers = new HashSet<>();
|
||||
invites = old.invites;
|
||||
announcements = old.announcements;
|
||||
}
|
||||
@ -540,11 +537,11 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
public Set<FPlayer> getFPlayers() {
|
||||
// return a shallow copy of the FPlayer list, to prevent tampering and
|
||||
// concurrency issues
|
||||
return new HashSet<FPlayer>(fplayers);
|
||||
return new HashSet<>(fplayers);
|
||||
}
|
||||
|
||||
public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
|
||||
Set<FPlayer> ret = new HashSet<FPlayer>();
|
||||
Set<FPlayer> ret = new HashSet<>();
|
||||
if (!this.isNormal()) {
|
||||
return ret;
|
||||
}
|
||||
@ -572,7 +569,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
public ArrayList<FPlayer> getFPlayersWhereRole(Role role) {
|
||||
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
ArrayList<FPlayer> ret = new ArrayList<>();
|
||||
if (!this.isNormal()) {
|
||||
return ret;
|
||||
}
|
||||
@ -587,7 +584,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
}
|
||||
|
||||
public ArrayList<Player> getOnlinePlayers() {
|
||||
ArrayList<Player> ret = new ArrayList<Player>();
|
||||
ArrayList<Player> ret = new ArrayList<>();
|
||||
if (this.isPlayerFreeType()) {
|
||||
return ret;
|
||||
}
|
||||
@ -763,16 +760,13 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
return false;
|
||||
}
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
if (ownerData == null) {
|
||||
return false;
|
||||
}
|
||||
return ownerData.contains(player.getId());
|
||||
return ownerData != null && ownerData.contains(player.getId());
|
||||
}
|
||||
|
||||
public void setPlayerAsOwner(FPlayer player, FLocation loc) {
|
||||
Set<String> ownerData = claimOwnership.get(loc);
|
||||
if (ownerData == null) {
|
||||
ownerData = new HashSet<String>();
|
||||
ownerData = new HashSet<>();
|
||||
}
|
||||
ownerData.add(player.getId());
|
||||
claimOwnership.put(loc, ownerData);
|
||||
@ -797,18 +791,17 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
return "";
|
||||
}
|
||||
|
||||
String ownerList = "";
|
||||
StringBuilder ownerList = new StringBuilder();
|
||||
|
||||
Iterator<String> iter = ownerData.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!ownerList.isEmpty()) {
|
||||
ownerList += ", ";
|
||||
for (String anOwnerData : ownerData) {
|
||||
if (ownerList.length() > 0) {
|
||||
ownerList.append(", ");
|
||||
}
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(iter.next()));
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData));
|
||||
//TODO:TL
|
||||
ownerList += offlinePlayer != null ? offlinePlayer.getName() : "null player";
|
||||
ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : "null player");
|
||||
}
|
||||
return ownerList;
|
||||
return ownerList.toString();
|
||||
}
|
||||
|
||||
public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {
|
||||
|
@ -13,7 +13,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
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 void load() {
|
||||
@ -134,7 +134,7 @@ public abstract class MemoryFactions extends Factions {
|
||||
}
|
||||
|
||||
public Set<String> getFactionTags() {
|
||||
Set<String> tags = new HashSet<String>();
|
||||
Set<String> tags = new HashSet<>();
|
||||
for (Faction faction : factions.values()) {
|
||||
tags.add(faction.getTag());
|
||||
}
|
||||
@ -149,7 +149,7 @@ public abstract class MemoryFactions extends Factions {
|
||||
|
||||
@Override
|
||||
public ArrayList<Faction> getAllFactions() {
|
||||
return new ArrayList<Faction>(factions.values());
|
||||
return new ArrayList<>(factions.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,7 @@ public class JSONBoard extends MemoryBoard {
|
||||
// -------------------------------------------- //
|
||||
|
||||
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 id;
|
||||
|
@ -20,9 +20,6 @@ public class JSONFPlayer extends MemoryFPlayer {
|
||||
}
|
||||
|
||||
public boolean shouldBeSaved() {
|
||||
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return this.hasFaction() || (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(Conf.powerPlayerStarting));
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class JSONFPlayers extends MemoryFPlayers {
|
||||
}
|
||||
|
||||
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()) {
|
||||
if (((MemoryFPlayer) entity).shouldBeSaved()) {
|
||||
entitiesThatShouldBeSaved.put(entity.getId(), (JSONFPlayer) entity);
|
||||
@ -81,7 +81,7 @@ public class JSONFPlayers extends MemoryFPlayers {
|
||||
|
||||
private Map<String, JSONFPlayer> loadCore() {
|
||||
if (!this.file.exists()) {
|
||||
return new HashMap<String, JSONFPlayer>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
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>>() {
|
||||
}.getType());
|
||||
Set<String> list = new HashSet<String>();
|
||||
Set<String> invalidList = new HashSet<String>();
|
||||
Set<String> list = new HashSet<>();
|
||||
Set<String> invalidList = new HashSet<>();
|
||||
for (Entry<String, JSONFPlayer> entry : data.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
entry.getValue().setId(key);
|
||||
@ -117,12 +117,12 @@ public class JSONFPlayers extends MemoryFPlayers {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
saveCore(file, (Map<String, JSONFPlayer>) data, true);
|
||||
saveCore(file, data, true);
|
||||
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath());
|
||||
|
||||
// Start fetching those UUIDs
|
||||
Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + list.size() + " old player names to UUID. This may take a while.");
|
||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<String>(list));
|
||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list));
|
||||
try {
|
||||
Map<String, UUID> response = fetcher.call();
|
||||
for (String s : list) {
|
||||
@ -161,11 +161,11 @@ public class JSONFPlayers extends MemoryFPlayers {
|
||||
Bukkit.getLogger().log(Level.INFO, "While converting we found names that either don't have a UUID or aren't players and removed them from storage.");
|
||||
Bukkit.getLogger().log(Level.INFO, "The following names were detected as being invalid: " + StringUtils.join(invalidList, ", "));
|
||||
}
|
||||
saveCore(this.file, (Map<String, JSONFPlayer>) data, true); // Update the
|
||||
saveCore(this.file, data, true); // Update the
|
||||
// flatfile
|
||||
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
|
||||
}
|
||||
return (Map<String, JSONFPlayer>) data;
|
||||
return data;
|
||||
}
|
||||
|
||||
private boolean doesKeyNeedMigration(String key) {
|
||||
|
@ -49,7 +49,7 @@ public class JSONFactions extends MemoryFactions {
|
||||
}
|
||||
|
||||
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()) {
|
||||
entitiesThatShouldBeSaved.put(entity.getId(), (JSONFaction) entity);
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class JSONFactions extends MemoryFactions {
|
||||
|
||||
private Map<String, JSONFaction> loadCore() {
|
||||
if (!this.file.exists()) {
|
||||
return new HashMap<String, JSONFaction>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
String content = DiscUtil.readCatch(this.file);
|
||||
@ -112,7 +112,7 @@ public class JSONFactions extends MemoryFactions {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
saveCore(file, (Map<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, "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);
|
||||
|
||||
if (list.size() > 0) {
|
||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<String>(list));
|
||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list));
|
||||
try {
|
||||
Map<String, UUID> response = fetcher.call();
|
||||
for (String value : response.keySet()) {
|
||||
@ -155,7 +155,7 @@ public class JSONFactions extends MemoryFactions {
|
||||
Set<String> list = whichKeysNeedMigration(invites);
|
||||
|
||||
if (list.size() > 0) {
|
||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<String>(list));
|
||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList<>(list));
|
||||
try {
|
||||
Map<String, UUID> response = fetcher.call();
|
||||
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.");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private Set<String> whichKeysNeedMigration(Set<String> keys) {
|
||||
HashSet<String> list = new HashSet<String>();
|
||||
HashSet<String> list = new HashSet<>();
|
||||
for (String value : keys) {
|
||||
if (!value.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")) {
|
||||
// Not a valid UUID..
|
||||
@ -236,8 +236,7 @@ public class JSONFactions extends MemoryFactions {
|
||||
|
||||
@Override
|
||||
public Faction generateFactionObject(String id) {
|
||||
Faction faction = new JSONFaction(id);
|
||||
return faction;
|
||||
return new JSONFaction(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public class DiscUtil {
|
||||
// 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) {
|
||||
String name = file.getName();
|
||||
|
@ -12,7 +12,7 @@ import java.util.Map.Entry;
|
||||
|
||||
public class PermUtil {
|
||||
|
||||
public Map<String, String> permissionDescriptions = new HashMap<String, String>();
|
||||
public Map<String, String> permissionDescriptions = new HashMap<>();
|
||||
|
||||
protected MPlugin p;
|
||||
|
||||
|
@ -120,8 +120,7 @@ public class Persist {
|
||||
}
|
||||
|
||||
try {
|
||||
T instance = p.gson.fromJson(content, clazz);
|
||||
return instance;
|
||||
return p.gson.fromJson(content, clazz);
|
||||
} catch (Exception ex) { // output the error message rather than full stack trace; error parsing the file, most likely
|
||||
p.log(Level.WARNING, ex.getMessage());
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public enum TagReplacer {
|
||||
* @return a list of all the variables with this type
|
||||
*/
|
||||
protected static List<TagReplacer> getByType(TagType type) {
|
||||
List<TagReplacer> tagReplacers = new ArrayList<TagReplacer>();
|
||||
List<TagReplacer> tagReplacers = new ArrayList<>();
|
||||
for (TagReplacer tagReplacer : TagReplacer.values()) {
|
||||
if (type == TagType.FANCY) {
|
||||
if (tagReplacer.type == TagType.FANCY) {
|
||||
|
@ -124,7 +124,7 @@ public class TagUtil {
|
||||
* @return list of fancy messages to send
|
||||
*/
|
||||
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);
|
||||
|
||||
switch (type) {
|
||||
@ -212,7 +212,7 @@ public class TagUtil {
|
||||
* @return list of tooltips for a fancy message
|
||||
*/
|
||||
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")) {
|
||||
lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(faction, line)));
|
||||
}
|
||||
@ -227,7 +227,7 @@ public class TagUtil {
|
||||
* @return list of tooltips for a fancy message
|
||||
*/
|
||||
private static List<String> tipPlayer(FPlayer fplayer) {
|
||||
List<String> lines = new ArrayList<String>();
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (String line : P.p.getConfig().getStringList("tooltips.show")) {
|
||||
lines.add(ChatColor.translateAlternateColorCodes('&', TagUtil.parsePlain(fplayer, line)));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class TextUtil {
|
||||
public Map<String, String> tags;
|
||||
|
||||
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) {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
ArrayList<String> ret = new ArrayList<>();
|
||||
int pageZeroBased = pageHumanBased - 1;
|
||||
int pageheight = 9;
|
||||
int pagecount = (lines.size() / pageheight) + 1;
|
||||
|
@ -34,7 +34,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
}
|
||||
|
||||
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);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
HttpURLConnection connection = createConnection();
|
||||
@ -95,6 +95,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user