From 8536d3db7ba1ee04c79c95d4b43bdaea57b63ce4 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 19 Jan 2018 20:51:07 +0100 Subject: [PATCH] Use the Massive collections some more --- .../massivecraft/factions/cmd/CmdFactionsSetCircle.java | 3 ++- src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java | 5 +++-- .../massivecraft/factions/cmd/CmdFactionsSetSquare.java | 3 ++- src/com/massivecraft/factions/entity/BoardColl.java | 8 ++++---- src/com/massivecraft/factions/entity/FactionColl.java | 3 ++- src/com/massivecraft/factions/entity/MConf.java | 3 ++- src/com/massivecraft/factions/entity/MPerm.java | 5 +++-- .../factions/event/EventFactionsChunksChange.java | 3 ++- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java index 7a48a04e..364770ee 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -43,7 +44,7 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); - final Set chunks = new LinkedHashSet<>(); + final Set chunks = new MassiveSet<>(); chunks.add(chunk); // The center should come first for pretty messages diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java index 58f14598..fea669ea 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -46,7 +47,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); - final Set chunks = new LinkedHashSet<>(); + final Set chunks = new MassiveSet<>(); // What faction (aka color) resides there? // NOTE: Wilderness/None is valid. @@ -81,7 +82,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple if (color == null) throw new NullPointerException("color"); // Expand - Set expansion = new LinkedHashSet<>(); + Set expansion = new MassiveSet<>(); for (PS chunk : set) { Set neighbours = MUtil.set( diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java index 76606525..52cb1f21 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -43,7 +44,7 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); - final Set chunks = new LinkedHashSet<>(); + final Set chunks = new MassiveSet<>(); chunks.add(chunk); // The center should come first for pretty messages diff --git a/src/com/massivecraft/factions/entity/BoardColl.java b/src/com/massivecraft/factions/entity/BoardColl.java index 43e3c78d..d03a948f 100644 --- a/src/com/massivecraft/factions/entity/BoardColl.java +++ b/src/com/massivecraft/factions/entity/BoardColl.java @@ -338,7 +338,7 @@ public class BoardColl extends Coll implements BoardInterface psChunk = psChunk.getChunk(true); // Create - Set ret = new LinkedHashSet<>(); + Set ret = new MassiveSet<>(); if (distance < 0) return ret; // Fill @@ -369,7 +369,7 @@ public class BoardColl extends Coll implements BoardInterface if (chunks == null) throw new NullPointerException("chunks"); // Create - Set ret = new LinkedHashSet<>(); + Set ret = new MassiveSet<>(); if (distance < 0) return ret; @@ -389,7 +389,7 @@ public class BoardColl extends Coll implements BoardInterface if (chunks == null) throw new NullPointerException("chunks"); // Create - Set ret = new LinkedHashSet<>(); + Set ret = new MassiveSet<>(); // Fill for (PS chunk : chunks) @@ -406,7 +406,7 @@ public class BoardColl extends Coll implements BoardInterface public static Map getChunkFaction(Collection chunks) { // Create - Map ret = new LinkedHashMap<>(); + Map ret = new MassiveMap<>(); // Fill Faction none = FactionColl.get().getNone(); diff --git a/src/com/massivecraft/factions/entity/FactionColl.java b/src/com/massivecraft/factions/entity/FactionColl.java index c9d7d240..972d798c 100644 --- a/src/com/massivecraft/factions/entity/FactionColl.java +++ b/src/com/massivecraft/factions/entity/FactionColl.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.util.MiscUtil; +import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.util.Txt; @@ -228,7 +229,7 @@ public class FactionColl extends Coll public Map> getRelationNames(Faction faction, Set rels) { // Create - Map> ret = new LinkedHashMap<>(); + Map> ret = new MassiveMap<>(); MFlag flagPeaceful = MFlag.getFlagPeaceful(); boolean peaceful = faction.getFlag(flagPeaceful); for (Rel rel : rels) diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index 90876d43..91fe20aa 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.engine.EngineChat; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.massivecore.collections.BackstringSet; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.collections.WorldExceptionSet; import com.massivecraft.massivecore.command.editor.annotation.EditorName; import com.massivecraft.massivecore.command.editor.annotation.EditorType; @@ -89,7 +90,7 @@ public class MConf extends Entity // 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 playersWhoBypassAllProtection = new LinkedHashSet<>(); + public Set playersWhoBypassAllProtection = new MassiveSet<>(); // -------------------------------------------- // // TASKS diff --git a/src/com/massivecraft/factions/entity/MPerm.java b/src/com/massivecraft/factions/entity/MPerm.java index da60fbd0..b42c5256 100644 --- a/src/com/massivecraft/factions/entity/MPerm.java +++ b/src/com/massivecraft/factions/entity/MPerm.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.event.EventFactionsCreatePerms; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.Prioritized; import com.massivecraft.massivecore.Registerable; +import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.comparator.ComparatorSmart; import com.massivecraft.massivecore.predicate.PredicateIsRegistered; import com.massivecraft.massivecore.ps.PS; @@ -132,7 +133,7 @@ public class MPerm extends Entity implements Prioritized, Registerable, N } public static MPerm getPermBuild() { return getCreative(PRIORITY_BUILD, ID_BUILD, ID_BUILD, "edit the terrain", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER), true, true, true); } - public static MPerm getPermPainbuild() { return getCreative(PRIORITY_PAINBUILD, ID_PAINBUILD, ID_PAINBUILD, "edit, take damage", new LinkedHashSet(), true, true, true); } + public static MPerm getPermPainbuild() { return getCreative(PRIORITY_PAINBUILD, ID_PAINBUILD, ID_PAINBUILD, "edit, take damage", new MassiveSet(), true, true, true); } public static MPerm getPermDoor() { return getCreative(PRIORITY_DOOR, ID_DOOR, ID_DOOR, "use doors", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), true, true, true); } public static MPerm getPermButton() { return getCreative(PRIORITY_BUTTON, ID_BUTTON, ID_BUTTON, "use stone buttons", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), true, true, true); } public static MPerm getPermLever() { return getCreative(PRIORITY_LEVER, ID_LEVER, ID_LEVER, "use levers", MUtil.set(Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY), true, true, true); } @@ -232,7 +233,7 @@ public class MPerm extends Entity 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 standard = new LinkedHashSet<>(); + private Set standard = new MassiveSet<>(); public Set getStandard() { return this.standard; } public MPerm setStandard(Set standard) { this.standard = standard; this.changed(); return this; } diff --git a/src/com/massivecraft/factions/event/EventFactionsChunksChange.java b/src/com/massivecraft/factions/event/EventFactionsChunksChange.java index 425d2b75..ad8cb003 100644 --- a/src/com/massivecraft/factions/event/EventFactionsChunksChange.java +++ b/src/com/massivecraft/factions/event/EventFactionsChunksChange.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.event; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; import org.bukkit.command.CommandSender; @@ -62,7 +63,7 @@ public class EventFactionsChunksChange extends EventFactionsAbstractSender MPlayer msender = this.getMPlayer(); Faction self = null; if (msender != null) self = msender.getFaction(); - Map currentChunkType = new LinkedHashMap<>(); + Map currentChunkType = new MassiveMap<>(); for (Entry entry : this.oldChunkFaction.entrySet()) { PS chunk = entry.getKey();