mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-27 12:46:09 +01:00
More minor tweaks to TerritoryAccess
This commit is contained in:
parent
ab498b9f60
commit
1f303aef91
@ -12,20 +12,9 @@ public class TerritoryAccess
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private String hostFactionId;
|
private String hostFactionId;
|
||||||
public String getHostFactionId()
|
public String getHostFactionId() { return this.hostFactionId; }
|
||||||
{
|
|
||||||
return this.hostFactionId;
|
|
||||||
}
|
|
||||||
public Faction getHostFaction() { return FactionColl.i.get(this.hostFactionId); }
|
public Faction getHostFaction() { return FactionColl.i.get(this.hostFactionId); }
|
||||||
|
public void setHostFactionId(String hostFactionId) { this.hostFactionId = hostFactionId; }
|
||||||
public void setHostFactionId(String factionId)
|
|
||||||
{
|
|
||||||
// TODO: Why all these here???
|
|
||||||
this.hostFactionId = factionId;
|
|
||||||
this.hostFactionAllowed = true;
|
|
||||||
this.factionIds.clear();
|
|
||||||
this.fplayerIds.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hostFactionAllowed = true;
|
private boolean hostFactionAllowed = true;
|
||||||
public boolean isHostFactionAllowed() { return this.hostFactionAllowed; }
|
public boolean isHostFactionAllowed() { return this.hostFactionAllowed; }
|
||||||
@ -41,6 +30,8 @@ public class TerritoryAccess
|
|||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TerritoryAccess(String factionID)
|
public TerritoryAccess(String factionID)
|
||||||
{
|
{
|
||||||
hostFactionId = factionID;
|
hostFactionId = factionID;
|
||||||
@ -57,30 +48,30 @@ public class TerritoryAccess
|
|||||||
|
|
||||||
public void addFaction(String factionId) { this.getFactionIds().add(factionId); }
|
public void addFaction(String factionId) { this.getFactionIds().add(factionId); }
|
||||||
public void addFaction(Faction faction) { this.addFaction(faction.getId()); }
|
public void addFaction(Faction faction) { this.addFaction(faction.getId()); }
|
||||||
public void removeFaction(String factionID) { this.getFactionIds().remove(factionID); }
|
public void removeFaction(String factionId) { this.getFactionIds().remove(factionId); }
|
||||||
public void removeFaction(Faction faction) { this.removeFaction(faction.getId()); }
|
public void removeFaction(Faction faction) { this.removeFaction(faction.getId()); }
|
||||||
|
|
||||||
// return true if faction was added, false if it was removed
|
// return true if faction was added, false if it was removed
|
||||||
public boolean toggleFaction(String factionID)
|
public boolean toggleFaction(String factionId)
|
||||||
{
|
{
|
||||||
// if the host faction, special handling
|
// if the host faction, special handling
|
||||||
if (doesHostFactionMatch(factionID))
|
if (this.doesHostFactionMatch(factionId))
|
||||||
{
|
{
|
||||||
this.hostFactionAllowed ^= true;
|
this.hostFactionAllowed ^= true;
|
||||||
return this.hostFactionAllowed;
|
return this.hostFactionAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getFactionIds().contains(factionID))
|
if (this.getFactionIds().contains(factionId))
|
||||||
{
|
{
|
||||||
removeFaction(factionID);
|
this.removeFaction(factionId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.addFaction(factionID);
|
this.addFaction(factionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public boolean toggleFaction(Faction faction)
|
public boolean toggleFaction(Faction faction)
|
||||||
{
|
{
|
||||||
return toggleFaction(faction.getId());
|
return this.toggleFaction(faction.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,19 +84,18 @@ public class TerritoryAccess
|
|||||||
{
|
{
|
||||||
if (this.getFPlayerIds().contains(fplayerID))
|
if (this.getFPlayerIds().contains(fplayerID))
|
||||||
{
|
{
|
||||||
removeFPlayer(fplayerID);
|
this.removeFPlayer(fplayerID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
addFPlayer(fplayerID);
|
this.addFPlayer(fplayerID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public boolean toggleFPlayer(FPlayer fplayer)
|
public boolean toggleFPlayer(FPlayer fplayer)
|
||||||
{
|
{
|
||||||
return toggleFPlayer(fplayer.getId());
|
return this.toggleFPlayer(fplayer.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean doesHostFactionMatch(Object testSubject)
|
public boolean doesHostFactionMatch(Object testSubject)
|
||||||
{
|
{
|
||||||
if (testSubject instanceof String)
|
if (testSubject instanceof String)
|
||||||
@ -126,9 +116,16 @@ public class TerritoryAccess
|
|||||||
// considered "default" if host faction is still allowed and nobody has been granted access
|
// considered "default" if host faction is still allowed and nobody has been granted access
|
||||||
public boolean isDefault()
|
public boolean isDefault()
|
||||||
{
|
{
|
||||||
return this.hostFactionAllowed && factionIds.isEmpty() && fplayerIds.isEmpty();
|
return this.hostFactionAllowed && this.factionIds.isEmpty() && this.fplayerIds.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDefault(String factionId)
|
||||||
|
{
|
||||||
|
this.hostFactionId = factionId;
|
||||||
|
this.hostFactionAllowed = true;
|
||||||
|
this.factionIds.clear();
|
||||||
|
this.fplayerIds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public String factionList()
|
public String factionList()
|
||||||
{
|
{
|
||||||
@ -175,9 +172,9 @@ public class TerritoryAccess
|
|||||||
{
|
{
|
||||||
return factionHasAccess(faction.getId());
|
return factionHasAccess(faction.getId());
|
||||||
}
|
}
|
||||||
public boolean factionHasAccess(String factionID)
|
public boolean factionHasAccess(String factionId)
|
||||||
{
|
{
|
||||||
return factionIds.contains(factionID);
|
return factionIds.contains(factionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should normally only be checked after running subjectHasAccess() or fPlayerHasAccess() above to see if they have access explicitly granted
|
// this should normally only be checked after running subjectHasAccess() or fPlayerHasAccess() above to see if they have access explicitly granted
|
||||||
|
Loading…
Reference in New Issue
Block a user