Change the underlying mechanics of /f access
This commit is contained in:
@@ -59,8 +59,7 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand
|
||||
|
||||
msg("<k>Host Faction: %s", hostFaction.describeTo(msender, true));
|
||||
msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
|
||||
msg("<k>Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender));
|
||||
msg("<k>Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), msender));
|
||||
msg("<k>Granted to: %s", CmdFactionsPermShow.permablesToDisplayString(ta.getGranteds(), msender));
|
||||
}
|
||||
|
||||
public static String describeRelationParticipators(Collection<? extends RelationParticipator> relationParticipators, RelationParticipator observer)
|
||||
|
||||
@@ -29,13 +29,13 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.readArg();
|
||||
boolean newValue = this.readArg(!ta.isFactionGranted(faction));
|
||||
boolean newValue = this.readArg(!ta.isGranted(faction));
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
ta = ta.withFactionId(faction.getId(), newValue);
|
||||
ta = ta.withGrantedId(faction.getId(), newValue);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
// Inform
|
||||
|
||||
@@ -29,13 +29,13 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
|
||||
{
|
||||
// Args
|
||||
MPlayer mplayer = this.readArg();
|
||||
boolean newValue = this.readArg(!ta.isMPlayerGranted(mplayer));
|
||||
boolean newValue = this.readArg(!ta.isGranted(mplayer));
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
ta = ta.withPlayerId(mplayer.getId(), newValue);
|
||||
ta = ta.withGrantedId(mplayer.getId(), newValue);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
// Inform
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.Invitation;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.MPlayerColl;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
@@ -144,11 +145,11 @@ public class CmdFactionsClean extends FactionsCommand
|
||||
TerritoryAccess territoryAccess = entry.getValue();
|
||||
boolean changed = false;
|
||||
|
||||
for (String factionId : territoryAccess.getFactionIds())
|
||||
for (String grantedIds : territoryAccess.getGrantedIds())
|
||||
{
|
||||
if (FactionColl.get().containsId(factionId)) continue;
|
||||
if (MPerm.idToMPermableOptional(grantedIds).isPresent()) continue;
|
||||
|
||||
territoryAccess = territoryAccess.withFactionId(factionId, false);
|
||||
territoryAccess = territoryAccess.withGrantedId(grantedIds, false);
|
||||
ret += 1;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeMPerm;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.MPlayerColl;
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.collections.MassiveList;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
@@ -62,26 +58,10 @@ public class CmdFactionsPermShow extends FactionsCommand
|
||||
msg("<i>In <reset>%s <i>permission <reset>%s <i>is granted to <reset>%s<i>.", faction.describeTo(msender), mperm.getDesc(true, false), permableNames);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static MPerm.MPermable idToMPermable(String id)
|
||||
{
|
||||
MPlayer mplayer = MPlayerColl.get().get(id, false);
|
||||
if (mplayer != null) return mplayer;
|
||||
|
||||
Faction faction = Faction.get(id);
|
||||
if (faction != null) return faction;
|
||||
|
||||
for (Faction f : FactionColl.get().getAll())
|
||||
{
|
||||
Rank rank = f.getRank(id);
|
||||
if (rank != null) return rank;
|
||||
}
|
||||
|
||||
if (Rel.ALLY.name().equalsIgnoreCase(id)) return Rel.ALLY;
|
||||
if (Rel.TRUCE.name().equalsIgnoreCase(id)) return Rel.TRUCE;
|
||||
if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) return Rel.NEUTRAL;
|
||||
if (Rel.ENEMY.name().equalsIgnoreCase(id)) return Rel.ENEMY;
|
||||
|
||||
throw new RuntimeException(id);
|
||||
return MPerm.idToMPermable(id);
|
||||
}
|
||||
|
||||
public static String permablesToDisplayString(Collection<MPermable> permables, Object watcherObject)
|
||||
|
||||
Reference in New Issue
Block a user