2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
import com.massivecraft.factions.zcore.persist.json.JSONBoard;
|
2018-02-11 00:59:21 +01:00
|
|
|
import mkremins.fanciful.FancyMessage;
|
2017-09-04 22:57:51 +02:00
|
|
|
import org.bukkit.World;
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2019-08-21 19:52:03 +02:00
|
|
|
import java.util.List;
|
2015-04-26 07:02:30 +02:00
|
|
|
import java.util.Set;
|
2014-11-06 01:36:47 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-10-19 07:37:25 +02:00
|
|
|
public abstract class Board {
|
2019-09-15 11:15:33 +02:00
|
|
|
protected static Board instance = getBoardImpl();
|
2014-11-06 01:36:47 +01:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
private static Board getBoardImpl() {
|
|
|
|
switch (Conf.backEnd) {
|
|
|
|
case JSON:
|
|
|
|
return new JSONBoard();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public static Board getInstance() {
|
|
|
|
return instance;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
//----------------------------------------------//
|
|
|
|
// Get and Set
|
|
|
|
//----------------------------------------------//
|
|
|
|
public abstract String getIdAt(FLocation flocation);
|
2018-07-12 18:11:07 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract Faction getFactionAt(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void setIdAt(String id, FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void setFactionAt(Faction faction, FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void removeAt(FLocation flocation);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract Set<FLocation> getAllClaims(String factionId);
|
2015-04-26 07:02:30 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract Set<FLocation> getAllClaims(Faction faction);
|
2015-04-26 07:02:30 +02:00
|
|
|
|
2019-09-15 11:15:33 +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
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void unclaimAll(String factionId);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void unclaimAllInWorld(String factionId, World world);
|
2017-09-04 22:57:51 +02:00
|
|
|
|
2019-09-15 11:15:33 +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
|
|
|
|
2019-09-15 11:15:33 +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
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract boolean hasFactionWithin(FLocation flocation, Faction faction, int radius);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
//----------------------------------------------//
|
|
|
|
// Cleaner. Remove orphaned foreign keys
|
|
|
|
//----------------------------------------------//
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void clean();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
//----------------------------------------------//
|
|
|
|
// Coord count
|
|
|
|
//----------------------------------------------//
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract int getFactionCoordCount(String factionId);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract int getFactionCoordCount(Faction faction);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract int getFactionCoordCountInWorld(Faction faction, String worldName);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
//----------------------------------------------//
|
|
|
|
// Map generation
|
|
|
|
//----------------------------------------------//
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
/*
|
|
|
|
* 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 List<FancyMessage> getMap(FPlayer fPlayer, FLocation flocation, double inDegrees);
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void forceSave();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract void forceSave(boolean sync);
|
2015-08-07 00:41:37 +02:00
|
|
|
|
2019-09-15 11:15:33 +02:00
|
|
|
public abstract boolean load();
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|