mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-30 14:13:52 +01:00
Add method to get all claims for a given faction.
This commit is contained in:
parent
d0b514eff6
commit
9076e780cf
@ -3,6 +3,7 @@ package com.massivecraft.factions;
|
||||
import com.massivecraft.factions.zcore.persist.json.JSONBoard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public abstract class Board {
|
||||
@ -33,6 +34,10 @@ public abstract class Board {
|
||||
|
||||
public abstract void removeAt(FLocation flocation);
|
||||
|
||||
public abstract Set<FLocation> getAllClaims(String factionId);
|
||||
|
||||
public abstract Set<FLocation> getAllClaims(Faction faction);
|
||||
|
||||
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
|
||||
public abstract void clearOwnershipAt(FLocation flocation);
|
||||
|
||||
|
@ -232,5 +232,7 @@ public interface Faction extends EconomyParticipator {
|
||||
// ----------------------------------------------//
|
||||
public void remove();
|
||||
|
||||
public Set<FLocation> getAllClaims();
|
||||
|
||||
public void setId(String id);
|
||||
}
|
||||
|
@ -6,10 +6,7 @@ import com.massivecraft.factions.util.AsciiCompass;
|
||||
import com.massivecraft.factions.util.LazyLocation;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
@ -57,6 +54,22 @@ public abstract class MemoryBoard extends Board {
|
||||
flocationIds.remove(flocation);
|
||||
}
|
||||
|
||||
public Set<FLocation> getAllClaims(String factionId) {
|
||||
Set<FLocation> locs = new HashSet<FLocation>();
|
||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<FLocation, String> entry = iter.next();
|
||||
if (entry.getValue().equals(factionId)) {
|
||||
locs.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
public Set<FLocation> getAllClaims(Faction faction) {
|
||||
return getAllClaims(faction.getId());
|
||||
}
|
||||
|
||||
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
|
||||
public void clearOwnershipAt(FLocation flocation) {
|
||||
Faction faction = getFactionAt(flocation);
|
||||
@ -105,11 +118,13 @@ public abstract class MemoryBoard extends Board {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is another faction within a given radius other than Wilderness.
|
||||
* Used for HCF feature that requires a 'buffer' between factions.
|
||||
* Checks if there is another faction within a given radius other than Wilderness. Used for HCF feature that
|
||||
* requires a 'buffer' between factions.
|
||||
*
|
||||
* @param flocation - center location.
|
||||
* @param faction - faction checking for.
|
||||
* @param radius - chunk radius to check.
|
||||
* @param faction - faction checking for.
|
||||
* @param radius - chunk radius to check.
|
||||
*
|
||||
* @return true if another Faction is within the radius, otherwise false.
|
||||
*/
|
||||
public boolean hasFactionWithin(FLocation flocation, Faction faction, int radius) {
|
||||
|
@ -787,4 +787,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
fPlayer.resetFactionData(false);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<FLocation> getAllClaims() {
|
||||
return Board.getInstance().getAllClaims(this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user