IntelliJ Inspection Based Cleanup

This commit is contained in:
Olof Larsson
2017-03-24 14:03:29 +01:00
parent 60b4472735
commit bdbc1c79a2
53 changed files with 154 additions and 153 deletions

View File

@@ -72,12 +72,12 @@ public class Board extends Entity<Board> implements BoardInterface
public Board()
{
this.map = new ConcurrentSkipListMap<PS, TerritoryAccess>();
this.map = new ConcurrentSkipListMap<>();
}
public Board(Map<PS, TerritoryAccess> map)
{
this.map = new ConcurrentSkipListMap<PS, TerritoryAccess>(map);
this.map = new ConcurrentSkipListMap<>(map);
}
// -------------------------------------------- //
@@ -186,7 +186,7 @@ public class Board extends Entity<Board> implements BoardInterface
@Override
public Set<PS> getChunks(String factionId)
{
Set<PS> ret = new HashSet<PS>();
Set<PS> ret = new HashSet<>();
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
{
TerritoryAccess ta = entry.getValue();
@@ -202,7 +202,7 @@ public class Board extends Entity<Board> implements BoardInterface
@Override
public Map<Faction, Set<PS>> getFactionToChunks()
{
Map<Faction, Set<PS>> ret = new MassiveMap<Faction, Set<PS>>();
Map<Faction, Set<PS>> ret = new MassiveMap<>();
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
{
@@ -215,7 +215,7 @@ public class Board extends Entity<Board> implements BoardInterface
Set<PS> chunks = ret.get(faction);
if (chunks == null)
{
chunks = new MassiveSet<PS>();
chunks = new MassiveSet<>();
ret.put(faction, chunks);
}
@@ -251,7 +251,7 @@ public class Board extends Entity<Board> implements BoardInterface
@Override
public Map<Faction, Integer> getFactionToCount()
{
Map<Faction, Integer> ret = new MassiveMap<Faction, Integer>();
Map<Faction, Integer> ret = new MassiveMap<>();
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
{
@@ -388,7 +388,7 @@ public class Board extends Entity<Board> implements BoardInterface
// Make room for the list of names
height--;
Map<Faction, Character> fList = new HashMap<Faction, Character>();
Map<Faction, Character> fList = new HashMap<>();
int chrIdx = 0;
boolean overflown = false;

View File

@@ -132,7 +132,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
public Set<PS> getChunks(Faction faction)
{
// Create
Set<PS> ret = new HashSet<PS>();
Set<PS> ret = new HashSet<>();
// Fill
for (Board board : this.getAll())
@@ -148,7 +148,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
public Set<PS> getChunks(String factionId)
{
// Create
Set<PS> ret = new HashSet<PS>();
Set<PS> ret = new HashSet<>();
// Fill
for (Board board : this.getAll())
@@ -194,7 +194,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
}
// Enforce create
if (ret == null) ret = new MassiveMap<Faction, Set<PS>>();
if (ret == null) ret = new MassiveMap<>();
// Return
return ret;
@@ -249,7 +249,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
}
}
if (ret == null) ret = new MassiveMap<Faction, Integer>();
if (ret == null) ret = new MassiveMap<>();
return ret;
}
@@ -360,7 +360,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
psChunk = psChunk.getChunk(true);
// Create
Set<PS> ret = new LinkedHashSet<PS>();
Set<PS> ret = new LinkedHashSet<>();
if (distance < 0) return ret;
// Fill
@@ -391,7 +391,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
if (chunks == null) throw new NullPointerException("chunks");
// Create
Set<PS> ret = new LinkedHashSet<PS>();
Set<PS> ret = new LinkedHashSet<>();
if (distance < 0) return ret;
@@ -411,7 +411,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
if (chunks == null) throw new NullPointerException("chunks");
// Create
Set<Faction> ret = new LinkedHashSet<Faction>();
Set<Faction> ret = new LinkedHashSet<>();
// Fill
for (PS chunk : chunks)
@@ -428,7 +428,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
public static Map<PS, Faction> getChunkFaction(Collection<PS> chunks)
{
// Create
Map<PS, Faction> ret = new LinkedHashMap<PS, Faction>();
Map<PS, Faction> ret = new LinkedHashMap<>();
// Fill
Faction none = FactionColl.get().getNone();

View File

@@ -11,40 +11,40 @@ import java.util.Set;
public interface BoardInterface
{
// GET
public TerritoryAccess getTerritoryAccessAt(PS ps);
public Faction getFactionAt(PS ps);
TerritoryAccess getTerritoryAccessAt(PS ps);
Faction getFactionAt(PS ps);
// SET
public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess);
public void setFactionAt(PS ps, Faction faction);
void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess);
void setFactionAt(PS ps, Faction faction);
// REMOVE
public void removeAt(PS ps);
public void removeAll(Faction faction);
public void clean();
void removeAt(PS ps);
void removeAll(Faction faction);
void clean();
// CHUNKS
public Set<PS> getChunks(Faction faction);
public Set<PS> getChunks(String factionId);
public Map<Faction, Set<PS>> getFactionToChunks();
Set<PS> getChunks(Faction faction);
Set<PS> getChunks(String factionId);
Map<Faction, Set<PS>> getFactionToChunks();
// COUNT
public int getCount(Faction faction);
public int getCount(String factionId);
public Map<Faction, Integer> getFactionToCount();
int getCount(Faction faction);
int getCount(String factionId);
Map<Faction, Integer> getFactionToCount();
// CLAIMED
public boolean hasClaimed(Faction faction);
public boolean hasClaimed(String factionId);
boolean hasClaimed(Faction faction);
boolean hasClaimed(String factionId);
// NEARBY DETECTION
public boolean isBorderPs(PS ps);
public boolean isAnyBorderPs(Set<PS> pss);
public boolean isConnectedPs(PS ps, Faction faction);
public boolean isAnyConnectedPs(Set<PS> pss, Faction faction);
boolean isBorderPs(PS ps);
boolean isAnyBorderPs(Set<PS> pss);
boolean isConnectedPs(PS ps, Faction faction);
boolean isAnyConnectedPs(Set<PS> pss, Faction faction);
// MAP
// TODO: Could the degrees be embedded in centerPs yaw instead?
public List<Object> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height);
List<Object> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height);
}

View File

@@ -140,19 +140,19 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
// This is the ids of the invited players.
// They are actually "senderIds" since you can invite "@console" to your faction.
// Null means no one is invited
private MassiveTreeSetDef<String, ComparatorCaseInsensitive> invitedPlayerIds = new MassiveTreeSetDef<String, ComparatorCaseInsensitive>(ComparatorCaseInsensitive.get());
private MassiveTreeSetDef<String, ComparatorCaseInsensitive> invitedPlayerIds = new MassiveTreeSetDef<>(ComparatorCaseInsensitive.get());
// The keys in this map are factionIds.
// Null means no special relation whishes.
private MassiveMapDef<String, Rel> relationWishes = new MassiveMapDef<String, Rel>();
private MassiveMapDef<String, Rel> relationWishes = new MassiveMapDef<>();
// The flag overrides are modifications to the default values.
// Null means default.
private MassiveMapDef<String, Boolean> flags = new MassiveMapDef<String, Boolean>();
private MassiveMapDef<String, Boolean> flags = new MassiveMapDef<>();
// The perm overrides are modifications to the default values.
// Null means default.
private MassiveMapDef<String, Set<Rel>> perms = new MassiveMapDef<String, Set<Rel>>();
private MassiveMapDef<String, Set<Rel>> perms = new MassiveMapDef<>();
// -------------------------------------------- //
// FIELD: id
@@ -465,7 +465,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setInvitedPlayerIds(Collection<String> invitedPlayerIds)
{
// Clean input
MassiveTreeSetDef<String, ComparatorCaseInsensitive> target = new MassiveTreeSetDef<String, ComparatorCaseInsensitive>(ComparatorCaseInsensitive.get());
MassiveTreeSetDef<String, ComparatorCaseInsensitive> target = new MassiveTreeSetDef<>(ComparatorCaseInsensitive.get());
if (invitedPlayerIds != null)
{
for (String invitedPlayerId : invitedPlayerIds)
@@ -498,7 +498,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public boolean setInvited(String playerId, boolean invited)
{
List<String> invitedPlayerIds = new ArrayList<String>(this.getInvitedPlayerIds());
List<String> invitedPlayerIds = new ArrayList<>(this.getInvitedPlayerIds());
boolean ret;
if (invited)
{
@@ -520,7 +520,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public List<MPlayer> getInvitedMPlayers()
{
List<MPlayer> mplayers = new ArrayList<MPlayer>();
List<MPlayer> mplayers = new ArrayList<>();
for (String id : this.getInvitedPlayerIds())
{
@@ -544,7 +544,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setRelationWishes(Map<String, Rel> relationWishes)
{
// Clean input
MassiveMapDef<String, Rel> target = new MassiveMapDef<String, Rel>(relationWishes);
MassiveMapDef<String, Rel> target = new MassiveMapDef<>(relationWishes);
// Detect Nochange
if (MUtil.equals(this.relationWishes, target)) return;
@@ -598,7 +598,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public Map<MFlag, Boolean> getFlags()
{
// We start with default values ...
Map<MFlag, Boolean> ret = new LinkedHashMap<MFlag, Boolean>();
Map<MFlag, Boolean> ret = new LinkedHashMap<>();
for (MFlag mflag : MFlag.getAll())
{
ret.put(mflag, mflag.isStandard());
@@ -632,7 +632,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setFlags(Map<MFlag, Boolean> flags)
{
Map<String, Boolean> flagIds = new LinkedHashMap<String, Boolean>();
Map<String, Boolean> flagIds = new LinkedHashMap<>();
for (Entry<MFlag, Boolean> entry : flags.entrySet())
{
flagIds.put(entry.getKey().getId(), entry.getValue());
@@ -643,7 +643,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setFlagIds(Map<String, Boolean> flagIds)
{
// Clean input
MassiveMapDef<String, Boolean> target = new MassiveMapDef<String, Boolean>();
MassiveMapDef<String, Boolean> target = new MassiveMapDef<>();
for (Entry<String, Boolean> entry : flagIds.entrySet())
{
String key = entry.getKey();
@@ -660,7 +660,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
if (MUtil.equals(this.flags, target)) return;
// Apply
this.flags = new MassiveMapDef<String, Boolean>(target);
this.flags = new MassiveMapDef<>(target);
// Mark as changed
this.changed();
@@ -724,10 +724,10 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public Map<MPerm, Set<Rel>> getPerms()
{
// We start with default values ...
Map<MPerm, Set<Rel>> ret = new LinkedHashMap<MPerm, Set<Rel>>();
Map<MPerm, Set<Rel>> ret = new LinkedHashMap<>();
for (MPerm mperm : MPerm.getAll())
{
ret.put(mperm, new LinkedHashSet<Rel>(mperm.getStandard()));
ret.put(mperm, new LinkedHashSet<>(mperm.getStandard()));
}
// ... and if anything is explicitly set we use that info ...
@@ -749,7 +749,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
MPerm mperm = MPerm.get(id);
if (mperm == null) continue;
ret.put(mperm, new LinkedHashSet<Rel>(entry.getValue()));
ret.put(mperm, new LinkedHashSet<>(entry.getValue()));
}
return ret;
@@ -757,7 +757,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setPerms(Map<MPerm, Set<Rel>> perms)
{
Map<String, Set<Rel>> permIds = new LinkedHashMap<String, Set<Rel>>();
Map<String, Set<Rel>> permIds = new LinkedHashMap<>();
for (Entry<MPerm, Set<Rel>> entry : perms.entrySet())
{
permIds.put(entry.getKey().getId(), entry.getValue());
@@ -768,7 +768,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setPermIds(Map<String, Set<Rel>> perms)
{
// Clean input
MassiveMapDef<String, Set<Rel>> target = new MassiveMapDef<String, Set<Rel>>();
MassiveMapDef<String, Set<Rel>> target = new MassiveMapDef<>();
for (Entry<String, Set<Rel>> entry : perms.entrySet())
{
String key = entry.getKey();
@@ -866,7 +866,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public void setPermittedRelations(MPerm perm, Rel... rels)
{
Set<Rel> temp = new HashSet<Rel>();
Set<Rel> temp = new HashSet<>();
temp.addAll(Arrays.asList(rels));
this.setPermittedRelations(perm, temp);
}
@@ -1008,7 +1008,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
// FOREIGN KEY: MPLAYER
// -------------------------------------------- //
protected transient Set<MPlayer> mplayers = new MassiveSet<MPlayer>();
protected transient Set<MPlayer> mplayers = new MassiveSet<>();
public void reindexMPlayers()
{
@@ -1045,7 +1045,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public List<MPlayer> getMPlayers()
{
this.checkMPlayerIndex();
return new ArrayList<MPlayer>(this.mplayers);
return new ArrayList<>(this.mplayers);
}
public List<MPlayer> getMPlayersWhere(Predicate<? super MPlayer> predicate)
@@ -1083,7 +1083,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public List<CommandSender> getOnlineCommandSenders()
{
// Create Ret
List<CommandSender> ret = new ArrayList<CommandSender>();
List<CommandSender> ret = new ArrayList<>();
// Fill Ret
for (CommandSender sender : IdUtil.getLocalSenders())
@@ -1103,7 +1103,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
public List<Player> getOnlinePlayers()
{
// Create Ret
List<Player> ret = new ArrayList<Player>();
List<Player> ret = new ArrayList<>();
// Fill Ret
for (Player player : MUtil.getOnlinePlayers())

View File

@@ -246,7 +246,7 @@ public class FactionColl extends Coll<Faction>
public ArrayList<String> validateName(String str)
{
// Create
ArrayList<String> errors = new ArrayList<String>();
ArrayList<String> errors = new ArrayList<>();
// Fill
// Check minimum length
@@ -295,7 +295,7 @@ public class FactionColl extends Coll<Faction>
public Map<Rel, List<String>> getRelationNames(Faction faction, Set<Rel> rels)
{
// Create
Map<Rel, List<String>> ret = new LinkedHashMap<Rel, List<String>>();
Map<Rel, List<String>> ret = new LinkedHashMap<>();
MFlag flagPeaceful = MFlag.getFlagPeaceful();
boolean peaceful = faction.getFlag(flagPeaceful);
for (Rel rel : rels)

View File

@@ -79,7 +79,7 @@ public class MConf extends Entity<MConf>
// Add player names here who should bypass all protections.
// Should /not/ be used for admins. There is "/f adminmode" for that.
// This is for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections.
public Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
public Set<String> playersWhoBypassAllProtection = new LinkedHashSet<>();
// -------------------------------------------- //
// TASKS
@@ -337,7 +337,7 @@ public class MConf extends Entity<MConf>
// A list of commands to block for members of permanent factions.
// I don't really understand the user case for this option.
public List<String> denyCommandsPermanentFactionMember = new ArrayList<String>();
public List<String> denyCommandsPermanentFactionMember = new ArrayList<>();
// Lists of commands to deny depending on your relation to the current faction territory.
// You may for example not type /home (might be the plugin Essentials) in the territory of your enemies.
@@ -537,7 +537,7 @@ public class MConf extends Entity<MConf>
// This way they can be protected in Faction territory.
// Interacting with these materials when they are already placed in the terrain results in an edit.
public BackstringSet<Material> materialsEditOnInteract = new BackstringSet<Material>(Material.class,
public BackstringSet<Material> materialsEditOnInteract = new BackstringSet<>(Material.class,
"DIODE_BLOCK_OFF", // Minecraft 1.?
"DIODE_BLOCK_ON", // Minecraft 1.?
"NOTE_BLOCK", // Minecraft 1.?
@@ -551,7 +551,7 @@ public class MConf extends Entity<MConf>
// Interacting with the the terrain holding this item in hand results in an edit.
// There's no need to add all block materials here. Only special items other than blocks.
public BackstringSet<Material> materialsEditTools = new BackstringSet<Material>(Material.class,
public BackstringSet<Material> materialsEditTools = new BackstringSet<>(Material.class,
"FIREBALL", // Minecraft 1.?
"FLINT_AND_STEEL", // Minecraft 1.?
"BUCKET", // Minecraft 1.?
@@ -563,7 +563,7 @@ public class MConf extends Entity<MConf>
// The duplication bug found in Spigot 1.8 protocol patch
// https://github.com/MassiveCraft/Factions/issues/693
public BackstringSet<Material> materialsEditToolsDupeBug = new BackstringSet<Material>(Material.class,
public BackstringSet<Material> materialsEditToolsDupeBug = new BackstringSet<>(Material.class,
"CHEST", // Minecraft 1.?
"SIGN_POST", // Minecraft 1.?
"TRAPPED_CHEST", // Minecraft 1.?
@@ -573,7 +573,7 @@ public class MConf extends Entity<MConf>
);
// Interacting with these materials placed in the terrain results in door toggling.
public BackstringSet<Material> materialsDoor = new BackstringSet<Material>(Material.class,
public BackstringSet<Material> materialsDoor = new BackstringSet<>(Material.class,
"WOODEN_DOOR", // Minecraft 1.?
"ACACIA_DOOR", // Minecraft 1.8
"BIRCH_DOOR", // Minecraft 1.8
@@ -590,7 +590,7 @@ public class MConf extends Entity<MConf>
);
// Interacting with these materials placed in the terrain results in opening a container.
public BackstringSet<Material> materialsContainer = new BackstringSet<Material>(Material.class,
public BackstringSet<Material> materialsContainer = new BackstringSet<>(Material.class,
"DISPENSER", // Minecraft 1.?
"CHEST", // Minecraft 1.?
"FURNACE", // Minecraft 1.?
@@ -624,26 +624,26 @@ public class MConf extends Entity<MConf>
);
// Interacting with these entities results in an edit.
public BackstringSet<EntityType> entityTypesEditOnInteract = new BackstringSet<EntityType>(EntityType.class,
public BackstringSet<EntityType> entityTypesEditOnInteract = new BackstringSet<>(EntityType.class,
"ITEM_FRAME", // Minecraft 1.?
"ARMOR_STAND" // Minecraft 1.8
);
// Damaging these entities results in an edit.
public BackstringSet<EntityType> entityTypesEditOnDamage = new BackstringSet<EntityType>(EntityType.class,
public BackstringSet<EntityType> entityTypesEditOnDamage = new BackstringSet<>(EntityType.class,
"ITEM_FRAME", // Minecraft 1.?
"ARMOR_STAND", // Minecraft 1.8
"ENDER_CRYSTAL" // Minecraft 1.10
);
// Interacting with these entities results in opening a container.
public BackstringSet<EntityType> entityTypesContainer = new BackstringSet<EntityType>(EntityType.class,
public BackstringSet<EntityType> entityTypesContainer = new BackstringSet<>(EntityType.class,
"MINECART_CHEST", // Minecraft 1.?
"MINECART_HOPPER" // Minecraft 1.?
);
// The complete list of entities considered to be monsters.
public BackstringSet<EntityType> entityTypesMonsters = new BackstringSet<EntityType>(EntityType.class,
public BackstringSet<EntityType> entityTypesMonsters = new BackstringSet<>(EntityType.class,
"BLAZE", // Minecraft 1.?
"CAVE_SPIDER", // Minecraft 1.?
"CREEPER", // Minecraft 1.?
@@ -675,7 +675,7 @@ public class MConf extends Entity<MConf>
);
// List of entities considered to be animals.
public BackstringSet<EntityType> entityTypesAnimals = new BackstringSet<EntityType>(EntityType.class,
public BackstringSet<EntityType> entityTypesAnimals = new BackstringSet<>(EntityType.class,
"BAT", // Minecraft 1.?
"CHICKEN", // Minecraft 1.?
"COW", // Minecraft 1.?
@@ -714,7 +714,7 @@ public class MConf extends Entity<MConf>
public boolean herochatFactionIsShortcutAllowed = false;
public boolean herochatFactionCrossWorld = true;
public boolean herochatFactionMuted = false;
public Set<String> herochatFactionWorlds = new HashSet<String>();
public Set<String> herochatFactionWorlds = new HashSet<>();
// The Allies Channel
public String herochatAlliesName = "Allies";
@@ -725,7 +725,7 @@ public class MConf extends Entity<MConf>
public boolean herochatAlliesIsShortcutAllowed = false;
public boolean herochatAlliesCrossWorld = true;
public boolean herochatAlliesMuted = false;
public Set<String> herochatAlliesWorlds = new HashSet<String>();
public Set<String> herochatAlliesWorlds = new HashSet<>();
// -------------------------------------------- //
// INTEGRATION: LWC

View File

@@ -47,7 +47,7 @@ public class MFlagColl extends Coll<MFlag>
public List<MFlag> getAll(boolean registered)
{
// Create
List<MFlag> ret = new ArrayList<MFlag>();
List<MFlag> ret = new ArrayList<>();
// Fill
for (MFlag mflag : this.getAll())

View File

@@ -231,7 +231,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
// What is the standard (aka default) perm value?
// This value will be set for factions from the beginning.
// Example: ... set of relations ...
private Set<Rel> standard = new LinkedHashSet<Rel>();
private Set<Rel> standard = new LinkedHashSet<>();
public Set<Rel> getStandard() { return this.standard; }
public MPerm setStandard(Set<Rel> standard) { this.standard = standard; this.changed(); return this; }
@@ -305,7 +305,7 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public String getDesc(boolean withName, boolean withDesc)
{
List<String> parts = new ArrayList<String>();
List<String> parts = new ArrayList<>();
if (withName)
{

View File

@@ -47,7 +47,7 @@ public class MPermColl extends Coll<MPerm>
public List<MPerm> getAll(boolean registered)
{
// Create
List<MPerm> ret = new ArrayList<MPerm>();
List<MPerm> ret = new ArrayList<>();
// Fill
for (MPerm mperm : this.getAll())

View File

@@ -925,7 +925,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public static Set<MPlayer> getClaimInformees(MPlayer msender, Faction... factions)
{
Set<MPlayer> ret = new HashSet<MPlayer>();
Set<MPlayer> ret = new HashSet<>();
if (msender != null) ret.add(msender);