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.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<PS> chunks = new LinkedHashSet<>();
final Set<PS> chunks = new MassiveSet<>();
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.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<PS> chunks = new LinkedHashSet<>();
final Set<PS> 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<PS> expansion = new LinkedHashSet<>();
Set<PS> expansion = new MassiveSet<>();
for (PS chunk : 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.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<PS> chunks = new LinkedHashSet<>();
final Set<PS> chunks = new MassiveSet<>();
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);
// Create
Set<PS> ret = new LinkedHashSet<>();
Set<PS> ret = new MassiveSet<>();
if (distance < 0) return ret;
// Fill
@ -369,7 +369,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
if (chunks == null) throw new NullPointerException("chunks");
// Create
Set<PS> ret = new LinkedHashSet<>();
Set<PS> ret = new MassiveSet<>();
if (distance < 0) return ret;
@ -389,7 +389,7 @@ public class BoardColl extends Coll<Board> implements BoardInterface
if (chunks == null) throw new NullPointerException("chunks");
// Create
Set<Faction> ret = new LinkedHashSet<>();
Set<Faction> ret = new MassiveSet<>();
// Fill
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)
{
// Create
Map<PS, Faction> ret = new LinkedHashMap<>();
Map<PS, Faction> ret = new MassiveMap<>();
// Fill
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.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<Faction>
public Map<Rel, List<String>> getRelationNames(Faction faction, Set<Rel> rels)
{
// Create
Map<Rel, List<String>> ret = new LinkedHashMap<>();
Map<Rel, List<String>> ret = new MassiveMap<>();
MFlag flagPeaceful = MFlag.getFlagPeaceful();
boolean peaceful = faction.getFlag(flagPeaceful);
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.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<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<>();
public Set<String> playersWhoBypassAllProtection = new MassiveSet<>();
// -------------------------------------------- //
// TASKS

View File

@ -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<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 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 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<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<>();
private Set<Rel> standard = new MassiveSet<>();
public Set<Rel> getStandard() { return this.standard; }
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.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<PS, EventFactionsChunkChangeType> currentChunkType = new LinkedHashMap<>();
Map<PS, EventFactionsChunkChangeType> currentChunkType = new MassiveMap<>();
for (Entry<PS, Faction> entry : this.oldChunkFaction.entrySet())
{
PS chunk = entry.getKey();