Use the Massive collections some more

This commit is contained in:
Olof Larsson 2018-01-19 20:51:07 +01:00
parent 1a8a601357
commit 8536d3db7b
8 changed files with 20 additions and 13 deletions

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -43,7 +44,7 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius
{ {
// Common Startup // Common Startup
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = new LinkedHashSet<>(); final Set<PS> chunks = new MassiveSet<>();
chunks.add(chunk); // The center should come first for pretty messages chunks.add(chunk); // The center should come first for pretty messages

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; 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.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -46,7 +47,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple
{ {
// Common Startup // Common Startup
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = new LinkedHashSet<>(); final Set<PS> chunks = new MassiveSet<>();
// What faction (aka color) resides there? // What faction (aka color) resides there?
// NOTE: Wilderness/None is valid. // NOTE: Wilderness/None is valid.
@ -81,7 +82,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple
if (color == null) throw new NullPointerException("color"); if (color == null) throw new NullPointerException("color");
// Expand // Expand
Set<PS> expansion = new LinkedHashSet<>(); Set<PS> expansion = new MassiveSet<>();
for (PS chunk : set) for (PS chunk : set)
{ {
Set<PS> neighbours = MUtil.set( Set<PS> neighbours = MUtil.set(

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -43,7 +44,7 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius
{ {
// Common Startup // Common Startup
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
final Set<PS> chunks = new LinkedHashSet<>(); final Set<PS> chunks = new MassiveSet<>();
chunks.add(chunk); // The center should come first for pretty messages chunks.add(chunk); // The center should come first for pretty messages

View File

@ -338,7 +338,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
psChunk = psChunk.getChunk(true); psChunk = psChunk.getChunk(true);
// Create // Create
Set<PS> ret = new LinkedHashSet<>(); Set<PS> ret = new MassiveSet<>();
if (distance < 0) return ret; if (distance < 0) return ret;
// Fill // Fill
@ -369,7 +369,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
if (chunks == null) throw new NullPointerException("chunks"); if (chunks == null) throw new NullPointerException("chunks");
// Create // Create
Set<PS> ret = new LinkedHashSet<>(); Set<PS> ret = new MassiveSet<>();
if (distance < 0) return ret; if (distance < 0) return ret;
@ -389,7 +389,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
if (chunks == null) throw new NullPointerException("chunks"); if (chunks == null) throw new NullPointerException("chunks");
// Create // Create
Set<Faction> ret = new LinkedHashSet<>(); Set<Faction> ret = new MassiveSet<>();
// Fill // Fill
for (PS chunk : chunks) for (PS chunk : chunks)
@ -406,7 +406,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
public static Map<PS, Faction> getChunkFaction(Collection<PS> chunks) public static Map<PS, Faction> getChunkFaction(Collection<PS> chunks)
{ {
// Create // Create
Map<PS, Faction> ret = new LinkedHashMap<>(); Map<PS, Faction> ret = new MassiveMap<>();
// Fill // Fill
Faction none = FactionColl.get().getNone(); Faction none = FactionColl.get().getNone();

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -228,7 +229,7 @@ public class FactionColl extends Coll<Faction>
public Map<Rel, List<String>> getRelationNames(Faction faction, Set<Rel> rels) public Map<Rel, List<String>> getRelationNames(Faction faction, Set<Rel> rels)
{ {
// Create // Create
Map<Rel, List<String>> ret = new LinkedHashMap<>(); Map<Rel, List<String>> ret = new MassiveMap<>();
MFlag flagPeaceful = MFlag.getFlagPeaceful(); MFlag flagPeaceful = MFlag.getFlagPeaceful();
boolean peaceful = faction.getFlag(flagPeaceful); boolean peaceful = faction.getFlag(flagPeaceful);
for (Rel rel : rels) for (Rel rel : rels)

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.engine.EngineChat; import com.massivecraft.factions.engine.EngineChat;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.massivecore.collections.BackstringSet; import com.massivecraft.massivecore.collections.BackstringSet;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.collections.WorldExceptionSet; import com.massivecraft.massivecore.collections.WorldExceptionSet;
import com.massivecraft.massivecore.command.editor.annotation.EditorName; import com.massivecraft.massivecore.command.editor.annotation.EditorName;
import com.massivecraft.massivecore.command.editor.annotation.EditorType; import com.massivecraft.massivecore.command.editor.annotation.EditorType;
@ -89,7 +90,7 @@ public class MConf extends Entity<MConf>
// Add player names here who should bypass all protections. // Add player names here who should bypass all protections.
// Should /not/ be used for admins. There is "/f adminmode" for that. // 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. // 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<>(); public Set<String> playersWhoBypassAllProtection = new MassiveSet<>();
// -------------------------------------------- // // -------------------------------------------- //
// TASKS // TASKS

View File

@ -9,6 +9,7 @@ import com.massivecraft.factions.event.EventFactionsCreatePerms;
import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.Prioritized; import com.massivecraft.massivecore.Prioritized;
import com.massivecraft.massivecore.Registerable; import com.massivecraft.massivecore.Registerable;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.comparator.ComparatorSmart; import com.massivecraft.massivecore.comparator.ComparatorSmart;
import com.massivecraft.massivecore.predicate.PredicateIsRegistered; import com.massivecraft.massivecore.predicate.PredicateIsRegistered;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -132,7 +133,7 @@ public class MPerm extends Entity<MPerm> 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 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<Rel>(), true, true, true); } public static MPerm getPermPainbuild() { return getCreative(PRIORITY_PAINBUILD, ID_PAINBUILD, ID_PAINBUILD, "edit, take damage", new MassiveSet<Rel>(), 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 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 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); } 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<MPerm> implements Prioritized, Registerable, N
// What is the standard (aka default) perm value? // What is the standard (aka default) perm value?
// This value will be set for factions from the beginning. // This value will be set for factions from the beginning.
// Example: ... set of relations ... // Example: ... set of relations ...
private Set<Rel> standard = new LinkedHashSet<>(); private Set<Rel> standard = new MassiveSet<>();
public Set<Rel> getStandard() { return this.standard; } public Set<Rel> getStandard() { return this.standard; }
public MPerm setStandard(Set<Rel> standard) { this.standard = standard; this.changed(); return this; } public MPerm setStandard(Set<Rel> standard) { this.standard = standard; this.changed(); return this; }

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.event;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -62,7 +63,7 @@ public class EventFactionsChunksChange extends EventFactionsAbstractSender
MPlayer msender = this.getMPlayer(); MPlayer msender = this.getMPlayer();
Faction self = null; Faction self = null;
if (msender != null) self = msender.getFaction(); if (msender != null) self = msender.getFaction();
Map<PS, EventFactionsChunkChangeType> currentChunkType = new LinkedHashMap<>(); Map<PS, EventFactionsChunkChangeType> currentChunkType = new MassiveMap<>();
for (Entry<PS, Faction> entry : this.oldChunkFaction.entrySet()) for (Entry<PS, Faction> entry : this.oldChunkFaction.entrySet())
{ {
PS chunk = entry.getKey(); PS chunk = entry.getKey();