Saber-Factions/src/main/java/com/massivecraft/factions/Board.java

80 lines
2.6 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions;
2011-02-06 13:36:11 +01:00
import com.massivecraft.factions.zcore.persist.json.JSONBoard;
2014-11-06 01:36:47 +01:00
import java.util.ArrayList;
2014-04-04 20:55:21 +02:00
public abstract class Board {
protected static Board instance = getBoardImpl();
2014-11-06 01:36:47 +01:00
2014-04-04 20:55:21 +02:00
//----------------------------------------------//
// Get and Set
//----------------------------------------------//
public abstract String getIdAt(FLocation flocation);
2014-04-04 20:55:21 +02:00
private static Board getBoardImpl() {
switch (Conf.backEnd) {
case JSON:
return new JSONBoard();
}
return null;
2014-04-04 20:55:21 +02:00
}
public static Board getInstance() {
return instance;
2014-04-04 20:55:21 +02:00
}
public abstract Faction getFactionAt(FLocation flocation);
2014-04-04 20:55:21 +02:00
public abstract void setIdAt(String id, FLocation flocation);
2014-04-04 20:55:21 +02:00
public abstract void setFactionAt(Faction faction, FLocation flocation);
2014-04-04 20:55:21 +02:00
public abstract void removeAt(FLocation flocation);
2014-04-04 20:55:21 +02:00
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
public abstract void clearOwnershipAt(FLocation flocation);
2014-04-04 20:55:21 +02:00
public abstract void unclaimAll(String factionId);
2014-04-04 20:55:21 +02:00
// Is this coord NOT completely surrounded by coords claimed by the same faction?
// Simpler: Is there any nearby coord with a faction other than the faction here?
public abstract boolean isBorderLocation(FLocation flocation);
2014-04-04 20:55:21 +02:00
// Is this coord connected to any coord claimed by the specified faction?
public abstract boolean isConnectedLocation(FLocation flocation, Faction faction);
2014-04-04 20:55:21 +02:00
public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius);
2014-04-04 20:55:21 +02:00
//----------------------------------------------//
// Cleaner. Remove orphaned foreign keys
//----------------------------------------------//
public abstract void clean();
2014-04-04 20:55:21 +02:00
//----------------------------------------------//
// Coord count
//----------------------------------------------//
public abstract int getFactionCoordCount(String factionId);
2014-04-04 20:55:21 +02:00
public abstract int getFactionCoordCount(Faction faction);
2014-04-04 20:55:21 +02:00
public abstract int getFactionCoordCountInWorld(Faction faction, String worldName);
2014-04-04 20:55:21 +02:00
//----------------------------------------------//
// Map generation
//----------------------------------------------//
/**
* The map is relative to a coord and a faction north is in the direction of decreasing x east is in the direction
* of decreasing z
*/
public abstract ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees);
2014-04-04 20:55:21 +02:00
public abstract boolean forceSave();
2014-04-04 20:55:21 +02:00
public abstract boolean load();
2011-02-06 13:36:11 +01:00
}