Saber-Factions/src/main/java/com/massivecraft/factions/Board.java
t00thpick1 ee52016a87 Abstract Data storage method for future implementations. Thanks to Ryan from Reactive MC
Also included:
-Heavily optimized loading process
-Optimizations for various commands.
2014-10-30 23:59:59 -04:00

78 lines
2.5 KiB
Java

package com.massivecraft.factions;
import java.util.*;
import com.massivecraft.factions.zcore.persist.json.JSONBoard;
public abstract class Board {
protected static Board instance = getBoardImpl();
//----------------------------------------------//
// Get and Set
//----------------------------------------------//
public abstract String getIdAt(FLocation flocation);
private static Board getBoardImpl() {
switch (Conf.backEnd) {
case JSON:
return new JSONBoard();
}
return null;
}
public static Board getInstance() {
return instance;
}
public abstract Faction getFactionAt(FLocation flocation);
public abstract void setIdAt(String id, FLocation flocation);
public abstract void setFactionAt(Faction faction, FLocation flocation);
public abstract void removeAt(FLocation flocation);
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
public abstract void clearOwnershipAt(FLocation flocation);
public abstract void unclaimAll(String factionId);
// 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);
// Is this coord connected to any coord claimed by the specified faction?
public abstract boolean isConnectedLocation(FLocation flocation, Faction faction);
//----------------------------------------------//
// Cleaner. Remove orphaned foreign keys
//----------------------------------------------//
public abstract void clean();
//----------------------------------------------//
// Coord count
//----------------------------------------------//
public abstract int getFactionCoordCount(String factionId);
public abstract int getFactionCoordCount(Faction faction);
public abstract int getFactionCoordCountInWorld(Faction faction, String worldName);
//----------------------------------------------//
// 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);
public abstract boolean forceSave();
public abstract boolean load();
}