More reformatting
This commit is contained in:
parent
dc54f78cc1
commit
5066934a95
@ -46,28 +46,23 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAt(FLocation flocation) {
|
public static void removeAt(FLocation flocation) {
|
||||||
clearOwnershipAt(flocation);
|
clearOwnershipAt(flocation); flocationIds.remove(flocation);
|
||||||
flocationIds.remove(flocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
|
// not to be confused with claims, ownership referring to further member-specific ownership of a claim
|
||||||
public static void clearOwnershipAt(FLocation flocation) {
|
public static void clearOwnershipAt(FLocation flocation) {
|
||||||
Faction faction = getFactionAt(flocation);
|
Faction faction = getFactionAt(flocation); if (faction != null && faction.isNormal()) {
|
||||||
if (faction != null && faction.isNormal()) {
|
|
||||||
faction.clearClaimOwnership(flocation);
|
faction.clearClaimOwnership(flocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unclaimAll(String factionId) {
|
public static void unclaimAll(String factionId) {
|
||||||
Faction faction = Factions.i.get(factionId);
|
Faction faction = Factions.i.get(factionId); if (faction != null && faction.isNormal()) {
|
||||||
if (faction != null && faction.isNormal()) {
|
|
||||||
faction.clearAllClaimOwnership();
|
faction.clearAllClaimOwnership();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator(); while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
Entry<FLocation, String> entry = iter.next(); if (entry.getValue().equals(factionId)) {
|
||||||
Entry<FLocation, String> entry = iter.next();
|
|
||||||
if (entry.getValue().equals(factionId)) {
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,20 +71,16 @@ public class Board {
|
|||||||
// Is this coord NOT completely surrounded by coords claimed by the same faction?
|
// 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?
|
// Simpler: Is there any nearby coord with a faction other than the faction here?
|
||||||
public static boolean isBorderLocation(FLocation flocation) {
|
public static boolean isBorderLocation(FLocation flocation) {
|
||||||
Faction faction = getFactionAt(flocation);
|
Faction faction = getFactionAt(flocation); FLocation a = flocation.getRelative(1, 0);
|
||||||
FLocation a = flocation.getRelative(1, 0);
|
FLocation b = flocation.getRelative(-1, 0); FLocation c = flocation.getRelative(0, 1);
|
||||||
FLocation b = flocation.getRelative(-1, 0);
|
|
||||||
FLocation c = flocation.getRelative(0, 1);
|
|
||||||
FLocation d = flocation.getRelative(0, -1);
|
FLocation d = flocation.getRelative(0, -1);
|
||||||
return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d);
|
return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this coord connected to any coord claimed by the specified faction?
|
// Is this coord connected to any coord claimed by the specified faction?
|
||||||
public static boolean isConnectedLocation(FLocation flocation, Faction faction) {
|
public static boolean isConnectedLocation(FLocation flocation, Faction faction) {
|
||||||
FLocation a = flocation.getRelative(1, 0);
|
FLocation a = flocation.getRelative(1, 0); FLocation b = flocation.getRelative(-1, 0);
|
||||||
FLocation b = flocation.getRelative(-1, 0);
|
FLocation c = flocation.getRelative(0, 1); FLocation d = flocation.getRelative(0, -1);
|
||||||
FLocation c = flocation.getRelative(0, 1);
|
|
||||||
FLocation d = flocation.getRelative(0, -1);
|
|
||||||
return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d);
|
return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +90,9 @@ public class Board {
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public static void clean() {
|
public static void clean() {
|
||||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator(); while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
Entry<FLocation, String> entry = iter.next(); if (!Factions.i.exists(entry.getValue())) {
|
||||||
Entry<FLocation, String> entry = iter.next();
|
P.p.log("Board cleaner removed " + entry.getValue() + " from " + entry.getKey()); iter.remove();
|
||||||
if (!Factions.i.exists(entry.getValue())) {
|
|
||||||
P.p.log("Board cleaner removed " + entry.getValue() + " from " + entry.getKey());
|
|
||||||
iter.remove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,13 +102,11 @@ public class Board {
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public static int getFactionCoordCount(String factionId) {
|
public static int getFactionCoordCount(String factionId) {
|
||||||
int ret = 0;
|
int ret = 0; for (String thatFactionId : flocationIds.values()) {
|
||||||
for (String thatFactionId : flocationIds.values()) {
|
|
||||||
if (thatFactionId.equals(factionId)) {
|
if (thatFactionId.equals(factionId)) {
|
||||||
ret += 1;
|
ret += 1;
|
||||||
}
|
}
|
||||||
}
|
} return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getFactionCoordCount(Faction faction) {
|
public static int getFactionCoordCount(Faction faction) {
|
||||||
@ -128,16 +114,13 @@ public class Board {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getFactionCoordCountInWorld(Faction faction, String worldName) {
|
public static int getFactionCoordCountInWorld(Faction faction, String worldName) {
|
||||||
String factionId = faction.getId();
|
String factionId = faction.getId(); int ret = 0;
|
||||||
int ret = 0;
|
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator(); while (iter.hasNext()) {
|
||||||
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Entry<FLocation, String> entry = iter.next();
|
Entry<FLocation, String> entry = iter.next();
|
||||||
if (entry.getValue().equals(factionId) && entry.getKey().getWorldName().equals(worldName)) {
|
if (entry.getValue().equals(factionId) && entry.getKey().getWorldName().equals(worldName)) {
|
||||||
ret += 1;
|
ret += 1;
|
||||||
}
|
}
|
||||||
}
|
} return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
@ -149,68 +132,47 @@ public class Board {
|
|||||||
* of decreasing z
|
* of decreasing z
|
||||||
*/
|
*/
|
||||||
public static ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) {
|
public static ArrayList<String> getMap(Faction faction, FLocation flocation, double inDegrees) {
|
||||||
ArrayList<String> ret = new ArrayList<String>();
|
ArrayList<String> ret = new ArrayList<String>(); Faction factionLoc = getFactionAt(flocation);
|
||||||
Faction factionLoc = getFactionAt(flocation);
|
|
||||||
ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction)));
|
ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction)));
|
||||||
|
|
||||||
int halfWidth = Conf.mapWidth / 2;
|
int halfWidth = Conf.mapWidth / 2; int halfHeight = Conf.mapHeight / 2;
|
||||||
int halfHeight = Conf.mapHeight / 2;
|
FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight); int width = halfWidth * 2 + 1;
|
||||||
FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight);
|
|
||||||
int width = halfWidth * 2 + 1;
|
|
||||||
int height = halfHeight * 2 + 1;
|
int height = halfHeight * 2 + 1;
|
||||||
|
|
||||||
if (Conf.showMapFactionKey) {
|
if (Conf.showMapFactionKey) {
|
||||||
height--;
|
height--;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Character> fList = new HashMap<String, Character>();
|
Map<String, Character> fList = new HashMap<String, Character>(); int chrIdx = 0;
|
||||||
int chrIdx = 0;
|
|
||||||
|
|
||||||
// For each row
|
// For each row
|
||||||
for (int dz = 0; dz < height; dz++) {
|
for (int dz = 0; dz < height; dz++) {
|
||||||
// Draw and add that row
|
// Draw and add that row
|
||||||
String row = "";
|
String row = ""; for (int dx = 0; dx < width; dx++) {
|
||||||
for (int dx = 0; dx < width; dx++) {
|
|
||||||
if (dx == halfWidth && dz == halfHeight) {
|
if (dx == halfWidth && dz == halfHeight) {
|
||||||
row += ChatColor.AQUA + "+";
|
row += ChatColor.AQUA + "+";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
||||||
Faction factionHere = getFactionAt(flocationHere);
|
Faction factionHere = getFactionAt(flocationHere);
|
||||||
Relation relation = faction.getRelationTo(factionHere);
|
Relation relation = faction.getRelationTo(factionHere); if (factionHere.isNone()) {
|
||||||
if (factionHere.isNone()) {
|
|
||||||
row += ChatColor.GRAY + "-";
|
row += ChatColor.GRAY + "-";
|
||||||
}
|
} else if (factionHere.isSafeZone()) {
|
||||||
else if (factionHere.isSafeZone()) {
|
|
||||||
row += Conf.colorPeaceful + "+";
|
row += Conf.colorPeaceful + "+";
|
||||||
}
|
} else if (factionHere.isWarZone()) {
|
||||||
else if (factionHere.isWarZone()) {
|
|
||||||
row += ChatColor.DARK_RED + "+";
|
row += ChatColor.DARK_RED + "+";
|
||||||
}
|
} else if (factionHere == faction ||
|
||||||
else if
|
factionHere == factionLoc ||
|
||||||
(
|
relation.isAtLeast(Relation.ALLY) ||
|
||||||
factionHere == faction
|
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL)) ||
|
||||||
||
|
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))) {
|
||||||
factionHere == factionLoc
|
|
||||||
||
|
|
||||||
relation.isAtLeast(Relation.ALLY)
|
|
||||||
||
|
|
||||||
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
|
||||||
||
|
|
||||||
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
|
|
||||||
) {
|
|
||||||
if (!fList.containsKey(factionHere.getTag())) {
|
if (!fList.containsKey(factionHere.getTag())) {
|
||||||
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
|
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
|
||||||
}
|
} char tag = fList.get(factionHere.getTag()); row += factionHere.getColorTo(faction) + "" + tag;
|
||||||
char tag = fList.get(factionHere.getTag());
|
} else {
|
||||||
row += factionHere.getColorTo(faction) + "" + tag;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
row += ChatColor.GRAY + "-";
|
row += ChatColor.GRAY + "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} ret.add(row);
|
||||||
ret.add(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the compass
|
// Get the compass
|
||||||
@ -223,11 +185,9 @@ public class Board {
|
|||||||
|
|
||||||
// Add the faction key
|
// Add the faction key
|
||||||
if (Conf.showMapFactionKey) {
|
if (Conf.showMapFactionKey) {
|
||||||
String fRow = "";
|
String fRow = ""; for (String key : fList.keySet()) {
|
||||||
for (String key : fList.keySet()) {
|
|
||||||
fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key);
|
fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key);
|
||||||
}
|
} ret.add(fRow);
|
||||||
ret.add(fRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -241,13 +201,10 @@ public class Board {
|
|||||||
public static Map<String, Map<String, String>> dumpAsSaveFormat() {
|
public static Map<String, Map<String, String>> dumpAsSaveFormat() {
|
||||||
Map<String, Map<String, String>> worldCoordIds = new HashMap<String, Map<String, String>>();
|
Map<String, Map<String, String>> worldCoordIds = new HashMap<String, Map<String, String>>();
|
||||||
|
|
||||||
String worldName, coords;
|
String worldName, coords; String id;
|
||||||
String id;
|
|
||||||
|
|
||||||
for (Entry<FLocation, String> entry : flocationIds.entrySet()) {
|
for (Entry<FLocation, String> entry : flocationIds.entrySet()) {
|
||||||
worldName = entry.getKey().getWorldName();
|
worldName = entry.getKey().getWorldName(); coords = entry.getKey().getCoordString(); id = entry.getValue();
|
||||||
coords = entry.getKey().getCoordString();
|
|
||||||
id = entry.getValue();
|
|
||||||
if (!worldCoordIds.containsKey(worldName)) {
|
if (!worldCoordIds.containsKey(worldName)) {
|
||||||
worldCoordIds.put(worldName, new TreeMap<String, String>());
|
worldCoordIds.put(worldName, new TreeMap<String, String>());
|
||||||
}
|
}
|
||||||
@ -261,18 +218,12 @@ public class Board {
|
|||||||
public static void loadFromSaveFormat(Map<String, Map<String, String>> worldCoordIds) {
|
public static void loadFromSaveFormat(Map<String, Map<String, String>> worldCoordIds) {
|
||||||
flocationIds.clear();
|
flocationIds.clear();
|
||||||
|
|
||||||
String worldName;
|
String worldName; String[] coords; int x, z; String factionId;
|
||||||
String[] coords;
|
|
||||||
int x, z;
|
|
||||||
String factionId;
|
|
||||||
|
|
||||||
for (Entry<String, Map<String, String>> entry : worldCoordIds.entrySet()) {
|
for (Entry<String, Map<String, String>> entry : worldCoordIds.entrySet()) {
|
||||||
worldName = entry.getKey();
|
worldName = entry.getKey(); for (Entry<String, String> entry2 : entry.getValue().entrySet()) {
|
||||||
for (Entry<String, String> entry2 : entry.getValue().entrySet()) {
|
coords = entry2.getKey().trim().split("[,\\s]+"); x = Integer.parseInt(coords[0]);
|
||||||
coords = entry2.getKey().trim().split("[,\\s]+");
|
z = Integer.parseInt(coords[1]); factionId = entry2.getValue();
|
||||||
x = Integer.parseInt(coords[0]);
|
|
||||||
z = Integer.parseInt(coords[1]);
|
|
||||||
factionId = entry2.getValue();
|
|
||||||
flocationIds.put(new FLocation(worldName, x, z), factionId);
|
flocationIds.put(new FLocation(worldName, x, z), factionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,9 +235,7 @@ public class Board {
|
|||||||
try {
|
try {
|
||||||
DiscUtil.write(file, P.p.gson.toJson(dumpAsSaveFormat()));
|
DiscUtil.write(file, P.p.gson.toJson(dumpAsSaveFormat()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace(); P.p.log("Failed to save the board to disk."); return false;
|
||||||
P.p.log("Failed to save the board to disk.");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -296,20 +245,15 @@ public class Board {
|
|||||||
P.p.log("Loading board from disk");
|
P.p.log("Loading board from disk");
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
P.p.log("No board to load from disk. Creating new file.");
|
P.p.log("No board to load from disk. Creating new file."); save(); return true;
|
||||||
save();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Type type = new TypeToken<Map<String, Map<String, String>>>() {
|
Type type = new TypeToken<Map<String, Map<String, String>>>() {}.getType();
|
||||||
}.getType();
|
|
||||||
Map<String, Map<String, String>> worldCoordIds = P.p.gson.fromJson(DiscUtil.read(file), type);
|
Map<String, Map<String, String>> worldCoordIds = P.p.gson.fromJson(DiscUtil.read(file), type);
|
||||||
loadFromSaveFormat(worldCoordIds);
|
loadFromSaveFormat(worldCoordIds);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace(); P.p.log("Failed to load the board from disk."); return false;
|
||||||
P.p.log("Failed to load the board from disk.");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -266,37 +266,24 @@ public class Conf {
|
|||||||
static {
|
static {
|
||||||
baseCommandAliases.add("f");
|
baseCommandAliases.add("f");
|
||||||
|
|
||||||
territoryEnemyDenyCommands.add("home");
|
territoryEnemyDenyCommands.add("home"); territoryEnemyDenyCommands.add("sethome");
|
||||||
territoryEnemyDenyCommands.add("sethome");
|
territoryEnemyDenyCommands.add("spawn"); territoryEnemyDenyCommands.add("tpahere");
|
||||||
territoryEnemyDenyCommands.add("spawn");
|
territoryEnemyDenyCommands.add("tpaccept"); territoryEnemyDenyCommands.add("tpa");
|
||||||
territoryEnemyDenyCommands.add("tpahere");
|
|
||||||
territoryEnemyDenyCommands.add("tpaccept");
|
|
||||||
territoryEnemyDenyCommands.add("tpa");
|
|
||||||
|
|
||||||
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
|
territoryProtectedMaterials.add(Material.WOODEN_DOOR); territoryProtectedMaterials.add(Material.TRAP_DOOR);
|
||||||
territoryProtectedMaterials.add(Material.TRAP_DOOR);
|
territoryProtectedMaterials.add(Material.FENCE_GATE); territoryProtectedMaterials.add(Material.DISPENSER);
|
||||||
territoryProtectedMaterials.add(Material.FENCE_GATE);
|
territoryProtectedMaterials.add(Material.CHEST); territoryProtectedMaterials.add(Material.FURNACE);
|
||||||
territoryProtectedMaterials.add(Material.DISPENSER);
|
|
||||||
territoryProtectedMaterials.add(Material.CHEST);
|
|
||||||
territoryProtectedMaterials.add(Material.FURNACE);
|
|
||||||
territoryProtectedMaterials.add(Material.BURNING_FURNACE);
|
territoryProtectedMaterials.add(Material.BURNING_FURNACE);
|
||||||
territoryProtectedMaterials.add(Material.DIODE_BLOCK_OFF);
|
territoryProtectedMaterials.add(Material.DIODE_BLOCK_OFF);
|
||||||
territoryProtectedMaterials.add(Material.DIODE_BLOCK_ON);
|
territoryProtectedMaterials.add(Material.DIODE_BLOCK_ON); territoryProtectedMaterials.add(Material.JUKEBOX);
|
||||||
territoryProtectedMaterials.add(Material.JUKEBOX);
|
|
||||||
territoryProtectedMaterials.add(Material.BREWING_STAND);
|
territoryProtectedMaterials.add(Material.BREWING_STAND);
|
||||||
territoryProtectedMaterials.add(Material.ENCHANTMENT_TABLE);
|
territoryProtectedMaterials.add(Material.ENCHANTMENT_TABLE); territoryProtectedMaterials.add(Material.CAULDRON);
|
||||||
territoryProtectedMaterials.add(Material.CAULDRON);
|
territoryProtectedMaterials.add(Material.SOIL); territoryProtectedMaterials.add(Material.BEACON);
|
||||||
territoryProtectedMaterials.add(Material.SOIL);
|
territoryProtectedMaterials.add(Material.ANVIL); territoryProtectedMaterials.add(Material.TRAPPED_CHEST);
|
||||||
territoryProtectedMaterials.add(Material.BEACON);
|
territoryProtectedMaterials.add(Material.DROPPER); territoryProtectedMaterials.add(Material.HOPPER);
|
||||||
territoryProtectedMaterials.add(Material.ANVIL);
|
|
||||||
territoryProtectedMaterials.add(Material.TRAPPED_CHEST);
|
|
||||||
territoryProtectedMaterials.add(Material.DROPPER);
|
|
||||||
territoryProtectedMaterials.add(Material.HOPPER);
|
|
||||||
|
|
||||||
territoryDenyUseageMaterials.add(Material.FIREBALL);
|
territoryDenyUseageMaterials.add(Material.FIREBALL); territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
|
||||||
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
|
territoryDenyUseageMaterials.add(Material.BUCKET); territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
|
||||||
territoryDenyUseageMaterials.add(Material.BUCKET);
|
|
||||||
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
|
|
||||||
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
|
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
|
||||||
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR);
|
territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR);
|
||||||
@ -325,20 +312,13 @@ public class Conf {
|
|||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
|
||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
|
||||||
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
|
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE); safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
|
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER); safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER);
|
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN); safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
|
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE); safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
|
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH); safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
|
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER); safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
|
safeZoneNerfedCreatureTypes.add(EntityType.WITCH); safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.WITCH);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
|
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ public class FLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FLocation(String worldName, int x, int z) {
|
public FLocation(String worldName, int x, int z) {
|
||||||
this.worldName = worldName;
|
this.worldName = worldName; this.x = x; this.z = z;
|
||||||
this.x = x;
|
|
||||||
this.z = z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation(Location location) {
|
public FLocation(Location location) {
|
||||||
@ -126,22 +124,17 @@ public class FLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getDistanceTo(FLocation that) {
|
public double getDistanceTo(FLocation that) {
|
||||||
double dx = that.x - this.x;
|
double dx = that.x - this.x; double dz = that.z - this.z; return Math.sqrt(dx * dx + dz * dz);
|
||||||
double dz = that.z - this.z;
|
|
||||||
return Math.sqrt(dx * dx + dz * dz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Some Geometry
|
// Some Geometry
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public Set<FLocation> getCircle(double radius) {
|
public Set<FLocation> getCircle(double radius) {
|
||||||
Set<FLocation> ret = new LinkedHashSet<FLocation>();
|
Set<FLocation> ret = new LinkedHashSet<FLocation>(); if (radius <= 0) { return ret; }
|
||||||
if (radius <= 0) { return ret; }
|
|
||||||
|
|
||||||
int xfrom = (int) Math.floor(this.x - radius);
|
int xfrom = (int) Math.floor(this.x - radius); int xto = (int) Math.ceil(this.x + radius);
|
||||||
int xto = (int) Math.ceil(this.x + radius);
|
int zfrom = (int) Math.floor(this.z - radius); int zto = (int) Math.ceil(this.z + radius);
|
||||||
int zfrom = (int) Math.floor(this.z - radius);
|
|
||||||
int zto = (int) Math.ceil(this.z + radius);
|
|
||||||
|
|
||||||
for (int x = xfrom; x <= xto; x++) {
|
for (int x = xfrom; x <= xto; x++) {
|
||||||
for (int z = zfrom; z <= zto; z++) {
|
for (int z = zfrom; z <= zto; z++) {
|
||||||
@ -177,8 +170,7 @@ public class FLocation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == this) { return true; }
|
if (obj == this) { return true; } if (!(obj instanceof FLocation)) { return false; }
|
||||||
if (!(obj instanceof FLocation)) { return false; }
|
|
||||||
|
|
||||||
FLocation that = (FLocation) obj;
|
FLocation that = (FLocation) obj;
|
||||||
return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName));
|
return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName));
|
||||||
|
@ -44,8 +44,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
public Faction getFaction() {
|
public Faction getFaction() {
|
||||||
if (this.factionId == null) {
|
if (this.factionId == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
} return Factions.i.get(this.factionId);
|
||||||
return Factions.i.get(this.factionId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId() {
|
public String getFactionId() {
|
||||||
@ -57,10 +56,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFaction(Faction faction) {
|
public void setFaction(Faction faction) {
|
||||||
Faction oldFaction = this.getFaction();
|
Faction oldFaction = this.getFaction(); if (oldFaction != null) { oldFaction.removeFPlayer(this); }
|
||||||
if (oldFaction != null) { oldFaction.removeFPlayer(this); }
|
faction.addFPlayer(this); this.factionId = faction.getId();
|
||||||
faction.addFPlayer(this);
|
|
||||||
this.factionId = faction.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIELD: role
|
// FIELD: role
|
||||||
@ -109,11 +106,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoClaimFor(Faction faction) {
|
public void setAutoClaimFor(Faction faction) {
|
||||||
this.autoClaimFor = faction;
|
this.autoClaimFor = faction; if (this.autoClaimFor != null) {
|
||||||
if (this.autoClaimFor != null) {
|
|
||||||
// TODO: merge these into same autoclaim
|
// TODO: merge these into same autoclaim
|
||||||
this.autoSafeZoneEnabled = false;
|
this.autoSafeZoneEnabled = false; this.autoWarZoneEnabled = false;
|
||||||
this.autoWarZoneEnabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,10 +120,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIsAutoSafeClaimEnabled(boolean enabled) {
|
public void setIsAutoSafeClaimEnabled(boolean enabled) {
|
||||||
this.autoSafeZoneEnabled = enabled;
|
this.autoSafeZoneEnabled = enabled; if (enabled) {
|
||||||
if (enabled) {
|
this.autoClaimFor = null; this.autoWarZoneEnabled = false;
|
||||||
this.autoClaimFor = null;
|
|
||||||
this.autoWarZoneEnabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,10 +133,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIsAutoWarClaimEnabled(boolean enabled) {
|
public void setIsAutoWarClaimEnabled(boolean enabled) {
|
||||||
this.autoWarZoneEnabled = enabled;
|
this.autoWarZoneEnabled = enabled; if (enabled) {
|
||||||
if (enabled) {
|
this.autoClaimFor = null; this.autoSafeZoneEnabled = false;
|
||||||
this.autoClaimFor = null;
|
|
||||||
this.autoSafeZoneEnabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,8 +164,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
public ChatMode getChatMode() {
|
public ChatMode getChatMode() {
|
||||||
if (this.factionId.equals("0") || !Conf.factionOnlyChat) {
|
if (this.factionId.equals("0") || !Conf.factionOnlyChat) {
|
||||||
this.chatMode = ChatMode.PUBLIC;
|
this.chatMode = ChatMode.PUBLIC;
|
||||||
}
|
} return chatMode;
|
||||||
return chatMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIELD: chatSpy
|
// FIELD: chatSpy
|
||||||
@ -199,17 +189,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
|
|
||||||
// GSON need this noarg constructor.
|
// GSON need this noarg constructor.
|
||||||
public FPlayer() {
|
public FPlayer() {
|
||||||
this.resetFactionData(false);
|
this.resetFactionData(false); this.power = Conf.powerPlayerStarting;
|
||||||
this.power = Conf.powerPlayerStarting;
|
this.lastPowerUpdateTime = System.currentTimeMillis(); this.lastLoginTime = System.currentTimeMillis();
|
||||||
this.lastPowerUpdateTime = System.currentTimeMillis();
|
this.mapAutoUpdating = false; this.autoClaimFor = null; this.autoSafeZoneEnabled = false;
|
||||||
this.lastLoginTime = System.currentTimeMillis();
|
|
||||||
this.mapAutoUpdating = false;
|
|
||||||
this.autoClaimFor = null;
|
|
||||||
this.autoSafeZoneEnabled = false;
|
|
||||||
this.autoWarZoneEnabled = false;
|
this.autoWarZoneEnabled = false;
|
||||||
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
|
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
|
||||||
this.deleteMe = false;
|
this.deleteMe = false; this.powerBoost = 0.0;
|
||||||
this.powerBoost = 0.0;
|
|
||||||
|
|
||||||
if (!Conf.newPlayerStartingFactionID.equals("0") && Factions.i.exists(Conf.newPlayerStartingFactionID)) {
|
if (!Conf.newPlayerStartingFactionID.equals("0") && Factions.i.exists(Conf.newPlayerStartingFactionID)) {
|
||||||
this.factionId = Conf.newPlayerStartingFactionID;
|
this.factionId = Conf.newPlayerStartingFactionID;
|
||||||
@ -219,18 +204,14 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
public final void resetFactionData(boolean doSpoutUpdate) {
|
public final void resetFactionData(boolean doSpoutUpdate) {
|
||||||
// clean up any territory ownership in old faction, if there is one
|
// clean up any territory ownership in old faction, if there is one
|
||||||
if (Factions.i.exists(this.getFactionId())) {
|
if (Factions.i.exists(this.getFactionId())) {
|
||||||
Faction currentFaction = this.getFaction();
|
Faction currentFaction = this.getFaction(); currentFaction.removeFPlayer(this);
|
||||||
currentFaction.removeFPlayer(this);
|
|
||||||
if (currentFaction.isNormal()) {
|
if (currentFaction.isNormal()) {
|
||||||
currentFaction.clearClaimOwnership(this);
|
currentFaction.clearClaimOwnership(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.factionId = "0"; // The default neutral faction
|
this.factionId = "0"; // The default neutral faction
|
||||||
this.chatMode = ChatMode.PUBLIC;
|
this.chatMode = ChatMode.PUBLIC; this.role = Role.NORMAL; this.title = ""; this.autoClaimFor = null;
|
||||||
this.role = Role.NORMAL;
|
|
||||||
this.title = "";
|
|
||||||
this.autoClaimFor = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetFactionData() {
|
public void resetFactionData() {
|
||||||
@ -248,9 +229,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
|
|
||||||
|
|
||||||
public void setLastLoginTime(long lastLoginTime) {
|
public void setLastLoginTime(long lastLoginTime) {
|
||||||
losePowerFromBeingOffline();
|
losePowerFromBeingOffline(); this.lastLoginTime = lastLoginTime; this.lastPowerUpdateTime = lastLoginTime;
|
||||||
this.lastLoginTime = lastLoginTime;
|
|
||||||
this.lastPowerUpdateTime = lastLoginTime;
|
|
||||||
if (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) {
|
if (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) {
|
||||||
this.loginPvpDisabled = true;
|
this.loginPvpDisabled = true;
|
||||||
}
|
}
|
||||||
@ -269,10 +248,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.lastLoginTime + (Conf.noPVPDamageToOthersForXSecondsAfterLogin * 1000) < System.currentTimeMillis()) {
|
if (this.lastLoginTime + (Conf.noPVPDamageToOthersForXSecondsAfterLogin * 1000) < System.currentTimeMillis()) {
|
||||||
this.loginPvpDisabled = false;
|
this.loginPvpDisabled = false; return false;
|
||||||
return false;
|
} return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation getLastStoodAt() {
|
public FLocation getLastStoodAt() {
|
||||||
@ -304,27 +281,22 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
if (isOnline()) {
|
if (isOnline()) {
|
||||||
return getPlayer().getName();
|
return getPlayer().getName();
|
||||||
}
|
} OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(getId()));
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(getId()));
|
|
||||||
return player.getName() != null ? player.getName() : getId();
|
return player.getName() != null ? player.getName() : getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
if (!this.hasFaction()) {
|
if (!this.hasFaction()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
} return this.getFaction().getTag();
|
||||||
return this.getFaction().getTag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base concatenations:
|
// Base concatenations:
|
||||||
|
|
||||||
public String getNameAndSomething(String something) {
|
public String getNameAndSomething(String something) {
|
||||||
String ret = this.role.getPrefix();
|
String ret = this.role.getPrefix(); if (something.length() > 0) {
|
||||||
if (something.length() > 0) {
|
|
||||||
ret += something + " ";
|
ret += something + " ";
|
||||||
}
|
} ret += this.getName(); return ret;
|
||||||
ret += this.getName();
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameAndTitle() {
|
public String getNameAndTitle() {
|
||||||
@ -440,11 +412,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
// Health
|
// Health
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public void heal(int amnt) {
|
public void heal(int amnt) {
|
||||||
Player player = this.getPlayer();
|
Player player = this.getPlayer(); if (player == null) {
|
||||||
if (player == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
} player.setHealth(player.getHealth() + amnt);
|
||||||
player.setHealth(player.getHealth() + amnt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -452,14 +422,13 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
// Power
|
// Power
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public double getPower() {
|
public double getPower() {
|
||||||
this.updatePower();
|
this.updatePower(); return this.power;
|
||||||
return this.power;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void alterPower(double delta) {
|
protected void alterPower(double delta) {
|
||||||
this.power += delta;
|
this.power += delta; if (this.power > this.getPowerMax()) {
|
||||||
if (this.power > this.getPowerMax()) { this.power = this.getPowerMax(); }
|
this.power = this.getPowerMax();
|
||||||
else if (this.power < this.getPowerMin()) { this.power = this.getPowerMin(); }
|
} else if (this.power < this.getPowerMin()) { this.power = this.getPowerMin(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMax() {
|
public double getPowerMax() {
|
||||||
@ -484,41 +453,33 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
|
|
||||||
protected void updatePower() {
|
protected void updatePower() {
|
||||||
if (this.isOffline()) {
|
if (this.isOffline()) {
|
||||||
losePowerFromBeingOffline();
|
losePowerFromBeingOffline(); if (!Conf.powerRegenOffline) {
|
||||||
if (!Conf.powerRegenOffline) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} long now = System.currentTimeMillis(); long millisPassed = now - this.lastPowerUpdateTime;
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
long millisPassed = now - this.lastPowerUpdateTime;
|
|
||||||
this.lastPowerUpdateTime = now;
|
this.lastPowerUpdateTime = now;
|
||||||
|
|
||||||
Player thisPlayer = this.getPlayer();
|
Player thisPlayer = this.getPlayer(); if (thisPlayer != null && thisPlayer.isDead()) {
|
||||||
if (thisPlayer != null && thisPlayer.isDead()) {
|
|
||||||
return; // don't let dead players regain power until they respawn
|
return; // don't let dead players regain power until they respawn
|
||||||
}
|
}
|
||||||
|
|
||||||
int millisPerMinute = 60 * 1000;
|
int millisPerMinute = 60 * 1000; this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
|
||||||
this.alterPower(millisPassed * Conf.powerPerMinute / millisPerMinute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void losePowerFromBeingOffline() {
|
protected void losePowerFromBeingOffline() {
|
||||||
if (Conf.powerOfflineLossPerDay > 0.0 && this.power > Conf.powerOfflineLossLimit) {
|
if (Conf.powerOfflineLossPerDay > 0.0 && this.power > Conf.powerOfflineLossLimit) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis(); long millisPassed = now - this.lastPowerUpdateTime;
|
||||||
long millisPassed = now - this.lastPowerUpdateTime;
|
|
||||||
this.lastPowerUpdateTime = now;
|
this.lastPowerUpdateTime = now;
|
||||||
|
|
||||||
double loss = millisPassed * Conf.powerOfflineLossPerDay / (24 * 60 * 60 * 1000);
|
double loss = millisPassed * Conf.powerOfflineLossPerDay / (24 * 60 * 60 * 1000);
|
||||||
if (this.power - loss < Conf.powerOfflineLossLimit) {
|
if (this.power - loss < Conf.powerOfflineLossLimit) {
|
||||||
loss = this.power;
|
loss = this.power;
|
||||||
}
|
} this.alterPower(-loss);
|
||||||
this.alterPower(-loss);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDeath() {
|
public void onDeath() {
|
||||||
this.updatePower();
|
this.updatePower(); this.alterPower(-Conf.powerPerDeath);
|
||||||
this.alterPower(-Conf.powerPerDeath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
@ -550,8 +511,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
String msg = P.p.txt.parse("<i>") + " ~ " + factionHere.getTag(this);
|
String msg = P.p.txt.parse("<i>") + " ~ " + factionHere.getTag(this);
|
||||||
if (factionHere.getDescription().length() > 0) {
|
if (factionHere.getDescription().length() > 0) {
|
||||||
msg += " - " + factionHere.getDescription();
|
msg += " - " + factionHere.getDescription();
|
||||||
}
|
} this.sendMessage(msg);
|
||||||
this.sendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
@ -559,32 +519,27 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
public void leave(boolean makePay) {
|
public void leave(boolean makePay) {
|
||||||
Faction myFaction = this.getFaction();
|
Faction myFaction = this.getFaction(); makePay = makePay && Econ.shouldBeUsed() && !this.isAdminBypassing();
|
||||||
makePay = makePay && Econ.shouldBeUsed() && !this.isAdminBypassing();
|
|
||||||
|
|
||||||
if (myFaction == null) {
|
if (myFaction == null) {
|
||||||
resetFactionData();
|
resetFactionData(); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean perm = myFaction.isPermanent();
|
boolean perm = myFaction.isPermanent();
|
||||||
|
|
||||||
if (!perm && this.getRole() == Role.ADMIN && myFaction.getFPlayers().size() > 1) {
|
if (!perm && this.getRole() == Role.ADMIN && myFaction.getFPlayers().size() > 1) {
|
||||||
msg("<b>You must give the admin role to someone else first.");
|
msg("<b>You must give the admin role to someone else first."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.canLeaveWithNegativePower && this.getPower() < 0) {
|
if (!Conf.canLeaveWithNegativePower && this.getPower() < 0) {
|
||||||
msg("<b>You cannot leave until your power is positive.");
|
msg("<b>You cannot leave until your power is positive."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
||||||
if (makePay && !Econ.hasAtLeast(this, Conf.econCostLeave, "to leave your faction.")) { return; }
|
if (makePay && !Econ.hasAtLeast(this, Conf.econCostLeave, "to leave your faction.")) { return; }
|
||||||
|
|
||||||
FPlayerLeaveEvent leaveEvent = new FPlayerLeaveEvent(this, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.LEAVE);
|
FPlayerLeaveEvent leaveEvent = new FPlayerLeaveEvent(this, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.LEAVE);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(leaveEvent);
|
Bukkit.getServer().getPluginManager().callEvent(leaveEvent); if (leaveEvent.isCancelled()) { return; }
|
||||||
if (leaveEvent.isCancelled()) { return; }
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction.")) {
|
if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction.")) {
|
||||||
@ -615,8 +570,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
myFaction.detach();
|
myFaction.detach(); if (Conf.logFactionDisband) {
|
||||||
if (Conf.logFactionDisband) {
|
|
||||||
P.p.log("The faction " + myFaction.getTag() + " (" + myFaction.getId() + ") was disbanded due to the last player (" + this.getName() + ") leaving.");
|
P.p.log("The faction " + myFaction.getTag() + " (" + myFaction.getId() + ") was disbanded due to the last player (" + this.getName() + ") leaving.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -625,10 +579,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
public boolean canClaimForFaction(Faction forFaction) {
|
public boolean canClaimForFaction(Faction forFaction) {
|
||||||
if (forFaction.isNone()) { return false; }
|
if (forFaction.isNone()) { return false; }
|
||||||
|
|
||||||
if (this.isAdminBypassing()
|
if (this.isAdminBypassing() || (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR)) || (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) || (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) {
|
||||||
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|
|
||||||
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|
|
||||||
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,95 +587,67 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure) {
|
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure) {
|
||||||
String error = null;
|
String error = null; FLocation flocation = new FLocation(location); Faction myFaction = getFaction();
|
||||||
FLocation flocation = new FLocation(location);
|
Faction currentFaction = Board.getFactionAt(flocation); int ownedLand = forFaction.getLandRounded();
|
||||||
Faction myFaction = getFaction();
|
|
||||||
Faction currentFaction = Board.getFactionAt(flocation);
|
|
||||||
int ownedLand = forFaction.getLandRounded();
|
|
||||||
|
|
||||||
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) {
|
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(location)) {
|
||||||
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
// Checks for WorldGuard regions in the chunk attempting to be claimed
|
||||||
error = P.p.txt.parse("<b>This land is protected");
|
error = P.p.txt.parse("<b>This land is protected");
|
||||||
}
|
} else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
|
||||||
else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
|
|
||||||
error = P.p.txt.parse("<b>Sorry, this world has land claiming disabled.");
|
error = P.p.txt.parse("<b>Sorry, this world has land claiming disabled.");
|
||||||
}
|
} else if (this.isAdminBypassing()) {
|
||||||
else if (this.isAdminBypassing()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) {
|
||||||
else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
|
||||||
else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (myFaction != forFaction) {
|
||||||
else if (myFaction != forFaction) {
|
|
||||||
error = P.p.txt.parse("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(this));
|
error = P.p.txt.parse("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(this));
|
||||||
}
|
} else if (forFaction == currentFaction) {
|
||||||
else if (forFaction == currentFaction) {
|
|
||||||
error = P.p.txt.parse("%s<i> already own this land.", forFaction.describeTo(this, true));
|
error = P.p.txt.parse("%s<i> already own this land.", forFaction.describeTo(this, true));
|
||||||
}
|
} else if (this.getRole().value < Role.MODERATOR.value) {
|
||||||
else if (this.getRole().value < Role.MODERATOR.value) {
|
|
||||||
error = P.p.txt.parse("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
error = P.p.txt.parse("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||||
}
|
} else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
|
||||||
else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
|
|
||||||
error = P.p.txt.parse("Factions must have at least <h>%s<b> members to claim land.", Conf.claimsRequireMinFactionMembers);
|
error = P.p.txt.parse("Factions must have at least <h>%s<b> members to claim land.", Conf.claimsRequireMinFactionMembers);
|
||||||
}
|
} else if (currentFaction.isSafeZone()) {
|
||||||
else if (currentFaction.isSafeZone()) {
|
|
||||||
error = P.p.txt.parse("<b>You can not claim a Safe Zone.");
|
error = P.p.txt.parse("<b>You can not claim a Safe Zone.");
|
||||||
}
|
} else if (currentFaction.isWarZone()) {
|
||||||
else if (currentFaction.isWarZone()) {
|
|
||||||
error = P.p.txt.parse("<b>You can not claim a War Zone.");
|
error = P.p.txt.parse("<b>You can not claim a War Zone.");
|
||||||
}
|
} else if (ownedLand >= forFaction.getPowerRounded()) {
|
||||||
else if (ownedLand >= forFaction.getPowerRounded()) {
|
|
||||||
error = P.p.txt.parse("<b>You can't claim more land! You need more power!");
|
error = P.p.txt.parse("<b>You can't claim more land! You need more power!");
|
||||||
}
|
} else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) {
|
||||||
else if (Conf.claimedLandsMax != 0 && ownedLand >= Conf.claimedLandsMax && forFaction.isNormal()) {
|
|
||||||
error = P.p.txt.parse("<b>Limit reached. You can't claim more land!");
|
error = P.p.txt.parse("<b>Limit reached. You can't claim more land!");
|
||||||
}
|
} else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
|
||||||
else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
|
|
||||||
error = P.p.txt.parse("<b>You can't claim the land of your allies.");
|
error = P.p.txt.parse("<b>You can't claim the land of your allies.");
|
||||||
}
|
} else if (Conf.claimsMustBeConnected && !this.isAdminBypassing() && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, myFaction) && (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) {
|
||||||
else if (Conf.claimsMustBeConnected
|
|
||||||
&& !this.isAdminBypassing()
|
|
||||||
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
|
||||||
&& !Board.isConnectedLocation(flocation, myFaction)
|
|
||||||
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())) {
|
|
||||||
if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) {
|
if (Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction) {
|
||||||
error = P.p.txt.parse("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
|
error = P.p.txt.parse("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
error = P.p.txt.parse("<b>You can only claim additional land which is connected to your first claim!");
|
error = P.p.txt.parse("<b>You can only claim additional land which is connected to your first claim!");
|
||||||
}
|
}
|
||||||
}
|
} else if (currentFaction.isNormal()) {
|
||||||
else if (currentFaction.isNormal()) {
|
|
||||||
if (myFaction.isPeaceful()) {
|
if (myFaction.isPeaceful()) {
|
||||||
error = P.p.txt.parse("%s<i> owns this land. Your faction is peaceful, so you cannot claim land from other factions.", currentFaction.getTag(this));
|
error = P.p.txt.parse("%s<i> owns this land. Your faction is peaceful, so you cannot claim land from other factions.", currentFaction.getTag(this));
|
||||||
}
|
} else if (currentFaction.isPeaceful()) {
|
||||||
else if (currentFaction.isPeaceful()) {
|
|
||||||
error = P.p.txt.parse("%s<i> owns this land, and is a peaceful faction. You cannot claim land from them.", currentFaction.getTag(this));
|
error = P.p.txt.parse("%s<i> owns this land, and is a peaceful faction. You cannot claim land from them.", currentFaction.getTag(this));
|
||||||
}
|
} else if (!currentFaction.hasLandInflation()) {
|
||||||
else if (!currentFaction.hasLandInflation()) {
|
|
||||||
// TODO more messages WARN current faction most importantly
|
// TODO more messages WARN current faction most importantly
|
||||||
error = P.p.txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
|
error = P.p.txt.parse("%s<i> owns this land and is strong enough to keep it.", currentFaction.getTag(this));
|
||||||
}
|
} else if (!Board.isBorderLocation(flocation)) {
|
||||||
else if (!Board.isBorderLocation(flocation)) {
|
|
||||||
error = P.p.txt.parse("<b>You must start claiming land at the border of the territory.");
|
error = P.p.txt.parse("<b>You must start claiming land at the border of the territory.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notifyFailure && error != null) {
|
if (notifyFailure && error != null) {
|
||||||
msg(error);
|
msg(error);
|
||||||
}
|
} return error == null;
|
||||||
return error == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean attemptClaim(Faction forFaction, Location location, boolean notifyFailure) {
|
public boolean attemptClaim(Faction forFaction, Location location, boolean notifyFailure) {
|
||||||
// notifyFailure is false if called by auto-claim; no need to notify on every failure for it
|
// notifyFailure is false if called by auto-claim; no need to notify on every failure for it
|
||||||
// return value is false on failure, true on success
|
// return value is false on failure, true on success
|
||||||
|
|
||||||
FLocation flocation = new FLocation(location);
|
FLocation flocation = new FLocation(location); Faction currentFaction = Board.getFactionAt(flocation);
|
||||||
Faction currentFaction = Board.getFactionAt(flocation);
|
|
||||||
|
|
||||||
int ownedLand = forFaction.getLandRounded();
|
int ownedLand = forFaction.getLandRounded();
|
||||||
|
|
||||||
@ -732,24 +655,22 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
// if economy is enabled and they're not on the bypass list, make sure they can pay
|
||||||
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone();
|
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone();
|
||||||
double cost = 0.0;
|
double cost = 0.0; EconomyParticipator payee = null; if (mustPay) {
|
||||||
EconomyParticipator payee = null;
|
|
||||||
if (mustPay) {
|
|
||||||
cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
|
||||||
|
|
||||||
if (Conf.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, forFaction)) {
|
if (Conf.econClaimUnconnectedFee != 0.0 && forFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, forFaction)) {
|
||||||
cost += Conf.econClaimUnconnectedFee;
|
cost += Conf.econClaimUnconnectedFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts && this.hasFaction()) { payee = this.getFaction(); }
|
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts && this.hasFaction()) {
|
||||||
else { payee = this; }
|
payee = this.getFaction();
|
||||||
|
} else { payee = this; }
|
||||||
|
|
||||||
if (!Econ.hasAtLeast(payee, cost, "to claim this land")) { return false; }
|
if (!Econ.hasAtLeast(payee, cost, "to claim this land")) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
|
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(claimEvent);
|
Bukkit.getServer().getPluginManager().callEvent(claimEvent); if (claimEvent.isCancelled()) { return false; }
|
||||||
if (claimEvent.isCancelled()) { return false; }
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) {
|
if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) {
|
||||||
@ -757,10 +678,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// announce success
|
// announce success
|
||||||
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>();
|
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>(); informTheseFPlayers.add(this);
|
||||||
informTheseFPlayers.add(this);
|
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true)); for (FPlayer fp : informTheseFPlayers) {
|
||||||
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
|
||||||
for (FPlayer fp : informTheseFPlayers) {
|
|
||||||
fp.msg("<h>%s<i> claimed land for <h>%s<i> from <h>%s<i>.", this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
fp.msg("<h>%s<i> claimed land for <h>%s<i> from <h>%s<i>.", this.describeTo(fp, true), forFaction.describeTo(fp), currentFaction.describeTo(fp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,8 +700,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
|||||||
public boolean shouldBeSaved() {
|
public boolean shouldBeSaved() {
|
||||||
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) {
|
if (!this.hasFaction() && (this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} return !this.deleteMe;
|
||||||
return !this.deleteMe;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(String str, Object... args) {
|
public void msg(String str, Object... args) {
|
||||||
|
@ -15,22 +15,14 @@ public class FPlayers extends PlayerEntityCollection<FPlayer> {
|
|||||||
P p = P.p;
|
P p = P.p;
|
||||||
|
|
||||||
private FPlayers() {
|
private FPlayers() {
|
||||||
super
|
super(FPlayer.class, new CopyOnWriteArrayList<FPlayer>(), new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER), new File(P.p.getDataFolder(), "players.json"), P.p.gson);
|
||||||
(
|
|
||||||
FPlayer.class,
|
|
||||||
new CopyOnWriteArrayList<FPlayer>(),
|
|
||||||
new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER),
|
|
||||||
new File(P.p.getDataFolder(), "players.json"),
|
|
||||||
P.p.gson
|
|
||||||
);
|
|
||||||
|
|
||||||
this.setCreative(true);
|
this.setCreative(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getMapType() {
|
public Type getMapType() {
|
||||||
return new TypeToken<Map<String, FPlayer>>() {
|
return new TypeToken<Map<String, FPlayer>>() {}.getType();
|
||||||
}.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clean() {
|
public void clean() {
|
||||||
|
@ -115,22 +115,19 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
public String getTag(Faction otherFaction) {
|
public String getTag(Faction otherFaction) {
|
||||||
if (otherFaction == null) {
|
if (otherFaction == null) {
|
||||||
return getTag();
|
return getTag();
|
||||||
}
|
} return this.getTag(this.getColorTo(otherFaction).toString());
|
||||||
return this.getTag(this.getColorTo(otherFaction).toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag(FPlayer otherFplayer) {
|
public String getTag(FPlayer otherFplayer) {
|
||||||
if (otherFplayer == null) {
|
if (otherFplayer == null) {
|
||||||
return getTag();
|
return getTag();
|
||||||
}
|
} return this.getTag(this.getColorTo(otherFplayer).toString());
|
||||||
return this.getTag(this.getColorTo(otherFplayer).toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTag(String str) {
|
public void setTag(String str) {
|
||||||
if (Conf.factionTagForceUpperCase) {
|
if (Conf.factionTagForceUpperCase) {
|
||||||
str = str.toUpperCase();
|
str = str.toUpperCase();
|
||||||
}
|
} this.tag = str;
|
||||||
this.tag = str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getComparisonTag() {
|
public String getComparisonTag() {
|
||||||
@ -160,8 +157,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Location getHome() {
|
public Location getHome() {
|
||||||
confirmValidHome();
|
confirmValidHome(); return (this.home != null) ? this.home.getLocation() : null;
|
||||||
return (this.home != null) ? this.home.getLocation() : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void confirmValidHome() {
|
public void confirmValidHome() {
|
||||||
@ -169,8 +165,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("<b>Your faction home has been un-set since it is no longer in your territory.");
|
msg("<b>Your faction home has been un-set since it is no longer in your territory."); this.home = null;
|
||||||
this.home = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIELD: lastPlayerLoggedOffTime
|
// FIELD: lastPlayerLoggedOffTime
|
||||||
@ -222,17 +217,10 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public Faction() {
|
public Faction() {
|
||||||
this.relationWish = new HashMap<String, Relation>();
|
this.relationWish = new HashMap<String, Relation>(); this.invites = new HashSet<String>();
|
||||||
this.invites = new HashSet<String>();
|
this.open = Conf.newFactionsDefaultOpen; this.tag = "???"; this.description = "Default faction description :(";
|
||||||
this.open = Conf.newFactionsDefaultOpen;
|
this.lastPlayerLoggedOffTime = 0; this.peaceful = false; this.peacefulExplosionsEnabled = false;
|
||||||
this.tag = "???";
|
this.permanent = false; this.money = 0.0; this.powerBoost = 0.0;
|
||||||
this.description = "Default faction description :(";
|
|
||||||
this.lastPlayerLoggedOffTime = 0;
|
|
||||||
this.peaceful = false;
|
|
||||||
this.peacefulExplosionsEnabled = false;
|
|
||||||
this.permanent = false;
|
|
||||||
this.money = 0.0;
|
|
||||||
this.powerBoost = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -305,15 +293,13 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
public Relation getRelationWish(Faction otherFaction) {
|
public Relation getRelationWish(Faction otherFaction) {
|
||||||
if (this.relationWish.containsKey(otherFaction.getId())) {
|
if (this.relationWish.containsKey(otherFaction.getId())) {
|
||||||
return this.relationWish.get(otherFaction.getId());
|
return this.relationWish.get(otherFaction.getId());
|
||||||
}
|
} return Relation.NEUTRAL;
|
||||||
return Relation.NEUTRAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRelationWish(Faction otherFaction, Relation relation) {
|
public void setRelationWish(Faction otherFaction, Relation relation) {
|
||||||
if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) {
|
if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) {
|
||||||
this.relationWish.remove(otherFaction.getId());
|
this.relationWish.remove(otherFaction.getId());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.relationWish.put(otherFaction.getId(), relation);
|
this.relationWish.put(otherFaction.getId(), relation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,14 +312,11 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
return this.getPermanentPower();
|
return this.getPermanentPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
double ret = 0;
|
double ret = 0; for (FPlayer fplayer : fplayers) {
|
||||||
for (FPlayer fplayer : fplayers) {
|
|
||||||
ret += fplayer.getPower();
|
ret += fplayer.getPower();
|
||||||
}
|
} if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) {
|
||||||
if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) {
|
|
||||||
ret = Conf.powerFactionMax;
|
ret = Conf.powerFactionMax;
|
||||||
}
|
} return ret + this.powerBoost;
|
||||||
return ret + this.powerBoost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMax() {
|
public double getPowerMax() {
|
||||||
@ -341,14 +324,11 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
return this.getPermanentPower();
|
return this.getPermanentPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
double ret = 0;
|
double ret = 0; for (FPlayer fplayer : fplayers) {
|
||||||
for (FPlayer fplayer : fplayers) {
|
|
||||||
ret += fplayer.getPowerMax();
|
ret += fplayer.getPowerMax();
|
||||||
}
|
} if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) {
|
||||||
if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) {
|
|
||||||
ret = Conf.powerFactionMax;
|
ret = Conf.powerFactionMax;
|
||||||
}
|
} return ret + this.powerBoost;
|
||||||
return ret + this.powerBoost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerRounded() {
|
public int getPowerRounded() {
|
||||||
@ -377,8 +357,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
|
|
||||||
// maintain the reference list of FPlayers in this faction
|
// maintain the reference list of FPlayers in this faction
|
||||||
public void refreshFPlayers() {
|
public void refreshFPlayers() {
|
||||||
fplayers.clear();
|
fplayers.clear(); if (this.isPlayerFreeType()) { return; }
|
||||||
if (this.isPlayerFreeType()) { return; }
|
|
||||||
|
|
||||||
for (FPlayer fplayer : FPlayers.i.get()) {
|
for (FPlayer fplayer : FPlayers.i.get()) {
|
||||||
if (fplayer.getFaction() == this) {
|
if (fplayer.getFaction() == this) {
|
||||||
@ -401,8 +380,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
|
|
||||||
public Set<FPlayer> getFPlayers() {
|
public Set<FPlayer> getFPlayers() {
|
||||||
// return a shallow copy of the FPlayer list, to prevent tampering and concurrency issues
|
// return a shallow copy of the FPlayer list, to prevent tampering and concurrency issues
|
||||||
Set<FPlayer> ret = new HashSet<FPlayer>(fplayers);
|
Set<FPlayer> ret = new HashSet<FPlayer>(fplayers); return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
|
public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
|
||||||
@ -424,13 +402,11 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
if (fplayer.getRole() == Role.ADMIN) {
|
if (fplayer.getRole() == Role.ADMIN) {
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
}
|
} return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<FPlayer> getFPlayersWhereRole(Role role) {
|
public ArrayList<FPlayer> getFPlayersWhereRole(Role role) {
|
||||||
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
ArrayList<FPlayer> ret = new ArrayList<FPlayer>(); if (!this.isNormal()) { return ret; }
|
||||||
if (!this.isNormal()) { return ret; }
|
|
||||||
|
|
||||||
for (FPlayer fplayer : fplayers) {
|
for (FPlayer fplayer : fplayers) {
|
||||||
if (fplayer.getRole() == role) {
|
if (fplayer.getRole() == role) {
|
||||||
@ -442,12 +418,10 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Player> getOnlinePlayers() {
|
public ArrayList<Player> getOnlinePlayers() {
|
||||||
ArrayList<Player> ret = new ArrayList<Player>();
|
ArrayList<Player> ret = new ArrayList<Player>(); if (this.isPlayerFreeType()) { return ret; }
|
||||||
if (this.isPlayerFreeType()) { return ret; }
|
|
||||||
|
|
||||||
for (Player player : P.p.getServer().getOnlinePlayers()) {
|
for (Player player : P.p.getServer().getOnlinePlayers()) {
|
||||||
FPlayer fplayer = FPlayers.i.get(player);
|
FPlayer fplayer = FPlayers.i.get(player); if (fplayer.getFaction() == this) {
|
||||||
if (fplayer.getFaction() == this) {
|
|
||||||
ret.add(player);
|
ret.add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,8 +435,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
if (this.isPlayerFreeType()) { return false; }
|
if (this.isPlayerFreeType()) { return false; }
|
||||||
|
|
||||||
for (Player player : P.p.getServer().getOnlinePlayers()) {
|
for (Player player : P.p.getServer().getOnlinePlayers()) {
|
||||||
FPlayer fplayer = FPlayers.i.get(player);
|
FPlayer fplayer = FPlayers.i.get(player); if (fplayer != null && fplayer.getFaction() == this) {
|
||||||
if (fplayer != null && fplayer.getFaction() == this) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -470,8 +443,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
// even if all players are technically logged off, maybe someone was on recently enough to not consider them officially offline yet
|
// even if all players are technically logged off, maybe someone was on recently enough to not consider them officially offline yet
|
||||||
if (Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000)) {
|
if (Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void memberLoggedOff() {
|
public void memberLoggedOff() {
|
||||||
@ -493,8 +465,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
|
|
||||||
if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction
|
if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction
|
||||||
if (this.isPermanent()) {
|
if (this.isPermanent()) {
|
||||||
if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); }
|
if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); } return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// no members left and faction isn't permanent, so disband it
|
// no members left and faction isn't permanent, so disband it
|
||||||
@ -507,10 +478,8 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.detach();
|
this.detach();
|
||||||
}
|
} else { // promote new faction admin
|
||||||
else { // promote new faction admin
|
if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); } replacements.get(0).setRole(Role.ADMIN);
|
||||||
if (oldLeader != null) { oldLeader.setRole(Role.NORMAL); }
|
|
||||||
replacements.get(0).setRole(Role.ADMIN);
|
|
||||||
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
|
||||||
P.p.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName());
|
P.p.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName());
|
||||||
}
|
}
|
||||||
@ -568,8 +537,7 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
|
|
||||||
if (ownerData == null) { continue; }
|
if (ownerData == null) { continue; }
|
||||||
|
|
||||||
Iterator<String> iter = ownerData.iterator();
|
Iterator<String> iter = ownerData.iterator(); while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
if (iter.next().equals(player.getId())) {
|
if (iter.next().equals(player.getId())) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
@ -590,19 +558,15 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
Set<String> ownerData = claimOwnership.get(loc); return ownerData != null && !ownerData.isEmpty();
|
||||||
return ownerData != null && !ownerData.isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerInOwnerList(FPlayer player, FLocation loc) {
|
public boolean isPlayerInOwnerList(FPlayer player, FLocation loc) {
|
||||||
if (claimOwnership.isEmpty()) {
|
if (claimOwnership.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} Set<String> ownerData = claimOwnership.get(loc); if (ownerData == null) {
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
|
||||||
if (ownerData == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} if (ownerData.contains(player.getId())) {
|
||||||
if (ownerData.contains(player.getId())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,21 +574,15 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerAsOwner(FPlayer player, FLocation loc) {
|
public void setPlayerAsOwner(FPlayer player, FLocation loc) {
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
Set<String> ownerData = claimOwnership.get(loc); if (ownerData == null) {
|
||||||
if (ownerData == null) {
|
|
||||||
ownerData = new HashSet<String>();
|
ownerData = new HashSet<String>();
|
||||||
}
|
} ownerData.add(player.getId()); claimOwnership.put(loc, ownerData);
|
||||||
ownerData.add(player.getId());
|
|
||||||
claimOwnership.put(loc, ownerData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayerAsOwner(FPlayer player, FLocation loc) {
|
public void removePlayerAsOwner(FPlayer player, FLocation loc) {
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
Set<String> ownerData = claimOwnership.get(loc); if (ownerData == null) {
|
||||||
if (ownerData == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
} ownerData.remove(player.getId()); claimOwnership.put(loc, ownerData);
|
||||||
ownerData.remove(player.getId());
|
|
||||||
claimOwnership.put(loc, ownerData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getOwnerList(FLocation loc) {
|
public Set<String> getOwnerList(FLocation loc) {
|
||||||
@ -632,29 +590,23 @@ public class Faction extends Entity implements EconomyParticipator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getOwnerListString(FLocation loc) {
|
public String getOwnerListString(FLocation loc) {
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
Set<String> ownerData = claimOwnership.get(loc); if (ownerData == null || ownerData.isEmpty()) {
|
||||||
if (ownerData == null || ownerData.isEmpty()) {
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String ownerList = "";
|
String ownerList = "";
|
||||||
|
|
||||||
Iterator<String> iter = ownerData.iterator();
|
Iterator<String> iter = ownerData.iterator(); while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
if (!ownerList.isEmpty()) {
|
if (!ownerList.isEmpty()) {
|
||||||
ownerList += ", ";
|
ownerList += ", ";
|
||||||
}
|
} OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(iter.next()));
|
||||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(iter.next()));
|
|
||||||
ownerList += offlinePlayer != null ? offlinePlayer.getName() : "null player";
|
ownerList += offlinePlayer != null ? offlinePlayer.getName() : "null player";
|
||||||
}
|
} return ownerList;
|
||||||
return ownerList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {
|
public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {
|
||||||
// in own faction, with sufficient role or permission to bypass ownership?
|
// in own faction, with sufficient role or permission to bypass ownership?
|
||||||
if (fplayer.getFaction() == this
|
if (fplayer.getFaction() == this && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN) || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) {
|
||||||
&& (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)
|
|
||||||
|| Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@ public class Factions extends EntityCollection<Faction> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getMapType() {
|
public Type getMapType() {
|
||||||
return new TypeToken<Map<String, Faction>>() {
|
return new TypeToken<Map<String, Faction>>() {}.getType();
|
||||||
}.getType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,30 +36,24 @@ public class Factions extends EntityCollection<Faction> {
|
|||||||
|
|
||||||
// Make sure the default neutral faction exists
|
// Make sure the default neutral faction exists
|
||||||
if (!this.exists("0")) {
|
if (!this.exists("0")) {
|
||||||
Faction faction = this.create("0");
|
Faction faction = this.create("0"); faction.setTag(TL.WILDERNESS.toString());
|
||||||
faction.setTag(TL.WILDERNESS.toString());
|
|
||||||
faction.setDescription(TL.WILDERNESS_DESCRIPTION.toString());
|
faction.setDescription(TL.WILDERNESS_DESCRIPTION.toString());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!this.get("0").getTag().equalsIgnoreCase(TL.WILDERNESS.toString())) {
|
if (!this.get("0").getTag().equalsIgnoreCase(TL.WILDERNESS.toString())) {
|
||||||
get("0").setTag(TL.WILDERNESS.toString());
|
get("0").setTag(TL.WILDERNESS.toString());
|
||||||
}
|
} if (!this.get("0").getDescription().equalsIgnoreCase(TL.WILDERNESS_DESCRIPTION.toString())) {
|
||||||
if (!this.get("0").getDescription().equalsIgnoreCase(TL.WILDERNESS_DESCRIPTION.toString())) {
|
|
||||||
get("0").setDescription(TL.WILDERNESS_DESCRIPTION.toString());
|
get("0").setDescription(TL.WILDERNESS_DESCRIPTION.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the safe zone faction exists
|
// Make sure the safe zone faction exists
|
||||||
if (!this.exists("-1")) {
|
if (!this.exists("-1")) {
|
||||||
Faction faction = this.create("-1");
|
Faction faction = this.create("-1"); faction.setTag(TL.SAFEZONE.toString());
|
||||||
faction.setTag(TL.SAFEZONE.toString());
|
|
||||||
faction.setDescription(TL.SAFEZONE_DESCRIPTION.toString());
|
faction.setDescription(TL.SAFEZONE_DESCRIPTION.toString());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!getSafeZone().getTag().equalsIgnoreCase(TL.SAFEZONE.toString())) {
|
if (!getSafeZone().getTag().equalsIgnoreCase(TL.SAFEZONE.toString())) {
|
||||||
getSafeZone().setTag(TL.SAFEZONE.toString());
|
getSafeZone().setTag(TL.SAFEZONE.toString());
|
||||||
}
|
} if (!getSafeZone().getDescription().equalsIgnoreCase(TL.SAFEZONE_DESCRIPTION.toString())) {
|
||||||
if (!getSafeZone().getDescription().equalsIgnoreCase(TL.SAFEZONE_DESCRIPTION.toString())) {
|
|
||||||
getSafeZone().setDescription(TL.SAFEZONE_DESCRIPTION.toString());
|
getSafeZone().setDescription(TL.SAFEZONE_DESCRIPTION.toString());
|
||||||
}
|
}
|
||||||
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||||
@ -70,15 +63,12 @@ public class Factions extends EntityCollection<Faction> {
|
|||||||
|
|
||||||
// Make sure the war zone faction exists
|
// Make sure the war zone faction exists
|
||||||
if (!this.exists("-2")) {
|
if (!this.exists("-2")) {
|
||||||
Faction faction = this.create("-2");
|
Faction faction = this.create("-2"); faction.setTag(TL.WARZONE.toString());
|
||||||
faction.setTag(TL.WARZONE.toString());
|
|
||||||
faction.setDescription(TL.WARZONE_DESCRIPTION.toString());
|
faction.setDescription(TL.WARZONE_DESCRIPTION.toString());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!getWarZone().getTag().equalsIgnoreCase(TL.WARZONE.toString())) {
|
if (!getWarZone().getTag().equalsIgnoreCase(TL.WARZONE.toString())) {
|
||||||
getWarZone().setTag(TL.WARZONE.toString());
|
getWarZone().setTag(TL.WARZONE.toString());
|
||||||
}
|
} if (!getWarZone().getDescription().equalsIgnoreCase(TL.WARZONE_DESCRIPTION.toString())) {
|
||||||
if (!getWarZone().getDescription().equalsIgnoreCase(TL.WARZONE_DESCRIPTION.toString())) {
|
|
||||||
getWarZone().setDescription(TL.WARZONE_DESCRIPTION.toString());
|
getWarZone().setDescription(TL.WARZONE_DESCRIPTION.toString());
|
||||||
}
|
}
|
||||||
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||||
@ -102,8 +92,7 @@ public class Factions extends EntityCollection<Faction> {
|
|||||||
@Override
|
@Override
|
||||||
public Faction get(String id) {
|
public Faction get(String id) {
|
||||||
if (!this.exists(id)) {
|
if (!this.exists(id)) {
|
||||||
p.log(Level.WARNING, "Non existing factionId " + id + " requested! Issuing cleaning!");
|
p.log(Level.WARNING, "Non existing factionId " + id + " requested! Issuing cleaning!"); Board.clean();
|
||||||
Board.clean();
|
|
||||||
FPlayers.i.clean();
|
FPlayers.i.clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,13 +138,11 @@ public class Factions extends EntityCollection<Faction> {
|
|||||||
|
|
||||||
// Loops through all faction tags. Case and color insensitive.
|
// Loops through all faction tags. Case and color insensitive.
|
||||||
public Faction getByTag(String str) {
|
public Faction getByTag(String str) {
|
||||||
String compStr = MiscUtil.getComparisonString(str);
|
String compStr = MiscUtil.getComparisonString(str); for (Faction faction : this.get()) {
|
||||||
for (Faction faction : this.get()) {
|
|
||||||
if (faction.getComparisonTag().equals(compStr)) {
|
if (faction.getComparisonTag().equals(compStr)) {
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
}
|
} return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getBestTagMatch(String searchFor) {
|
public Faction getBestTagMatch(String searchFor) {
|
||||||
@ -166,8 +153,7 @@ public class Factions extends EntityCollection<Faction> {
|
|||||||
tag2faction.put(ChatColor.stripColor(faction.getTag()), faction);
|
tag2faction.put(ChatColor.stripColor(faction.getTag()), faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tag = TextUtil.getBestStartWithCI(tag2faction.keySet(), searchFor);
|
String tag = TextUtil.getBestStartWithCI(tag2faction.keySet(), searchFor); if (tag == null) { return null; }
|
||||||
if (tag == null) { return null; }
|
|
||||||
return tag2faction.get(tag);
|
return tag2faction.get(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,7 @@ public class P extends MPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLocked(boolean val) {
|
public void setLocked(boolean val) {
|
||||||
this.locked = val;
|
this.locked = val; this.setAutoSave(val);
|
||||||
this.setAutoSave(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer AutoLeaveTask = null;
|
private Integer AutoLeaveTask = null;
|
||||||
@ -59,12 +58,9 @@ public class P extends MPlugin {
|
|||||||
public CmdAutoHelp cmdAutoHelp;
|
public CmdAutoHelp cmdAutoHelp;
|
||||||
|
|
||||||
public P() {
|
public P() {
|
||||||
p = this;
|
p = this; this.playerListener = new FactionsPlayerListener(this);
|
||||||
this.playerListener = new FactionsPlayerListener(this);
|
this.chatListener = new FactionsChatListener(this); this.entityListener = new FactionsEntityListener(this);
|
||||||
this.chatListener = new FactionsChatListener(this);
|
this.exploitListener = new FactionsExploitListener(); this.blockListener = new FactionsBlockListener(this);
|
||||||
this.entityListener = new FactionsEntityListener(this);
|
|
||||||
this.exploitListener = new FactionsExploitListener();
|
|
||||||
this.blockListener = new FactionsBlockListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,24 +71,16 @@ public class P extends MPlugin {
|
|||||||
Class.forName("org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken");
|
Class.forName("org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken");
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
this.log(Level.SEVERE, "GSON lib not found. Your CraftBukkit build is too old (< 1.3.2) or otherwise not compatible.");
|
this.log(Level.SEVERE, "GSON lib not found. Your CraftBukkit build is too old (< 1.3.2) or otherwise not compatible.");
|
||||||
this.suicide();
|
this.suicide(); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preEnable()) { return; }
|
if (!preEnable()) { return; } this.loadSuccessful = false;
|
||||||
this.loadSuccessful = false;
|
|
||||||
|
|
||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
Conf.load();
|
Conf.load(); Essentials.setup(); FPlayers.i.loadFromDisc(); Factions.i.loadFromDisc(); Board.load();
|
||||||
Essentials.setup();
|
|
||||||
FPlayers.i.loadFromDisc();
|
|
||||||
Factions.i.loadFromDisc();
|
|
||||||
Board.load();
|
|
||||||
|
|
||||||
// Add Base Commands
|
// Add Base Commands
|
||||||
this.cmdBase = new FCmdRoot();
|
this.cmdBase = new FCmdRoot(); this.cmdAutoHelp = new CmdAutoHelp(); this.getBaseCommands().add(cmdBase);
|
||||||
this.cmdAutoHelp = new CmdAutoHelp();
|
|
||||||
this.getBaseCommands().add(cmdBase);
|
|
||||||
|
|
||||||
Econ.setup();
|
Econ.setup();
|
||||||
|
|
||||||
@ -113,41 +101,29 @@ public class P extends MPlugin {
|
|||||||
// since some other plugins execute commands directly through this command interface, provide it
|
// since some other plugins execute commands directly through this command interface, provide it
|
||||||
this.getCommand(this.refCommand).setExecutor(this);
|
this.getCommand(this.refCommand).setExecutor(this);
|
||||||
|
|
||||||
postEnable();
|
postEnable(); this.loadSuccessful = true;
|
||||||
this.loadSuccessful = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GsonBuilder getGsonBuilder() {
|
public GsonBuilder getGsonBuilder() {
|
||||||
Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>() {
|
Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>() {}.getType();
|
||||||
}.getType();
|
|
||||||
|
|
||||||
return new GsonBuilder()
|
return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE).registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter()).registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter());
|
||||||
.setPrettyPrinting()
|
|
||||||
.disableHtmlEscaping()
|
|
||||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
|
||||||
.registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter())
|
|
||||||
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// only save data if plugin actually completely loaded successfully
|
// only save data if plugin actually completely loaded successfully
|
||||||
if (this.loadSuccessful) {
|
if (this.loadSuccessful) {
|
||||||
Board.save();
|
Board.save(); Conf.save();
|
||||||
Conf.save();
|
} if (AutoLeaveTask != null) {
|
||||||
}
|
this.getServer().getScheduler().cancelTask(AutoLeaveTask); AutoLeaveTask = null;
|
||||||
if (AutoLeaveTask != null) {
|
} super.onDisable();
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
|
||||||
AutoLeaveTask = null;
|
|
||||||
}
|
|
||||||
super.onDisable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startAutoLeaveTask(boolean restartIfRunning) {
|
public void startAutoLeaveTask(boolean restartIfRunning) {
|
||||||
if (AutoLeaveTask != null) {
|
if (AutoLeaveTask != null) {
|
||||||
if (!restartIfRunning) { return; }
|
if (!restartIfRunning) { return; } this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.autoLeaveRoutineRunsEveryXMinutes > 0.0) {
|
if (Conf.autoLeaveRoutineRunsEveryXMinutes > 0.0) {
|
||||||
@ -158,8 +134,7 @@ public class P extends MPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postAutoSave() {
|
public void postAutoSave() {
|
||||||
Board.save();
|
Board.save(); Conf.save();
|
||||||
Conf.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,11 +187,9 @@ public class P extends MPlugin {
|
|||||||
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
||||||
// local chat, or anything else which targets individual recipients, so Faction Chat can be done
|
// local chat, or anything else which targets individual recipients, so Faction Chat can be done
|
||||||
public boolean isPlayerFactionChatting(Player player) {
|
public boolean isPlayerFactionChatting(Player player) {
|
||||||
if (player == null) { return false; }
|
if (player == null) { return false; } FPlayer me = FPlayers.i.get(player);
|
||||||
FPlayer me = FPlayers.i.get(player);
|
|
||||||
|
|
||||||
if (me == null) { return false; }
|
if (me == null) { return false; } return me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
||||||
return me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this chat message actually a Factions command, and thus should be left alone by other plugins?
|
// Is this chat message actually a Factions command, and thus should be left alone by other plugins?
|
||||||
@ -224,8 +197,7 @@ public class P extends MPlugin {
|
|||||||
// TODO: GET THIS BACK AND WORKING
|
// TODO: GET THIS BACK AND WORKING
|
||||||
|
|
||||||
public boolean isFactionsCommand(String check) {
|
public boolean isFactionsCommand(String check) {
|
||||||
if (check == null || check.isEmpty()) { return false; }
|
if (check == null || check.isEmpty()) { return false; } return this.handleCommand(null, check, true);
|
||||||
return this.handleCommand(null, check, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
|
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
|
||||||
@ -239,20 +211,16 @@ public class P extends MPlugin {
|
|||||||
|
|
||||||
if (speaker == null) { return tag; }
|
if (speaker == null) { return tag; }
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(speaker);
|
FPlayer me = FPlayers.i.get(speaker); if (me == null) { return tag; }
|
||||||
if (me == null) { return tag; }
|
|
||||||
|
|
||||||
// if listener isn't set, or config option is disabled, give back uncolored tag
|
// if listener isn't set, or config option is disabled, give back uncolored tag
|
||||||
if (listener == null || !Conf.chatTagRelationColored) {
|
if (listener == null || !Conf.chatTagRelationColored) {
|
||||||
tag = me.getChatTag().trim();
|
tag = me.getChatTag().trim();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
FPlayer you = FPlayers.i.get(listener);
|
FPlayer you = FPlayers.i.get(listener);
|
||||||
if (you == null) { tag = me.getChatTag().trim(); }
|
if (you == null) { tag = me.getChatTag().trim(); } else // everything checks out, give the colored tag
|
||||||
else // everything checks out, give the colored tag
|
|
||||||
{ tag = me.getChatTag(you).trim(); }
|
{ tag = me.getChatTag(you).trim(); }
|
||||||
}
|
} if (tag.isEmpty()) { tag = "~"; }
|
||||||
if (tag.isEmpty()) { tag = "~"; }
|
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@ -261,42 +229,35 @@ public class P extends MPlugin {
|
|||||||
public String getPlayerTitle(Player player) {
|
public String getPlayerTitle(Player player) {
|
||||||
if (player == null) { return ""; }
|
if (player == null) { return ""; }
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(player);
|
FPlayer me = FPlayers.i.get(player); if (me == null) { return ""; }
|
||||||
if (me == null) { return ""; }
|
|
||||||
|
|
||||||
return me.getTitle().trim();
|
return me.getTitle().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of all faction tags (names)
|
// Get a list of all faction tags (names)
|
||||||
public Set<String> getFactionTags() {
|
public Set<String> getFactionTags() {
|
||||||
Set<String> tags = new HashSet<String>();
|
Set<String> tags = new HashSet<String>(); for (Faction faction : Factions.i.get()) {
|
||||||
for (Faction faction : Factions.i.get()) {
|
|
||||||
tags.add(faction.getTag());
|
tags.add(faction.getTag());
|
||||||
}
|
} return tags;
|
||||||
return tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of all players in the specified faction
|
// Get a list of all players in the specified faction
|
||||||
public Set<String> getPlayersInFaction(String factionTag) {
|
public Set<String> getPlayersInFaction(String factionTag) {
|
||||||
Set<String> players = new HashSet<String>();
|
Set<String> players = new HashSet<String>(); Faction faction = Factions.i.getByTag(factionTag);
|
||||||
Faction faction = Factions.i.getByTag(factionTag);
|
|
||||||
if (faction != null) {
|
if (faction != null) {
|
||||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||||
players.add(fplayer.getName());
|
players.add(fplayer.getName());
|
||||||
}
|
}
|
||||||
}
|
} return players;
|
||||||
return players;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of all online players in the specified faction
|
// Get a list of all online players in the specified faction
|
||||||
public Set<String> getOnlinePlayersInFaction(String factionTag) {
|
public Set<String> getOnlinePlayersInFaction(String factionTag) {
|
||||||
Set<String> players = new HashSet<String>();
|
Set<String> players = new HashSet<String>(); Faction faction = Factions.i.getByTag(factionTag);
|
||||||
Faction faction = Factions.i.getByTag(factionTag);
|
|
||||||
if (faction != null) {
|
if (faction != null) {
|
||||||
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) {
|
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) {
|
||||||
players.add(fplayer.getName());
|
players.add(fplayer.getName());
|
||||||
}
|
}
|
||||||
}
|
} return players;
|
||||||
return players;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,49 +10,39 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class CmdAdmin extends FCommand {
|
public class CmdAdmin extends FCommand {
|
||||||
public CmdAdmin() {
|
public CmdAdmin() {
|
||||||
super();
|
super(); this.aliases.add("admin");
|
||||||
this.aliases.add("admin");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.ADMIN.node;
|
this.permission = Permission.ADMIN.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
FPlayer fyou = this.argAsBestFPlayerMatch(0); if (fyou == null) { return; }
|
||||||
if (fyou == null) { return; }
|
|
||||||
|
|
||||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
boolean permAny = Permission.ADMIN_ANY.has(sender, false); Faction targetFaction = fyou.getFaction();
|
||||||
Faction targetFaction = fyou.getFaction();
|
|
||||||
|
|
||||||
if (targetFaction != myFaction && !permAny) {
|
if (targetFaction != myFaction && !permAny) {
|
||||||
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
|
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||||
msg("<b>You are not the faction admin.");
|
msg("<b>You are not the faction admin."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fyou == fme && !permAny) {
|
if (fyou == fme && !permAny) {
|
||||||
msg("<b>The target player musn't be yourself.");
|
msg("<b>The target player musn't be yourself."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
||||||
if (fyou.getFaction() != targetFaction) {
|
if (fyou.getFaction() != targetFaction) {
|
||||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.i.get(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.i.get(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; }
|
||||||
if (event.isCancelled()) { return; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||||
@ -66,8 +56,7 @@ public class CmdAdmin extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// promote target player, and demote existing admin if one exists
|
// promote target player, and demote existing admin if one exists
|
||||||
if (admin != null) { admin.setRole(Role.MODERATOR); }
|
if (admin != null) { admin.setRole(Role.MODERATOR); } fyou.setRole(Role.ADMIN);
|
||||||
fyou.setRole(Role.ADMIN);
|
|
||||||
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
|
@ -6,33 +6,27 @@ import com.massivecraft.factions.struct.Role;
|
|||||||
|
|
||||||
public class CmdAutoClaim extends FCommand {
|
public class CmdAutoClaim extends FCommand {
|
||||||
public CmdAutoClaim() {
|
public CmdAutoClaim() {
|
||||||
super();
|
super(); this.aliases.add("autoclaim");
|
||||||
this.aliases.add("autoclaim");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "your");
|
this.optionalArgs.put("faction", "your");
|
||||||
|
|
||||||
this.permission = Permission.AUTOCLAIM.node;
|
this.permission = Permission.AUTOCLAIM.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction forFaction = this.argAsFaction(0, myFaction);
|
Faction forFaction = this.argAsFaction(0, myFaction);
|
||||||
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
|
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
|
||||||
fme.setAutoClaimFor(null);
|
fme.setAutoClaimFor(null); msg("<i>Auto-claiming of land disabled."); return;
|
||||||
msg("<i>Auto-claiming of land disabled.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fme.canClaimForFaction(forFaction)) {
|
if (!fme.canClaimForFaction(forFaction)) {
|
||||||
if (myFaction == forFaction) { msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString()); }
|
if (myFaction == forFaction) {
|
||||||
else { msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme)); }
|
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||||
|
} else { msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme)); }
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class CmdAutoHelp extends MCommand<P> {
|
public class CmdAutoHelp extends MCommand<P> {
|
||||||
public CmdAutoHelp() {
|
public CmdAutoHelp() {
|
||||||
super(P.p);
|
super(P.p); this.aliases.add("?"); this.aliases.add("h"); this.aliases.add("help");
|
||||||
this.aliases.add("?");
|
|
||||||
this.aliases.add("h");
|
|
||||||
this.aliases.add("help");
|
|
||||||
|
|
||||||
this.setHelpShort("");
|
this.setHelpShort("");
|
||||||
|
|
||||||
@ -28,12 +25,7 @@ public class CmdAutoHelp extends MCommand<P> {
|
|||||||
lines.addAll(pcmd.helpLong);
|
lines.addAll(pcmd.helpLong);
|
||||||
|
|
||||||
for (MCommand<?> scmd : pcmd.subCommands) {
|
for (MCommand<?> scmd : pcmd.subCommands) {
|
||||||
if
|
if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) {
|
||||||
(
|
|
||||||
scmd.visibility == CommandVisibility.VISIBLE
|
|
||||||
||
|
|
||||||
(scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))
|
|
||||||
) {
|
|
||||||
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,26 +5,20 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdBoom extends FCommand {
|
public class CmdBoom extends FCommand {
|
||||||
public CmdBoom() {
|
public CmdBoom() {
|
||||||
super();
|
super(); this.aliases.add("noboom");
|
||||||
this.aliases.add("noboom");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.NO_BOOM.node;
|
this.permission = Permission.NO_BOOM.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
if (!myFaction.isPeaceful()) {
|
if (!myFaction.isPeaceful()) {
|
||||||
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful.");
|
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
|
@ -5,19 +5,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdBypass extends FCommand {
|
public class CmdBypass extends FCommand {
|
||||||
public CmdBypass() {
|
public CmdBypass() {
|
||||||
super();
|
super(); this.aliases.add("bypass");
|
||||||
this.aliases.add("bypass");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.BYPASS.node;
|
this.permission = Permission.BYPASS.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,10 +23,8 @@ public class CmdBypass extends FCommand {
|
|||||||
if (fme.isAdminBypassing()) {
|
if (fme.isAdminBypassing()) {
|
||||||
fme.msg("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
|
fme.msg("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
|
||||||
P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
|
P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
|
||||||
}
|
} else {
|
||||||
else {
|
fme.msg("<i>You have disabled admin bypass mode."); P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
||||||
fme.msg("<i>You have disabled admin bypass mode.");
|
|
||||||
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,46 +7,33 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdChat extends FCommand {
|
public class CmdChat extends FCommand {
|
||||||
|
|
||||||
public CmdChat() {
|
public CmdChat() {
|
||||||
super();
|
super(); this.aliases.add("c"); this.aliases.add("chat");
|
||||||
this.aliases.add("c");
|
|
||||||
this.aliases.add("chat");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("mode", "next");
|
this.optionalArgs.put("mode", "next");
|
||||||
|
|
||||||
this.permission = Permission.CHAT.node;
|
this.permission = Permission.CHAT.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = true;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
if (!Conf.factionOnlyChat) {
|
if (!Conf.factionOnlyChat) {
|
||||||
msg("<b>The built in chat chat channels are disabled on this server.");
|
msg("<b>The built in chat chat channels are disabled on this server."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String modeString = this.argAsString(0);
|
String modeString = this.argAsString(0); ChatMode modeTarget = fme.getChatMode().getNext();
|
||||||
ChatMode modeTarget = fme.getChatMode().getNext();
|
|
||||||
|
|
||||||
if (modeString != null) {
|
if (modeString != null) {
|
||||||
modeString.toLowerCase();
|
modeString.toLowerCase(); if (modeString.startsWith("p")) {
|
||||||
if (modeString.startsWith("p")) {
|
|
||||||
modeTarget = ChatMode.PUBLIC;
|
modeTarget = ChatMode.PUBLIC;
|
||||||
}
|
} else if (modeString.startsWith("a")) {
|
||||||
else if (modeString.startsWith("a")) {
|
|
||||||
modeTarget = ChatMode.ALLIANCE;
|
modeTarget = ChatMode.ALLIANCE;
|
||||||
}
|
} else if (modeString.startsWith("f")) {
|
||||||
else if (modeString.startsWith("f")) {
|
|
||||||
modeTarget = ChatMode.FACTION;
|
modeTarget = ChatMode.FACTION;
|
||||||
}
|
} else {
|
||||||
else {
|
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'"); return;
|
||||||
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,11 +41,9 @@ public class CmdChat extends FCommand {
|
|||||||
|
|
||||||
if (fme.getChatMode() == ChatMode.PUBLIC) {
|
if (fme.getChatMode() == ChatMode.PUBLIC) {
|
||||||
msg("<i>Public chat mode.");
|
msg("<i>Public chat mode.");
|
||||||
}
|
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
|
||||||
else if (fme.getChatMode() == ChatMode.ALLIANCE) {
|
|
||||||
msg("<i>Alliance only chat mode.");
|
msg("<i>Alliance only chat mode.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
msg("<i>Faction only chat mode.");
|
msg("<i>Faction only chat mode.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,13 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdChatSpy extends FCommand {
|
public class CmdChatSpy extends FCommand {
|
||||||
public CmdChatSpy() {
|
public CmdChatSpy() {
|
||||||
super();
|
super(); this.aliases.add("chatspy");
|
||||||
this.aliases.add("chatspy");
|
|
||||||
|
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.CHATSPY.node;
|
this.permission = Permission.CHATSPY.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,12 +19,9 @@ public class CmdChatSpy extends FCommand {
|
|||||||
fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat()));
|
fme.setSpyingChat(this.argAsBool(0, !fme.isSpyingChat()));
|
||||||
|
|
||||||
if (fme.isSpyingChat()) {
|
if (fme.isSpyingChat()) {
|
||||||
fme.msg("<i>You have enabled chat spying mode.");
|
fme.msg("<i>You have enabled chat spying mode."); P.p.log(fme.getName() + " has ENABLED chat spying mode.");
|
||||||
P.p.log(fme.getName() + " has ENABLED chat spying mode.");
|
} else {
|
||||||
}
|
fme.msg("<i>You have disabled chat spying mode."); P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
||||||
else {
|
|
||||||
fme.msg("<i>You have disabled chat spying mode.");
|
|
||||||
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,42 +10,32 @@ import com.massivecraft.factions.util.SpiralTask;
|
|||||||
public class CmdClaim extends FCommand {
|
public class CmdClaim extends FCommand {
|
||||||
|
|
||||||
public CmdClaim() {
|
public CmdClaim() {
|
||||||
super();
|
super(); this.aliases.add("claim");
|
||||||
this.aliases.add("claim");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "your");
|
this.optionalArgs.put("faction", "your"); this.optionalArgs.put("radius", "1");
|
||||||
this.optionalArgs.put("radius", "1");
|
|
||||||
|
|
||||||
this.permission = Permission.CLAIM.node;
|
this.permission = Permission.CLAIM.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
// Read and validate input
|
// Read and validate input
|
||||||
final Faction forFaction = this.argAsFaction(0, myFaction);
|
final Faction forFaction = this.argAsFaction(0, myFaction); int radius = this.argAsInt(1, 1);
|
||||||
int radius = this.argAsInt(1, 1);
|
|
||||||
|
|
||||||
if (radius < 1) {
|
if (radius < 1) {
|
||||||
msg("<b>If you specify a radius, it must be at least 1.");
|
msg("<b>If you specify a radius, it must be at least 1."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radius < 2) {
|
if (radius < 2) {
|
||||||
// single chunk
|
// single chunk
|
||||||
fme.attemptClaim(forFaction, me.getLocation(), true);
|
fme.attemptClaim(forFaction, me.getLocation(), true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// radius claim
|
// radius claim
|
||||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||||
msg("<b>You do not have permission to claim in a radius.");
|
msg("<b>You do not have permission to claim in a radius."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new SpiralTask(new FLocation(me), radius) {
|
new SpiralTask(new FLocation(me), radius) {
|
||||||
@ -55,10 +45,8 @@ public class CmdClaim extends FCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean work() {
|
public boolean work() {
|
||||||
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
|
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
|
||||||
if (success) { failCount = 0; }
|
if (success) { failCount = 0; } else if (!success && failCount++ >= limit) {
|
||||||
else if (!success && failCount++ >= limit) {
|
this.stop(); return false;
|
||||||
this.stop();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,19 +17,13 @@ public class CmdConfig extends FCommand {
|
|||||||
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
|
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
|
||||||
|
|
||||||
public CmdConfig() {
|
public CmdConfig() {
|
||||||
super();
|
super(); this.aliases.add("config");
|
||||||
this.aliases.add("config");
|
|
||||||
|
|
||||||
this.requiredArgs.add("setting");
|
this.requiredArgs.add("setting"); this.requiredArgs.add("value"); this.errorOnToManyArgs = false;
|
||||||
this.requiredArgs.add("value");
|
|
||||||
this.errorOnToManyArgs = false;
|
|
||||||
|
|
||||||
this.permission = Permission.CONFIG.node;
|
this.permission = Permission.CONFIG.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,27 +32,22 @@ public class CmdConfig extends FCommand {
|
|||||||
// store a lookup map of lowercase field names paired with proper capitalization field names
|
// store a lookup map of lowercase field names paired with proper capitalization field names
|
||||||
// that way, if the person using this command messes up the capitalization, we can fix that
|
// that way, if the person using this command messes up the capitalization, we can fix that
|
||||||
if (properFieldNames.isEmpty()) {
|
if (properFieldNames.isEmpty()) {
|
||||||
Field[] fields = Conf.class.getDeclaredFields();
|
Field[] fields = Conf.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) {
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
|
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String field = this.argAsString(0).toLowerCase();
|
String field = this.argAsString(0).toLowerCase(); if (field.startsWith("\"") && field.endsWith("\"")) {
|
||||||
if (field.startsWith("\"") && field.endsWith("\"")) {
|
|
||||||
field = field.substring(1, field.length() - 1);
|
field = field.substring(1, field.length() - 1);
|
||||||
}
|
} String fieldName = properFieldNames.get(field);
|
||||||
String fieldName = properFieldNames.get(field);
|
|
||||||
|
|
||||||
if (fieldName == null || fieldName.isEmpty()) {
|
if (fieldName == null || fieldName.isEmpty()) {
|
||||||
msg("<b>No configuration setting \"<h>%s<b>\" exists.", field);
|
msg("<b>No configuration setting \"<h>%s<b>\" exists.", field); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String success;
|
String success;
|
||||||
|
|
||||||
String value = args.get(1);
|
String value = args.get(1); for (int i = 2; i < args.size(); i++) {
|
||||||
for (int i = 2; i < args.size(); i++) {
|
|
||||||
value += ' ' + args.get(i);
|
value += ' ' + args.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,13 +56,11 @@ public class CmdConfig extends FCommand {
|
|||||||
|
|
||||||
// boolean
|
// boolean
|
||||||
if (target.getType() == boolean.class) {
|
if (target.getType() == boolean.class) {
|
||||||
boolean targetValue = this.strAsBool(value);
|
boolean targetValue = this.strAsBool(value); target.setBoolean(null, targetValue);
|
||||||
target.setBoolean(null, targetValue);
|
|
||||||
|
|
||||||
if (targetValue) {
|
if (targetValue) {
|
||||||
success = "\"" + fieldName + "\" option set to true (enabled).";
|
success = "\"" + fieldName + "\" option set to true (enabled).";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
success = "\"" + fieldName + "\" option set to false (disabled).";
|
success = "\"" + fieldName + "\" option set to false (disabled).";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,20 +68,17 @@ public class CmdConfig extends FCommand {
|
|||||||
// int
|
// int
|
||||||
else if (target.getType() == int.class) {
|
else if (target.getType() == int.class) {
|
||||||
try {
|
try {
|
||||||
int intVal = Integer.parseInt(value);
|
int intVal = Integer.parseInt(value); target.setInt(null, intVal);
|
||||||
target.setInt(null, intVal);
|
|
||||||
success = "\"" + fieldName + "\" option set to " + intVal + ".";
|
success = "\"" + fieldName + "\" option set to " + intVal + ".";
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
sendMessage("Cannot set \"" + fieldName + "\": integer (whole number) value required.");
|
sendMessage("Cannot set \"" + fieldName + "\": integer (whole number) value required."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// long
|
// long
|
||||||
else if (target.getType() == long.class) {
|
else if (target.getType() == long.class) {
|
||||||
try {
|
try {
|
||||||
long longVal = Long.parseLong(value);
|
long longVal = Long.parseLong(value); target.setLong(null, longVal);
|
||||||
target.setLong(null, longVal);
|
|
||||||
success = "\"" + fieldName + "\" option set to " + longVal + ".";
|
success = "\"" + fieldName + "\" option set to " + longVal + ".";
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
sendMessage("Cannot set \"" + fieldName + "\": long integer (whole number) value required.");
|
sendMessage("Cannot set \"" + fieldName + "\": long integer (whole number) value required.");
|
||||||
@ -105,46 +89,38 @@ public class CmdConfig extends FCommand {
|
|||||||
// double
|
// double
|
||||||
else if (target.getType() == double.class) {
|
else if (target.getType() == double.class) {
|
||||||
try {
|
try {
|
||||||
double doubleVal = Double.parseDouble(value);
|
double doubleVal = Double.parseDouble(value); target.setDouble(null, doubleVal);
|
||||||
target.setDouble(null, doubleVal);
|
|
||||||
success = "\"" + fieldName + "\" option set to " + doubleVal + ".";
|
success = "\"" + fieldName + "\" option set to " + doubleVal + ".";
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
sendMessage("Cannot set \"" + fieldName + "\": double (numeric) value required.");
|
sendMessage("Cannot set \"" + fieldName + "\": double (numeric) value required."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// float
|
// float
|
||||||
else if (target.getType() == float.class) {
|
else if (target.getType() == float.class) {
|
||||||
try {
|
try {
|
||||||
float floatVal = Float.parseFloat(value);
|
float floatVal = Float.parseFloat(value); target.setFloat(null, floatVal);
|
||||||
target.setFloat(null, floatVal);
|
|
||||||
success = "\"" + fieldName + "\" option set to " + floatVal + ".";
|
success = "\"" + fieldName + "\" option set to " + floatVal + ".";
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
sendMessage("Cannot set \"" + fieldName + "\": float (numeric) value required.");
|
sendMessage("Cannot set \"" + fieldName + "\": float (numeric) value required."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// String
|
// String
|
||||||
else if (target.getType() == String.class) {
|
else if (target.getType() == String.class) {
|
||||||
target.set(null, value);
|
target.set(null, value); success = "\"" + fieldName + "\" option set to \"" + value + "\".";
|
||||||
success = "\"" + fieldName + "\" option set to \"" + value + "\".";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatColor
|
// ChatColor
|
||||||
else if (target.getType() == ChatColor.class) {
|
else if (target.getType() == ChatColor.class) {
|
||||||
ChatColor newColor = null;
|
ChatColor newColor = null; try {
|
||||||
try {
|
|
||||||
newColor = ChatColor.valueOf(value.toUpperCase());
|
newColor = ChatColor.valueOf(value.toUpperCase());
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
|
|
||||||
}
|
} if (newColor == null) {
|
||||||
if (newColor == null) {
|
|
||||||
sendMessage("Cannot set \"" + fieldName + "\": \"" + value.toUpperCase() + "\" is not a valid color.");
|
sendMessage("Cannot set \"" + fieldName + "\": \"" + value.toUpperCase() + "\" is not a valid color.");
|
||||||
return;
|
return;
|
||||||
}
|
} target.set(null, newColor);
|
||||||
target.set(null, newColor);
|
|
||||||
success = "\"" + fieldName + "\" color option set to \"" + value.toUpperCase() + "\".";
|
success = "\"" + fieldName + "\" color option set to \"" + value.toUpperCase() + "\".";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,49 +137,41 @@ public class CmdConfig extends FCommand {
|
|||||||
|
|
||||||
// Set<Material>
|
// Set<Material>
|
||||||
else if (innerType == Material.class) {
|
else if (innerType == Material.class) {
|
||||||
Material newMat = null;
|
Material newMat = null; try {
|
||||||
try {
|
|
||||||
newMat = Material.valueOf(value.toUpperCase());
|
newMat = Material.valueOf(value.toUpperCase());
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
|
|
||||||
}
|
} if (newMat == null) {
|
||||||
if (newMat == null) {
|
|
||||||
sendMessage("Cannot change \"" + fieldName + "\" set: \"" + value.toUpperCase() + "\" is not a valid material.");
|
sendMessage("Cannot change \"" + fieldName + "\" set: \"" + value.toUpperCase() + "\" is not a valid material.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked") Set<Material> matSet = (Set<Material>) target.get(null);
|
||||||
Set<Material> matSet = (Set<Material>) target.get(null);
|
|
||||||
|
|
||||||
// Material already present, so remove it
|
// Material already present, so remove it
|
||||||
if (matSet.contains(newMat)) {
|
if (matSet.contains(newMat)) {
|
||||||
matSet.remove(newMat);
|
matSet.remove(newMat); target.set(null, matSet);
|
||||||
target.set(null, matSet);
|
|
||||||
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" removed.";
|
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" removed.";
|
||||||
}
|
}
|
||||||
// Material not present yet, add it
|
// Material not present yet, add it
|
||||||
else {
|
else {
|
||||||
matSet.add(newMat);
|
matSet.add(newMat); target.set(null, matSet);
|
||||||
target.set(null, matSet);
|
|
||||||
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" added.";
|
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" added.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set<String>
|
// Set<String>
|
||||||
else if (innerType == String.class) {
|
else if (innerType == String.class) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked") Set<String> stringSet = (Set<String>) target.get(null);
|
||||||
Set<String> stringSet = (Set<String>) target.get(null);
|
|
||||||
|
|
||||||
// String already present, so remove it
|
// String already present, so remove it
|
||||||
if (stringSet.contains(value)) {
|
if (stringSet.contains(value)) {
|
||||||
stringSet.remove(value);
|
stringSet.remove(value); target.set(null, stringSet);
|
||||||
target.set(null, stringSet);
|
|
||||||
success = "\"" + fieldName + "\" set: \"" + value + "\" removed.";
|
success = "\"" + fieldName + "\" set: \"" + value + "\" removed.";
|
||||||
}
|
}
|
||||||
// String not present yet, add it
|
// String not present yet, add it
|
||||||
else {
|
else {
|
||||||
stringSet.add(value);
|
stringSet.add(value); target.set(null, stringSet);
|
||||||
target.set(null, stringSet);
|
|
||||||
success = "\"" + fieldName + "\" set: \"" + value + "\" added.";
|
success = "\"" + fieldName + "\" set: \"" + value + "\" added.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,16 +192,13 @@ public class CmdConfig extends FCommand {
|
|||||||
sendMessage("Configuration setting \"" + fieldName + "\" couldn't be matched, though it should be... please report this error.");
|
sendMessage("Configuration setting \"" + fieldName + "\" couldn't be matched, though it should be... please report this error.");
|
||||||
return;
|
return;
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
sendMessage("Error setting configuration setting \"" + fieldName + "\" to \"" + value + "\".");
|
sendMessage("Error setting configuration setting \"" + fieldName + "\" to \"" + value + "\"."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success.isEmpty()) {
|
if (!success.isEmpty()) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
sendMessage(success);
|
sendMessage(success); P.p.log(success + " Command was run by " + fme.getName() + ".");
|
||||||
P.p.log(success + " Command was run by " + fme.getName() + ".");
|
} else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||||
}
|
|
||||||
else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
|
||||||
{ P.p.log(success); }
|
{ P.p.log(success); }
|
||||||
}
|
}
|
||||||
// save change to disk
|
// save change to disk
|
||||||
|
@ -12,19 +12,14 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class CmdCreate extends FCommand {
|
public class CmdCreate extends FCommand {
|
||||||
public CmdCreate() {
|
public CmdCreate() {
|
||||||
super();
|
super(); this.aliases.add("create");
|
||||||
this.aliases.add("create");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.CREATE.node;
|
this.permission = Permission.CREATE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,19 +27,15 @@ public class CmdCreate extends FCommand {
|
|||||||
String tag = this.argAsString(0);
|
String tag = this.argAsString(0);
|
||||||
|
|
||||||
if (fme.hasFaction()) {
|
if (fme.hasFaction()) {
|
||||||
msg("<b>You must leave your current faction first.");
|
msg("<b>You must leave your current faction first."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Factions.i.isTagTaken(tag)) {
|
if (Factions.i.isTagTaken(tag)) {
|
||||||
msg("<b>That tag is already in use.");
|
msg("<b>That tag is already in use."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> tagValidationErrors = Factions.validateTag(tag);
|
ArrayList<String> tagValidationErrors = Factions.validateTag(tag); if (tagValidationErrors.size() > 0) {
|
||||||
if (tagValidationErrors.size() > 0) {
|
sendMessage(tagValidationErrors); return;
|
||||||
sendMessage(tagValidationErrors);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||||
@ -52,8 +43,7 @@ public class CmdCreate extends FCommand {
|
|||||||
|
|
||||||
// trigger the faction creation event (cancellable)
|
// trigger the faction creation event (cancellable)
|
||||||
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
|
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(createEvent);
|
Bukkit.getServer().getPluginManager().callEvent(createEvent); if (createEvent.isCancelled()) { return; }
|
||||||
if (createEvent.isCancelled()) { return; }
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) { return; }
|
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) { return; }
|
||||||
@ -62,8 +52,7 @@ public class CmdCreate extends FCommand {
|
|||||||
|
|
||||||
// TODO: Why would this even happen??? Auto increment clash??
|
// TODO: Why would this even happen??? Auto increment clash??
|
||||||
if (faction == null) {
|
if (faction == null) {
|
||||||
msg("<b>There was an internal error while trying to create your faction. Please try again.");
|
msg("<b>There was an internal error while trying to create your faction. Please try again."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish setting up the Faction
|
// finish setting up the Faction
|
||||||
@ -75,8 +64,7 @@ public class CmdCreate extends FCommand {
|
|||||||
// join event cannot be cancelled or you'll have an empty faction
|
// join event cannot be cancelled or you'll have an empty faction
|
||||||
|
|
||||||
// finish setting up the FPlayer
|
// finish setting up the FPlayer
|
||||||
fme.setRole(Role.ADMIN);
|
fme.setRole(Role.ADMIN); fme.setFaction(faction);
|
||||||
fme.setFaction(faction);
|
|
||||||
|
|
||||||
for (FPlayer follower : FPlayers.i.getOnline()) {
|
for (FPlayer follower : FPlayers.i.getOnline()) {
|
||||||
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
|
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
|
||||||
|
@ -6,31 +6,23 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdDeinvite extends FCommand {
|
public class CmdDeinvite extends FCommand {
|
||||||
|
|
||||||
public CmdDeinvite() {
|
public CmdDeinvite() {
|
||||||
super();
|
super(); this.aliases.add("deinvite"); this.aliases.add("deinv");
|
||||||
this.aliases.add("deinvite");
|
|
||||||
this.aliases.add("deinv");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.DEINVITE.node;
|
this.permission = Permission.DEINVITE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||||
if (you == null) { return; }
|
|
||||||
|
|
||||||
if (you.getFaction() == myFaction) {
|
if (you.getFaction() == myFaction) {
|
||||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||||
msg("<i>You might want to: %s", p.cmdBase.cmdKick.getUseageTemplate(false));
|
msg("<i>You might want to: %s", p.cmdBase.cmdKick.getUseageTemplate(false)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myFaction.deinvite(you);
|
myFaction.deinvite(you);
|
||||||
|
@ -8,20 +8,14 @@ import com.massivecraft.factions.zcore.util.TextUtil;
|
|||||||
|
|
||||||
public class CmdDescription extends FCommand {
|
public class CmdDescription extends FCommand {
|
||||||
public CmdDescription() {
|
public CmdDescription() {
|
||||||
super();
|
super(); this.aliases.add("desc");
|
||||||
this.aliases.add("desc");
|
|
||||||
|
|
||||||
this.requiredArgs.add("desc");
|
this.requiredArgs.add("desc"); this.errorOnToManyArgs = false;
|
||||||
this.errorOnToManyArgs = false;
|
|
||||||
//this.optionalArgs
|
//this.optionalArgs
|
||||||
|
|
||||||
this.permission = Permission.DESCRIPTION.node;
|
this.permission = Permission.DESCRIPTION.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -35,8 +29,7 @@ public class CmdDescription extends FCommand {
|
|||||||
|
|
||||||
if (!Conf.broadcastDescriptionChanges) {
|
if (!Conf.broadcastDescriptionChanges) {
|
||||||
fme.msg("You have changed the description for <h>%s<i> to:", myFaction.describeTo(fme));
|
fme.msg("You have changed the description for <h>%s<i> to:", myFaction.describeTo(fme));
|
||||||
fme.sendMessage(myFaction.getDescription());
|
fme.sendMessage(myFaction.getDescription()); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast the description to everyone
|
// Broadcast the description to everyone
|
||||||
|
@ -11,50 +11,40 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class CmdDisband extends FCommand {
|
public class CmdDisband extends FCommand {
|
||||||
public CmdDisband() {
|
public CmdDisband() {
|
||||||
super();
|
super(); this.aliases.add("disband");
|
||||||
this.aliases.add("disband");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction tag", "yours");
|
this.optionalArgs.put("faction tag", "yours");
|
||||||
|
|
||||||
this.permission = Permission.DISBAND.node;
|
this.permission = Permission.DISBAND.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
// The faction, default to your own.. but null if console sender.
|
// The faction, default to your own.. but null if console sender.
|
||||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction); if (faction == null) { return; }
|
||||||
if (faction == null) { return; }
|
|
||||||
|
|
||||||
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
||||||
|
|
||||||
if (isMyFaction) {
|
if (isMyFaction) {
|
||||||
if (!assertMinRole(Role.ADMIN)) { return; }
|
if (!assertMinRole(Role.ADMIN)) { return; }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Permission.DISBAND_ANY.has(sender, true)) {
|
if (!Permission.DISBAND_ANY.has(sender, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!faction.isNormal()) {
|
if (!faction.isNormal()) {
|
||||||
msg("<i>You cannot disband the Wilderness, SafeZone, or WarZone.");
|
msg("<i>You cannot disband the Wilderness, SafeZone, or WarZone."); return;
|
||||||
return;
|
} if (faction.isPermanent()) {
|
||||||
}
|
msg("<i>This faction is designated as permanent, so you cannot disband it."); return;
|
||||||
if (faction.isPermanent()) {
|
|
||||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
|
Bukkit.getServer().getPluginManager().callEvent(disbandEvent); if (disbandEvent.isCancelled()) { return; }
|
||||||
if (disbandEvent.isCancelled()) { return; }
|
|
||||||
|
|
||||||
// Send FPlayerLeaveEvent for each player in the faction
|
// Send FPlayerLeaveEvent for each player in the faction
|
||||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||||
@ -66,12 +56,10 @@ public class CmdDisband extends FCommand {
|
|||||||
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
|
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
|
||||||
if (fplayer.getFaction() == faction) {
|
if (fplayer.getFaction() == faction) {
|
||||||
fplayer.msg("<h>%s<i> disbanded your faction.", who);
|
fplayer.msg("<h>%s<i> disbanded your faction.", who);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
||||||
}
|
}
|
||||||
}
|
} if (Conf.logFactionDisband) {
|
||||||
if (Conf.logFactionDisband) {
|
|
||||||
P.p.log("The faction " + faction.getTag() + " (" + faction.getId() + ") was disbanded by " + (senderIsConsole ? "console command" : fme.getName()) + ".");
|
P.p.log("The faction " + faction.getTag() + " (" + faction.getId() + ") was disbanded by " + (senderIsConsole ? "console command" : fme.getName()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,20 +11,14 @@ import java.util.ArrayList;
|
|||||||
public class CmdHelp extends FCommand {
|
public class CmdHelp extends FCommand {
|
||||||
|
|
||||||
public CmdHelp() {
|
public CmdHelp() {
|
||||||
super();
|
super(); this.aliases.add("help"); this.aliases.add("h"); this.aliases.add("?");
|
||||||
this.aliases.add("help");
|
|
||||||
this.aliases.add("h");
|
|
||||||
this.aliases.add("?");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("page", "1");
|
this.optionalArgs.put("page", "1");
|
||||||
|
|
||||||
this.permission = Permission.HELP.node;
|
this.permission = Permission.HELP.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,10 +33,8 @@ public class CmdHelp extends FCommand {
|
|||||||
page -= 1;
|
page -= 1;
|
||||||
|
|
||||||
if (page < 0 || page >= helpPages.size()) {
|
if (page < 0 || page >= helpPages.size()) {
|
||||||
msg("<b>This page does not exist");
|
msg("<b>This page does not exist"); return;
|
||||||
return;
|
} sendMessage(helpPages.get(page));
|
||||||
}
|
|
||||||
sendMessage(helpPages.get(page));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
@ -52,11 +44,9 @@ public class CmdHelp extends FCommand {
|
|||||||
public ArrayList<ArrayList<String>> helpPages;
|
public ArrayList<ArrayList<String>> helpPages;
|
||||||
|
|
||||||
public void updateHelp() {
|
public void updateHelp() {
|
||||||
helpPages = new ArrayList<ArrayList<String>>();
|
helpPages = new ArrayList<ArrayList<String>>(); ArrayList<String> pageLines;
|
||||||
ArrayList<String> pageLines;
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
|
|
||||||
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true));
|
||||||
@ -64,11 +54,9 @@ public class CmdHelp extends FCommand {
|
|||||||
pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>Learn how to create a faction on the next page."));
|
pageLines.add(p.txt.parse("<i>Learn how to create a faction on the next page.")); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
|
|
||||||
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>You might want to close it and use invitations:"));
|
pageLines.add(p.txt.parse("<i>You might want to close it and use invitations:"));
|
||||||
@ -76,25 +64,18 @@ public class CmdHelp extends FCommand {
|
|||||||
pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>And don't forget to set your home:"));
|
pageLines.add(p.txt.parse("<i>And don't forget to set your home:"));
|
||||||
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
|
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add("");
|
||||||
pageLines.add("");
|
|
||||||
pageLines.add(p.txt.parse("<i>Your faction has a bank which is used to pay for certain"));
|
pageLines.add(p.txt.parse("<i>Your faction has a bank which is used to pay for certain"));
|
||||||
pageLines.add(p.txt.parse("<i>things, so it will need to have money deposited into it."));
|
pageLines.add(p.txt.parse("<i>things, so it will need to have money deposited into it."));
|
||||||
pageLines.add(p.txt.parse("<i>To learn more, use the money command."));
|
pageLines.add(p.txt.parse("<i>To learn more, use the money command.")); pageLines.add("");
|
||||||
pageLines.add("");
|
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true)); pageLines.add(""); pageLines.add("");
|
||||||
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true));
|
pageLines.add(""); helpPages.add(pageLines);
|
||||||
pageLines.add("");
|
|
||||||
pageLines.add("");
|
|
||||||
pageLines.add("");
|
|
||||||
helpPages.add(pageLines);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
|
|
||||||
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true));
|
||||||
@ -105,20 +86,16 @@ public class CmdHelp extends FCommand {
|
|||||||
pageLines.add(p.txt.parse("<i>Player titles are just for fun. No rules connected to them."));
|
pageLines.add(p.txt.parse("<i>Player titles are just for fun. No rules connected to them."));
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
|
|
||||||
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so"));
|
pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so"));
|
||||||
pageLines.add(p.txt.parse("<i>that only the owner(s), faction admin, and possibly the"));
|
pageLines.add(p.txt.parse("<i>that only the owner(s), faction admin, and possibly the"));
|
||||||
pageLines.add(p.txt.parse("<i>faction moderators have full access."));
|
pageLines.add(p.txt.parse("<i>faction moderators have full access.")); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
|
pageLines.add(""); pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
|
||||||
pageLines.add("");
|
|
||||||
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
|
|
||||||
pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction."));
|
pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction."));
|
||||||
@ -127,11 +104,9 @@ public class CmdHelp extends FCommand {
|
|||||||
pageLines.add(p.txt.parse("<i>If ONE faction chooses \"enemy\" you will be enemies."));
|
pageLines.add(p.txt.parse("<i>If ONE faction chooses \"enemy\" you will be enemies."));
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.txt.parse("<i>You can never hurt members or allies."));
|
||||||
pageLines.add(p.txt.parse("<i>You can never hurt members or allies."));
|
|
||||||
pageLines.add(p.txt.parse("<i>You can not hurt neutrals in their own territory."));
|
pageLines.add(p.txt.parse("<i>You can not hurt neutrals in their own territory."));
|
||||||
pageLines.add(p.txt.parse("<i>You can always hurt enemies and players without faction."));
|
pageLines.add(p.txt.parse("<i>You can always hurt enemies and players without faction.")); pageLines.add("");
|
||||||
pageLines.add("");
|
|
||||||
pageLines.add(p.txt.parse("<i>Damage from enemies is reduced in your own territory."));
|
pageLines.add(p.txt.parse("<i>Damage from enemies is reduced in your own territory."));
|
||||||
pageLines.add(p.txt.parse("<i>When you die you lose power. It is restored over time."));
|
pageLines.add(p.txt.parse("<i>When you die you lose power. It is restored over time."));
|
||||||
pageLines.add(p.txt.parse("<i>The power of a faction is the sum of all member power."));
|
pageLines.add(p.txt.parse("<i>The power of a faction is the sum of all member power."));
|
||||||
@ -142,17 +117,14 @@ public class CmdHelp extends FCommand {
|
|||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add(p.txt.parse("<i>Only faction members can build and destroy in their own"));
|
pageLines.add(p.txt.parse("<i>Only faction members can build and destroy in their own"));
|
||||||
pageLines.add(p.txt.parse("<i>territory. Usage of the following items is also restricted:"));
|
pageLines.add(p.txt.parse("<i>territory. Usage of the following items is also restricted:"));
|
||||||
pageLines.add(p.txt.parse("<i>Door, Chest, Furnace, Dispenser, Diode."));
|
pageLines.add(p.txt.parse("<i>Door, Chest, Furnace, Dispenser, Diode.")); pageLines.add("");
|
||||||
pageLines.add("");
|
|
||||||
pageLines.add(p.txt.parse("<i>Make sure to put pressure plates in front of doors for your"));
|
pageLines.add(p.txt.parse("<i>Make sure to put pressure plates in front of doors for your"));
|
||||||
pageLines.add(p.txt.parse("<i>guest visitors. Otherwise they can't get through. You can"));
|
pageLines.add(p.txt.parse("<i>guest visitors. Otherwise they can't get through. You can"));
|
||||||
pageLines.add(p.txt.parse("<i>also use this to create member only areas."));
|
pageLines.add(p.txt.parse("<i>also use this to create member only areas."));
|
||||||
pageLines.add(p.txt.parse("<i>As dispensers are protected, you can create traps without"));
|
pageLines.add(p.txt.parse("<i>As dispensers are protected, you can create traps without"));
|
||||||
pageLines.add(p.txt.parse("<i>worrying about those arrows getting stolen."));
|
pageLines.add(p.txt.parse("<i>worrying about those arrows getting stolen.")); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add("Finally some commands for the server admins:");
|
||||||
pageLines.add("Finally some commands for the server admins:");
|
|
||||||
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone"));
|
pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone"));
|
||||||
pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone"));
|
pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone"));
|
||||||
@ -160,25 +132,20 @@ public class CmdHelp extends FCommand {
|
|||||||
pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well."));
|
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well."));
|
||||||
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
||||||
pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
|
||||||
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>(); pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
||||||
pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
|
||||||
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true));
|
||||||
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true));
|
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true)); helpPages.add(pageLines);
|
||||||
helpPages.add(pageLines);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,86 +17,55 @@ import java.util.List;
|
|||||||
public class CmdHome extends FCommand {
|
public class CmdHome extends FCommand {
|
||||||
|
|
||||||
public CmdHome() {
|
public CmdHome() {
|
||||||
super();
|
super(); this.aliases.add("home");
|
||||||
this.aliases.add("home");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.HOME.node;
|
this.permission = Permission.HOME.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = true;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
// TODO: Hide this command on help also.
|
// TODO: Hide this command on help also.
|
||||||
if (!Conf.homesEnabled) {
|
if (!Conf.homesEnabled) {
|
||||||
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
fme.msg("<b>Sorry, Faction homes are disabled on this server."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.homesTeleportCommandEnabled) {
|
if (!Conf.homesTeleportCommandEnabled) {
|
||||||
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
|
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myFaction.hasHome()) {
|
if (!myFaction.hasHome()) {
|
||||||
fme.msg("<b>Your faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? "<i> Ask your leader to:" : "<i>You should:"));
|
fme.msg("<b>Your faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? "<i> Ask your leader to:" : "<i>You should:"));
|
||||||
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
|
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
|
||||||
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
|
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) {
|
if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) {
|
||||||
fme.msg("<b>You cannot teleport to your faction home while in a different world.");
|
fme.msg("<b>You cannot teleport to your faction home while in a different world."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction faction = Board.getFactionAt(new FLocation(me.getLocation()));
|
Faction faction = Board.getFactionAt(new FLocation(me.getLocation())); Location loc = me.getLocation().clone();
|
||||||
Location loc = me.getLocation().clone();
|
|
||||||
|
|
||||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||||
if
|
if (Conf.homesTeleportAllowedEnemyDistance > 0 &&
|
||||||
(
|
!faction.isSafeZone() &&
|
||||||
Conf.homesTeleportAllowedEnemyDistance > 0
|
(!fme.isInOwnTerritory() || (fme.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))) {
|
||||||
&&
|
World w = loc.getWorld(); double x = loc.getX(); double y = loc.getY(); double z = loc.getZ();
|
||||||
!faction.isSafeZone()
|
|
||||||
&&
|
|
||||||
(
|
|
||||||
!fme.isInOwnTerritory()
|
|
||||||
||
|
|
||||||
(
|
|
||||||
fme.isInOwnTerritory()
|
|
||||||
&&
|
|
||||||
!Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
World w = loc.getWorld();
|
|
||||||
double x = loc.getX();
|
|
||||||
double y = loc.getY();
|
|
||||||
double z = loc.getZ();
|
|
||||||
|
|
||||||
for (Player p : me.getServer().getOnlinePlayers()) {
|
for (Player p : me.getServer().getOnlinePlayers()) {
|
||||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { continue; }
|
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { continue; }
|
||||||
|
|
||||||
FPlayer fp = FPlayers.i.get(p);
|
FPlayer fp = FPlayers.i.get(p); if (fme.getRelationTo(fp) != Relation.ENEMY) { continue; }
|
||||||
if (fme.getRelationTo(fp) != Relation.ENEMY) { continue; }
|
|
||||||
|
|
||||||
Location l = p.getLocation();
|
Location l = p.getLocation(); double dx = Math.abs(x - l.getX()); double dy = Math.abs(y - l.getY());
|
||||||
double dx = Math.abs(x - l.getX());
|
double dz = Math.abs(z - l.getZ()); double max = Conf.homesTeleportAllowedEnemyDistance;
|
||||||
double dy = Math.abs(y - l.getY());
|
|
||||||
double dz = Math.abs(z - l.getZ());
|
|
||||||
double max = Conf.homesTeleportAllowedEnemyDistance;
|
|
||||||
|
|
||||||
// box-shaped distance check
|
// box-shaped distance check
|
||||||
if (dx > max || dy > max || dz > max) { continue; }
|
if (dx > max || dy > max || dz > max) { continue; }
|
||||||
@ -116,10 +85,8 @@ public class CmdHome extends FCommand {
|
|||||||
|
|
||||||
// Create a smoke effect
|
// Create a smoke effect
|
||||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||||
List<Location> smokeLocations = new ArrayList<Location>();
|
List<Location> smokeLocations = new ArrayList<Location>(); smokeLocations.add(loc);
|
||||||
smokeLocations.add(loc);
|
smokeLocations.add(loc.add(0, 1, 0)); smokeLocations.add(myFaction.getHome());
|
||||||
smokeLocations.add(loc.add(0, 1, 0));
|
|
||||||
smokeLocations.add(myFaction.getHome());
|
|
||||||
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
||||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||||
}
|
}
|
||||||
|
@ -6,31 +6,23 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdInvite extends FCommand {
|
public class CmdInvite extends FCommand {
|
||||||
public CmdInvite() {
|
public CmdInvite() {
|
||||||
super();
|
super(); this.aliases.add("invite"); this.aliases.add("inv");
|
||||||
this.aliases.add("invite");
|
|
||||||
this.aliases.add("inv");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.INVITE.node;
|
this.permission = Permission.INVITE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||||
if (you == null) { return; }
|
|
||||||
|
|
||||||
if (you.getFaction() == myFaction) {
|
if (you.getFaction() == myFaction) {
|
||||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||||
msg("<i>You might want to: " + p.cmdBase.cmdKick.getUseageTemplate(false));
|
msg("<i>You might want to: " + p.cmdBase.cmdKick.getUseageTemplate(false)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
|
@ -7,37 +7,27 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class CmdJoin extends FCommand {
|
public class CmdJoin extends FCommand {
|
||||||
public CmdJoin() {
|
public CmdJoin() {
|
||||||
super();
|
super(); this.aliases.add("join");
|
||||||
this.aliases.add("join");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction name");
|
this.requiredArgs.add("faction name"); this.optionalArgs.put("player", "you");
|
||||||
this.optionalArgs.put("player", "you");
|
|
||||||
|
|
||||||
this.permission = Permission.JOIN.node;
|
this.permission = Permission.JOIN.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction faction = this.argAsFaction(0);
|
Faction faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||||
if (faction == null) { return; }
|
|
||||||
|
|
||||||
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);
|
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false); boolean samePlayer = fplayer == fme;
|
||||||
boolean samePlayer = fplayer == fme;
|
|
||||||
|
|
||||||
if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) {
|
if (!samePlayer && !Permission.JOIN_OTHERS.has(sender, false)) {
|
||||||
msg("<b>You do not have permission to move other players into a faction.");
|
msg("<b>You do not have permission to move other players into a faction."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!faction.isNormal()) {
|
if (!faction.isNormal()) {
|
||||||
msg("<b>Players may only join normal factions. This is a system faction.");
|
msg("<b>Players may only join normal factions. This is a system faction."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (faction == fplayer.getFaction()) {
|
if (faction == fplayer.getFaction()) {
|
||||||
@ -56,8 +46,7 @@ public class CmdJoin extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) {
|
if (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0) {
|
||||||
msg("<b>%s cannot join a faction with a negative power level.", fplayer.describeTo(fme, true));
|
msg("<b>%s cannot join a faction with a negative power level.", fplayer.describeTo(fme, true)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) {
|
if (!(faction.getOpen() || faction.isInvited(fplayer) || fme.isAdminBypassing() || Permission.JOIN_ANY.has(sender, false))) {
|
||||||
@ -71,8 +60,7 @@ public class CmdJoin extends FCommand {
|
|||||||
|
|
||||||
// trigger the join event (cancellable)
|
// trigger the join event (cancellable)
|
||||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
Bukkit.getServer().getPluginManager().callEvent(joinEvent); if (joinEvent.isCancelled()) { return; }
|
||||||
if (joinEvent.isCancelled()) { return; }
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) { return; }
|
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) { return; }
|
||||||
@ -81,16 +69,12 @@ public class CmdJoin extends FCommand {
|
|||||||
|
|
||||||
if (!samePlayer) {
|
if (!samePlayer) {
|
||||||
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||||
}
|
} faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
||||||
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
|
||||||
|
|
||||||
fplayer.resetFactionData();
|
fplayer.resetFactionData(); fplayer.setFaction(faction); faction.deinvite(fplayer);
|
||||||
fplayer.setFaction(faction);
|
|
||||||
faction.deinvite(fplayer);
|
|
||||||
|
|
||||||
if (Conf.logFactionJoin) {
|
if (Conf.logFactionJoin) {
|
||||||
if (samePlayer) { P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag()); }
|
if (samePlayer) { P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag()); } else {
|
||||||
else {
|
|
||||||
P.p.log("%s moved the player %s into the faction %s.", fme.getName(), fplayer.getName(), faction.getTag());
|
P.p.log("%s moved the player %s into the faction %s.", fme.getName(), fplayer.getName(), faction.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,30 +12,23 @@ import org.bukkit.Bukkit;
|
|||||||
public class CmdKick extends FCommand {
|
public class CmdKick extends FCommand {
|
||||||
|
|
||||||
public CmdKick() {
|
public CmdKick() {
|
||||||
super();
|
super(); this.aliases.add("kick");
|
||||||
this.aliases.add("kick");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.KICK.node;
|
this.permission = Permission.KICK.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||||
if (you == null) { return; }
|
|
||||||
|
|
||||||
if (fme == you) {
|
if (fme == you) {
|
||||||
msg("<b>You cannot kick yourself.");
|
msg("<b>You cannot kick yourself.");
|
||||||
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
|
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction yourFaction = you.getFaction();
|
Faction yourFaction = you.getFaction();
|
||||||
@ -43,19 +36,16 @@ public class CmdKick extends FCommand {
|
|||||||
// players with admin-level "disband" permission can bypass these requirements
|
// players with admin-level "disband" permission can bypass these requirements
|
||||||
if (!Permission.KICK_ANY.has(sender)) {
|
if (!Permission.KICK_ANY.has(sender)) {
|
||||||
if (yourFaction != myFaction) {
|
if (yourFaction != myFaction) {
|
||||||
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme));
|
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole().value >= fme.getRole().value) {
|
if (you.getRole().value >= fme.getRole().value) {
|
||||||
// TODO add more informative messages.
|
// TODO add more informative messages.
|
||||||
msg("<b>Your rank is too low to kick this player.");
|
msg("<b>Your rank is too low to kick this player."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.canLeaveWithNegativePower && you.getPower() < 0) {
|
if (!Conf.canLeaveWithNegativePower && you.getPower() < 0) {
|
||||||
msg("<b>You cannot kick that member until their power is positive.");
|
msg("<b>You cannot kick that member until their power is positive."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +54,7 @@ public class CmdKick extends FCommand {
|
|||||||
|
|
||||||
// trigger the leave event (cancellable) [reason:kicked]
|
// trigger the leave event (cancellable) [reason:kicked]
|
||||||
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; }
|
||||||
if (event.isCancelled()) { return; }
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) {
|
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) {
|
||||||
@ -84,8 +73,7 @@ public class CmdKick extends FCommand {
|
|||||||
|
|
||||||
if (you.getRole() == Role.ADMIN) { yourFaction.promoteNewLeader(); }
|
if (you.getRole() == Role.ADMIN) { yourFaction.promoteNewLeader(); }
|
||||||
|
|
||||||
yourFaction.deinvite(you);
|
yourFaction.deinvite(you); you.resetFactionData();
|
||||||
you.resetFactionData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdLeave extends FCommand {
|
public class CmdLeave extends FCommand {
|
||||||
|
|
||||||
public CmdLeave() {
|
public CmdLeave() {
|
||||||
super();
|
super(); this.aliases.add("leave");
|
||||||
this.aliases.add("leave");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.LEAVE.node;
|
this.permission = Permission.LEAVE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = true; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = true;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,19 +13,14 @@ import java.util.Comparator;
|
|||||||
public class CmdList extends FCommand {
|
public class CmdList extends FCommand {
|
||||||
|
|
||||||
public CmdList() {
|
public CmdList() {
|
||||||
super();
|
super(); this.aliases.add("list"); this.aliases.add("ls");
|
||||||
this.aliases.add("list");
|
|
||||||
this.aliases.add("ls");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("page", "1");
|
this.optionalArgs.put("page", "1");
|
||||||
|
|
||||||
this.permission = Permission.LIST.node;
|
this.permission = Permission.LIST.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,19 +30,15 @@ public class CmdList extends FCommand {
|
|||||||
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) { return; }
|
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) { return; }
|
||||||
|
|
||||||
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
||||||
factionList.remove(Factions.i.getNone());
|
factionList.remove(Factions.i.getNone()); factionList.remove(Factions.i.getSafeZone());
|
||||||
factionList.remove(Factions.i.getSafeZone());
|
|
||||||
factionList.remove(Factions.i.getWarZone());
|
factionList.remove(Factions.i.getWarZone());
|
||||||
|
|
||||||
// Sort by total followers first
|
// Sort by total followers first
|
||||||
Collections.sort(factionList, new Comparator<Faction>() {
|
Collections.sort(factionList, new Comparator<Faction>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Faction f1, Faction f2) {
|
public int compare(Faction f1, Faction f2) {
|
||||||
int f1Size = f1.getFPlayers().size();
|
int f1Size = f1.getFPlayers().size(); int f2Size = f2.getFPlayers().size();
|
||||||
int f2Size = f2.getFPlayers().size();
|
if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { return -1; } return 0;
|
||||||
if (f1Size < f2Size) { return 1; }
|
|
||||||
else if (f1Size > f2Size) { return -1; }
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -57,9 +48,7 @@ public class CmdList extends FCommand {
|
|||||||
public int compare(Faction f1, Faction f2) {
|
public int compare(Faction f1, Faction f2) {
|
||||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||||
if (f1Size < f2Size) { return 1; }
|
if (f1Size < f2Size) { return 1; } else if (f1Size > f2Size) { return -1; } return 0;
|
||||||
else if (f1Size > f2Size) { return -1; }
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -84,13 +73,10 @@ public class CmdList extends FCommand {
|
|||||||
|
|
||||||
factionList.add(0, Factions.i.getNone());
|
factionList.add(0, Factions.i.getNone());
|
||||||
|
|
||||||
final int pageheight = 9;
|
final int pageheight = 9; int pagenumber = this.argAsInt(0, 1);
|
||||||
int pagenumber = this.argAsInt(0, 1);
|
|
||||||
int pagecount = (factionList.size() / pageheight) + 1;
|
int pagecount = (factionList.size() / pageheight) + 1;
|
||||||
if (pagenumber > pagecount) { pagenumber = pagecount; }
|
if (pagenumber > pagecount) { pagenumber = pagecount; } else if (pagenumber < 1) { pagenumber = 1; }
|
||||||
else if (pagenumber < 1) { pagenumber = 1; }
|
int start = (pagenumber - 1) * pageheight; int end = start + pageheight;
|
||||||
int start = (pagenumber - 1) * pageheight;
|
|
||||||
int end = start + pageheight;
|
|
||||||
if (end > factionList.size()) { end = factionList.size(); }
|
if (end > factionList.size()) { end = factionList.size(); }
|
||||||
|
|
||||||
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
|
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
|
||||||
@ -100,14 +86,7 @@ public class CmdList extends FCommand {
|
|||||||
lines.add(p.txt.parse("<i>Factionless<i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
|
lines.add(p.txt.parse("<i>Factionless<i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d", faction.getTag(fme), faction.getFPlayersWhereOnline(true).size(), faction.getFPlayers().size(), faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded()));
|
||||||
faction.getTag(fme),
|
|
||||||
faction.getFPlayersWhereOnline(true).size(),
|
|
||||||
faction.getFPlayers().size(),
|
|
||||||
faction.getLandRounded(),
|
|
||||||
faction.getPowerRounded(),
|
|
||||||
faction.getPowerMaxRounded())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(lines);
|
sendMessage(lines);
|
||||||
|
@ -12,18 +12,14 @@ public class CmdLock extends FCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdLock() {
|
public CmdLock() {
|
||||||
super();
|
super(); this.aliases.add("lock");
|
||||||
this.aliases.add("lock");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.LOCK.node;
|
this.permission = Permission.LOCK.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +29,7 @@ public class CmdLock extends FCommand {
|
|||||||
|
|
||||||
if (p.getLocked()) {
|
if (p.getLocked()) {
|
||||||
msg("<i>Factions is now locked");
|
msg("<i>Factions is now locked");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
msg("<i>Factions in now unlocked");
|
msg("<i>Factions in now unlocked");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,19 +8,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdMap extends FCommand {
|
public class CmdMap extends FCommand {
|
||||||
public CmdMap() {
|
public CmdMap() {
|
||||||
super();
|
super(); this.aliases.add("map");
|
||||||
this.aliases.add("map");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "once");
|
this.optionalArgs.put("on/off", "once");
|
||||||
|
|
||||||
this.permission = Permission.MAP.node;
|
this.permission = Permission.MAP.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,19 +27,15 @@ public class CmdMap extends FCommand {
|
|||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
||||||
|
|
||||||
fme.setMapAutoUpdating(true);
|
fme.setMapAutoUpdating(true); msg("<i>Map auto update <green>ENABLED.");
|
||||||
msg("<i>Map auto update <green>ENABLED.");
|
|
||||||
|
|
||||||
// And show the map once
|
// And show the map once
|
||||||
showMap();
|
showMap();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Turn off
|
// Turn off
|
||||||
fme.setMapAutoUpdating(false);
|
fme.setMapAutoUpdating(false); msg("<i>Map auto update <red>DISABLED.");
|
||||||
msg("<i>Map auto update <red>DISABLED.");
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) { return; }
|
||||||
|
|
||||||
|
@ -8,47 +8,37 @@ import com.massivecraft.factions.struct.Role;
|
|||||||
public class CmdMod extends FCommand {
|
public class CmdMod extends FCommand {
|
||||||
|
|
||||||
public CmdMod() {
|
public CmdMod() {
|
||||||
super();
|
super(); this.aliases.add("mod");
|
||||||
this.aliases.add("mod");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MOD.node;
|
this.permission = Permission.MOD.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||||
if (you == null) { return; }
|
|
||||||
|
|
||||||
boolean permAny = Permission.MOD_ANY.has(sender, false);
|
boolean permAny = Permission.MOD_ANY.has(sender, false); Faction targetFaction = you.getFaction();
|
||||||
Faction targetFaction = you.getFaction();
|
|
||||||
|
|
||||||
if (targetFaction != myFaction && !permAny) {
|
if (targetFaction != myFaction && !permAny) {
|
||||||
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
|
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true)); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||||
msg("<b>You are not the faction admin.");
|
msg("<b>You are not the faction admin."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you == fme && !permAny) {
|
if (you == fme && !permAny) {
|
||||||
msg("<b>The target player musn't be yourself.");
|
msg("<b>The target player musn't be yourself."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole() == Role.ADMIN) {
|
if (you.getRole() == Role.ADMIN) {
|
||||||
msg("<b>The target player is a faction admin. Demote them first.");
|
msg("<b>The target player is a faction admin. Demote them first."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole() == Role.MODERATOR) {
|
if (you.getRole() == Role.MODERATOR) {
|
||||||
@ -56,8 +46,7 @@ public class CmdMod extends FCommand {
|
|||||||
you.setRole(Role.NORMAL);
|
you.setRole(Role.NORMAL);
|
||||||
targetFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(targetFaction, true));
|
targetFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(targetFaction, true));
|
||||||
msg("<i>You have removed moderator status from %s<i>.", you.describeTo(fme, true));
|
msg("<i>You have removed moderator status from %s<i>.", you.describeTo(fme, true));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Give
|
// Give
|
||||||
you.setRole(Role.MODERATOR);
|
you.setRole(Role.MODERATOR);
|
||||||
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
|
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
|
||||||
|
@ -11,34 +11,27 @@ public class CmdMoney extends FCommand {
|
|||||||
public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf();
|
public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf();
|
||||||
|
|
||||||
public CmdMoney() {
|
public CmdMoney() {
|
||||||
super();
|
super(); this.aliases.add("money");
|
||||||
this.aliases.add("money");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("","")
|
//this.optionalArgs.put("","")
|
||||||
|
|
||||||
this.isMoneyCommand = true;
|
this.isMoneyCommand = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("faction money commands");
|
this.setHelpShort("faction money commands");
|
||||||
this.helpLong.add(p.txt.parseTags("<i>The faction money commands."));
|
this.helpLong.add(p.txt.parseTags("<i>The faction money commands."));
|
||||||
|
|
||||||
this.addSubCommand(this.cmdMoneyBalance);
|
this.addSubCommand(this.cmdMoneyBalance); this.addSubCommand(this.cmdMoneyDeposit);
|
||||||
this.addSubCommand(this.cmdMoneyDeposit);
|
this.addSubCommand(this.cmdMoneyWithdraw); this.addSubCommand(this.cmdMoneyTransferFf);
|
||||||
this.addSubCommand(this.cmdMoneyWithdraw);
|
this.addSubCommand(this.cmdMoneyTransferFp); this.addSubCommand(this.cmdMoneyTransferPf);
|
||||||
this.addSubCommand(this.cmdMoneyTransferFf);
|
|
||||||
this.addSubCommand(this.cmdMoneyTransferFp);
|
|
||||||
this.addSubCommand(this.cmdMoneyTransferPf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
this.commandChain.add(this);
|
this.commandChain.add(this); P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
||||||
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,26 +6,20 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdMoneyBalance extends FCommand {
|
public class CmdMoneyBalance extends FCommand {
|
||||||
public CmdMoneyBalance() {
|
public CmdMoneyBalance() {
|
||||||
super();
|
super(); this.aliases.add("b"); this.aliases.add("balance");
|
||||||
this.aliases.add("b");
|
|
||||||
this.aliases.add("balance");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "yours");
|
this.optionalArgs.put("faction", "yours");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_BALANCE.node;
|
this.permission = Permission.MONEY_BALANCE.node; this.setHelpShort("show faction balance");
|
||||||
this.setHelpShort("show faction balance");
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction faction = myFaction;
|
Faction faction = myFaction; if (this.argIsSet(0)) {
|
||||||
if (this.argIsSet(0)) {
|
|
||||||
faction = this.argAsFaction(0);
|
faction = this.argAsFaction(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,28 +11,19 @@ import org.bukkit.ChatColor;
|
|||||||
public class CmdMoneyDeposit extends FCommand {
|
public class CmdMoneyDeposit extends FCommand {
|
||||||
|
|
||||||
public CmdMoneyDeposit() {
|
public CmdMoneyDeposit() {
|
||||||
super();
|
super(); this.aliases.add("d"); this.aliases.add("deposit");
|
||||||
this.aliases.add("d");
|
|
||||||
this.aliases.add("deposit");
|
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount"); this.optionalArgs.put("faction", "yours");
|
||||||
this.optionalArgs.put("faction", "yours");
|
|
||||||
|
|
||||||
this.permission = Permission.MONEY_DEPOSIT.node;
|
this.permission = Permission.MONEY_DEPOSIT.node; this.setHelpShort("deposit money");
|
||||||
this.setHelpShort("deposit money");
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
double amount = this.argAsDouble(0, 0d);
|
double amount = this.argAsDouble(0, 0d); EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
if (faction == null) { return; } boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
||||||
if (faction == null) { return; }
|
|
||||||
boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions) {
|
if (success && Conf.logMoneyTransactions) {
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||||
|
@ -12,28 +12,20 @@ public class CmdMoneyTransferFf extends FCommand {
|
|||||||
public CmdMoneyTransferFf() {
|
public CmdMoneyTransferFf() {
|
||||||
this.aliases.add("ff");
|
this.aliases.add("ff");
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount"); this.requiredArgs.add("faction"); this.requiredArgs.add("faction");
|
||||||
this.requiredArgs.add("faction");
|
|
||||||
this.requiredArgs.add("faction");
|
|
||||||
|
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_F2F.node;
|
this.permission = Permission.MONEY_F2F.node; this.setHelpShort("transfer f -> f");
|
||||||
this.setHelpShort("transfer f -> f");
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
double amount = this.argAsDouble(0, 0d);
|
double amount = this.argAsDouble(0, 0d); EconomyParticipator from = this.argAsFaction(1);
|
||||||
EconomyParticipator from = this.argAsFaction(1);
|
if (from == null) { return; } EconomyParticipator to = this.argAsFaction(2); if (to == null) { return; }
|
||||||
if (from == null) { return; }
|
|
||||||
EconomyParticipator to = this.argAsFaction(2);
|
|
||||||
if (to == null) { return; }
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||||
|
|
||||||
|
@ -12,27 +12,20 @@ public class CmdMoneyTransferFp extends FCommand {
|
|||||||
public CmdMoneyTransferFp() {
|
public CmdMoneyTransferFp() {
|
||||||
this.aliases.add("fp");
|
this.aliases.add("fp");
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount"); this.requiredArgs.add("faction"); this.requiredArgs.add("player");
|
||||||
this.requiredArgs.add("faction");
|
|
||||||
this.requiredArgs.add("player");
|
|
||||||
|
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_F2P.node;
|
this.permission = Permission.MONEY_F2P.node; this.setHelpShort("transfer f -> p");
|
||||||
this.setHelpShort("transfer f -> p");
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
double amount = this.argAsDouble(0, 0d);
|
double amount = this.argAsDouble(0, 0d); EconomyParticipator from = this.argAsFaction(1);
|
||||||
EconomyParticipator from = this.argAsFaction(1);
|
if (from == null) { return; } EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
||||||
if (from == null) { return; }
|
|
||||||
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
|
||||||
if (to == null) { return; }
|
if (to == null) { return; }
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||||
|
@ -12,28 +12,20 @@ public class CmdMoneyTransferPf extends FCommand {
|
|||||||
public CmdMoneyTransferPf() {
|
public CmdMoneyTransferPf() {
|
||||||
this.aliases.add("pf");
|
this.aliases.add("pf");
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount"); this.requiredArgs.add("player"); this.requiredArgs.add("faction");
|
||||||
this.requiredArgs.add("player");
|
|
||||||
this.requiredArgs.add("faction");
|
|
||||||
|
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_P2F.node;
|
this.permission = Permission.MONEY_P2F.node; this.setHelpShort("transfer p -> f");
|
||||||
this.setHelpShort("transfer p -> f");
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
double amount = this.argAsDouble(0, 0d);
|
double amount = this.argAsDouble(0, 0d); EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
||||||
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
if (from == null) { return; } EconomyParticipator to = this.argAsFaction(2); if (to == null) { return; }
|
||||||
if (from == null) { return; }
|
|
||||||
EconomyParticipator to = this.argAsFaction(2);
|
|
||||||
if (to == null) { return; }
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||||
|
|
||||||
|
@ -10,27 +10,19 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
public class CmdMoneyWithdraw extends FCommand {
|
public class CmdMoneyWithdraw extends FCommand {
|
||||||
public CmdMoneyWithdraw() {
|
public CmdMoneyWithdraw() {
|
||||||
this.aliases.add("w");
|
this.aliases.add("w"); this.aliases.add("withdraw");
|
||||||
this.aliases.add("withdraw");
|
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount"); this.optionalArgs.put("faction", "yours");
|
||||||
this.optionalArgs.put("faction", "yours");
|
|
||||||
|
|
||||||
this.permission = Permission.MONEY_WITHDRAW.node;
|
this.permission = Permission.MONEY_WITHDRAW.node; this.setHelpShort("withdraw money");
|
||||||
this.setHelpShort("withdraw money");
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
double amount = this.argAsDouble(0, 0d);
|
double amount = this.argAsDouble(0, 0d); EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
if (faction == null) { return; } boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
||||||
if (faction == null) { return; }
|
|
||||||
boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions) {
|
if (success && Conf.logMoneyTransactions) {
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||||
|
@ -7,19 +7,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdOpen extends FCommand {
|
public class CmdOpen extends FCommand {
|
||||||
public CmdOpen() {
|
public CmdOpen() {
|
||||||
super();
|
super(); this.aliases.add("open");
|
||||||
this.aliases.add("open");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("yes/no", "flip");
|
this.optionalArgs.put("yes/no", "flip");
|
||||||
|
|
||||||
this.permission = Permission.OPEN.node;
|
this.permission = Permission.OPEN.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,8 +33,7 @@ public class CmdOpen extends FCommand {
|
|||||||
for (Faction faction : Factions.i.get()) {
|
for (Faction faction : Factions.i.get()) {
|
||||||
if (faction == myFaction) {
|
if (faction == myFaction) {
|
||||||
continue;
|
continue;
|
||||||
}
|
} faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), open);
|
||||||
faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), open);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,19 +8,14 @@ import com.massivecraft.factions.struct.Role;
|
|||||||
public class CmdOwner extends FCommand {
|
public class CmdOwner extends FCommand {
|
||||||
|
|
||||||
public CmdOwner() {
|
public CmdOwner() {
|
||||||
super();
|
super(); this.aliases.add("owner");
|
||||||
this.aliases.add("owner");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("player name", "you");
|
this.optionalArgs.put("player name", "you");
|
||||||
|
|
||||||
this.permission = Permission.OWNER.node;
|
this.permission = Permission.OWNER.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix colors!
|
// TODO: Fix colors!
|
||||||
@ -34,8 +29,7 @@ public class CmdOwner extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.ownedAreasEnabled) {
|
if (!Conf.ownedAreasEnabled) {
|
||||||
fme.msg("<b>Sorry, but owned areas are disabled on this server.");
|
fme.msg("<b>Sorry, but owned areas are disabled on this server."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
|
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
|
||||||
@ -49,40 +43,33 @@ public class CmdOwner extends FCommand {
|
|||||||
|
|
||||||
FLocation flocation = new FLocation(fme);
|
FLocation flocation = new FLocation(fme);
|
||||||
|
|
||||||
Faction factionHere = Board.getFactionAt(flocation);
|
Faction factionHere = Board.getFactionAt(flocation); if (factionHere != myFaction) {
|
||||||
if (factionHere != myFaction) {
|
|
||||||
if (!hasBypass) {
|
if (!hasBypass) {
|
||||||
fme.msg("<b>This land is not claimed by your faction, so you can't set ownership of it.");
|
fme.msg("<b>This land is not claimed by your faction, so you can't set ownership of it."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!factionHere.isNormal()) {
|
if (!factionHere.isNormal()) {
|
||||||
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible.");
|
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
FPlayer target = this.argAsBestFPlayerMatch(0, fme); if (target == null) { return; }
|
||||||
if (target == null) { return; }
|
|
||||||
|
|
||||||
String playerName = target.getName();
|
String playerName = target.getName();
|
||||||
|
|
||||||
if (target.getFaction() != myFaction) {
|
if (target.getFaction() != myFaction) {
|
||||||
fme.msg("%s<i> is not a member of this faction.", playerName);
|
fme.msg("%s<i> is not a member of this faction.", playerName); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no player name was passed, and this claim does already have owners set, clear them
|
// if no player name was passed, and this claim does already have owners set, clear them
|
||||||
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
|
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
|
||||||
myFaction.clearClaimOwnership(flocation);
|
myFaction.clearClaimOwnership(flocation); fme.msg("<i>You have cleared ownership for this claimed area.");
|
||||||
fme.msg("<i>You have cleared ownership for this claimed area.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myFaction.isPlayerInOwnerList(target, flocation)) {
|
if (myFaction.isPlayerInOwnerList(target, flocation)) {
|
||||||
myFaction.removePlayerAsOwner(target, flocation);
|
myFaction.removePlayerAsOwner(target, flocation);
|
||||||
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName);
|
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
|
@ -9,19 +9,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdOwnerList extends FCommand {
|
public class CmdOwnerList extends FCommand {
|
||||||
|
|
||||||
public CmdOwnerList() {
|
public CmdOwnerList() {
|
||||||
super();
|
super(); this.aliases.add("ownerlist");
|
||||||
this.aliases.add("ownerlist");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.OWNERLIST.node;
|
this.permission = Permission.OWNERLIST.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,30 +28,25 @@ public class CmdOwnerList extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Conf.ownedAreasEnabled) {
|
if (!Conf.ownedAreasEnabled) {
|
||||||
fme.msg("<b>Owned areas are disabled on this server.");
|
fme.msg("<b>Owned areas are disabled on this server."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FLocation flocation = new FLocation(fme);
|
FLocation flocation = new FLocation(fme);
|
||||||
|
|
||||||
if (Board.getFactionAt(flocation) != myFaction) {
|
if (Board.getFactionAt(flocation) != myFaction) {
|
||||||
if (!hasBypass) {
|
if (!hasBypass) {
|
||||||
fme.msg("<b>This land is not claimed by your faction.");
|
fme.msg("<b>This land is not claimed by your faction."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myFaction = Board.getFactionAt(flocation);
|
myFaction = Board.getFactionAt(flocation); if (!myFaction.isNormal()) {
|
||||||
if (!myFaction.isNormal()) {
|
fme.msg("<i>This land is not claimed by any faction, thus no owners."); return;
|
||||||
fme.msg("<i>This land is not claimed by any faction, thus no owners.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String owners = myFaction.getOwnerListString(flocation);
|
String owners = myFaction.getOwnerListString(flocation);
|
||||||
|
|
||||||
if (owners == null || owners.isEmpty()) {
|
if (owners == null || owners.isEmpty()) {
|
||||||
fme.msg("<i>No owners are set here; everyone in the faction has access.");
|
fme.msg("<i>No owners are set here; everyone in the faction has access."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.msg("<i>Current owner(s) of this land: %s", owners);
|
fme.msg("<i>Current owner(s) of this land: %s", owners);
|
||||||
|
@ -8,42 +8,32 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdPeaceful extends FCommand {
|
public class CmdPeaceful extends FCommand {
|
||||||
|
|
||||||
public CmdPeaceful() {
|
public CmdPeaceful() {
|
||||||
super();
|
super(); this.aliases.add("peaceful");
|
||||||
this.aliases.add("peaceful");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SET_PEACEFUL.node;
|
this.permission = Permission.SET_PEACEFUL.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction faction = this.argAsFaction(0);
|
Faction faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||||
if (faction == null) { return; }
|
|
||||||
|
|
||||||
String change;
|
String change; if (faction.isPeaceful()) {
|
||||||
if (faction.isPeaceful()) {
|
change = "removed peaceful status from"; faction.setPeaceful(false);
|
||||||
change = "removed peaceful status from";
|
} else {
|
||||||
faction.setPeaceful(false);
|
change = "granted peaceful status to"; faction.setPeaceful(true);
|
||||||
}
|
|
||||||
else {
|
|
||||||
change = "granted peaceful status to";
|
|
||||||
faction.setPeaceful(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
if (fplayer.getFaction() == faction) {
|
if (fplayer.getFaction() == faction) {
|
||||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " your faction.");
|
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " your faction.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " the faction \"" + faction.getTag(fplayer) + "<i>\".");
|
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " the faction \"" + faction.getTag(fplayer) + "<i>\".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,34 +9,25 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdPermanent extends FCommand {
|
public class CmdPermanent extends FCommand {
|
||||||
public CmdPermanent() {
|
public CmdPermanent() {
|
||||||
super();
|
super(); this.aliases.add("permanent");
|
||||||
this.aliases.add("permanent");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SET_PERMANENT.node;
|
this.permission = Permission.SET_PERMANENT.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction faction = this.argAsFaction(0);
|
Faction faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||||
if (faction == null) { return; }
|
|
||||||
|
|
||||||
String change;
|
String change; if (faction.isPermanent()) {
|
||||||
if (faction.isPermanent()) {
|
change = "removed permanent status from"; faction.setPermanent(false);
|
||||||
change = "removed permanent status from";
|
} else {
|
||||||
faction.setPermanent(false);
|
change = "added permanent status to"; faction.setPermanent(true);
|
||||||
}
|
|
||||||
else {
|
|
||||||
change = "added permanent status to";
|
|
||||||
faction.setPermanent(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
|
P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
|
||||||
@ -45,8 +36,7 @@ public class CmdPermanent extends FCommand {
|
|||||||
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
if (fplayer.getFaction() == faction) {
|
if (fplayer.getFaction() == faction) {
|
||||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " your faction.");
|
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " your faction.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " the faction \"" + faction.getTag(fplayer) + "\".");
|
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> " + change + " the faction \"" + faction.getTag(fplayer) + "\".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,32 +6,25 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdPermanentPower extends FCommand {
|
public class CmdPermanentPower extends FCommand {
|
||||||
public CmdPermanentPower() {
|
public CmdPermanentPower() {
|
||||||
super();
|
super(); this.aliases.add("permanentpower");
|
||||||
this.aliases.add("permanentpower");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction");
|
this.requiredArgs.add("faction"); this.optionalArgs.put("power", "reset");
|
||||||
this.optionalArgs.put("power", "reset");
|
|
||||||
|
|
||||||
this.permission = Permission.SET_PERMANENTPOWER.node;
|
this.permission = Permission.SET_PERMANENTPOWER.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction targetFaction = this.argAsFaction(0);
|
Faction targetFaction = this.argAsFaction(0); if (targetFaction == null) { return; }
|
||||||
if (targetFaction == null) { return; }
|
|
||||||
|
|
||||||
Integer targetPower = this.argAsInt(1);
|
Integer targetPower = this.argAsInt(1);
|
||||||
|
|
||||||
targetFaction.setPermanentPower(targetPower);
|
targetFaction.setPermanentPower(targetPower);
|
||||||
|
|
||||||
String change = "removed permanentpower status from";
|
String change = "removed permanentpower status from"; if (targetFaction.hasPermanentPower()) {
|
||||||
if (targetFaction.hasPermanentPower()) {
|
|
||||||
change = "added permanentpower status to";
|
change = "added permanentpower status to";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,26 +7,20 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdPower extends FCommand {
|
public class CmdPower extends FCommand {
|
||||||
|
|
||||||
public CmdPower() {
|
public CmdPower() {
|
||||||
super();
|
super(); this.aliases.add("power"); this.aliases.add("pow");
|
||||||
this.aliases.add("power");
|
|
||||||
this.aliases.add("pow");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("faction tag");
|
//this.requiredArgs.add("faction tag");
|
||||||
this.optionalArgs.put("player name", "you");
|
this.optionalArgs.put("player name", "you");
|
||||||
|
|
||||||
this.permission = Permission.POWER.node;
|
this.permission = Permission.POWER.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
FPlayer target = this.argAsBestFPlayerMatch(0, fme); if (target == null) { return; }
|
||||||
if (target == null) { return; }
|
|
||||||
|
|
||||||
if (target != fme && !Permission.POWER_ANY.has(sender, true)) { return; }
|
if (target != fme && !Permission.POWER_ANY.has(sender, true)) { return; }
|
||||||
|
|
||||||
|
@ -7,54 +7,38 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdPowerBoost extends FCommand {
|
public class CmdPowerBoost extends FCommand {
|
||||||
public CmdPowerBoost() {
|
public CmdPowerBoost() {
|
||||||
super();
|
super(); this.aliases.add("powerboost");
|
||||||
this.aliases.add("powerboost");
|
|
||||||
|
|
||||||
this.requiredArgs.add("p|f|player|faction");
|
this.requiredArgs.add("p|f|player|faction"); this.requiredArgs.add("name"); this.requiredArgs.add("#");
|
||||||
this.requiredArgs.add("name");
|
|
||||||
this.requiredArgs.add("#");
|
|
||||||
|
|
||||||
this.permission = Permission.POWERBOOST.node;
|
this.permission = Permission.POWERBOOST.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
String type = this.argAsString(0).toLowerCase();
|
String type = this.argAsString(0).toLowerCase(); boolean doPlayer = true;
|
||||||
boolean doPlayer = true;
|
|
||||||
if (type.equals("f") || type.equals("faction")) {
|
if (type.equals("f") || type.equals("faction")) {
|
||||||
doPlayer = false;
|
doPlayer = false;
|
||||||
}
|
} else if (!type.equals("p") && !type.equals("player")) {
|
||||||
else if (!type.equals("p") && !type.equals("player")) {
|
|
||||||
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
|
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
|
||||||
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
|
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5"); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Double targetPower = this.argAsDouble(2);
|
Double targetPower = this.argAsDouble(2); if (targetPower == null) {
|
||||||
if (targetPower == null) {
|
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount."); return;
|
||||||
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String target;
|
String target;
|
||||||
|
|
||||||
if (doPlayer) {
|
if (doPlayer) {
|
||||||
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
|
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1); if (targetPlayer == null) { return; }
|
||||||
if (targetPlayer == null) { return; }
|
targetPlayer.setPowerBoost(targetPower); target = "Player \"" + targetPlayer.getName() + "\"";
|
||||||
targetPlayer.setPowerBoost(targetPower);
|
} else {
|
||||||
target = "Player \"" + targetPlayer.getName() + "\"";
|
Faction targetFaction = this.argAsFaction(1); if (targetFaction == null) { return; }
|
||||||
}
|
targetFaction.setPowerBoost(targetPower); target = "Faction \"" + targetFaction.getTag() + "\"";
|
||||||
else {
|
|
||||||
Faction targetFaction = this.argAsFaction(1);
|
|
||||||
if (targetFaction == null) { return; }
|
|
||||||
targetFaction.setPowerBoost(targetPower);
|
|
||||||
target = "Faction \"" + targetFaction.getTag() + "\"";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("<i>" + target + " now has a power bonus/penalty of " + targetPower + " to min and max power levels.");
|
msg("<i>" + target + " now has a power bonus/penalty of " + targetPower + " to min and max power levels.");
|
||||||
|
@ -4,7 +4,6 @@ import com.massivecraft.factions.struct.Relation;
|
|||||||
|
|
||||||
public class CmdRelationAlly extends FRelationCommand {
|
public class CmdRelationAlly extends FRelationCommand {
|
||||||
public CmdRelationAlly() {
|
public CmdRelationAlly() {
|
||||||
aliases.add("ally");
|
aliases.add("ally"); targetRelation = Relation.ALLY;
|
||||||
targetRelation = Relation.ALLY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.massivecraft.factions.struct.Relation;
|
|||||||
|
|
||||||
public class CmdRelationEnemy extends FRelationCommand {
|
public class CmdRelationEnemy extends FRelationCommand {
|
||||||
public CmdRelationEnemy() {
|
public CmdRelationEnemy() {
|
||||||
aliases.add("enemy");
|
aliases.add("enemy"); targetRelation = Relation.ENEMY;
|
||||||
targetRelation = Relation.ENEMY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.massivecraft.factions.struct.Relation;
|
|||||||
|
|
||||||
public class CmdRelationNeutral extends FRelationCommand {
|
public class CmdRelationNeutral extends FRelationCommand {
|
||||||
public CmdRelationNeutral() {
|
public CmdRelationNeutral() {
|
||||||
aliases.add("neutral");
|
aliases.add("neutral"); targetRelation = Relation.NEUTRAL;
|
||||||
targetRelation = Relation.NEUTRAL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,55 +6,36 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdReload extends FCommand {
|
public class CmdReload extends FCommand {
|
||||||
|
|
||||||
public CmdReload() {
|
public CmdReload() {
|
||||||
super();
|
super(); this.aliases.add("reload");
|
||||||
this.aliases.add("reload");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("file", "all");
|
this.optionalArgs.put("file", "all");
|
||||||
|
|
||||||
this.permission = Permission.RELOAD.node;
|
this.permission = Permission.RELOAD.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
long timeInitStart = System.currentTimeMillis();
|
long timeInitStart = System.currentTimeMillis(); String file = this.argAsString(0, "all").toLowerCase();
|
||||||
String file = this.argAsString(0, "all").toLowerCase();
|
|
||||||
|
|
||||||
String fileName;
|
String fileName;
|
||||||
|
|
||||||
if (file.startsWith("c")) {
|
if (file.startsWith("c")) {
|
||||||
Conf.load();
|
Conf.load(); fileName = "conf.json";
|
||||||
fileName = "conf.json";
|
} else if (file.startsWith("b")) {
|
||||||
}
|
Board.load(); fileName = "board.json";
|
||||||
else if (file.startsWith("b")) {
|
} else if (file.startsWith("f")) {
|
||||||
Board.load();
|
Factions.i.loadFromDisc(); fileName = "factions.json";
|
||||||
fileName = "board.json";
|
} else if (file.startsWith("p")) {
|
||||||
}
|
FPlayers.i.loadFromDisc(); fileName = "players.json";
|
||||||
else if (file.startsWith("f")) {
|
} else if (file.startsWith("a")) {
|
||||||
Factions.i.loadFromDisc();
|
fileName = "all"; Conf.load(); FPlayers.i.loadFromDisc(); Factions.i.loadFromDisc(); Board.load();
|
||||||
fileName = "factions.json";
|
} else {
|
||||||
}
|
|
||||||
else if (file.startsWith("p")) {
|
|
||||||
FPlayers.i.loadFromDisc();
|
|
||||||
fileName = "players.json";
|
|
||||||
}
|
|
||||||
else if (file.startsWith("a")) {
|
|
||||||
fileName = "all";
|
|
||||||
Conf.load();
|
|
||||||
FPlayers.i.loadFromDisc();
|
|
||||||
Factions.i.loadFromDisc();
|
|
||||||
Board.load();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
||||||
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
|
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players"); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
||||||
|
@ -9,18 +9,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdSafeunclaimall extends FCommand {
|
public class CmdSafeunclaimall extends FCommand {
|
||||||
|
|
||||||
public CmdSafeunclaimall() {
|
public CmdSafeunclaimall() {
|
||||||
this.aliases.add("safeunclaimall");
|
this.aliases.add("safeunclaimall"); this.aliases.add("safedeclaimall");
|
||||||
this.aliases.add("safedeclaimall");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("radius", "0");
|
//this.optionalArgs.put("radius", "0");
|
||||||
|
|
||||||
this.permission = Permission.MANAGE_SAFE_ZONE.node;
|
this.permission = Permission.MANAGE_SAFE_ZONE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("Unclaim all safezone land");
|
this.setHelpShort("Unclaim all safezone land");
|
||||||
@ -28,8 +24,7 @@ public class CmdSafeunclaimall extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Board.unclaimAll(Factions.i.getSafeZone().getId());
|
Board.unclaimAll(Factions.i.getSafeZone().getId()); msg("<i>You unclaimed ALL safe zone land.");
|
||||||
msg("<i>You unclaimed ALL safe zone land.");
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all safe zones."); }
|
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all safe zones."); }
|
||||||
}
|
}
|
||||||
|
@ -9,29 +9,20 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdSaveAll extends FCommand {
|
public class CmdSaveAll extends FCommand {
|
||||||
|
|
||||||
public CmdSaveAll() {
|
public CmdSaveAll() {
|
||||||
super();
|
super(); this.aliases.add("saveall"); this.aliases.add("save");
|
||||||
this.aliases.add("saveall");
|
|
||||||
this.aliases.add("save");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SAVE.node;
|
this.permission = Permission.SAVE.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayers.i.saveToDisc();
|
FPlayers.i.saveToDisc(); Factions.i.saveToDisc(); Board.save(); Conf.save(); msg("<i>Factions saved to disk!");
|
||||||
Factions.i.saveToDisc();
|
|
||||||
Board.save();
|
|
||||||
Conf.save();
|
|
||||||
msg("<i>Factions saved to disk!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -14,44 +14,31 @@ public class CmdSethome extends FCommand {
|
|||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction tag", "mine");
|
this.optionalArgs.put("faction tag", "mine");
|
||||||
|
|
||||||
this.permission = Permission.SETHOME.node;
|
this.permission = Permission.SETHOME.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
if (!Conf.homesEnabled) {
|
if (!Conf.homesEnabled) {
|
||||||
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
fme.msg("<b>Sorry, Faction homes are disabled on this server."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction faction = this.argAsFaction(0, myFaction);
|
Faction faction = this.argAsFaction(0, myFaction); if (faction == null) { return; }
|
||||||
if (faction == null) { return; }
|
|
||||||
|
|
||||||
// Can the player set the home for this faction?
|
// Can the player set the home for this faction?
|
||||||
if (faction == myFaction) {
|
if (faction == myFaction) {
|
||||||
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) { return; }
|
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) { return; }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Permission.SETHOME_ANY.has(sender, true)) { return; }
|
if (!Permission.SETHOME_ANY.has(sender, true)) { return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can the player set the faction home HERE?
|
// Can the player set the faction home HERE?
|
||||||
if
|
if (!Permission.BYPASS.has(me) &&
|
||||||
(
|
Conf.homesMustBeInClaimedTerritory &&
|
||||||
!Permission.BYPASS.has(me)
|
Board.getFactionAt(new FLocation(me)) != faction) {
|
||||||
&&
|
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory."); return;
|
||||||
Conf.homesMustBeInClaimedTerritory
|
|
||||||
&&
|
|
||||||
Board.getFactionAt(new FLocation(me)) != faction
|
|
||||||
) {
|
|
||||||
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
@ -60,8 +47,7 @@ public class CmdSethome extends FCommand {
|
|||||||
faction.setHome(me.getLocation());
|
faction.setHome(me.getLocation());
|
||||||
|
|
||||||
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
||||||
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate());
|
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate()); if (faction != myFaction) {
|
||||||
if (faction != myFaction) {
|
|
||||||
fme.msg("<b>You have set the home for the " + faction.getTag(fme) + "<i> faction.");
|
fme.msg("<b>You have set the home for the " + faction.getTag(fme) + "<i> faction.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,27 +14,20 @@ import java.util.Collection;
|
|||||||
public class CmdShow extends FCommand {
|
public class CmdShow extends FCommand {
|
||||||
|
|
||||||
public CmdShow() {
|
public CmdShow() {
|
||||||
this.aliases.add("show");
|
this.aliases.add("show"); this.aliases.add("who");
|
||||||
this.aliases.add("who");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction tag", "yours");
|
this.optionalArgs.put("faction tag", "yours");
|
||||||
|
|
||||||
this.permission = Permission.SHOW.node;
|
this.permission = Permission.SHOW.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction faction = myFaction;
|
Faction faction = myFaction; if (this.argIsSet(0)) {
|
||||||
if (this.argIsSet(0)) {
|
faction = this.argAsFaction(0); if (faction == null) { return; }
|
||||||
faction = this.argAsFaction(0);
|
|
||||||
if (faction == null) { return; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
@ -46,14 +39,12 @@ public class CmdShow extends FCommand {
|
|||||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
||||||
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
||||||
|
|
||||||
msg(p.txt.titleize(faction.getTag(fme)));
|
msg(p.txt.titleize(faction.getTag(fme))); msg("<a>Description: <i>%s", faction.getDescription());
|
||||||
msg("<a>Description: <i>%s", faction.getDescription());
|
|
||||||
if (!faction.isNormal()) {
|
if (!faction.isNormal()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String peaceStatus = "";
|
String peaceStatus = ""; if (faction.isPeaceful()) {
|
||||||
if (faction.isPeaceful()) {
|
|
||||||
peaceStatus = " " + Conf.colorNeutral + "This faction is Peaceful";
|
peaceStatus = " " + Conf.colorNeutral + "This faction is Peaceful";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +61,7 @@ public class CmdShow extends FCommand {
|
|||||||
// show the land value
|
// show the land value
|
||||||
if (Econ.shouldBeUsed()) {
|
if (Econ.shouldBeUsed()) {
|
||||||
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
||||||
double refund = value * Conf.econClaimRefundMultiplier;
|
double refund = value * Conf.econClaimRefundMultiplier; if (value > 0) {
|
||||||
if (value > 0) {
|
|
||||||
String stringValue = Econ.moneyString(value);
|
String stringValue = Econ.moneyString(value);
|
||||||
String stringRefund = (refund > 0.0) ? (" (" + Econ.moneyString(refund) + " depreciated)") : "";
|
String stringRefund = (refund > 0.0) ? (" (" + Econ.moneyString(refund) + " depreciated)") : "";
|
||||||
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
||||||
@ -86,67 +76,53 @@ public class CmdShow extends FCommand {
|
|||||||
String listpart;
|
String listpart;
|
||||||
|
|
||||||
// List relation
|
// List relation
|
||||||
String allyList = p.txt.parse("<a>Allies: ");
|
String allyList = p.txt.parse("<a>Allies: "); String enemyList = p.txt.parse("<a>Enemies: ");
|
||||||
String enemyList = p.txt.parse("<a>Enemies: ");
|
|
||||||
for (Faction otherFaction : Factions.i.get()) {
|
for (Faction otherFaction : Factions.i.get()) {
|
||||||
if (otherFaction == faction) { continue; }
|
if (otherFaction == faction) { continue; }
|
||||||
|
|
||||||
Relation rel = otherFaction.getRelationTo(faction);
|
Relation rel = otherFaction.getRelationTo(faction); if (!rel.isAlly() && !rel.isEnemy()) {
|
||||||
if (!rel.isAlly() && !rel.isEnemy()) {
|
|
||||||
continue; // if not ally or enemy, drop out now so we're not wasting time on it; good performance boost
|
continue; // if not ally or enemy, drop out now so we're not wasting time on it; good performance boost
|
||||||
}
|
}
|
||||||
|
|
||||||
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
||||||
if (rel.isAlly()) { allyList += listpart; }
|
if (rel.isAlly()) { allyList += listpart; } else if (rel.isEnemy()) { enemyList += listpart; }
|
||||||
else if (rel.isEnemy()) { enemyList += listpart; }
|
} if (allyList.endsWith(", ")) { allyList = allyList.substring(0, allyList.length() - 2); }
|
||||||
}
|
|
||||||
if (allyList.endsWith(", ")) { allyList = allyList.substring(0, allyList.length() - 2); }
|
|
||||||
if (enemyList.endsWith(", ")) { enemyList = enemyList.substring(0, enemyList.length() - 2); }
|
if (enemyList.endsWith(", ")) { enemyList = enemyList.substring(0, enemyList.length() - 2); }
|
||||||
|
|
||||||
sendMessage(allyList);
|
sendMessage(allyList); sendMessage(enemyList);
|
||||||
sendMessage(enemyList);
|
|
||||||
|
|
||||||
// List the members...
|
// List the members...
|
||||||
String onlineList = p.txt.parse("<a>") + "Members online: ";
|
String onlineList = p.txt.parse("<a>") + "Members online: ";
|
||||||
String offlineList = p.txt.parse("<a>") + "Members offline: ";
|
String offlineList = p.txt.parse("<a>") + "Members offline: "; for (FPlayer follower : admins) {
|
||||||
for (FPlayer follower : admins) {
|
|
||||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
if (follower.isOnlineAndVisibleTo(me)) {
|
if (follower.isOnlineAndVisibleTo(me)) {
|
||||||
onlineList += listpart;
|
onlineList += listpart;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
offlineList += listpart;
|
offlineList += listpart;
|
||||||
}
|
}
|
||||||
}
|
} for (FPlayer follower : mods) {
|
||||||
for (FPlayer follower : mods) {
|
|
||||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
|
||||||
if
|
|
||||||
(follower.isOnlineAndVisibleTo(me)) {
|
|
||||||
onlineList += listpart;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
offlineList += listpart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (FPlayer follower : normals) {
|
|
||||||
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
if (follower.isOnlineAndVisibleTo(me)) {
|
if (follower.isOnlineAndVisibleTo(me)) {
|
||||||
onlineList += listpart;
|
onlineList += listpart;
|
||||||
|
} else {
|
||||||
|
offlineList += listpart;
|
||||||
}
|
}
|
||||||
else {
|
} for (FPlayer follower : normals) {
|
||||||
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
|
if (follower.isOnlineAndVisibleTo(me)) {
|
||||||
|
onlineList += listpart;
|
||||||
|
} else {
|
||||||
offlineList += listpart;
|
offlineList += listpart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onlineList.endsWith(", ")) {
|
if (onlineList.endsWith(", ")) {
|
||||||
onlineList = onlineList.substring(0, onlineList.length() - 2);
|
onlineList = onlineList.substring(0, onlineList.length() - 2);
|
||||||
}
|
} if (offlineList.endsWith(", ")) {
|
||||||
if (offlineList.endsWith(", ")) {
|
|
||||||
offlineList = offlineList.substring(0, offlineList.length() - 2);
|
offlineList = offlineList.substring(0, offlineList.length() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(onlineList);
|
sendMessage(onlineList); sendMessage(offlineList);
|
||||||
sendMessage(offlineList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,9 @@ public class CmdTag extends FCommand {
|
|||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.TAG.node;
|
this.permission = Permission.TAG.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,15 +29,12 @@ public class CmdTag extends FCommand {
|
|||||||
|
|
||||||
// TODO does not first test cover selfcase?
|
// TODO does not first test cover selfcase?
|
||||||
if (Factions.i.isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) {
|
if (Factions.i.isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) {
|
||||||
msg("<b>That tag is already taken");
|
msg("<b>That tag is already taken"); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> errors = new ArrayList<String>();
|
ArrayList<String> errors = new ArrayList<String>(); errors.addAll(Factions.validateTag(tag));
|
||||||
errors.addAll(Factions.validateTag(tag));
|
|
||||||
if (errors.size() > 0) {
|
if (errors.size() > 0) {
|
||||||
sendMessage(errors);
|
sendMessage(errors); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||||
@ -49,14 +42,12 @@ public class CmdTag extends FCommand {
|
|||||||
|
|
||||||
// trigger the faction rename event (cancellable)
|
// trigger the faction rename event (cancellable)
|
||||||
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
Bukkit.getServer().getPluginManager().callEvent(renameEvent); if (renameEvent.isCancelled()) { return; }
|
||||||
if (renameEvent.isCancelled()) { return; }
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) { return; }
|
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) { return; }
|
||||||
|
|
||||||
String oldtag = myFaction.getTag();
|
String oldtag = myFaction.getTag(); myFaction.setTag(tag);
|
||||||
myFaction.setTag(tag);
|
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
|
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
|
||||||
|
@ -9,25 +9,18 @@ public class CmdTitle extends FCommand {
|
|||||||
public CmdTitle() {
|
public CmdTitle() {
|
||||||
this.aliases.add("title");
|
this.aliases.add("title");
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name"); this.optionalArgs.put("title", "");
|
||||||
this.optionalArgs.put("title", "");
|
|
||||||
|
|
||||||
this.permission = Permission.TITLE.node;
|
this.permission = Permission.TITLE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
FPlayer you = this.argAsBestFPlayerMatch(0); if (you == null) { return; }
|
||||||
if (you == null) { return; }
|
|
||||||
|
|
||||||
args.remove(0);
|
args.remove(0); String title = TextUtil.implode(args, " ");
|
||||||
String title = TextUtil.implode(args, " ");
|
|
||||||
|
|
||||||
if (!canIAdministerYou(fme, you)) { return; }
|
if (!canIAdministerYou(fme, you)) { return; }
|
||||||
|
|
||||||
|
@ -9,53 +9,40 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class CmdUnclaim extends FCommand {
|
public class CmdUnclaim extends FCommand {
|
||||||
public CmdUnclaim() {
|
public CmdUnclaim() {
|
||||||
this.aliases.add("unclaim");
|
this.aliases.add("unclaim"); this.aliases.add("declaim");
|
||||||
this.aliases.add("declaim");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.UNCLAIM.node;
|
this.permission = Permission.UNCLAIM.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
FLocation flocation = new FLocation(fme);
|
FLocation flocation = new FLocation(fme); Faction otherFaction = Board.getFactionAt(flocation);
|
||||||
Faction otherFaction = Board.getFactionAt(flocation);
|
|
||||||
|
|
||||||
if (otherFaction.isSafeZone()) {
|
if (otherFaction.isSafeZone()) {
|
||||||
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
||||||
Board.removeAt(flocation);
|
Board.removeAt(flocation); msg("<i>Safe zone was unclaimed.");
|
||||||
msg("<i>Safe zone was unclaimed.");
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims) {
|
if (Conf.logLandUnclaims) {
|
||||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
msg("<b>This is a safe zone. You lack permissions to unclaim.");
|
msg("<b>This is a safe zone. You lack permissions to unclaim.");
|
||||||
}
|
} return;
|
||||||
return;
|
} else if (otherFaction.isWarZone()) {
|
||||||
}
|
|
||||||
else if (otherFaction.isWarZone()) {
|
|
||||||
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||||
Board.removeAt(flocation);
|
Board.removeAt(flocation); msg("<i>War zone was unclaimed.");
|
||||||
msg("<i>War zone was unclaimed.");
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims) {
|
if (Conf.logLandUnclaims) {
|
||||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
msg("<b>This is a war zone. You lack permissions to unclaim.");
|
msg("<b>This is a war zone. You lack permissions to unclaim.");
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fme.isAdminBypassing()) {
|
if (fme.isAdminBypassing()) {
|
||||||
@ -81,13 +68,11 @@ public class CmdUnclaim extends FCommand {
|
|||||||
|
|
||||||
|
|
||||||
if (myFaction != otherFaction) {
|
if (myFaction != otherFaction) {
|
||||||
msg("<b>You don't own this land.");
|
msg("<b>You don't own this land."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent); if (unclaimEvent.isCancelled()) { return; }
|
||||||
if (unclaimEvent.isCancelled()) { return; }
|
|
||||||
|
|
||||||
if (Econ.shouldBeUsed()) {
|
if (Econ.shouldBeUsed()) {
|
||||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||||
@ -96,14 +81,12 @@ public class CmdUnclaim extends FCommand {
|
|||||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) {
|
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) { return; }
|
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) { return; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Board.removeAt(flocation);
|
Board.removeAt(flocation); myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims) {
|
if (Conf.logLandUnclaims) {
|
||||||
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||||
|
@ -10,19 +10,14 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class CmdUnclaimall extends FCommand {
|
public class CmdUnclaimall extends FCommand {
|
||||||
public CmdUnclaimall() {
|
public CmdUnclaimall() {
|
||||||
this.aliases.add("unclaimall");
|
this.aliases.add("unclaimall"); this.aliases.add("declaimall");
|
||||||
this.aliases.add("declaimall");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.UNCLAIM_ALL.node;
|
this.permission = Permission.UNCLAIM_ALL.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,8 +28,7 @@ public class CmdUnclaimall extends FCommand {
|
|||||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
|
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Econ.modifyMoney(fme, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
|
if (!Econ.modifyMoney(fme, refund, "to unclaim all faction land", "for unclaiming all faction land")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,9 @@ public class CmdVersion extends FCommand {
|
|||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.VERSION.node;
|
this.permission = Permission.VERSION.node; this.disableOnLock = false;
|
||||||
this.disableOnLock = false;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,18 +9,14 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
public class CmdWarunclaimall extends FCommand {
|
public class CmdWarunclaimall extends FCommand {
|
||||||
|
|
||||||
public CmdWarunclaimall() {
|
public CmdWarunclaimall() {
|
||||||
this.aliases.add("warunclaimall");
|
this.aliases.add("warunclaimall"); this.aliases.add("wardeclaimall");
|
||||||
this.aliases.add("wardeclaimall");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MANAGE_WAR_ZONE.node;
|
this.permission = Permission.MANAGE_WAR_ZONE.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("unclaim all warzone land");
|
this.setHelpShort("unclaim all warzone land");
|
||||||
@ -28,8 +24,7 @@ public class CmdWarunclaimall extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Board.unclaimAll(Factions.i.getWarZone().getId());
|
Board.unclaimAll(Factions.i.getWarZone().getId()); msg("<i>You unclaimed ALL war zone land.");
|
||||||
msg("<i>You unclaimed ALL war zone land.");
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all war zones."); }
|
if (Conf.logLandUnclaims) { P.p.log(fme.getName() + " unclaimed all war zones."); }
|
||||||
}
|
}
|
||||||
|
@ -52,17 +52,14 @@ public class FCmdRoot extends FCommand {
|
|||||||
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
||||||
|
|
||||||
public FCmdRoot() {
|
public FCmdRoot() {
|
||||||
super();
|
super(); this.aliases.addAll(Conf.baseCommandAliases);
|
||||||
this.aliases.addAll(Conf.baseCommandAliases);
|
|
||||||
this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas
|
this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas
|
||||||
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
|
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("","")
|
//this.optionalArgs.put("","")
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false; senderMustBeMember = false; senderMustBeModerator = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
@ -72,57 +69,29 @@ public class FCmdRoot extends FCommand {
|
|||||||
|
|
||||||
//this.subCommands.add(p.cmdHelp);
|
//this.subCommands.add(p.cmdHelp);
|
||||||
|
|
||||||
this.addSubCommand(this.cmdAdmin);
|
this.addSubCommand(this.cmdAdmin); this.addSubCommand(this.cmdAutoClaim); this.addSubCommand(this.cmdBoom);
|
||||||
this.addSubCommand(this.cmdAutoClaim);
|
this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdChat); this.addSubCommand(this.cmdChatSpy);
|
||||||
this.addSubCommand(this.cmdBoom);
|
this.addSubCommand(this.cmdClaim); this.addSubCommand(this.cmdConfig); this.addSubCommand(this.cmdCreate);
|
||||||
this.addSubCommand(this.cmdBypass);
|
this.addSubCommand(this.cmdDeinvite); this.addSubCommand(this.cmdDescription);
|
||||||
this.addSubCommand(this.cmdChat);
|
this.addSubCommand(this.cmdDisband); this.addSubCommand(this.cmdHelp); this.addSubCommand(this.cmdHome);
|
||||||
this.addSubCommand(this.cmdChatSpy);
|
this.addSubCommand(this.cmdInvite); this.addSubCommand(this.cmdJoin); this.addSubCommand(this.cmdKick);
|
||||||
this.addSubCommand(this.cmdClaim);
|
this.addSubCommand(this.cmdLeave); this.addSubCommand(this.cmdList); this.addSubCommand(this.cmdLock);
|
||||||
this.addSubCommand(this.cmdConfig);
|
this.addSubCommand(this.cmdMap); this.addSubCommand(this.cmdMod); this.addSubCommand(this.cmdMoney);
|
||||||
this.addSubCommand(this.cmdCreate);
|
this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwnerList);
|
||||||
this.addSubCommand(this.cmdDeinvite);
|
this.addSubCommand(this.cmdPeaceful); this.addSubCommand(this.cmdPermanent);
|
||||||
this.addSubCommand(this.cmdDescription);
|
this.addSubCommand(this.cmdPermanentPower); this.addSubCommand(this.cmdPower);
|
||||||
this.addSubCommand(this.cmdDisband);
|
this.addSubCommand(this.cmdPowerBoost); this.addSubCommand(this.cmdRelationAlly);
|
||||||
this.addSubCommand(this.cmdHelp);
|
this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationNeutral);
|
||||||
this.addSubCommand(this.cmdHome);
|
this.addSubCommand(this.cmdReload); this.addSubCommand(this.cmdSafeunclaimall);
|
||||||
this.addSubCommand(this.cmdInvite);
|
this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSethome); this.addSubCommand(this.cmdShow);
|
||||||
this.addSubCommand(this.cmdJoin);
|
this.addSubCommand(this.cmdTag); this.addSubCommand(this.cmdTitle); this.addSubCommand(this.cmdUnclaim);
|
||||||
this.addSubCommand(this.cmdKick);
|
this.addSubCommand(this.cmdUnclaimall); this.addSubCommand(this.cmdVersion);
|
||||||
this.addSubCommand(this.cmdLeave);
|
|
||||||
this.addSubCommand(this.cmdList);
|
|
||||||
this.addSubCommand(this.cmdLock);
|
|
||||||
this.addSubCommand(this.cmdMap);
|
|
||||||
this.addSubCommand(this.cmdMod);
|
|
||||||
this.addSubCommand(this.cmdMoney);
|
|
||||||
this.addSubCommand(this.cmdOpen);
|
|
||||||
this.addSubCommand(this.cmdOwner);
|
|
||||||
this.addSubCommand(this.cmdOwnerList);
|
|
||||||
this.addSubCommand(this.cmdPeaceful);
|
|
||||||
this.addSubCommand(this.cmdPermanent);
|
|
||||||
this.addSubCommand(this.cmdPermanentPower);
|
|
||||||
this.addSubCommand(this.cmdPower);
|
|
||||||
this.addSubCommand(this.cmdPowerBoost);
|
|
||||||
this.addSubCommand(this.cmdRelationAlly);
|
|
||||||
this.addSubCommand(this.cmdRelationEnemy);
|
|
||||||
this.addSubCommand(this.cmdRelationNeutral);
|
|
||||||
this.addSubCommand(this.cmdReload);
|
|
||||||
this.addSubCommand(this.cmdSafeunclaimall);
|
|
||||||
this.addSubCommand(this.cmdSaveAll);
|
|
||||||
this.addSubCommand(this.cmdSethome);
|
|
||||||
this.addSubCommand(this.cmdShow);
|
|
||||||
this.addSubCommand(this.cmdTag);
|
|
||||||
this.addSubCommand(this.cmdTitle);
|
|
||||||
this.addSubCommand(this.cmdUnclaim);
|
|
||||||
this.addSubCommand(this.cmdUnclaimall);
|
|
||||||
this.addSubCommand(this.cmdVersion);
|
|
||||||
this.addSubCommand(this.cmdWarunclaimall);
|
this.addSubCommand(this.cmdWarunclaimall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
this.commandChain.add(this);
|
this.commandChain.add(this); this.cmdHelp.execute(this.sender, this.args, this.commandChain);
|
||||||
this.cmdHelp.execute(this.sender, this.args, this.commandChain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,39 +32,30 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
// The money commands must be disabled if money should not be used.
|
// The money commands must be disabled if money should not be used.
|
||||||
isMoneyCommand = false;
|
isMoneyCommand = false;
|
||||||
|
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
this.fme = FPlayers.i.get((Player) sender);
|
this.fme = FPlayers.i.get((Player) sender); this.myFaction = this.fme.getFaction();
|
||||||
this.myFaction = this.fme.getFaction();
|
} else {
|
||||||
}
|
this.fme = null; this.myFaction = null;
|
||||||
else {
|
} super.execute(sender, args, commandChain);
|
||||||
this.fme = null;
|
|
||||||
this.myFaction = null;
|
|
||||||
}
|
|
||||||
super.execute(sender, args, commandChain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
if (p.getLocked() && this.disableOnLock) {
|
if (p.getLocked() && this.disableOnLock) {
|
||||||
msg("<b>Factions was locked by an admin. Please try again later.");
|
msg("<b>Factions was locked by an admin. Please try again later."); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isMoneyCommand && !Conf.econEnabled) {
|
if (this.isMoneyCommand && !Conf.econEnabled) {
|
||||||
msg("<b>Faction economy features are disabled on this server.");
|
msg("<b>Faction economy features are disabled on this server."); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isMoneyCommand && !Conf.bankEnabled) {
|
if (this.isMoneyCommand && !Conf.bankEnabled) {
|
||||||
msg("<b>The faction bank system is disabled on this server.");
|
msg("<b>The faction bank system is disabled on this server."); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -72,8 +63,7 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
||||||
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
boolean superValid = super.validSenderType(sender, informSenderIfNot); if (!superValid) { return false; }
|
||||||
if (!superValid) { return false; }
|
|
||||||
|
|
||||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) { return true; }
|
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) { return true; }
|
||||||
|
|
||||||
@ -82,18 +72,15 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
FPlayer fplayer = FPlayers.i.get((Player) sender);
|
FPlayer fplayer = FPlayers.i.get((Player) sender);
|
||||||
|
|
||||||
if (!fplayer.hasFaction()) {
|
if (!fplayer.hasFaction()) {
|
||||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
sender.sendMessage(p.txt.parse("<b>You are not member of any faction.")); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeModerator && !fplayer.getRole().isAtLeast(Role.MODERATOR)) {
|
if (this.senderMustBeModerator && !fplayer.getRole().isAtLeast(Role.MODERATOR)) {
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort())); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeAdmin && !fplayer.getRole().isAtLeast(Role.ADMIN)) {
|
if (this.senderMustBeAdmin && !fplayer.getRole().isAtLeast(Role.ADMIN)) {
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort())); return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -107,20 +94,16 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
if (me == null) { return true; }
|
if (me == null) { return true; }
|
||||||
|
|
||||||
if (!fme.hasFaction()) {
|
if (!fme.hasFaction()) {
|
||||||
sendMessage("You are not member of any faction.");
|
sendMessage("You are not member of any faction."); return false;
|
||||||
return false;
|
} return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean assertMinRole(Role role) {
|
public boolean assertMinRole(Role role) {
|
||||||
if (me == null) { return true; }
|
if (me == null) { return true; }
|
||||||
|
|
||||||
if (fme.getRole().value < role.value) {
|
if (fme.getRole().value < role.value) {
|
||||||
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + ".");
|
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + "."); return false;
|
||||||
return false;
|
} return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -132,8 +115,7 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
FPlayer ret = def;
|
FPlayer ret = def;
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(name); FPlayer fplayer = FPlayers.i.get(player);
|
||||||
FPlayer fplayer = FPlayers.i.get(player);
|
|
||||||
if (fplayer != null) {
|
if (fplayer != null) {
|
||||||
ret = fplayer;
|
ret = fplayer;
|
||||||
}
|
}
|
||||||
@ -194,8 +176,7 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
|
|
||||||
// Next we match player names
|
// Next we match player names
|
||||||
if (faction == null) {
|
if (faction == null) {
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
OfflinePlayer player = Bukkit.getOfflinePlayer(name); FPlayer fplayer = FPlayers.i.get(player);
|
||||||
FPlayer fplayer = FPlayers.i.get(player);
|
|
||||||
if (fplayer != null) {
|
if (fplayer != null) {
|
||||||
faction = fplayer.getFaction();
|
faction = fplayer.getFaction();
|
||||||
}
|
}
|
||||||
@ -241,16 +222,13 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
|
|
||||||
if (you.getRole().equals(Role.ADMIN)) {
|
if (you.getRole().equals(Role.ADMIN)) {
|
||||||
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
||||||
}
|
} else if (i.getRole().equals(Role.MODERATOR)) {
|
||||||
else if (i.getRole().equals(Role.MODERATOR)) {
|
|
||||||
if (i == you) {
|
if (i == you) {
|
||||||
return true; //Moderators can control themselves
|
return true; //Moderators can control themselves
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
|
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
|
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +241,7 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
|
|
||||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||||
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
||||||
}
|
} else { return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); }
|
||||||
else { return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
||||||
@ -273,7 +250,6 @@ public abstract class FCommand extends MCommand<P> {
|
|||||||
|
|
||||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||||
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
||||||
}
|
} else { return Econ.hasAtLeast(fme, cost, toDoThis); }
|
||||||
else { return Econ.hasAtLeast(fme, cost, toDoThis); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,37 +12,28 @@ public abstract class FRelationCommand extends FCommand {
|
|||||||
public Relation targetRelation;
|
public Relation targetRelation;
|
||||||
|
|
||||||
public FRelationCommand() {
|
public FRelationCommand() {
|
||||||
super();
|
super(); this.requiredArgs.add("faction tag");
|
||||||
this.requiredArgs.add("faction tag");
|
|
||||||
//this.optionalArgs.put("player name", "you");
|
//this.optionalArgs.put("player name", "you");
|
||||||
|
|
||||||
this.permission = Permission.RELATION.node;
|
this.permission = Permission.RELATION.node; this.disableOnLock = true;
|
||||||
this.disableOnLock = true;
|
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true; senderMustBeMember = false; senderMustBeModerator = true; senderMustBeAdmin = false;
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform() {
|
public void perform() {
|
||||||
Faction them = this.argAsFaction(0);
|
Faction them = this.argAsFaction(0); if (them == null) { return; }
|
||||||
if (them == null) { return; }
|
|
||||||
|
|
||||||
if (!them.isNormal()) {
|
if (!them.isNormal()) {
|
||||||
msg("<b>Nope! You can't.");
|
msg("<b>Nope! You can't."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (them == myFaction) {
|
if (them == myFaction) {
|
||||||
msg("<b>Nope! You can't declare a relation to yourself :)");
|
msg("<b>Nope! You can't declare a relation to yourself :)"); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myFaction.getRelationWish(them) == targetRelation) {
|
if (myFaction.getRelationWish(them) == targetRelation) {
|
||||||
msg("<b>You already have that relation wish set with %s.", them.getTag());
|
msg("<b>You already have that relation wish set with %s.", them.getTag()); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
@ -51,8 +42,7 @@ public abstract class FRelationCommand extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try to set the new relation
|
// try to set the new relation
|
||||||
Relation oldRelation = myFaction.getRelationTo(them, true);
|
Relation oldRelation = myFaction.getRelationTo(them, true); myFaction.setRelationWish(them, targetRelation);
|
||||||
myFaction.setRelationWish(them, targetRelation);
|
|
||||||
Relation currentRelation = myFaction.getRelationTo(them, true);
|
Relation currentRelation = myFaction.getRelationTo(them, true);
|
||||||
ChatColor currentRelationColor = currentRelation.getColor();
|
ChatColor currentRelationColor = currentRelation.getColor();
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ public class FPlayerJoinEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) {
|
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) {
|
||||||
fplayer = fp;
|
fplayer = fp; faction = f; reason = r;
|
||||||
faction = f;
|
|
||||||
reason = r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
public FPlayer getFPlayer() {
|
||||||
|
@ -18,9 +18,7 @@ public class FPlayerLeaveEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
|
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
|
||||||
FPlayer = p;
|
FPlayer = p; Faction = f; reason = r;
|
||||||
Faction = f;
|
|
||||||
reason = r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
@ -51,9 +49,7 @@ public class FPlayerLeaveEvent extends Event implements Cancellable {
|
|||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c) {
|
public void setCancelled(boolean c) {
|
||||||
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
|
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
|
||||||
cancelled = false;
|
cancelled = false; return;
|
||||||
return;
|
} cancelled = c;
|
||||||
}
|
|
||||||
cancelled = c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,9 +16,7 @@ public class FactionCreateEvent extends Event implements Cancellable {
|
|||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public FactionCreateEvent(Player sender, String tag) {
|
public FactionCreateEvent(Player sender, String tag) {
|
||||||
this.factionTag = tag;
|
this.factionTag = tag; this.sender = sender; this.cancelled = false;
|
||||||
this.sender = sender;
|
|
||||||
this.cancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer() {
|
public FPlayer getFPlayer() {
|
||||||
|
@ -17,9 +17,7 @@ public class FactionDisbandEvent extends Event implements Cancellable {
|
|||||||
private Player sender;
|
private Player sender;
|
||||||
|
|
||||||
public FactionDisbandEvent(Player sender, String factionId) {
|
public FactionDisbandEvent(Player sender, String factionId) {
|
||||||
cancelled = false;
|
cancelled = false; this.sender = sender; this.id = factionId;
|
||||||
this.sender = sender;
|
|
||||||
this.id = factionId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -15,10 +15,7 @@ public class FactionRelationEvent extends Event {
|
|||||||
private Relation frel;
|
private Relation frel;
|
||||||
|
|
||||||
public FactionRelationEvent(Faction sender, Faction target, Relation oldrel, Relation rel) {
|
public FactionRelationEvent(Faction sender, Faction target, Relation oldrel, Relation rel) {
|
||||||
fsender = sender;
|
fsender = sender; ftarget = target; foldrel = oldrel; frel = rel;
|
||||||
ftarget = target;
|
|
||||||
foldrel = oldrel;
|
|
||||||
frel = rel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -16,10 +16,7 @@ public class FactionRenameEvent extends Event implements Cancellable {
|
|||||||
private String tag;
|
private String tag;
|
||||||
|
|
||||||
public FactionRenameEvent(FPlayer sender, String newTag) {
|
public FactionRenameEvent(FPlayer sender, String newTag) {
|
||||||
fplayer = sender;
|
fplayer = sender; faction = sender.getFaction(); tag = newTag; this.cancelled = false;
|
||||||
faction = sender.getFaction();
|
|
||||||
tag = newTag;
|
|
||||||
this.cancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction() {
|
public Faction getFaction() {
|
||||||
|
@ -17,10 +17,7 @@ public class LandClaimEvent extends Event implements Cancellable {
|
|||||||
private FPlayer fplayer;
|
private FPlayer fplayer;
|
||||||
|
|
||||||
public LandClaimEvent(FLocation loc, Faction f, FPlayer p) {
|
public LandClaimEvent(FLocation loc, Faction f, FPlayer p) {
|
||||||
cancelled = false;
|
cancelled = false; location = loc; faction = f; fplayer = p;
|
||||||
location = loc;
|
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -13,8 +13,7 @@ public class LandUnclaimAllEvent extends Event {
|
|||||||
private FPlayer fplayer;
|
private FPlayer fplayer;
|
||||||
|
|
||||||
public LandUnclaimAllEvent(Faction f, FPlayer p) {
|
public LandUnclaimAllEvent(Faction f, FPlayer p) {
|
||||||
faction = f;
|
faction = f; fplayer = p;
|
||||||
fplayer = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -17,10 +17,7 @@ public class LandUnclaimEvent extends Event implements Cancellable {
|
|||||||
private FPlayer fplayer;
|
private FPlayer fplayer;
|
||||||
|
|
||||||
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) {
|
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) {
|
||||||
cancelled = false;
|
cancelled = false; location = loc; faction = f; fplayer = p;
|
||||||
location = loc;
|
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
@ -17,9 +17,7 @@ public class PowerLossEvent extends Event implements Cancellable {
|
|||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public PowerLossEvent(Faction f, FPlayer p) {
|
public PowerLossEvent(Faction f, FPlayer p) {
|
||||||
cancelled = false;
|
cancelled = false; faction = f; fplayer = p;
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,16 +24,13 @@ public class Econ {
|
|||||||
String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" ";
|
String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" ";
|
||||||
|
|
||||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
P.p.log(integrationFail + "is not installed.");
|
P.p.log(integrationFail + "is not installed."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (rsp == null) {
|
if (rsp == null) {
|
||||||
P.p.log(integrationFail + "is not hooked into an economy plugin.");
|
P.p.log(integrationFail + "is not hooked into an economy plugin."); return;
|
||||||
return;
|
} econ = rsp.getProvider();
|
||||||
}
|
|
||||||
econ = rsp.getProvider();
|
|
||||||
|
|
||||||
P.p.log("Economy integration through Vault plugin successful.");
|
P.p.log("Economy integration through Vault plugin successful.");
|
||||||
|
|
||||||
@ -58,8 +55,7 @@ public class Econ {
|
|||||||
public static void modifyUniverseMoney(double delta) {
|
public static void modifyUniverseMoney(double delta) {
|
||||||
if (!shouldBeUsed()) { return; }
|
if (!shouldBeUsed()) { return; }
|
||||||
|
|
||||||
if (Conf.econUniverseAccount == null) { return; }
|
if (Conf.econUniverseAccount == null) { return; } if (Conf.econUniverseAccount.length() == 0) { return; }
|
||||||
if (Conf.econUniverseAccount.length() == 0) { return; }
|
|
||||||
if (!econ.hasAccount(Conf.econUniverseAccount)) { return; }
|
if (!econ.hasAccount(Conf.econUniverseAccount)) { return; }
|
||||||
|
|
||||||
modifyBalance(Conf.econUniverseAccount, delta);
|
modifyBalance(Conf.econUniverseAccount, delta);
|
||||||
@ -67,15 +63,13 @@ public class Econ {
|
|||||||
|
|
||||||
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about) {
|
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about) {
|
||||||
if (!shouldBeUsed()) {
|
if (!shouldBeUsed()) {
|
||||||
P.p.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
P.p.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin."); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Econ.moneyString(econ.getBalance(about.getAccountId())));
|
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Econ.moneyString(econ.getBalance(about.getAccountId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) {
|
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) {
|
||||||
Faction fI = RelationUtil.getFaction(i);
|
Faction fI = RelationUtil.getFaction(i); Faction fYou = RelationUtil.getFaction(you);
|
||||||
Faction fYou = RelationUtil.getFaction(you);
|
|
||||||
|
|
||||||
// This is a system invoker. Accept it.
|
// This is a system invoker. Accept it.
|
||||||
if (fI == null) { return true; }
|
if (fI == null) { return true; }
|
||||||
@ -114,10 +108,7 @@ public class Econ {
|
|||||||
// The amount must be positive.
|
// The amount must be positive.
|
||||||
// If the amount is negative we must flip and multiply amount with -1.
|
// If the amount is negative we must flip and multiply amount with -1.
|
||||||
if (amount < 0) {
|
if (amount < 0) {
|
||||||
amount *= -1;
|
amount *= -1; EconomyParticipator temp = from; from = to; to = temp;
|
||||||
EconomyParticipator temp = from;
|
|
||||||
from = to;
|
|
||||||
to = temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the rights
|
// Check the rights
|
||||||
@ -137,12 +128,9 @@ public class Econ {
|
|||||||
EconomyResponse erw = econ.withdrawPlayer(from.getAccountId(), amount);
|
EconomyResponse erw = econ.withdrawPlayer(from.getAccountId(), amount);
|
||||||
|
|
||||||
if (erw.transactionSuccess()) {
|
if (erw.transactionSuccess()) {
|
||||||
EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount);
|
EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount); if (erd.transactionSuccess()) {
|
||||||
if (erd.transactionSuccess()) {
|
if (notify) { sendTransferInfo(invoker, from, to, amount); } return true;
|
||||||
if (notify) { sendTransferInfo(invoker, from, to, amount); }
|
} else {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// transaction failed, refund account
|
// transaction failed, refund account
|
||||||
econ.depositPlayer(from.getAccountId(), amount);
|
econ.depositPlayer(from.getAccountId(), amount);
|
||||||
}
|
}
|
||||||
@ -161,11 +149,9 @@ public class Econ {
|
|||||||
|
|
||||||
if (ep == null) {
|
if (ep == null) {
|
||||||
// Add nothing
|
// Add nothing
|
||||||
}
|
} else if (ep instanceof FPlayer) {
|
||||||
else if (ep instanceof FPlayer) {
|
|
||||||
fplayers.add((FPlayer) ep);
|
fplayers.add((FPlayer) ep);
|
||||||
}
|
} else if (ep instanceof Faction) {
|
||||||
else if (ep instanceof Faction) {
|
|
||||||
fplayers.addAll(((Faction) ep).getFPlayers());
|
fplayers.addAll(((Faction) ep).getFPlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,27 +159,22 @@ public class Econ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
|
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
|
||||||
Set<FPlayer> recipients = new HashSet<FPlayer>();
|
Set<FPlayer> recipients = new HashSet<FPlayer>(); recipients.addAll(getFplayers(invoker));
|
||||||
recipients.addAll(getFplayers(invoker));
|
recipients.addAll(getFplayers(from)); recipients.addAll(getFplayers(to));
|
||||||
recipients.addAll(getFplayers(from));
|
|
||||||
recipients.addAll(getFplayers(to));
|
|
||||||
|
|
||||||
if (invoker == null) {
|
if (invoker == null) {
|
||||||
for (FPlayer recipient : recipients) {
|
for (FPlayer recipient : recipients) {
|
||||||
recipient.msg("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i>.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
recipient.msg("<h>%s<i> was transfered from <h>%s<i> to <h>%s<i>.", moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||||
}
|
}
|
||||||
}
|
} else if (invoker == from) {
|
||||||
else if (invoker == from) {
|
|
||||||
for (FPlayer recipient : recipients) {
|
for (FPlayer recipient : recipients) {
|
||||||
recipient.msg("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient));
|
recipient.msg("<h>%s<i> <h>gave %s<i> to <h>%s<i>.", from.describeTo(recipient, true), moneyString(amount), to.describeTo(recipient));
|
||||||
}
|
}
|
||||||
}
|
} else if (invoker == to) {
|
||||||
else if (invoker == to) {
|
|
||||||
for (FPlayer recipient : recipients) {
|
for (FPlayer recipient : recipients) {
|
||||||
recipient.msg("<h>%s<i> <h>took %s<i> from <h>%s<i>.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient));
|
recipient.msg("<h>%s<i> <h>took %s<i> from <h>%s<i>.", to.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (FPlayer recipient : recipients) {
|
for (FPlayer recipient : recipients) {
|
||||||
recipient.msg("<h>%s<i> transfered <h>%s<i> from <h>%s<i> to <h>%s<i>.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
recipient.msg("<h>%s<i> transfered <h>%s<i> from <h>%s<i> to <h>%s<i>.", invoker.describeTo(recipient, true), moneyString(amount), from.describeTo(recipient), to.describeTo(recipient));
|
||||||
}
|
}
|
||||||
@ -206,17 +187,14 @@ public class Econ {
|
|||||||
if (!econ.has(ep.getAccountId(), delta)) {
|
if (!econ.has(ep.getAccountId(), delta)) {
|
||||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
||||||
}
|
} return false;
|
||||||
return false;
|
} return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) {
|
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) {
|
||||||
if (!shouldBeUsed()) { return false; }
|
if (!shouldBeUsed()) { return false; }
|
||||||
|
|
||||||
String acc = ep.getAccountId();
|
String acc = ep.getAccountId(); String You = ep.describeTo(ep, true);
|
||||||
String You = ep.describeTo(ep, true);
|
|
||||||
|
|
||||||
if (delta == 0) {
|
if (delta == 0) {
|
||||||
// no money actually transferred?
|
// no money actually transferred?
|
||||||
@ -227,40 +205,30 @@ public class Econ {
|
|||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
// The player should gain money
|
// The player should gain money
|
||||||
// The account might not have enough space
|
// The account might not have enough space
|
||||||
EconomyResponse er = econ.depositPlayer(acc, delta);
|
EconomyResponse er = econ.depositPlayer(acc, delta); if (er.transactionSuccess()) {
|
||||||
if (er.transactionSuccess()) {
|
modifyUniverseMoney(-delta); if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||||
modifyUniverseMoney(-delta);
|
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
|
||||||
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
||||||
}
|
} return true;
|
||||||
return true;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
// transfer to account failed
|
// transfer to account failed
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||||
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// The player should loose money
|
// The player should loose money
|
||||||
// The player might not have enough.
|
// The player might not have enough.
|
||||||
|
|
||||||
if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) {
|
if (econ.has(acc, -delta) && econ.withdrawPlayer(acc, -delta).transactionSuccess()) {
|
||||||
// There is enough money to pay
|
// There is enough money to pay
|
||||||
modifyUniverseMoney(-delta);
|
modifyUniverseMoney(-delta); if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty()) {
|
|
||||||
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
|
ep.msg("<h>%s<i> lost <h>%s<i> %s.", You, moneyString(-delta), forDoingThis);
|
||||||
}
|
} return true;
|
||||||
return true;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
// There was not enough money to pay
|
// There was not enough money to pay
|
||||||
if (toDoThis != null && !toDoThis.isEmpty()) {
|
if (toDoThis != null && !toDoThis.isEmpty()) {
|
||||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,8 +243,7 @@ public class Econ {
|
|||||||
|
|
||||||
for (Faction faction : Factions.i.get()) {
|
for (Faction faction : Factions.i.get()) {
|
||||||
if (faction.money > 0) {
|
if (faction.money > 0) {
|
||||||
econ.depositPlayer(faction.getAccountId(), faction.money);
|
econ.depositPlayer(faction.getAccountId(), faction.money); faction.money = 0;
|
||||||
faction.money = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,9 +255,7 @@ public class Econ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
||||||
return Conf.econCostClaimWilderness
|
return Conf.econCostClaimWilderness + (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand) - (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0);
|
||||||
+ (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand)
|
|
||||||
- (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate refund amount for unclaiming land
|
// calculate refund amount for unclaiming land
|
||||||
@ -300,11 +265,9 @@ public class Econ {
|
|||||||
|
|
||||||
// calculate value of all owned land
|
// calculate value of all owned land
|
||||||
public static double calculateTotalLandValue(int ownedLand) {
|
public static double calculateTotalLandValue(int ownedLand) {
|
||||||
double amount = 0;
|
double amount = 0; for (int x = 0; x < ownedLand; x++) {
|
||||||
for (int x = 0; x < ownedLand; x++) {
|
|
||||||
amount += calculateClaimCost(x, false);
|
amount += calculateClaimCost(x, false);
|
||||||
}
|
} return amount;
|
||||||
return amount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate refund amount for all owned land
|
// calculate refund amount for all owned land
|
||||||
@ -327,13 +290,15 @@ public class Econ {
|
|||||||
|
|
||||||
public static boolean setBalance(String account, double amount) {
|
public static boolean setBalance(String account, double amount) {
|
||||||
double current = econ.getBalance(account);
|
double current = econ.getBalance(account);
|
||||||
if (current > amount) { return econ.withdrawPlayer(account, current - amount).transactionSuccess(); }
|
if (current > amount) { return econ.withdrawPlayer(account, current - amount).transactionSuccess(); } else {
|
||||||
else { return econ.depositPlayer(account, amount - current).transactionSuccess(); }
|
return econ.depositPlayer(account, amount - current).transactionSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean modifyBalance(String account, double amount) {
|
public static boolean modifyBalance(String account, double amount) {
|
||||||
if (amount < 0) { return econ.withdrawPlayer(account, -amount).transactionSuccess(); }
|
if (amount < 0) { return econ.withdrawPlayer(account, -amount).transactionSuccess(); } else {
|
||||||
else { return econ.depositPlayer(account, amount).transactionSuccess(); }
|
return econ.depositPlayer(account, amount).transactionSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deposit(String account, double amount) {
|
public static boolean deposit(String account, double amount) {
|
||||||
|
@ -15,8 +15,7 @@ public class Essentials {
|
|||||||
private static IEssentials essentials;
|
private static IEssentials essentials;
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
|
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials"); if (ess != null) {
|
||||||
if (ess != null) {
|
|
||||||
essentials = (IEssentials) ess;
|
essentials = (IEssentials) ess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,12 +25,10 @@ public class Essentials {
|
|||||||
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { return false; }
|
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) { return false; }
|
||||||
|
|
||||||
Teleport teleport = (Teleport) essentials.getUser(player).getTeleport();
|
Teleport teleport = (Teleport) essentials.getUser(player).getTeleport();
|
||||||
Trade trade = new Trade(Conf.econCostHome, essentials);
|
Trade trade = new Trade(Conf.econCostHome, essentials); try {
|
||||||
try {
|
|
||||||
teleport.teleport(loc, trade);
|
teleport.teleport(loc, trade);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
|
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
|
||||||
}
|
} return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,9 @@ public class Worldguard {
|
|||||||
public static void init(Plugin plugin) {
|
public static void init(Plugin plugin) {
|
||||||
Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
Plugin wgplug = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
if (wgplug == null || !(wgplug instanceof WorldGuardPlugin)) {
|
||||||
enabled = false;
|
enabled = false; wg = null; P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||||
wg = null;
|
} else {
|
||||||
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
wg = (WorldGuardPlugin) wgplug; enabled = true; P.p.log("Successfully hooked to WorldGuard.");
|
||||||
}
|
|
||||||
else {
|
|
||||||
wg = (WorldGuardPlugin) wgplug;
|
|
||||||
enabled = true;
|
|
||||||
P.p.log("Successfully hooked to WorldGuard.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,13 +53,10 @@ public class Worldguard {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation(); World world = loc.getWorld(); Vector pt = toVector(loc);
|
||||||
World world = loc.getWorld();
|
|
||||||
Vector pt = toVector(loc);
|
|
||||||
|
|
||||||
RegionManager regionManager = wg.getRegionManager(world);
|
RegionManager regionManager = wg.getRegionManager(world);
|
||||||
ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
|
ApplicableRegionSet set = regionManager.getApplicableRegions(pt); return set.allows(DefaultFlag.PVP);
|
||||||
return set.allows(DefaultFlag.PVP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player can build at location by worldguards rules.
|
// Check if player can build at location by worldguards rules.
|
||||||
@ -77,8 +69,7 @@ public class Worldguard {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld(); Vector pt = toVector(loc);
|
||||||
Vector pt = toVector(loc);
|
|
||||||
|
|
||||||
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { return wg.canBuild(player, loc); }
|
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0) { return wg.canBuild(player, loc); }
|
||||||
return false;
|
return false;
|
||||||
@ -94,12 +85,8 @@ public class Worldguard {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld(); Chunk chunk = world.getChunkAt(loc); int minChunkX = chunk.getX() << 4;
|
||||||
Chunk chunk = world.getChunkAt(loc);
|
int minChunkZ = chunk.getZ() << 4; int maxChunkX = minChunkX + 15; int maxChunkZ = minChunkZ + 15;
|
||||||
int minChunkX = chunk.getX() << 4;
|
|
||||||
int minChunkZ = chunk.getZ() << 4;
|
|
||||||
int maxChunkX = minChunkX + 15;
|
|
||||||
int maxChunkZ = minChunkZ + 15;
|
|
||||||
|
|
||||||
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
|
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
|
||||||
|
|
||||||
@ -110,15 +97,12 @@ public class Worldguard {
|
|||||||
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
||||||
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
||||||
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
||||||
List<ProtectedRegion> overlaps;
|
List<ProtectedRegion> overlaps; boolean foundregions = false;
|
||||||
boolean foundregions = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
overlaps = region.getIntersectingRegions(allregionslist);
|
overlaps = region.getIntersectingRegions(allregionslist); if (overlaps == null || overlaps.isEmpty()) {
|
||||||
if (overlaps == null || overlaps.isEmpty()) {
|
|
||||||
foundregions = false;
|
foundregions = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
foundregions = true;
|
foundregions = true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -23,8 +23,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; } if (!event.canBuild()) { return; }
|
||||||
if (!event.canBuild()) { return; }
|
|
||||||
|
|
||||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
||||||
@ -56,8 +55,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; } if (!Conf.pistonProtectionThroughDenyBuild) { return; }
|
||||||
if (!Conf.pistonProtectionThroughDenyBuild) { return; }
|
|
||||||
|
|
||||||
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
||||||
|
|
||||||
@ -66,8 +64,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
|
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -94,8 +91,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
||||||
|
|
||||||
if (!canPistonMoveBlock(pistonFaction, targetLoc)) {
|
if (!canPistonMoveBlock(pistonFaction, targetLoc)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,13 +107,11 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isSafeZone()) {
|
||||||
else if (otherFaction.isSafeZone()) {
|
|
||||||
if (!Conf.safeZoneDenyBuild) { return true; }
|
if (!Conf.safeZoneDenyBuild) { return true; }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
else if (otherFaction.isWarZone()) {
|
|
||||||
if (!Conf.warZoneDenyBuild) { return true; }
|
if (!Conf.warZoneDenyBuild) { return true; }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -131,14 +125,11 @@ public class FactionsBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
|
||||||
String name = player.getName();
|
String name = player.getName(); if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; }
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; }
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(player.getUniqueId().toString());
|
FPlayer me = FPlayers.i.get(player.getUniqueId().toString()); if (me.isAdminBypassing()) { return true; }
|
||||||
if (me.isAdminBypassing()) { return true; }
|
|
||||||
|
|
||||||
FLocation loc = new FLocation(location);
|
FLocation loc = new FLocation(location); Faction otherFaction = Board.getFactionAt(loc);
|
||||||
Faction otherFaction = Board.getFactionAt(loc);
|
|
||||||
|
|
||||||
if (otherFaction.isNone()) {
|
if (otherFaction.isNone()) {
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
||||||
@ -150,8 +141,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (!justCheck) { me.msg("<b>You can't " + action + " in the wilderness."); }
|
if (!justCheck) { me.msg("<b>You can't " + action + " in the wilderness."); }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isSafeZone()) {
|
||||||
else if (otherFaction.isSafeZone()) {
|
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
||||||
|
|
||||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; }
|
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; }
|
||||||
@ -159,8 +149,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (!justCheck) { me.msg("<b>You can't " + action + " in a safe zone."); }
|
if (!justCheck) { me.msg("<b>You can't " + action + " in a safe zone."); }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
else if (otherFaction.isWarZone()) {
|
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return true; }
|
||||||
|
|
||||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) { return true; }
|
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) { return true; }
|
||||||
@ -170,10 +159,8 @@ public class FactionsBlockListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelationTo(otherFaction);
|
||||||
Relation rel = myFaction.getRelationTo(otherFaction);
|
boolean online = otherFaction.hasPlayersOnline(); boolean pain = !justCheck && rel.confPainBuild(online);
|
||||||
boolean online = otherFaction.hasPlayersOnline();
|
|
||||||
boolean pain = !justCheck && rel.confPainBuild(online);
|
|
||||||
boolean deny = rel.confDenyBuild(online);
|
boolean deny = rel.confDenyBuild(online);
|
||||||
|
|
||||||
// hurt the player for building/destroying in other territory?
|
// hurt the player for building/destroying in other territory?
|
||||||
@ -202,8 +189,7 @@ public class FactionsBlockListener implements Listener {
|
|||||||
if (!Conf.ownedAreaDenyBuild) {
|
if (!Conf.ownedAreaDenyBuild) {
|
||||||
me.msg("<b>It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
|
me.msg("<b>It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
|
||||||
}
|
}
|
||||||
}
|
} if (Conf.ownedAreaDenyBuild) {
|
||||||
if (Conf.ownedAreaDenyBuild) {
|
|
||||||
if (!justCheck) {
|
if (!justCheck) {
|
||||||
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
|
me.msg("<b>You can't " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
|
||||||
}
|
}
|
||||||
|
@ -27,18 +27,14 @@ public class FactionsChatListener implements Listener {
|
|||||||
public void onPlayerEarlyChat(PlayerChatEvent event) {
|
public void onPlayerEarlyChat(PlayerChatEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
Player talkingPlayer = event.getPlayer();
|
Player talkingPlayer = event.getPlayer(); String msg = event.getMessage();
|
||||||
String msg = event.getMessage();
|
FPlayer me = FPlayers.i.get(talkingPlayer); ChatMode chat = me.getChatMode();
|
||||||
FPlayer me = FPlayers.i.get(talkingPlayer);
|
|
||||||
ChatMode chat = me.getChatMode();
|
|
||||||
|
|
||||||
// slashless factions commands need to be handled here if the user isn't in public chat mode
|
// slashless factions commands need to be handled here if the user isn't in public chat mode
|
||||||
if (chat != ChatMode.PUBLIC && p.handleCommand(talkingPlayer, msg, false, true)) {
|
if (chat != ChatMode.PUBLIC && p.handleCommand(talkingPlayer, msg, false, true)) {
|
||||||
if (Conf.logPlayerCommands) {
|
if (Conf.logPlayerCommands) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[PLAYER_COMMAND] " + talkingPlayer.getName() + ": " + msg);
|
Bukkit.getLogger().log(Level.INFO, "[PLAYER_COMMAND] " + talkingPlayer.getName() + ": " + msg);
|
||||||
}
|
} event.setCancelled(true); return;
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it a faction chat message?
|
// Is it a faction chat message?
|
||||||
@ -57,10 +53,8 @@ public class FactionsChatListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
} else if (chat == ChatMode.ALLIANCE) {
|
||||||
}
|
|
||||||
else if (chat == ChatMode.ALLIANCE) {
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg);
|
String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg);
|
||||||
@ -78,8 +72,7 @@ public class FactionsChatListener implements Listener {
|
|||||||
|
|
||||||
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message));
|
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message));
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,35 +85,26 @@ public class FactionsChatListener implements Listener {
|
|||||||
// If we are not to insert it - we are done.
|
// If we are not to insert it - we are done.
|
||||||
if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) { return; }
|
if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) { return; }
|
||||||
|
|
||||||
Player talkingPlayer = event.getPlayer();
|
Player talkingPlayer = event.getPlayer(); String msg = event.getMessage();
|
||||||
String msg = event.getMessage();
|
String eventFormat = event.getFormat(); FPlayer me = FPlayers.i.get(talkingPlayer); int InsertIndex;
|
||||||
String eventFormat = event.getFormat();
|
|
||||||
FPlayer me = FPlayers.i.get(talkingPlayer);
|
|
||||||
int InsertIndex;
|
|
||||||
|
|
||||||
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) {
|
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) {
|
||||||
// we're using the "replace" method of inserting the faction tags
|
// we're using the "replace" method of inserting the faction tags
|
||||||
// if they stuck "[FACTION_TITLE]" in there, go ahead and do it too
|
// if they stuck "[FACTION_TITLE]" in there, go ahead and do it too
|
||||||
if (eventFormat.contains("[FACTION_TITLE]")) {
|
if (eventFormat.contains("[FACTION_TITLE]")) {
|
||||||
eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle());
|
eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle());
|
||||||
}
|
} InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString);
|
||||||
InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString);
|
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, ""); Conf.chatTagPadAfter = false;
|
||||||
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
|
|
||||||
Conf.chatTagPadAfter = false;
|
|
||||||
Conf.chatTagPadBefore = false;
|
Conf.chatTagPadBefore = false;
|
||||||
}
|
} else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) {
|
||||||
else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) {
|
|
||||||
// we're using the "insert after string" method
|
// we're using the "insert after string" method
|
||||||
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length();
|
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length();
|
||||||
}
|
} else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) {
|
||||||
else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) {
|
|
||||||
// we're using the "insert before string" method
|
// we're using the "insert before string" method
|
||||||
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString);
|
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// we'll fall back to using the index place method
|
// we'll fall back to using the index place method
|
||||||
InsertIndex = Conf.chatTagInsertIndex;
|
InsertIndex = Conf.chatTagInsertIndex; if (InsertIndex > eventFormat.length()) { return; }
|
||||||
if (InsertIndex > eventFormat.length()) { return; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");
|
String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");
|
||||||
@ -136,12 +120,10 @@ public class FactionsChatListener implements Listener {
|
|||||||
|
|
||||||
for (Player listeningPlayer : event.getRecipients()) {
|
for (Player listeningPlayer : event.getRecipients()) {
|
||||||
FPlayer you = FPlayers.i.get(listeningPlayer);
|
FPlayer you = FPlayers.i.get(listeningPlayer);
|
||||||
String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd;
|
String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd; try {
|
||||||
try {
|
|
||||||
listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg));
|
listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg));
|
||||||
} catch (UnknownFormatConversionException ex) {
|
} catch (UnknownFormatConversionException ex) {
|
||||||
Conf.chatTagInsertIndex = 0;
|
Conf.chatTagInsertIndex = 0; P.p.log(Level.SEVERE, "Critical error in chat message formatting!");
|
||||||
P.p.log(Level.SEVERE, "Critical error in chat message formatting!");
|
|
||||||
P.p.log(Level.SEVERE, "NOTE: This has been automatically fixed right now by setting chatTagInsertIndex to 0.");
|
P.p.log(Level.SEVERE, "NOTE: This has been automatically fixed right now by setting chatTagInsertIndex to 0.");
|
||||||
P.p.log(Level.SEVERE, "For a more proper fix, please read this regarding chat configuration: http://massivecraft.com/plugins/factions/config#Chat_configuration");
|
P.p.log(Level.SEVERE, "For a more proper fix, please read this regarding chat configuration: http://massivecraft.com/plugins/factions/config#Chat_configuration");
|
||||||
return;
|
return;
|
||||||
@ -151,8 +133,7 @@ public class FactionsChatListener implements Listener {
|
|||||||
// Write to the log... We will write the non colored message.
|
// Write to the log... We will write the non colored message.
|
||||||
String nonColoredMsg = ChatColor.stripColor(String.format(nonColoredMsgFormat, talkingPlayer.getDisplayName(), msg));
|
String nonColoredMsg = ChatColor.stripColor(String.format(nonColoredMsgFormat, talkingPlayer.getDisplayName(), msg));
|
||||||
Bukkit.getLogger().log(Level.INFO, nonColoredMsg);
|
Bukkit.getLogger().log(Level.INFO, nonColoredMsg);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// No relation color.
|
// No relation color.
|
||||||
event.setFormat(nonColoredMsgFormat);
|
event.setFormat(nonColoredMsgFormat);
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,11 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity(); if (!(entity instanceof Player)) {
|
||||||
if (!(entity instanceof Player)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity; FPlayer fplayer = FPlayers.i.get(player);
|
||||||
FPlayer fplayer = FPlayers.i.get(player);
|
|
||||||
Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
|
Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
|
||||||
|
|
||||||
PowerLossEvent powerLossEvent = new PowerLossEvent(faction, fplayer);
|
PowerLossEvent powerLossEvent = new PowerLossEvent(faction, fplayer);
|
||||||
@ -50,24 +48,19 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (!Conf.warZonePowerLoss) {
|
if (!Conf.warZonePowerLoss) {
|
||||||
powerLossEvent.setMessage("<i>You didn't lose any power since you were in a war zone.");
|
powerLossEvent.setMessage("<i>You didn't lose any power since you were in a war zone.");
|
||||||
powerLossEvent.setCancelled(true);
|
powerLossEvent.setCancelled(true);
|
||||||
}
|
} if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
||||||
if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
|
||||||
powerLossEvent.setMessage("<b>The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\n<i>Your power is now <h>%d / %d");
|
powerLossEvent.setMessage("<b>The world you are in has power loss normally disabled, but you still lost power since you were in a war zone.\n<i>Your power is now <h>%d / %d");
|
||||||
}
|
}
|
||||||
}
|
} else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) {
|
||||||
else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) {
|
|
||||||
powerLossEvent.setMessage("<i>You didn't lose any power since you were in the wilderness.");
|
powerLossEvent.setMessage("<i>You didn't lose any power since you were in the wilderness.");
|
||||||
powerLossEvent.setCancelled(true);
|
powerLossEvent.setCancelled(true);
|
||||||
}
|
} else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
||||||
else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) {
|
|
||||||
powerLossEvent.setMessage("<i>You didn't lose any power due to the world you died in.");
|
powerLossEvent.setMessage("<i>You didn't lose any power due to the world you died in.");
|
||||||
powerLossEvent.setCancelled(true);
|
powerLossEvent.setCancelled(true);
|
||||||
}
|
} else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) {
|
||||||
else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) {
|
|
||||||
powerLossEvent.setMessage("<i>You didn't lose any power since you are in a peaceful faction.");
|
powerLossEvent.setMessage("<i>You didn't lose any power since you are in a peaceful faction.");
|
||||||
powerLossEvent.setCancelled(true);
|
powerLossEvent.setCancelled(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
powerLossEvent.setMessage("<i>Your power is now <h>%d / %d");
|
powerLossEvent.setMessage("<i>Your power is now <h>%d / %d");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +72,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
fplayer.onDeath();
|
fplayer.onDeath();
|
||||||
}
|
}
|
||||||
// Send the message from the powerLossEvent
|
// Send the message from the powerLossEvent
|
||||||
final String msg = powerLossEvent.getMessage();
|
final String msg = powerLossEvent.getMessage(); if (msg != null && !msg.isEmpty()) {
|
||||||
if (msg != null && !msg.isEmpty()) {
|
|
||||||
fplayer.msg(msg, fplayer.getPowerRounded(), fplayer.getPowerMaxRounded());
|
fplayer.msg(msg, fplayer.getPowerRounded(), fplayer.getPowerMaxRounded());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,8 +90,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
} else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
|
||||||
else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
|
|
||||||
// Players can not take any damage in a Safe Zone
|
// Players can not take any damage in a Safe Zone
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -109,86 +100,47 @@ public class FactionsEntityListener implements Listener {
|
|||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
Location loc = event.getLocation();
|
Location loc = event.getLocation(); Entity boomer = event.getEntity();
|
||||||
Entity boomer = event.getEntity();
|
|
||||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||||
|
|
||||||
if (faction.noExplosionsInTerritory()) {
|
if (faction.noExplosionsInTerritory()) {
|
||||||
// faction is peaceful and has explosions set to disabled
|
// faction is peaceful and has explosions set to disabled
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean online = faction.hasPlayersOnline();
|
boolean online = faction.hasPlayersOnline();
|
||||||
|
|
||||||
//TODO: :(
|
//TODO: :(
|
||||||
if
|
if (boomer instanceof Creeper && ((faction.isNone() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
|
||||||
(
|
(faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline)) ||
|
||||||
boomer instanceof Creeper
|
(faction.isWarZone() && Conf.warZoneBlockCreepers) ||
|
||||||
&&
|
faction.isSafeZone())) {
|
||||||
(
|
|
||||||
(faction.isNone() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
|
||||||
||
|
|
||||||
(faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline))
|
|
||||||
||
|
|
||||||
(faction.isWarZone() && Conf.warZoneBlockCreepers)
|
|
||||||
||
|
|
||||||
faction.isSafeZone()
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// creeper which needs prevention
|
// creeper which needs prevention
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
} else if (
|
||||||
else if
|
|
||||||
(
|
|
||||||
// it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
// it's a bit crude just using fireball protection for Wither boss too, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
||||||
(boomer instanceof Fireball || boomer instanceof WitherSkull || boomer instanceof Wither)
|
(boomer instanceof Fireball || boomer instanceof WitherSkull || boomer instanceof Wither) && ((faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
|
||||||
&&
|
(faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) ||
|
||||||
(
|
(faction.isWarZone() && Conf.warZoneBlockFireballs) ||
|
||||||
(faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
faction.isSafeZone())) {
|
||||||
||
|
|
||||||
(faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline))
|
|
||||||
||
|
|
||||||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
|
|
||||||
||
|
|
||||||
faction.isSafeZone()
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// ghast fireball which needs prevention
|
// ghast fireball which needs prevention
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
} else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && ((faction.isNone() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
|
||||||
else if
|
(faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline)) ||
|
||||||
(
|
(faction.isWarZone() && Conf.warZoneBlockTNT) ||
|
||||||
(boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart)
|
(faction.isSafeZone() && Conf.safeZoneBlockTNT))) {
|
||||||
&&
|
|
||||||
(
|
|
||||||
(faction.isNone() && Conf.wildernessBlockTNT && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
|
||||||
||
|
|
||||||
(faction.isNormal() && (online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline))
|
|
||||||
||
|
|
||||||
(faction.isWarZone() && Conf.warZoneBlockTNT)
|
|
||||||
||
|
|
||||||
(faction.isSafeZone() && Conf.safeZoneBlockTNT)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// TNT which needs prevention
|
// TNT which needs prevention
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
} else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
||||||
else if ((boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart) && Conf.handleExploitTNTWaterlog) {
|
|
||||||
// TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but...
|
// TNT in water/lava doesn't normally destroy any surrounding blocks, which is usually desired behavior, but...
|
||||||
// this change below provides workaround for waterwalling providing perfect protection,
|
// this change below provides workaround for waterwalling providing perfect protection,
|
||||||
// and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots
|
// and makes cheap (non-obsidian) TNT cannons require minor maintenance between shots
|
||||||
Block center = loc.getBlock();
|
Block center = loc.getBlock(); if (center.isLiquid()) {
|
||||||
if (center.isLiquid()) {
|
|
||||||
// a single surrounding block in all 6 directions is broken if the material is weak enough
|
// a single surrounding block in all 6 directions is broken if the material is weak enough
|
||||||
List<Block> targets = new ArrayList<Block>();
|
List<Block> targets = new ArrayList<Block>(); targets.add(center.getRelative(0, 0, 1));
|
||||||
targets.add(center.getRelative(0, 0, 1));
|
targets.add(center.getRelative(0, 0, -1)); targets.add(center.getRelative(0, 1, 0));
|
||||||
targets.add(center.getRelative(0, 0, -1));
|
targets.add(center.getRelative(0, -1, 0)); targets.add(center.getRelative(1, 0, 0));
|
||||||
targets.add(center.getRelative(0, 1, 0));
|
targets.add(center.getRelative(-1, 0, 0)); for (Block target : targets) {
|
||||||
targets.add(center.getRelative(0, -1, 0));
|
|
||||||
targets.add(center.getRelative(1, 0, 0));
|
|
||||||
targets.add(center.getRelative(-1, 0, 0));
|
|
||||||
for (Block target : targets) {
|
|
||||||
int id = target.getTypeId();
|
int id = target.getTypeId();
|
||||||
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet
|
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet
|
||||||
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) {
|
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130) {
|
||||||
@ -205,55 +157,42 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0);
|
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0);
|
||||||
if (!this.canDamagerHurtDamagee(sub, false)) { event.setCancelled(true); }
|
if (!this.canDamagerHurtDamagee(sub, false)) { event.setCancelled(true); } sub = null;
|
||||||
sub = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<PotionEffectType>(Arrays.asList(
|
private static final Set<PotionEffectType> badPotionEffects = new LinkedHashSet<PotionEffectType>(Arrays.asList(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER));
|
||||||
PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER,
|
|
||||||
PotionEffectType.POISON, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS,
|
|
||||||
PotionEffectType.WITHER
|
|
||||||
));
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPotionSplashEvent(PotionSplashEvent event) {
|
public void onPotionSplashEvent(PotionSplashEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
// see if the potion has a harmful effect
|
// see if the potion has a harmful effect
|
||||||
boolean badjuju = false;
|
boolean badjuju = false; for (PotionEffect effect : event.getPotion().getEffects()) {
|
||||||
for (PotionEffect effect : event.getPotion().getEffects()) {
|
|
||||||
if (badPotionEffects.contains(effect.getType())) {
|
if (badPotionEffects.contains(effect.getType())) {
|
||||||
badjuju = true;
|
badjuju = true; break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
} if (!badjuju) { return; }
|
||||||
if (!badjuju) { return; }
|
|
||||||
|
|
||||||
ProjectileSource thrower = event.getPotion().getShooter();
|
ProjectileSource thrower = event.getPotion().getShooter(); if (!(thrower instanceof Entity)) {
|
||||||
if (!(thrower instanceof Entity)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan through affected entities to make sure they're all valid targets
|
// scan through affected entities to make sure they're all valid targets
|
||||||
Iterator<LivingEntity> iter = event.getAffectedEntities().iterator();
|
Iterator<LivingEntity> iter = event.getAffectedEntities().iterator(); while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
LivingEntity target = iter.next();
|
LivingEntity target = iter.next();
|
||||||
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent((Entity) thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
||||||
if (!this.canDamagerHurtDamagee(sub, true)) {
|
if (!this.canDamagerHurtDamagee(sub, true)) {
|
||||||
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works
|
event.setIntensity(target, 0.0); // affected entity list doesn't accept modification (so no iter.remove()), but this works
|
||||||
}
|
} sub = null;
|
||||||
sub = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerInSafeZone(Entity damagee) {
|
public boolean isPlayerInSafeZone(Entity damagee) {
|
||||||
if (!(damagee instanceof Player)) {
|
if (!(damagee instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} if (Board.getFactionAt(new FLocation(damagee.getLocation())).isSafeZone()) {
|
||||||
if (Board.getFactionAt(new FLocation(damagee.getLocation())).isSafeZone()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {
|
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) {
|
||||||
@ -261,9 +200,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub, boolean notify) {
|
public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub, boolean notify) {
|
||||||
Entity damager = sub.getDamager();
|
Entity damager = sub.getDamager(); Entity damagee = sub.getEntity(); double damage = sub.getDamage();
|
||||||
Entity damagee = sub.getEntity();
|
|
||||||
double damage = sub.getDamage();
|
|
||||||
|
|
||||||
if (!(damagee instanceof Player)) { return true; }
|
if (!(damagee instanceof Player)) { return true; }
|
||||||
|
|
||||||
@ -288,10 +225,8 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (notify) {
|
if (notify) {
|
||||||
FPlayer attacker = FPlayers.i.get((Player) damager);
|
FPlayer attacker = FPlayers.i.get((Player) damager);
|
||||||
attacker.msg("<i>You can't hurt other players in " + (defLocFaction.isSafeZone() ? "a SafeZone." : "peaceful territory."));
|
attacker.msg("<i>You can't hurt other players in " + (defLocFaction.isSafeZone() ? "a SafeZone." : "peaceful territory."));
|
||||||
}
|
} return false;
|
||||||
return false;
|
} return !defLocFaction.noMonstersInTerritory();
|
||||||
}
|
|
||||||
return !defLocFaction.noMonstersInTerritory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(damager instanceof Player)) { return true; }
|
if (!(damager instanceof Player)) { return true; }
|
||||||
@ -305,8 +240,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (attacker.hasLoginPvpDisabled()) {
|
if (attacker.hasLoginPvpDisabled()) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
attacker.msg("<i>You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in.");
|
attacker.msg("<i>You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in.");
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction locFaction = Board.getFactionAt(new FLocation(attacker));
|
Faction locFaction = Board.getFactionAt(new FLocation(attacker));
|
||||||
@ -315,37 +249,30 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (locFaction.noPvPInTerritory()) {
|
if (locFaction.noPvPInTerritory()) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
attacker.msg("<i>You can't hurt other players while you are in " + (locFaction.isSafeZone() ? "a SafeZone." : "peaceful territory."));
|
attacker.msg("<i>You can't hurt other players while you are in " + (locFaction.isSafeZone() ? "a SafeZone." : "peaceful territory."));
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) { return true; }
|
if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) { return true; }
|
||||||
|
|
||||||
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) { return true; }
|
if (Conf.worldsIgnorePvP.contains(defenderLoc.getWorld().getName())) { return true; }
|
||||||
|
|
||||||
Faction defendFaction = defender.getFaction();
|
Faction defendFaction = defender.getFaction(); Faction attackFaction = attacker.getFaction();
|
||||||
Faction attackFaction = attacker.getFaction();
|
|
||||||
|
|
||||||
if (attackFaction.isNone() && Conf.disablePVPForFactionlessPlayers) {
|
if (attackFaction.isNone() && Conf.disablePVPForFactionlessPlayers) {
|
||||||
if (notify) { attacker.msg("<i>You can't hurt other players until you join a faction."); }
|
if (notify) { attacker.msg("<i>You can't hurt other players until you join a faction."); } return false;
|
||||||
return false;
|
} else if (defendFaction.isNone()) {
|
||||||
}
|
|
||||||
else if (defendFaction.isNone()) {
|
|
||||||
if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) {
|
if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) {
|
||||||
// Allow PVP vs. Factionless in attacker's faction territory
|
// Allow PVP vs. Factionless in attacker's faction territory
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (Conf.disablePVPForFactionlessPlayers) {
|
||||||
else if (Conf.disablePVPForFactionlessPlayers) {
|
|
||||||
if (notify) { attacker.msg("<i>You can't hurt players who are not currently in a faction."); }
|
if (notify) { attacker.msg("<i>You can't hurt players who are not currently in a faction."); }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defendFaction.isPeaceful()) {
|
if (defendFaction.isPeaceful()) {
|
||||||
if (notify) { attacker.msg("<i>You can't hurt players who are in a peaceful faction."); }
|
if (notify) { attacker.msg("<i>You can't hurt players who are in a peaceful faction."); } return false;
|
||||||
return false;
|
} else if (attackFaction.isPeaceful()) {
|
||||||
}
|
|
||||||
else if (attackFaction.isPeaceful()) {
|
|
||||||
if (notify) { attacker.msg("<i>You can't hurt players while you are in a peaceful faction."); }
|
if (notify) { attacker.msg("<i>You can't hurt players while you are in a peaceful faction."); }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -354,8 +281,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
// You can not hurt neutral factions
|
// You can not hurt neutral factions
|
||||||
if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) {
|
if (Conf.disablePVPBetweenNeutralFactions && relation.isNeutral()) {
|
||||||
if (notify) { attacker.msg("<i>You can't hurt neutral factions. Declare them as an enemy."); }
|
if (notify) { attacker.msg("<i>You can't hurt neutral factions. Declare them as an enemy."); } return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Players without faction may be hurt anywhere
|
// Players without faction may be hurt anywhere
|
||||||
@ -363,8 +289,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
// You can never hurt faction members or allies
|
// You can never hurt faction members or allies
|
||||||
if (relation.isMember() || relation.isAlly()) {
|
if (relation.isMember() || relation.isAlly()) {
|
||||||
if (notify) { attacker.msg("<i>You can't hurt %s<i>.", defender.describeTo(attacker)); }
|
if (notify) { attacker.msg("<i>You can't hurt %s<i>.", defender.describeTo(attacker)); } return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ownTerritory = defender.isInOwnTerritory();
|
boolean ownTerritory = defender.isInOwnTerritory();
|
||||||
@ -374,14 +299,12 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (notify) {
|
if (notify) {
|
||||||
attacker.msg("<i>You can't hurt %s<i> in their own territory unless you declare them as an enemy.", defender.describeTo(attacker));
|
attacker.msg("<i>You can't hurt %s<i> in their own territory unless you declare them as an enemy.", defender.describeTo(attacker));
|
||||||
defender.msg("%s<i> tried to hurt you.", attacker.describeTo(defender, true));
|
defender.msg("%s<i> tried to hurt you.", attacker.describeTo(defender, true));
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Damage will be dealt. However check if the damage should be reduced.
|
// Damage will be dealt. However check if the damage should be reduced.
|
||||||
if (damage > 0.0 && ownTerritory && Conf.territoryShieldFactor > 0) {
|
if (damage > 0.0 && ownTerritory && Conf.territoryShieldFactor > 0) {
|
||||||
int newDamage = (int) Math.ceil(damage * (1D - Conf.territoryShieldFactor));
|
int newDamage = (int) Math.ceil(damage * (1D - Conf.territoryShieldFactor)); sub.setDamage(newDamage);
|
||||||
sub.setDamage(newDamage);
|
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
if (notify) {
|
if (notify) {
|
||||||
@ -409,8 +332,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
// if there is a target
|
// if there is a target
|
||||||
Entity target = event.getTarget();
|
Entity target = event.getTarget(); if (target == null) {
|
||||||
if (target == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,42 +349,19 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPaintingBreak(HangingBreakEvent event) {
|
public void onPaintingBreak(HangingBreakEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; } if (event.getCause() == RemoveCause.EXPLOSION) {
|
||||||
if (event.getCause() == RemoveCause.EXPLOSION) {
|
Location loc = event.getEntity().getLocation(); Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||||
Location loc = event.getEntity().getLocation();
|
|
||||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
|
||||||
if (faction.noExplosionsInTerritory()) {
|
if (faction.noExplosionsInTerritory()) {
|
||||||
// faction is peaceful and has explosions set to disabled
|
// faction is peaceful and has explosions set to disabled
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean online = faction.hasPlayersOnline();
|
boolean online = faction.hasPlayersOnline();
|
||||||
|
|
||||||
if
|
if ((faction.isNone() && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()) && (Conf.wildernessBlockCreepers || Conf.wildernessBlockFireballs || Conf.wildernessBlockTNT)) ||
|
||||||
(
|
(faction.isNormal() && (online ? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT) : (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline))) ||
|
||||||
(
|
(faction.isWarZone() && (Conf.warZoneBlockCreepers || Conf.warZoneBlockFireballs || Conf.warZoneBlockTNT)) ||
|
||||||
faction.isNone()
|
faction.isSafeZone()) {
|
||||||
&& !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())
|
|
||||||
&& (Conf.wildernessBlockCreepers || Conf.wildernessBlockFireballs || Conf.wildernessBlockTNT)
|
|
||||||
)
|
|
||||||
||
|
|
||||||
(
|
|
||||||
faction.isNormal()
|
|
||||||
&&
|
|
||||||
(online
|
|
||||||
? (Conf.territoryBlockCreepers || Conf.territoryBlockFireballs || Conf.territoryBlockTNT)
|
|
||||||
: (Conf.territoryBlockCreepersWhenOffline || Conf.territoryBlockFireballsWhenOffline || Conf.territoryBlockTNTWhenOffline)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
||
|
|
||||||
(
|
|
||||||
faction.isWarZone()
|
|
||||||
&& (Conf.warZoneBlockCreepers || Conf.warZoneBlockFireballs || Conf.warZoneBlockTNT)
|
|
||||||
)
|
|
||||||
||
|
|
||||||
faction.isSafeZone()
|
|
||||||
) {
|
|
||||||
// explosion which needs prevention
|
// explosion which needs prevention
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -472,8 +371,7 @@ public class FactionsEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity breaker = ((HangingBreakByEntityEvent) event).getRemover();
|
Entity breaker = ((HangingBreakByEntityEvent) event).getRemover(); if (!(breaker instanceof Player)) {
|
||||||
if (!(breaker instanceof Player)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,20 +402,13 @@ public class FactionsEntityListener implements Listener {
|
|||||||
|
|
||||||
if (entity instanceof Enderman) {
|
if (entity instanceof Enderman) {
|
||||||
if (stopEndermanBlockManipulation(loc)) { event.setCancelled(true); }
|
if (stopEndermanBlockManipulation(loc)) { event.setCancelled(true); }
|
||||||
}
|
} else if (entity instanceof Wither) {
|
||||||
else if (entity instanceof Wither) {
|
|
||||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||||
// it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
// it's a bit crude just using fireball protection, but I'd rather not add in a whole new set of xxxBlockWitherExplosion or whatever
|
||||||
if
|
if ((faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) ||
|
||||||
(
|
(faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) ||
|
||||||
(faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()))
|
(faction.isWarZone() && Conf.warZoneBlockFireballs) ||
|
||||||
||
|
faction.isSafeZone()) { event.setCancelled(true); }
|
||||||
(faction.isNormal() && (faction.hasPlayersOnline() ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline))
|
|
||||||
||
|
|
||||||
(faction.isWarZone() && Conf.warZoneBlockFireballs)
|
|
||||||
||
|
|
||||||
faction.isSafeZone()
|
|
||||||
) { event.setCancelled(true); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,34 +417,23 @@ public class FactionsEntityListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
|
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
|
||||||
if
|
if (Conf.wildernessDenyEndermanBlocks &&
|
||||||
(
|
Conf.territoryDenyEndermanBlocks &&
|
||||||
Conf.wildernessDenyEndermanBlocks
|
Conf.territoryDenyEndermanBlocksWhenOffline &&
|
||||||
&&
|
Conf.safeZoneDenyEndermanBlocks &&
|
||||||
Conf.territoryDenyEndermanBlocks
|
Conf.warZoneDenyEndermanBlocks) {
|
||||||
&&
|
|
||||||
Conf.territoryDenyEndermanBlocksWhenOffline
|
|
||||||
&&
|
|
||||||
Conf.safeZoneDenyEndermanBlocks
|
|
||||||
&&
|
|
||||||
Conf.warZoneDenyEndermanBlocks
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLocation fLoc = new FLocation(loc);
|
FLocation fLoc = new FLocation(loc); Faction claimFaction = Board.getFactionAt(fLoc);
|
||||||
Faction claimFaction = Board.getFactionAt(fLoc);
|
|
||||||
|
|
||||||
if (claimFaction.isNone()) {
|
if (claimFaction.isNone()) {
|
||||||
return Conf.wildernessDenyEndermanBlocks;
|
return Conf.wildernessDenyEndermanBlocks;
|
||||||
}
|
} else if (claimFaction.isNormal()) {
|
||||||
else if (claimFaction.isNormal()) {
|
|
||||||
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
|
return claimFaction.hasPlayersOnline() ? Conf.territoryDenyEndermanBlocks : Conf.territoryDenyEndermanBlocksWhenOffline;
|
||||||
}
|
} else if (claimFaction.isSafeZone()) {
|
||||||
else if (claimFaction.isSafeZone()) {
|
|
||||||
return Conf.safeZoneDenyEndermanBlocks;
|
return Conf.safeZoneDenyEndermanBlocks;
|
||||||
}
|
} else if (claimFaction.isWarZone()) {
|
||||||
else if (claimFaction.isWarZone()) {
|
|
||||||
return Conf.warZoneDenyEndermanBlocks;
|
return Conf.warZoneDenyEndermanBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,7 @@ public class FactionsExploitListener implements Listener {
|
|||||||
if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) { return; }
|
if (event.isCancelled() == true || !Conf.handleExploitObsidianGenerators) { return; }
|
||||||
|
|
||||||
// thanks to ObGenBlocker and WorldGuard for this method
|
// thanks to ObGenBlocker and WorldGuard for this method
|
||||||
Block block = event.getToBlock();
|
Block block = event.getToBlock(); int source = event.getBlock().getTypeId(); int target = block.getTypeId();
|
||||||
int source = event.getBlock().getTypeId();
|
|
||||||
int target = block.getTypeId();
|
|
||||||
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { block.setTypeId(0); }
|
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { block.setTypeId(0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,33 +28,20 @@ public class FactionsExploitListener implements Listener {
|
|||||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { return; }
|
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { return; }
|
||||||
|
|
||||||
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
||||||
Location target = event.getTo();
|
Location target = event.getTo(); Location from = event.getFrom();
|
||||||
Location from = event.getFrom();
|
|
||||||
|
|
||||||
// blocks who occupy less than 1 block width or length wise need to be handled differently
|
// blocks who occupy less than 1 block width or length wise need to be handled differently
|
||||||
Material mat = event.getTo().getBlock().getType();
|
Material mat = event.getTo().getBlock().getType();
|
||||||
if (
|
if (((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65)) || ((mat == Material.FENCE || mat == Material.NETHER_FENCE) && clippingThrough(target, from, 0.45))) {
|
||||||
((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65))
|
event.setTo(from); return;
|
||||||
|| ((mat == Material.FENCE || mat == Material.NETHER_FENCE) && clippingThrough(target, from, 0.45))
|
|
||||||
) {
|
|
||||||
event.setTo(from);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges
|
// simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges
|
||||||
target.setX(target.getBlockX() + 0.5);
|
target.setX(target.getBlockX() + 0.5); target.setZ(target.getBlockZ() + 0.5); event.setTo(target);
|
||||||
target.setZ(target.getBlockZ() + 0.5);
|
|
||||||
event.setTo(target);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean clippingThrough(Location target, Location from, double thickness) {
|
public static boolean clippingThrough(Location target, Location from, double thickness) {
|
||||||
return
|
return ((from.getX() > target.getX() && (from.getX() - target.getX() < thickness)) || (target.getX() > from.getX() && (target.getX() - from.getX() < thickness)) || (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness)) || (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness)));
|
||||||
(
|
|
||||||
(from.getX() > target.getX() && (from.getX() - target.getX() < thickness))
|
|
||||||
|| (target.getX() > from.getX() && (target.getX() - from.getX() < thickness))
|
|
||||||
|| (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness))
|
|
||||||
|| (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
// and update their last login time to point to when the logged off, for auto-remove routine
|
// and update their last login time to point to when the logged off, for auto-remove routine
|
||||||
me.setLastLoginTime(System.currentTimeMillis());
|
me.setLastLoginTime(System.currentTimeMillis());
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction(); if (myFaction != null) {
|
||||||
if (myFaction != null) {
|
|
||||||
myFaction.memberLoggedOff();
|
myFaction.memberLoggedOff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,16 +59,14 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
// quick check to make sure player is moving between chunks; good performance boost
|
// quick check to make sure player is moving between chunks; good performance boost
|
||||||
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4
|
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4 && event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4 && event.getFrom().getWorld() == event.getTo().getWorld()) {
|
||||||
&& event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4
|
return;
|
||||||
&& event.getFrom().getWorld() == event.getTo().getWorld()) { return; }
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer(); FPlayer me = FPlayers.i.get(player);
|
||||||
FPlayer me = FPlayers.i.get(player);
|
|
||||||
|
|
||||||
// Did we change coord?
|
// Did we change coord?
|
||||||
FLocation from = me.getLastStoodAt();
|
FLocation from = me.getLastStoodAt(); FLocation to = new FLocation(event.getTo());
|
||||||
FLocation to = new FLocation(event.getTo());
|
|
||||||
|
|
||||||
if (from.equals(to)) {
|
if (from.equals(to)) {
|
||||||
return;
|
return;
|
||||||
@ -80,8 +77,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
me.setLastStoodAt(to);
|
me.setLastStoodAt(to);
|
||||||
|
|
||||||
// Did we change "host"(faction)?
|
// Did we change "host"(faction)?
|
||||||
Faction factionFrom = Board.getFactionAt(from);
|
Faction factionFrom = Board.getFactionAt(from); Faction factionTo = Board.getFactionAt(to);
|
||||||
Faction factionTo = Board.getFactionAt(to);
|
|
||||||
boolean changedFaction = (factionFrom != factionTo);
|
boolean changedFaction = (factionFrom != factionTo);
|
||||||
|
|
||||||
/* Was used for displaying on Spout but we removed Spout compatibility.
|
/* Was used for displaying on Spout but we removed Spout compatibility.
|
||||||
@ -91,48 +87,40 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
if (me.isMapAutoUpdating()) {
|
if (me.isMapAutoUpdating()) {
|
||||||
me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw()));
|
me.sendMessage(Board.getMap(me.getFaction(), to, player.getLocation().getYaw()));
|
||||||
}
|
} else {
|
||||||
else {
|
Faction myFaction = me.getFaction(); String ownersTo = myFaction.getOwnerListString(to);
|
||||||
Faction myFaction = me.getFaction();
|
|
||||||
String ownersTo = myFaction.getOwnerListString(to);
|
|
||||||
|
|
||||||
if (changedFaction) {
|
if (changedFaction) {
|
||||||
me.sendFactionHereMessage();
|
me.sendFactionHereMessage();
|
||||||
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) {
|
if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) {
|
||||||
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
||||||
}
|
}
|
||||||
}
|
} else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo && myFaction == factionTo) {
|
||||||
else if (Conf.ownedAreasEnabled && Conf.ownedMessageInsideTerritory && factionFrom == factionTo && myFaction == factionTo) {
|
|
||||||
String ownersFrom = myFaction.getOwnerListString(from);
|
String ownersFrom = myFaction.getOwnerListString(from);
|
||||||
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) {
|
if (Conf.ownedMessageByChunk || !ownersFrom.equals(ownersTo)) {
|
||||||
if (!ownersTo.isEmpty()) { me.sendMessage(Conf.ownedLandMessage + ownersTo); }
|
if (!ownersTo.isEmpty()) {
|
||||||
else if (!Conf.publicLandMessage.isEmpty()) { me.sendMessage(Conf.publicLandMessage); }
|
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
||||||
|
} else if (!Conf.publicLandMessage.isEmpty()) { me.sendMessage(Conf.publicLandMessage); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.getAutoClaimFor() != null) {
|
if (me.getAutoClaimFor() != null) {
|
||||||
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
me.attemptClaim(me.getAutoClaimFor(), event.getTo(), true);
|
||||||
}
|
} else if (me.isAutoSafeClaimEnabled()) {
|
||||||
else if (me.isAutoSafeClaimEnabled()) {
|
|
||||||
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
|
||||||
me.setIsAutoSafeClaimEnabled(false);
|
me.setIsAutoSafeClaimEnabled(false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Board.getFactionAt(to).isSafeZone()) {
|
if (!Board.getFactionAt(to).isSafeZone()) {
|
||||||
Board.setFactionAt(Factions.i.getSafeZone(), to);
|
Board.setFactionAt(Factions.i.getSafeZone(), to); me.msg("<i>This land is now a safe zone.");
|
||||||
me.msg("<i>This land is now a safe zone.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (me.isAutoWarClaimEnabled()) {
|
||||||
else if (me.isAutoWarClaimEnabled()) {
|
|
||||||
if (!Permission.MANAGE_WAR_ZONE.has(player)) {
|
if (!Permission.MANAGE_WAR_ZONE.has(player)) {
|
||||||
me.setIsAutoWarClaimEnabled(false);
|
me.setIsAutoWarClaimEnabled(false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Board.getFactionAt(to).isWarZone()) {
|
if (!Board.getFactionAt(to).isWarZone()) {
|
||||||
Board.setFactionAt(Factions.i.getWarZone(), to);
|
Board.setFactionAt(Factions.i.getWarZone(), to); me.msg("<i>This land is now a war zone.");
|
||||||
me.msg("<i>This land is now a war zone.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,30 +132,23 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
// only need to check right-clicks and physical as of MC 1.4+; good performance boost
|
// only need to check right-clicks and physical as of MC 1.4+; good performance boost
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { return; }
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { return; }
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock(); Player player = event.getPlayer();
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
return; // clicked in air, apparently
|
return; // clicked in air, apparently
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canPlayerUseBlock(player, block, false)) {
|
if (!canPlayerUseBlock(player, block, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); if (Conf.handleExploitInteractionSpam) {
|
||||||
if (Conf.handleExploitInteractionSpam) {
|
String name = player.getName(); InteractAttemptSpam attempt = interactSpammers.get(name);
|
||||||
String name = player.getName();
|
|
||||||
InteractAttemptSpam attempt = interactSpammers.get(name);
|
|
||||||
if (attempt == null) {
|
if (attempt == null) {
|
||||||
attempt = new InteractAttemptSpam();
|
attempt = new InteractAttemptSpam(); interactSpammers.put(name, attempt);
|
||||||
interactSpammers.put(name, attempt);
|
} int count = attempt.increment(); if (count >= 10) {
|
||||||
}
|
|
||||||
int count = attempt.increment();
|
|
||||||
if (count >= 10) {
|
|
||||||
FPlayer me = FPlayers.i.get(name);
|
FPlayer me = FPlayers.i.get(name);
|
||||||
me.msg("<b>Ouch, that is starting to hurt. You should give it a rest.");
|
me.msg("<b>Ouch, that is starting to hurt. You should give it a rest.");
|
||||||
player.damage(NumberConversions.floor((double) count / 10));
|
player.damage(NumberConversions.floor((double) count / 10));
|
||||||
}
|
}
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||||
@ -175,8 +156,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,31 +170,24 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
// returns the current attempt count
|
// returns the current attempt count
|
||||||
public int increment() {
|
public int increment() {
|
||||||
long Now = System.currentTimeMillis();
|
long Now = System.currentTimeMillis(); if (Now > lastAttempt + 2000) { attempts = 1; } else { attempts++; }
|
||||||
if (Now > lastAttempt + 2000) { attempts = 1; }
|
lastAttempt = Now; return attempts;
|
||||||
else { attempts++; }
|
|
||||||
lastAttempt = Now;
|
|
||||||
return attempts;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) {
|
public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) {
|
||||||
String name = player.getName();
|
String name = player.getName(); if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; }
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(name)) { return true; }
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(player);
|
FPlayer me = FPlayers.i.get(player); if (me.isAdminBypassing()) { return true; }
|
||||||
if (me.isAdminBypassing()) { return true; }
|
|
||||||
|
|
||||||
FLocation loc = new FLocation(location);
|
FLocation loc = new FLocation(location); Faction otherFaction = Board.getFactionAt(loc);
|
||||||
Faction otherFaction = Board.getFactionAt(loc);
|
|
||||||
|
|
||||||
if (otherFaction.hasPlayersOnline()) {
|
if (otherFaction.hasPlayersOnline()) {
|
||||||
if (!Conf.territoryDenyUseageMaterials.contains(material)) {
|
if (!Conf.territoryDenyUseageMaterials.contains(material)) {
|
||||||
return true; // Item isn't one we're preventing for online factions.
|
return true; // Item isn't one we're preventing for online factions.
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) {
|
if (!Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) {
|
||||||
return true; // Item isn't one we're preventing for offline factions.
|
return true; // Item isn't one we're preventing for offline factions.
|
||||||
}
|
}
|
||||||
@ -230,15 +203,13 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isSafeZone()) {
|
||||||
else if (otherFaction.isSafeZone()) {
|
|
||||||
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; }
|
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) { return true; }
|
||||||
|
|
||||||
if (!justCheck) { me.msg("<b>You can't use <h>%s<b> in a safe zone.", TextUtil.getMaterialName(material)); }
|
if (!justCheck) { me.msg("<b>You can't use <h>%s<b> in a safe zone.", TextUtil.getMaterialName(material)); }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
else if (otherFaction.isWarZone()) {
|
|
||||||
if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) { return true; }
|
if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) { return true; }
|
||||||
|
|
||||||
if (!justCheck) { me.msg("<b>You can't use <h>%s<b> in a war zone.", TextUtil.getMaterialName(material)); }
|
if (!justCheck) { me.msg("<b>You can't use <h>%s<b> in a war zone.", TextUtil.getMaterialName(material)); }
|
||||||
@ -246,8 +217,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelationTo(otherFaction);
|
||||||
Relation rel = myFaction.getRelationTo(otherFaction);
|
|
||||||
|
|
||||||
// Cancel if we are not in our own territory
|
// Cancel if we are not in our own territory
|
||||||
if (rel.confDenyUseage()) {
|
if (rel.confDenyUseage()) {
|
||||||
@ -273,11 +243,9 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
|
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) { return true; }
|
if (Conf.playersWhoBypassAllProtection.contains(player.getName())) { return true; }
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(player);
|
FPlayer me = FPlayers.i.get(player); if (me.isAdminBypassing()) { return true; }
|
||||||
if (me.isAdminBypassing()) { return true; }
|
|
||||||
|
|
||||||
Material material = block.getType();
|
Material material = block.getType(); FLocation loc = new FLocation(block);
|
||||||
FLocation loc = new FLocation(block);
|
|
||||||
Faction otherFaction = Board.getFactionAt(loc);
|
Faction otherFaction = Board.getFactionAt(loc);
|
||||||
|
|
||||||
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
// no door/chest/whatever protection in wilderness, war zones, or safe zones
|
||||||
@ -286,13 +254,11 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
// We only care about some material types.
|
// We only care about some material types.
|
||||||
if (otherFaction.hasPlayersOnline()) {
|
if (otherFaction.hasPlayersOnline()) {
|
||||||
if (!Conf.territoryProtectedMaterials.contains(material)) { return true; }
|
if (!Conf.territoryProtectedMaterials.contains(material)) { return true; }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { return true; }
|
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction(); Relation rel = myFaction.getRelationTo(otherFaction);
|
||||||
Relation rel = myFaction.getRelationTo(otherFaction);
|
|
||||||
|
|
||||||
// You may use any block unless it is another faction's territory...
|
// You may use any block unless it is another faction's territory...
|
||||||
if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials)) {
|
if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials)) {
|
||||||
@ -321,21 +287,10 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
|
|
||||||
me.getPower(); // update power, so they won't have gained any while dead
|
me.getPower(); // update power, so they won't have gained any while dead
|
||||||
|
|
||||||
Location home = me.getFaction().getHome();
|
Location home = me.getFaction().getHome(); if (Conf.homesEnabled &&
|
||||||
if
|
Conf.homesTeleportToOnDeath &&
|
||||||
(
|
home != null &&
|
||||||
Conf.homesEnabled
|
(Conf.homesRespawnFromNoPowerLossWorlds || !Conf.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName()))) {
|
||||||
&&
|
|
||||||
Conf.homesTeleportToOnDeath
|
|
||||||
&&
|
|
||||||
home != null
|
|
||||||
&&
|
|
||||||
(
|
|
||||||
Conf.homesRespawnFromNoPowerLossWorlds
|
|
||||||
||
|
|
||||||
!Conf.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName())
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
event.setRespawnLocation(home);
|
event.setRespawnLocation(home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,12 +301,10 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked(); Player player = event.getPlayer();
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,12 +312,10 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked(); Player player = event.getPlayer();
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getBucket(), false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,24 +329,15 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
FPlayer me = FPlayers.i.get(player);
|
FPlayer me = FPlayers.i.get(player);
|
||||||
|
|
||||||
String shortCmd; // command without the slash at the beginning
|
String shortCmd; // command without the slash at the beginning
|
||||||
if (fullCmd.startsWith("/")) { shortCmd = fullCmd.substring(1); }
|
if (fullCmd.startsWith("/")) { shortCmd = fullCmd.substring(1); } else {
|
||||||
else {
|
shortCmd = fullCmd; fullCmd = "/" + fullCmd;
|
||||||
shortCmd = fullCmd;
|
|
||||||
fullCmd = "/" + fullCmd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if
|
if (me.hasFaction() &&
|
||||||
(
|
!me.isAdminBypassing() &&
|
||||||
me.hasFaction()
|
!Conf.permanentFactionMemberDenyCommands.isEmpty() &&
|
||||||
&&
|
me.getFaction().isPermanent() &&
|
||||||
!me.isAdminBypassing()
|
isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())) {
|
||||||
&&
|
|
||||||
!Conf.permanentFactionMemberDenyCommands.isEmpty()
|
|
||||||
&&
|
|
||||||
me.getFaction().isPermanent()
|
|
||||||
&&
|
|
||||||
isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())
|
|
||||||
) {
|
|
||||||
me.msg("<b>You can't use the command \"" + fullCmd + "\" because you are in a permanent faction.");
|
me.msg("<b>You can't use the command \"" + fullCmd + "\" because you are in a permanent faction.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -404,45 +346,37 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation rel = me.getRelationToLocation();
|
Relation rel = me.getRelationToLocation(); if (rel.isAtLeast(Relation.ALLY)) {
|
||||||
if (rel.isAtLeast(Relation.ALLY)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) {
|
if (rel.isNeutral() && !Conf.territoryNeutralDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())) {
|
||||||
me.msg("<b>You can't use the command \"" + fullCmd + "\" in neutral territory.");
|
me.msg("<b>You can't use the command \"" + fullCmd + "\" in neutral territory."); return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rel.isEnemy() && !Conf.territoryEnemyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())) {
|
if (rel.isEnemy() && !Conf.territoryEnemyDenyCommands.isEmpty() && !me.isAdminBypassing() && isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())) {
|
||||||
me.msg("<b>You can't use the command \"" + fullCmd + "\" in enemy territory.");
|
me.msg("<b>You can't use the command \"" + fullCmd + "\" in enemy territory."); return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isCommandInList(String fullCmd, String shortCmd, Iterator<String> iter) {
|
private static boolean isCommandInList(String fullCmd, String shortCmd, Iterator<String> iter) {
|
||||||
String cmdCheck;
|
String cmdCheck; while (iter.hasNext()) {
|
||||||
while (iter.hasNext()) {
|
cmdCheck = iter.next(); if (cmdCheck == null) {
|
||||||
cmdCheck = iter.next();
|
iter.remove(); continue;
|
||||||
if (cmdCheck == null) {
|
|
||||||
iter.remove();
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdCheck = cmdCheck.toLowerCase();
|
cmdCheck = cmdCheck.toLowerCase();
|
||||||
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) { return true; }
|
if (fullCmd.startsWith(cmdCheck) || shortCmd.startsWith(cmdCheck)) { return true; }
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
if (event.isCancelled()) { return; }
|
if (event.isCancelled()) { return; }
|
||||||
|
|
||||||
FPlayer badGuy = FPlayers.i.get(event.getPlayer());
|
FPlayer badGuy = FPlayers.i.get(event.getPlayer()); if (badGuy == null) {
|
||||||
if (badGuy == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,8 +384,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
||||||
if (badGuy.getRole() == Role.ADMIN) { badGuy.getFaction().promoteNewLeader(); }
|
if (badGuy.getRole() == Role.ADMIN) { badGuy.getFaction().promoteNewLeader(); }
|
||||||
|
|
||||||
badGuy.leave(false);
|
badGuy.leave(false); badGuy.detach();
|
||||||
badGuy.detach();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ public enum ChatMode {
|
|||||||
public final String nicename;
|
public final String nicename;
|
||||||
|
|
||||||
private ChatMode(final int value, final String nicename) {
|
private ChatMode(final int value, final String nicename) {
|
||||||
this.value = value;
|
this.value = value; this.nicename = nicename;
|
||||||
this.nicename = nicename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(ChatMode role) {
|
public boolean isAtLeast(ChatMode role) {
|
||||||
@ -27,8 +26,6 @@ public enum ChatMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChatMode getNext() {
|
public ChatMode getNext() {
|
||||||
if (this == PUBLIC) { return ALLIANCE; }
|
if (this == PUBLIC) { return ALLIANCE; } if (this == ALLIANCE) { return FACTION; } return PUBLIC;
|
||||||
if (this == ALLIANCE) { return FACTION; }
|
|
||||||
return PUBLIC;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ public enum Relation {
|
|||||||
public final String nicename;
|
public final String nicename;
|
||||||
|
|
||||||
private Relation(final int value, final String nicename) {
|
private Relation(final int value, final String nicename) {
|
||||||
this.value = value;
|
this.value = value; this.nicename = nicename;
|
||||||
this.nicename = nicename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,10 +47,9 @@ public enum Relation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor() {
|
public ChatColor getColor() {
|
||||||
if (this == MEMBER) { return Conf.colorMember; }
|
if (this == MEMBER) { return Conf.colorMember; } else if (this == ALLY) {
|
||||||
else if (this == ALLY) { return Conf.colorAlly; }
|
return Conf.colorAlly;
|
||||||
else if (this == NEUTRAL) { return Conf.colorNeutral; }
|
} else if (this == NEUTRAL) { return Conf.colorNeutral; } else { return Conf.colorEnemy; }
|
||||||
else { return Conf.colorEnemy; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
||||||
@ -59,14 +57,13 @@ public enum Relation {
|
|||||||
if (isMember()) { return false; }
|
if (isMember()) { return false; }
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
if (isEnemy()) { return Conf.territoryEnemyDenyBuild; }
|
if (isEnemy()) { return Conf.territoryEnemyDenyBuild; } else if (isAlly()) {
|
||||||
else if (isAlly()) { return Conf.territoryAllyDenyBuild; }
|
return Conf.territoryAllyDenyBuild;
|
||||||
else { return Conf.territoryDenyBuild; }
|
} else { return Conf.territoryDenyBuild; }
|
||||||
}
|
} else {
|
||||||
else {
|
if (isEnemy()) { return Conf.territoryEnemyDenyBuildWhenOffline; } else if (isAlly()) {
|
||||||
if (isEnemy()) { return Conf.territoryEnemyDenyBuildWhenOffline; }
|
return Conf.territoryAllyDenyBuildWhenOffline;
|
||||||
else if (isAlly()) { return Conf.territoryAllyDenyBuildWhenOffline; }
|
} else { return Conf.territoryDenyBuildWhenOffline; }
|
||||||
else { return Conf.territoryDenyBuildWhenOffline; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,28 +72,26 @@ public enum Relation {
|
|||||||
if (isMember()) { return false; }
|
if (isMember()) { return false; }
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
if (isEnemy()) { return Conf.territoryEnemyPainBuild; }
|
if (isEnemy()) { return Conf.territoryEnemyPainBuild; } else if (isAlly()) {
|
||||||
else if (isAlly()) { return Conf.territoryAllyPainBuild; }
|
return Conf.territoryAllyPainBuild;
|
||||||
else { return Conf.territoryPainBuild; }
|
} else { return Conf.territoryPainBuild; }
|
||||||
}
|
} else {
|
||||||
else {
|
if (isEnemy()) { return Conf.territoryEnemyPainBuildWhenOffline; } else if (isAlly()) {
|
||||||
if (isEnemy()) { return Conf.territoryEnemyPainBuildWhenOffline; }
|
return Conf.territoryAllyPainBuildWhenOffline;
|
||||||
else if (isAlly()) { return Conf.territoryAllyPainBuildWhenOffline; }
|
} else { return Conf.territoryPainBuildWhenOffline; }
|
||||||
else { return Conf.territoryPainBuildWhenOffline; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return appropriate Conf setting for DenyUseage based on this relation
|
// return appropriate Conf setting for DenyUseage based on this relation
|
||||||
public boolean confDenyUseage() {
|
public boolean confDenyUseage() {
|
||||||
if (isMember()) { return false; }
|
if (isMember()) { return false; } else if (isEnemy()) {
|
||||||
else if (isEnemy()) { return Conf.territoryEnemyDenyUseage; }
|
return Conf.territoryEnemyDenyUseage;
|
||||||
else if (isAlly()) { return Conf.territoryAllyDenyUseage; }
|
} else if (isAlly()) { return Conf.territoryAllyDenyUseage; } else { return Conf.territoryDenyUseage; }
|
||||||
else { return Conf.territoryDenyUseage; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRelationCost() {
|
public double getRelationCost() {
|
||||||
if (isEnemy()) { return Conf.econCostEnemy; }
|
if (isEnemy()) { return Conf.econCostEnemy; } else if (isAlly()) { return Conf.econCostAlly; } else {
|
||||||
else if (isAlly()) { return Conf.econCostAlly; }
|
return Conf.econCostNeutral;
|
||||||
else { return Conf.econCostNeutral; }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ public enum Role {
|
|||||||
public final String nicename;
|
public final String nicename;
|
||||||
|
|
||||||
private Role(final int value, final String nicename) {
|
private Role(final int value, final String nicename) {
|
||||||
this.value = value;
|
this.value = value; this.nicename = nicename;
|
||||||
this.nicename = nicename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(Role role) {
|
public boolean isAtLeast(Role role) {
|
||||||
|
@ -32,42 +32,40 @@ public class AsciiCompass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static AsciiCompass.Point getCompassPointForDirection(double inDegrees) {
|
public static AsciiCompass.Point getCompassPointForDirection(double inDegrees) {
|
||||||
double degrees = (inDegrees - 180) % 360;
|
double degrees = (inDegrees - 180) % 360; if (degrees < 0) { degrees += 360; }
|
||||||
if (degrees < 0) { degrees += 360; }
|
|
||||||
|
|
||||||
if (0 <= degrees && degrees < 22.5) { return AsciiCompass.Point.N; }
|
if (0 <= degrees && degrees < 22.5) {
|
||||||
else if (22.5 <= degrees && degrees < 67.5) { return AsciiCompass.Point.NE; }
|
return AsciiCompass.Point.N;
|
||||||
else if (67.5 <= degrees && degrees < 112.5) { return AsciiCompass.Point.E; }
|
} else if (22.5 <= degrees && degrees < 67.5) {
|
||||||
else if (112.5 <= degrees && degrees < 157.5) { return AsciiCompass.Point.SE; }
|
return AsciiCompass.Point.NE;
|
||||||
else if (157.5 <= degrees && degrees < 202.5) { return AsciiCompass.Point.S; }
|
} else if (67.5 <= degrees && degrees < 112.5) {
|
||||||
else if (202.5 <= degrees && degrees < 247.5) { return AsciiCompass.Point.SW; }
|
return AsciiCompass.Point.E;
|
||||||
else if (247.5 <= degrees && degrees < 292.5) { return AsciiCompass.Point.W; }
|
} else if (112.5 <= degrees && degrees < 157.5) {
|
||||||
else if (292.5 <= degrees && degrees < 337.5) { return AsciiCompass.Point.NW; }
|
return AsciiCompass.Point.SE;
|
||||||
else if (337.5 <= degrees && degrees < 360.0) { return AsciiCompass.Point.N; }
|
} else if (157.5 <= degrees && degrees < 202.5) {
|
||||||
else { return null; }
|
return AsciiCompass.Point.S;
|
||||||
|
} else if (202.5 <= degrees && degrees < 247.5) {
|
||||||
|
return AsciiCompass.Point.SW;
|
||||||
|
} else if (247.5 <= degrees && degrees < 292.5) {
|
||||||
|
return AsciiCompass.Point.W;
|
||||||
|
} else if (292.5 <= degrees && degrees < 337.5) {
|
||||||
|
return AsciiCompass.Point.NW;
|
||||||
|
} else if (337.5 <= degrees && degrees < 360.0) { return AsciiCompass.Point.N; } else { return null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) {
|
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) {
|
||||||
ArrayList<String> ret = new ArrayList<String>();
|
ArrayList<String> ret = new ArrayList<String>(); String row;
|
||||||
String row;
|
|
||||||
|
|
||||||
row = "";
|
row = ""; row += Point.NW.toString(Point.NW == point, colorActive, colorDefault);
|
||||||
row += Point.NW.toString(Point.NW == point, colorActive, colorDefault);
|
|
||||||
row += Point.N.toString(Point.N == point, colorActive, colorDefault);
|
row += Point.N.toString(Point.N == point, colorActive, colorDefault);
|
||||||
row += Point.NE.toString(Point.NE == point, colorActive, colorDefault);
|
row += Point.NE.toString(Point.NE == point, colorActive, colorDefault); ret.add(row);
|
||||||
ret.add(row);
|
|
||||||
|
|
||||||
row = "";
|
row = ""; row += Point.W.toString(Point.W == point, colorActive, colorDefault); row += colorDefault + "+";
|
||||||
row += Point.W.toString(Point.W == point, colorActive, colorDefault);
|
row += Point.E.toString(Point.E == point, colorActive, colorDefault); ret.add(row);
|
||||||
row += colorDefault + "+";
|
|
||||||
row += Point.E.toString(Point.E == point, colorActive, colorDefault);
|
|
||||||
ret.add(row);
|
|
||||||
|
|
||||||
row = "";
|
row = ""; row += Point.SW.toString(Point.SW == point, colorActive, colorDefault);
|
||||||
row += Point.SW.toString(Point.SW == point, colorActive, colorDefault);
|
|
||||||
row += Point.S.toString(Point.S == point, colorActive, colorDefault);
|
row += Point.S.toString(Point.S == point, colorActive, colorDefault);
|
||||||
row += Point.SE.toString(Point.SE == point, colorActive, colorDefault);
|
row += Point.SE.toString(Point.SE == point, colorActive, colorDefault); ret.add(row);
|
||||||
ret.add(row);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,14 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
|
|||||||
private transient double toleranceMillis;
|
private transient double toleranceMillis;
|
||||||
|
|
||||||
public AutoLeaveProcessTask() {
|
public AutoLeaveProcessTask() {
|
||||||
ArrayList<FPlayer> fplayers = new ArrayList<FPlayer>(FPlayers.i.get());
|
ArrayList<FPlayer> fplayers = new ArrayList<FPlayer>(FPlayers.i.get()); this.iterator = fplayers.listIterator();
|
||||||
this.iterator = fplayers.listIterator();
|
this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000; this.readyToGo = true;
|
||||||
this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000;
|
|
||||||
this.readyToGo = true;
|
|
||||||
this.finished = false;
|
this.finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (Conf.autoLeaveAfterDaysOfInactivity <= 0.0 || Conf.autoLeaveRoutineMaxMillisecondsPerTick <= 0.0) {
|
if (Conf.autoLeaveAfterDaysOfInactivity <= 0.0 || Conf.autoLeaveRoutineMaxMillisecondsPerTick <= 0.0) {
|
||||||
this.stop();
|
this.stop(); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!readyToGo) { return; }
|
if (!readyToGo) { return; }
|
||||||
@ -38,8 +35,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
|
|||||||
|
|
||||||
// if this iteration has been running for maximum time, stop to take a breather until next tick
|
// if this iteration has been running for maximum time, stop to take a breather until next tick
|
||||||
if (now > loopStartTime + Conf.autoLeaveRoutineMaxMillisecondsPerTick) {
|
if (now > loopStartTime + Conf.autoLeaveRoutineMaxMillisecondsPerTick) {
|
||||||
readyToGo = true;
|
readyToGo = true; return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer fplayer = iterator.next();
|
FPlayer fplayer = iterator.next();
|
||||||
@ -54,8 +50,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
|
|||||||
if (faction != null) { fplayer.getFaction().promoteNewLeader(); }
|
if (faction != null) { fplayer.getFaction().promoteNewLeader(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
fplayer.leave(false);
|
fplayer.leave(false); iterator.remove(); // go ahead and remove this list's link to the FPlayer object
|
||||||
iterator.remove(); // go ahead and remove this list's link to the FPlayer object
|
|
||||||
fplayer.detach();
|
fplayer.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,8 +61,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
|
|||||||
|
|
||||||
// we're done, shut down
|
// we're done, shut down
|
||||||
public void stop() {
|
public void stop() {
|
||||||
readyToGo = false;
|
readyToGo = false; finished = true;
|
||||||
finished = true;
|
|
||||||
|
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ public class AutoLeaveTask implements Runnable {
|
|||||||
public synchronized void run() {
|
public synchronized void run() {
|
||||||
if (task != null && !task.isFinished()) { return; }
|
if (task != null && !task.isFinished()) { return; }
|
||||||
|
|
||||||
task = new AutoLeaveProcessTask();
|
task = new AutoLeaveProcessTask(); task.runTaskTimer(P.p, 1, 1);
|
||||||
task.runTaskTimer(P.p, 1, 1);
|
|
||||||
|
|
||||||
// maybe setting has been changed? if so, restart this task at new rate
|
// maybe setting has been changed? if so, restart this task at new rate
|
||||||
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) { P.p.startAutoLeaveTask(true); }
|
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) { P.p.startAutoLeaveTask(true); }
|
||||||
|
@ -27,30 +27,19 @@ public class LazyLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LazyLocation(final String worldName, final double x, final double y, final double z, final float yaw, final float pitch) {
|
public LazyLocation(final String worldName, final double x, final double y, final double z, final float yaw, final float pitch) {
|
||||||
this.worldName = worldName;
|
this.worldName = worldName; this.x = x; this.y = y; this.z = z; this.yaw = yaw; this.pitch = pitch;
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.yaw = yaw;
|
|
||||||
this.pitch = pitch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This returns the actual Location
|
// This returns the actual Location
|
||||||
public final Location getLocation() {
|
public final Location getLocation() {
|
||||||
// make sure Location is initialized before returning it
|
// make sure Location is initialized before returning it
|
||||||
initLocation();
|
initLocation(); return location;
|
||||||
return location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// change the Location
|
// change the Location
|
||||||
public final void setLocation(Location loc) {
|
public final void setLocation(Location loc) {
|
||||||
this.location = loc;
|
this.location = loc; this.worldName = loc.getWorld().getName(); this.x = loc.getX(); this.y = loc.getY();
|
||||||
this.worldName = loc.getWorld().getName();
|
this.z = loc.getZ(); this.yaw = loc.getYaw(); this.pitch = loc.getPitch();
|
||||||
this.x = loc.getX();
|
|
||||||
this.y = loc.getY();
|
|
||||||
this.z = loc.getZ();
|
|
||||||
this.yaw = loc.getYaw();
|
|
||||||
this.pitch = loc.getPitch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,8 +49,7 @@ public class LazyLocation {
|
|||||||
if (location != null) { return; }
|
if (location != null) { return; }
|
||||||
|
|
||||||
// get World; hopefully it's initialized at this point
|
// get World; hopefully it's initialized at this point
|
||||||
World world = Bukkit.getWorld(worldName);
|
World world = Bukkit.getWorld(worldName); if (world == null) { return; }
|
||||||
if (world == null) { return; }
|
|
||||||
|
|
||||||
// store the Location for future calls, and pass it on
|
// store the Location for future calls, and pass it on
|
||||||
location = new Location(world, x, y, z, yaw, pitch);
|
location = new Location(world, x, y, z, yaw, pitch);
|
||||||
|
@ -19,27 +19,20 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
@Override
|
@Override
|
||||||
public Map<FLocation, Set<String>> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public Map<FLocation, Set<String>> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
try {
|
try {
|
||||||
JsonObject obj = json.getAsJsonObject();
|
JsonObject obj = json.getAsJsonObject(); if (obj == null) {
|
||||||
if (obj == null) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>();
|
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>();
|
||||||
Set<String> nameSet;
|
Set<String> nameSet; Iterator<JsonElement> iter; String worldName; String[] coords; int x, z;
|
||||||
Iterator<JsonElement> iter;
|
|
||||||
String worldName;
|
|
||||||
String[] coords;
|
|
||||||
int x, z;
|
|
||||||
|
|
||||||
for (Entry<String, JsonElement> entry : obj.entrySet()) {
|
for (Entry<String, JsonElement> entry : obj.entrySet()) {
|
||||||
worldName = entry.getKey();
|
worldName = entry.getKey();
|
||||||
for (Entry<String, JsonElement> entry2 : entry.getValue().getAsJsonObject().entrySet()) {
|
for (Entry<String, JsonElement> entry2 : entry.getValue().getAsJsonObject().entrySet()) {
|
||||||
coords = entry2.getKey().trim().split("[,\\s]+");
|
coords = entry2.getKey().trim().split("[,\\s]+"); x = Integer.parseInt(coords[0]);
|
||||||
x = Integer.parseInt(coords[0]);
|
|
||||||
z = Integer.parseInt(coords[1]);
|
z = Integer.parseInt(coords[1]);
|
||||||
|
|
||||||
nameSet = new HashSet<String>();
|
nameSet = new HashSet<String>(); iter = entry2.getValue().getAsJsonArray().iterator();
|
||||||
iter = entry2.getValue().getAsJsonArray().iterator();
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
nameSet.add(iter.next().getAsString());
|
nameSet.add(iter.next().getAsString());
|
||||||
}
|
}
|
||||||
@ -63,27 +56,18 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (src != null) {
|
if (src != null) {
|
||||||
FLocation loc;
|
FLocation loc; String locWorld; Set<String> nameSet; Iterator<String> iter; JsonArray nameArray;
|
||||||
String locWorld;
|
|
||||||
Set<String> nameSet;
|
|
||||||
Iterator<String> iter;
|
|
||||||
JsonArray nameArray;
|
|
||||||
JsonPrimitive nameElement;
|
JsonPrimitive nameElement;
|
||||||
|
|
||||||
for (Entry<FLocation, Set<String>> entry : src.entrySet()) {
|
for (Entry<FLocation, Set<String>> entry : src.entrySet()) {
|
||||||
loc = entry.getKey();
|
loc = entry.getKey(); locWorld = loc.getWorldName(); nameSet = entry.getValue();
|
||||||
locWorld = loc.getWorldName();
|
|
||||||
nameSet = entry.getValue();
|
|
||||||
|
|
||||||
if (nameSet == null || nameSet.isEmpty()) {
|
if (nameSet == null || nameSet.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nameArray = new JsonArray();
|
nameArray = new JsonArray(); iter = nameSet.iterator(); while (iter.hasNext()) {
|
||||||
iter = nameSet.iterator();
|
nameElement = new JsonPrimitive(iter.next()); nameArray.add(nameElement);
|
||||||
while (iter.hasNext()) {
|
|
||||||
nameElement = new JsonPrimitive(iter.next());
|
|
||||||
nameArray.add(nameElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj.has(locWorld)) {
|
if (!obj.has(locWorld)) {
|
||||||
@ -92,8 +76,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
|
|
||||||
obj.get(locWorld).getAsJsonObject().add(loc.getCoordString(), nameArray);
|
obj.get(locWorld).getAsJsonObject().add(loc.getCoordString(), nameArray);
|
||||||
}
|
}
|
||||||
}
|
} return obj;
|
||||||
return obj;
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -97,12 +97,10 @@ public final class Metrics {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
// load the config
|
// load the config
|
||||||
configurationFile = getConfigFile();
|
configurationFile = getConfigFile(); configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||||
configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
|
||||||
|
|
||||||
// add some defaults
|
// add some defaults
|
||||||
configuration.addDefault("opt-out", false);
|
configuration.addDefault("opt-out", false); configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
|
||||||
configuration.addDefault("debug", false);
|
configuration.addDefault("debug", false);
|
||||||
|
|
||||||
// Do we need to create the file?
|
// Do we need to create the file?
|
||||||
@ -112,8 +110,7 @@ public final class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the guid then
|
// Load the guid then
|
||||||
guid = configuration.getString("guid");
|
guid = configuration.getString("guid"); debug = configuration.getBoolean("debug", false);
|
||||||
debug = configuration.getBoolean("debug", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,8 +143,7 @@ public final class Metrics {
|
|||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
// Disable Task, if it is running and the server owner decided to opt-out
|
// Disable Task, if it is running and the server owner decided to opt-out
|
||||||
if (isOptOut() && task != null) {
|
if (isOptOut() && task != null) {
|
||||||
task.cancel();
|
task.cancel(); task = null;
|
||||||
task = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,8 +186,7 @@ public final class Metrics {
|
|||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
// Check if the server owner has already set opt-out, if not, set it.
|
// Check if the server owner has already set opt-out, if not, set it.
|
||||||
if (isOptOut()) {
|
if (isOptOut()) {
|
||||||
configuration.set("opt-out", false);
|
configuration.set("opt-out", false); configuration.save(configurationFile);
|
||||||
configuration.save(configurationFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable Task, if it is not running
|
// Enable Task, if it is not running
|
||||||
@ -211,14 +206,12 @@ public final class Metrics {
|
|||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
// Check if the server owner has already set opt-out, if not, set it.
|
// Check if the server owner has already set opt-out, if not, set it.
|
||||||
if (!isOptOut()) {
|
if (!isOptOut()) {
|
||||||
configuration.set("opt-out", true);
|
configuration.set("opt-out", true); configuration.save(configurationFile);
|
||||||
configuration.save(configurationFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Task, if it is running
|
// Disable Task, if it is running
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
task.cancel();
|
task.cancel(); task = null;
|
||||||
task = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,30 +238,24 @@ public final class Metrics {
|
|||||||
*/
|
*/
|
||||||
private void postPlugin(boolean isPing) throws IOException {
|
private void postPlugin(boolean isPing) throws IOException {
|
||||||
// Server software specific section
|
// Server software specific section
|
||||||
PluginDescriptionFile description = plugin.getDescription();
|
PluginDescriptionFile description = plugin.getDescription(); String pluginName = description.getName();
|
||||||
String pluginName = description.getName();
|
|
||||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||||
String pluginVersion = description.getVersion();
|
String pluginVersion = description.getVersion(); String serverVersion = Bukkit.getVersion();
|
||||||
String serverVersion = Bukkit.getVersion();
|
|
||||||
int playersOnline = Bukkit.getServer().getOnlinePlayers().size();
|
int playersOnline = Bukkit.getServer().getOnlinePlayers().size();
|
||||||
|
|
||||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||||
|
|
||||||
// Construct the post data
|
// Construct the post data
|
||||||
StringBuilder json = new StringBuilder(1024);
|
StringBuilder json = new StringBuilder(1024); json.append('{');
|
||||||
json.append('{');
|
|
||||||
|
|
||||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||||
appendJSONPair(json, "guid", guid);
|
appendJSONPair(json, "guid", guid); appendJSONPair(json, "plugin_version", pluginVersion);
|
||||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
|
||||||
appendJSONPair(json, "server_version", serverVersion);
|
appendJSONPair(json, "server_version", serverVersion);
|
||||||
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
||||||
|
|
||||||
// New data as of R6
|
// New data as of R6
|
||||||
String osname = System.getProperty("os.name");
|
String osname = System.getProperty("os.name"); String osarch = System.getProperty("os.arch");
|
||||||
String osarch = System.getProperty("os.arch");
|
String osversion = System.getProperty("os.version"); String java_version = System.getProperty("java.version");
|
||||||
String osversion = System.getProperty("os.version");
|
|
||||||
String java_version = System.getProperty("java.version");
|
|
||||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||||
|
|
||||||
// normalize os arch .. amd64 -> x86_64
|
// normalize os arch .. amd64 -> x86_64
|
||||||
@ -276,12 +263,9 @@ public final class Metrics {
|
|||||||
osarch = "x86_64";
|
osarch = "x86_64";
|
||||||
}
|
}
|
||||||
|
|
||||||
appendJSONPair(json, "osname", osname);
|
appendJSONPair(json, "osname", osname); appendJSONPair(json, "osarch", osarch);
|
||||||
appendJSONPair(json, "osarch", osarch);
|
appendJSONPair(json, "osversion", osversion); appendJSONPair(json, "cores", Integer.toString(coreCount));
|
||||||
appendJSONPair(json, "osversion", osversion);
|
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0"); appendJSONPair(json, "java_version", java_version);
|
||||||
appendJSONPair(json, "cores", Integer.toString(coreCount));
|
|
||||||
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
|
|
||||||
appendJSONPair(json, "java_version", java_version);
|
|
||||||
|
|
||||||
// If we're pinging, append it
|
// If we're pinging, append it
|
||||||
if (isPing) {
|
if (isPing) {
|
||||||
@ -301,14 +285,12 @@ public final class Metrics {
|
|||||||
// It does not reroute POST requests so we need to go around it
|
// It does not reroute POST requests so we need to go around it
|
||||||
if (isMineshafterPresent()) {
|
if (isMineshafterPresent()) {
|
||||||
connection = url.openConnection(Proxy.NO_PROXY);
|
connection = url.openConnection(Proxy.NO_PROXY);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
connection = url.openConnection();
|
connection = url.openConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
byte[] uncompressed = json.toString().getBytes();
|
byte[] uncompressed = json.toString().getBytes(); byte[] compressed = gzip(json.toString());
|
||||||
byte[] compressed = gzip(json.toString());
|
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
|
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
|
||||||
@ -325,23 +307,19 @@ public final class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
OutputStream os = connection.getOutputStream();
|
OutputStream os = connection.getOutputStream(); os.write(compressed); os.flush();
|
||||||
os.write(compressed);
|
|
||||||
os.flush();
|
|
||||||
|
|
||||||
// Now read the response
|
// Now read the response
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
String response = reader.readLine();
|
String response = reader.readLine();
|
||||||
|
|
||||||
// close resources
|
// close resources
|
||||||
os.close();
|
os.close(); reader.close();
|
||||||
reader.close();
|
|
||||||
|
|
||||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
response = "null";
|
response = "null";
|
||||||
}
|
} else if (response.startsWith("7")) {
|
||||||
else if (response.startsWith("7")) {
|
|
||||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,12 +335,10 @@ public final class Metrics {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static byte[] gzip(String input) {
|
public static byte[] gzip(String input) {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null;
|
||||||
GZIPOutputStream gzos = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
gzos = new GZIPOutputStream(baos);
|
gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8"));
|
||||||
gzos.write(input.getBytes("UTF-8"));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -384,8 +360,7 @@ public final class Metrics {
|
|||||||
*/
|
*/
|
||||||
private boolean isMineshafterPresent() {
|
private boolean isMineshafterPresent() {
|
||||||
try {
|
try {
|
||||||
Class.forName("mineshafter.MineServer");
|
Class.forName("mineshafter.MineServer"); return true;
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -405,8 +380,7 @@ public final class Metrics {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (value.equals("0") || !value.endsWith("0")) {
|
if (value.equals("0") || !value.endsWith("0")) {
|
||||||
Double.parseDouble(value);
|
Double.parseDouble(value); isValueNumeric = true;
|
||||||
isValueNumeric = true;
|
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
isValueNumeric = false;
|
isValueNumeric = false;
|
||||||
@ -416,13 +390,11 @@ public final class Metrics {
|
|||||||
json.append(',');
|
json.append(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
json.append(escapeJSON(key));
|
json.append(escapeJSON(key)); json.append(':');
|
||||||
json.append(':');
|
|
||||||
|
|
||||||
if (isValueNumeric) {
|
if (isValueNumeric) {
|
||||||
json.append(value);
|
json.append(value);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
json.append(escapeJSON(value));
|
json.append(escapeJSON(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -437,40 +409,21 @@ public final class Metrics {
|
|||||||
private static String escapeJSON(String text) {
|
private static String escapeJSON(String text) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append('"');
|
builder.append('"'); for (int index = 0; index < text.length(); index++) {
|
||||||
for (int index = 0; index < text.length(); index++) {
|
|
||||||
char chr = text.charAt(index);
|
char chr = text.charAt(index);
|
||||||
|
|
||||||
switch (chr) {
|
switch (chr) {
|
||||||
case '"':
|
case '"': case '\\': builder.append('\\'); builder.append(chr); break;
|
||||||
case '\\':
|
case '\b': builder.append("\\b"); break; case '\t': builder.append("\\t"); break;
|
||||||
builder.append('\\');
|
case '\n': builder.append("\\n"); break; case '\r': builder.append("\\r"); break;
|
||||||
|
default: if (chr < ' ') {
|
||||||
|
String t = "000" + Integer.toHexString(chr);
|
||||||
|
builder.append("\\u").append(t.substring(t.length() - 4));
|
||||||
|
} else {
|
||||||
builder.append(chr);
|
builder.append(chr);
|
||||||
break;
|
} break;
|
||||||
case '\b':
|
|
||||||
builder.append("\\b");
|
|
||||||
break;
|
|
||||||
case '\t':
|
|
||||||
builder.append("\\t");
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
builder.append("\\n");
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
builder.append("\\r");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (chr < ' ') {
|
|
||||||
String t = "000" + Integer.toHexString(chr);
|
|
||||||
builder.append("\\u").append(t.substring(t.length() - 4));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
builder.append(chr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
} builder.append('"');
|
||||||
builder.append('"');
|
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ public class MiscUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = entity.getClass().getSimpleName();
|
String name = entity.getClass().getSimpleName(); name = name.substring(5); // Remove "Craft"
|
||||||
name = name.substring(5); // Remove "Craft"
|
|
||||||
|
|
||||||
return EntityType.fromName(name);
|
return EntityType.fromName(name);
|
||||||
}
|
}
|
||||||
@ -25,9 +24,7 @@ public class MiscUtil {
|
|||||||
long[] values = new long[(int) Math.abs(end - start) + 1];
|
long[] values = new long[(int) Math.abs(end - start) + 1];
|
||||||
|
|
||||||
if (end < start) {
|
if (end < start) {
|
||||||
long oldstart = start;
|
long oldstart = start; start = end; end = oldstart;
|
||||||
start = end;
|
|
||||||
end = oldstart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (long i = start; i <= end; i++) {
|
for (long i = start; i <= end; i++) {
|
||||||
@ -38,25 +35,18 @@ public class MiscUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// TODO create tag whitelist!!
|
/// TODO create tag whitelist!!
|
||||||
public static HashSet<String> substanceChars = new HashSet<String>(Arrays.asList(new String[]{
|
public static HashSet<String> substanceChars = new HashSet<String>(Arrays.asList(new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}));
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
|
||||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
||||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
|
|
||||||
"s", "t", "u", "v", "w", "x", "y", "z"
|
|
||||||
}));
|
|
||||||
|
|
||||||
public static String getComparisonString(String str) {
|
public static String getComparisonString(String str) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
|
|
||||||
str = ChatColor.stripColor(str);
|
str = ChatColor.stripColor(str); str = str.toLowerCase();
|
||||||
str = str.toLowerCase();
|
|
||||||
|
|
||||||
for (char c : str.toCharArray()) {
|
for (char c : str.toCharArray()) {
|
||||||
if (substanceChars.contains(String.valueOf(c))) {
|
if (substanceChars.contains(String.valueOf(c))) {
|
||||||
ret += c;
|
ret += c;
|
||||||
}
|
}
|
||||||
}
|
} return ret.toLowerCase();
|
||||||
return ret.toLowerCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,18 +20,14 @@ public class MyLocationTypeAdapter implements JsonDeserializer<LazyLocation>, Js
|
|||||||
try {
|
try {
|
||||||
JsonObject obj = json.getAsJsonObject();
|
JsonObject obj = json.getAsJsonObject();
|
||||||
|
|
||||||
String worldName = obj.get(WORLD).getAsString();
|
String worldName = obj.get(WORLD).getAsString(); double x = obj.get(X).getAsDouble();
|
||||||
double x = obj.get(X).getAsDouble();
|
double y = obj.get(Y).getAsDouble(); double z = obj.get(Z).getAsDouble();
|
||||||
double y = obj.get(Y).getAsDouble();
|
float yaw = obj.get(YAW).getAsFloat(); float pitch = obj.get(PITCH).getAsFloat();
|
||||||
double z = obj.get(Z).getAsDouble();
|
|
||||||
float yaw = obj.get(YAW).getAsFloat();
|
|
||||||
float pitch = obj.get(PITCH).getAsFloat();
|
|
||||||
|
|
||||||
return new LazyLocation(worldName, x, y, z, yaw, pitch);
|
return new LazyLocation(worldName, x, y, z, yaw, pitch);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace(); P.p.log(Level.WARNING, "Error encountered while deserializing a LazyLocation.");
|
||||||
P.p.log(Level.WARNING, "Error encountered while deserializing a LazyLocation.");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,17 +37,12 @@ public class MyLocationTypeAdapter implements JsonDeserializer<LazyLocation>, Js
|
|||||||
JsonObject obj = new JsonObject();
|
JsonObject obj = new JsonObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
obj.addProperty(WORLD, src.getWorldName());
|
obj.addProperty(WORLD, src.getWorldName()); obj.addProperty(X, src.getX()); obj.addProperty(Y, src.getY());
|
||||||
obj.addProperty(X, src.getX());
|
obj.addProperty(Z, src.getZ()); obj.addProperty(YAW, src.getYaw()); obj.addProperty(PITCH, src.getPitch());
|
||||||
obj.addProperty(Y, src.getY());
|
|
||||||
obj.addProperty(Z, src.getZ());
|
|
||||||
obj.addProperty(YAW, src.getYaw());
|
|
||||||
obj.addProperty(PITCH, src.getPitch());
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace(); P.p.log(Level.WARNING, "Error encountered while serializing a LazyLocation.");
|
||||||
P.p.log(Level.WARNING, "Error encountered while serializing a LazyLocation.");
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ public class RelationUtil {
|
|||||||
public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) {
|
public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
|
|
||||||
Faction thatFaction = getFaction(that);
|
Faction thatFaction = getFaction(that); if (thatFaction == null) {
|
||||||
if (thatFaction == null) {
|
|
||||||
return "ERROR"; // ERROR
|
return "ERROR"; // ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,20 +22,15 @@ public class RelationUtil {
|
|||||||
if (that instanceof Faction) {
|
if (that instanceof Faction) {
|
||||||
if (me instanceof FPlayer && myFaction == thatFaction) {
|
if (me instanceof FPlayer && myFaction == thatFaction) {
|
||||||
ret = "your faction";
|
ret = "your faction";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ret = thatFaction.getTag();
|
ret = thatFaction.getTag();
|
||||||
}
|
}
|
||||||
}
|
} else if (that instanceof FPlayer) {
|
||||||
else if (that instanceof FPlayer) {
|
FPlayer fplayerthat = (FPlayer) that; if (that == me) {
|
||||||
FPlayer fplayerthat = (FPlayer) that;
|
|
||||||
if (that == me) {
|
|
||||||
ret = "you";
|
ret = "you";
|
||||||
}
|
} else if (thatFaction == myFaction) {
|
||||||
else if (thatFaction == myFaction) {
|
|
||||||
ret = fplayerthat.getNameAndTitle();
|
ret = fplayerthat.getNameAndTitle();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ret = fplayerthat.getNameAndTag();
|
ret = fplayerthat.getNameAndTag();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,13 +51,11 @@ public class RelationUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) {
|
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) {
|
||||||
Faction fthat = getFaction(that);
|
Faction fthat = getFaction(that); if (fthat == null) {
|
||||||
if (fthat == null) {
|
|
||||||
return Relation.NEUTRAL; // ERROR
|
return Relation.NEUTRAL; // ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction fme = getFaction(me);
|
Faction fme = getFaction(me); if (fme == null) {
|
||||||
if (fme == null) {
|
|
||||||
return Relation.NEUTRAL; // ERROR
|
return Relation.NEUTRAL; // ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +92,7 @@ public class RelationUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) {
|
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) {
|
||||||
Faction thatFaction = getFaction(that);
|
Faction thatFaction = getFaction(that); if (thatFaction != null) {
|
||||||
if (thatFaction != null) {
|
|
||||||
if (thatFaction.isPeaceful() && thatFaction != getFaction(me)) {
|
if (thatFaction.isPeaceful() && thatFaction != getFaction(me)) {
|
||||||
return Conf.colorPeaceful;
|
return Conf.colorPeaceful;
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,11 @@ public abstract class SpiralTask implements Runnable {
|
|||||||
// limit is determined based on spiral leg length for given radius; see insideRadius()
|
// limit is determined based on spiral leg length for given radius; see insideRadius()
|
||||||
this.limit = (radius - 1) * 2;
|
this.limit = (radius - 1) * 2;
|
||||||
|
|
||||||
this.world = Bukkit.getWorld(fLocation.getWorldName());
|
this.world = Bukkit.getWorld(fLocation.getWorldName()); if (this.world == null) {
|
||||||
if (this.world == null) {
|
P.p.log(Level.WARNING, "[SpiralTask] A valid world must be specified!"); this.stop(); return;
|
||||||
P.p.log(Level.WARNING, "[SpiralTask] A valid world must be specified!");
|
|
||||||
this.stop();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.x = (int) fLocation.getX();
|
this.x = (int) fLocation.getX(); this.z = (int) fLocation.getZ();
|
||||||
this.z = (int) fLocation.getZ();
|
|
||||||
|
|
||||||
this.readyToGo = true;
|
this.readyToGo = true;
|
||||||
|
|
||||||
@ -98,8 +94,7 @@ public abstract class SpiralTask implements Runnable {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public final void setTaskID(int ID) {
|
public final void setTaskID(int ID) {
|
||||||
if (ID == -1) { this.stop(); }
|
if (ID == -1) { this.stop(); } taskID = ID;
|
||||||
taskID = ID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void run() {
|
public final void run() {
|
||||||
@ -118,8 +113,7 @@ public abstract class SpiralTask implements Runnable {
|
|||||||
while (now() < loopStartTime + 20) {
|
while (now() < loopStartTime + 20) {
|
||||||
// run the primary task on the current X/Z coordinates
|
// run the primary task on the current X/Z coordinates
|
||||||
if (!this.work()) {
|
if (!this.work()) {
|
||||||
this.finish();
|
this.finish(); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// move on to next chunk in spiral
|
// move on to next chunk in spiral
|
||||||
@ -140,28 +134,22 @@ public abstract class SpiralTask implements Runnable {
|
|||||||
|
|
||||||
// if we're outside the radius, we're done
|
// if we're outside the radius, we're done
|
||||||
if (!this.insideRadius()) { return false; }
|
if (!this.insideRadius()) { return false; }
|
||||||
}
|
} else { // one leg/side of the spiral down...
|
||||||
else { // one leg/side of the spiral down...
|
current = 0; isZLeg ^= true;
|
||||||
current = 0;
|
|
||||||
isZLeg ^= true;
|
|
||||||
// every second leg (between X and Z legs, negative or positive), length increases
|
// every second leg (between X and Z legs, negative or positive), length increases
|
||||||
if (isZLeg) {
|
if (isZLeg) {
|
||||||
isNeg ^= true;
|
isNeg ^= true; length++;
|
||||||
length++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// move one chunk further in the appropriate direction
|
// move one chunk further in the appropriate direction
|
||||||
if (isZLeg) { z += (isNeg) ? -1 : 1; }
|
if (isZLeg) { z += (isNeg) ? -1 : 1; } else { x += (isNeg) ? -1 : 1; }
|
||||||
else { x += (isNeg) ? -1 : 1; }
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean insideRadius() {
|
public final boolean insideRadius() {
|
||||||
boolean inside = current < limit;
|
boolean inside = current < limit; if (!inside) { this.finish(); } return inside;
|
||||||
if (!inside) { this.finish(); }
|
|
||||||
return inside;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for successful completion
|
// for successful completion
|
||||||
@ -174,9 +162,7 @@ public abstract class SpiralTask implements Runnable {
|
|||||||
public final void stop() {
|
public final void stop() {
|
||||||
if (!this.valid()) { return; }
|
if (!this.valid()) { return; }
|
||||||
|
|
||||||
readyToGo = false;
|
readyToGo = false; Bukkit.getServer().getScheduler().cancelTask(taskID); taskID = -1;
|
||||||
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
|
||||||
taskID = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// is this task still valid/workable?
|
// is this task still valid/workable?
|
||||||
|
@ -14,7 +14,6 @@ public class FCommandHandler implements CommandExecutor {
|
|||||||
if (P.p.logPlayerCommands()) {
|
if (P.p.logPlayerCommands()) {
|
||||||
Bukkit.getLogger().info("[PLAYER_COMMAND] " + sender.getName() + ": " + cmd.getName() + args);
|
Bukkit.getLogger().info("[PLAYER_COMMAND] " + sender.getName() + ": " + cmd.getName() + args);
|
||||||
}
|
}
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
public List<MCommand<?>> subCommands;
|
public List<MCommand<?>> subCommands;
|
||||||
|
|
||||||
public void addSubCommand(MCommand<?> subCommand) {
|
public void addSubCommand(MCommand<?> subCommand) {
|
||||||
subCommand.commandChain.addAll(this.commandChain);
|
subCommand.commandChain.addAll(this.commandChain); subCommand.commandChain.add(this);
|
||||||
subCommand.commandChain.add(this);
|
|
||||||
this.subCommands.add(subCommand);
|
this.subCommands.add(subCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,13 +42,10 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
|
|
||||||
public String getHelpShort() {
|
public String getHelpShort() {
|
||||||
if (this.helpShort == null) {
|
if (this.helpShort == null) {
|
||||||
String pdesc = p.perm.getPermissionDescription(this.permission);
|
String pdesc = p.perm.getPermissionDescription(this.permission); if (pdesc != null) {
|
||||||
if (pdesc != null) {
|
|
||||||
return pdesc;
|
return pdesc;
|
||||||
}
|
} return "*info unavailable*";
|
||||||
return "*info unavailable*";
|
} return this.helpShort;
|
||||||
}
|
|
||||||
return this.helpShort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> helpLong;
|
public List<String> helpLong;
|
||||||
@ -73,40 +69,27 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
|
|
||||||
this.allowNoSlashAccess = false;
|
this.allowNoSlashAccess = false;
|
||||||
|
|
||||||
this.subCommands = new ArrayList<MCommand<?>>();
|
this.subCommands = new ArrayList<MCommand<?>>(); this.aliases = new ArrayList<String>();
|
||||||
this.aliases = new ArrayList<String>();
|
|
||||||
|
|
||||||
this.requiredArgs = new ArrayList<String>();
|
this.requiredArgs = new ArrayList<String>(); this.optionalArgs = new LinkedHashMap<String, String>();
|
||||||
this.optionalArgs = new LinkedHashMap<String, String>();
|
|
||||||
|
|
||||||
this.helpShort = null;
|
this.helpShort = null; this.helpLong = new ArrayList<String>(); this.visibility = CommandVisibility.VISIBLE;
|
||||||
this.helpLong = new ArrayList<String>();
|
|
||||||
this.visibility = CommandVisibility.VISIBLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The commandChain is a list of the parent command chain used to get to this command.
|
// The commandChain is a list of the parent command chain used to get to this command.
|
||||||
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
||||||
// Set the execution-time specific variables
|
// Set the execution-time specific variables
|
||||||
this.sender = sender;
|
this.sender = sender; if (sender instanceof Player) {
|
||||||
if (sender instanceof Player) {
|
this.me = (Player) sender; this.senderIsConsole = false;
|
||||||
this.me = (Player) sender;
|
} else {
|
||||||
this.senderIsConsole = false;
|
this.me = null; this.senderIsConsole = true;
|
||||||
}
|
} this.args = args; this.commandChain = commandChain;
|
||||||
else {
|
|
||||||
this.me = null;
|
|
||||||
this.senderIsConsole = true;
|
|
||||||
}
|
|
||||||
this.args = args;
|
|
||||||
this.commandChain = commandChain;
|
|
||||||
|
|
||||||
// Is there a matching sub command?
|
// Is there a matching sub command?
|
||||||
if (args.size() > 0) {
|
if (args.size() > 0) {
|
||||||
for (MCommand<?> subCommand : this.subCommands) {
|
for (MCommand<?> subCommand : this.subCommands) {
|
||||||
if (subCommand.aliases.contains(args.get(0))) {
|
if (subCommand.aliases.contains(args.get(0))) {
|
||||||
args.remove(0);
|
args.remove(0); commandChain.add(this); subCommand.execute(sender, args, commandChain); return;
|
||||||
commandChain.add(this);
|
|
||||||
subCommand.execute(sender, args, commandChain);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,24 +141,19 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
if (this.senderMustBePlayer && !(sender instanceof Player)) {
|
if (this.senderMustBePlayer && !(sender instanceof Player)) {
|
||||||
if (informSenderIfNot) {
|
if (informSenderIfNot) {
|
||||||
msg(Lang.commandSenderMustBePlayer);
|
msg(Lang.commandSenderMustBePlayer);
|
||||||
}
|
} return false;
|
||||||
return false;
|
} return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) {
|
public boolean validSenderPermissions(CommandSender sender, boolean informSenderIfNot) {
|
||||||
if (this.permission == null) { return true; }
|
if (this.permission == null) { return true; } return p.perm.has(sender, this.permission, informSenderIfNot);
|
||||||
return p.perm.has(sender, this.permission, informSenderIfNot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validArgs(List<String> args, CommandSender sender) {
|
public boolean validArgs(List<String> args, CommandSender sender) {
|
||||||
if (args.size() < this.requiredArgs.size()) {
|
if (args.size() < this.requiredArgs.size()) {
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
msg(Lang.commandToFewArgs);
|
msg(Lang.commandToFewArgs); sender.sendMessage(this.getUseageTemplate());
|
||||||
sender.sendMessage(this.getUseageTemplate());
|
} return false;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) {
|
if (args.size() > this.requiredArgs.size() + this.optionalArgs.size() && this.errorOnToManyArgs) {
|
||||||
@ -184,10 +162,8 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size());
|
List<String> theToMany = args.subList(this.requiredArgs.size() + this.optionalArgs.size(), args.size());
|
||||||
msg(Lang.commandToManyArgs, TextUtil.implode(theToMany, " "));
|
msg(Lang.commandToManyArgs, TextUtil.implode(theToMany, " "));
|
||||||
sender.sendMessage(this.getUseageTemplate());
|
sender.sendMessage(this.getUseageTemplate());
|
||||||
}
|
} return false;
|
||||||
return false;
|
} return true;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validArgs(List<String> args) {
|
public boolean validArgs(List<String> args) {
|
||||||
@ -199,13 +175,10 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public String getUseageTemplate(List<MCommand<?>> commandChain, boolean addShortHelp) {
|
public String getUseageTemplate(List<MCommand<?>> commandChain, boolean addShortHelp) {
|
||||||
StringBuilder ret = new StringBuilder();
|
StringBuilder ret = new StringBuilder(); ret.append(p.txt.parseTags("<c>")); ret.append('/');
|
||||||
ret.append(p.txt.parseTags("<c>"));
|
|
||||||
ret.append('/');
|
|
||||||
|
|
||||||
for (MCommand<?> mc : commandChain) {
|
for (MCommand<?> mc : commandChain) {
|
||||||
ret.append(TextUtil.implode(mc.aliases, ","));
|
ret.append(TextUtil.implode(mc.aliases, ",")); ret.append(' ');
|
||||||
ret.append(' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.append(TextUtil.implode(this.aliases, ","));
|
ret.append(TextUtil.implode(this.aliases, ","));
|
||||||
@ -217,24 +190,19 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, String> optionalArg : this.optionalArgs.entrySet()) {
|
for (Entry<String, String> optionalArg : this.optionalArgs.entrySet()) {
|
||||||
String val = optionalArg.getValue();
|
String val = optionalArg.getValue(); if (val == null) {
|
||||||
if (val == null) {
|
|
||||||
val = "";
|
val = "";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
val = "=" + val;
|
val = "=" + val;
|
||||||
}
|
} args.add("[" + optionalArg.getKey() + val + "]");
|
||||||
args.add("[" + optionalArg.getKey() + val + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() > 0) {
|
if (args.size() > 0) {
|
||||||
ret.append(p.txt.parseTags("<p> "));
|
ret.append(p.txt.parseTags("<p> ")); ret.append(TextUtil.implode(args, " "));
|
||||||
ret.append(TextUtil.implode(args, " "));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addShortHelp) {
|
if (addShortHelp) {
|
||||||
ret.append(p.txt.parseTags(" <i>"));
|
ret.append(p.txt.parseTags(" <i>")); ret.append(this.getHelpShort());
|
||||||
ret.append(this.getHelpShort());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret.toString();
|
return ret.toString();
|
||||||
@ -274,16 +242,14 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
public boolean argIsSet(int idx) {
|
public boolean argIsSet(int idx) {
|
||||||
if (this.args.size() < idx + 1) {
|
if (this.args.size() < idx + 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// STRING ======================
|
// STRING ======================
|
||||||
public String argAsString(int idx, String def) {
|
public String argAsString(int idx, String def) {
|
||||||
if (this.args.size() < idx + 1) {
|
if (this.args.size() < idx + 1) {
|
||||||
return def;
|
return def;
|
||||||
}
|
} return this.args.get(idx);
|
||||||
return this.args.get(idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String argAsString(int idx) {
|
public String argAsString(int idx) {
|
||||||
@ -292,10 +258,8 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
|
|
||||||
// INT ======================
|
// INT ======================
|
||||||
public Integer strAsInt(String str, Integer def) {
|
public Integer strAsInt(String str, Integer def) {
|
||||||
if (str == null) { return def; }
|
if (str == null) { return def; } try {
|
||||||
try {
|
Integer ret = Integer.parseInt(str); return ret;
|
||||||
Integer ret = Integer.parseInt(str);
|
|
||||||
return ret;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
@ -311,10 +275,8 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
|
|
||||||
// Double ======================
|
// Double ======================
|
||||||
public Double strAsDouble(String str, Double def) {
|
public Double strAsDouble(String str, Double def) {
|
||||||
if (str == null) { return def; }
|
if (str == null) { return def; } try {
|
||||||
try {
|
Double ret = Double.parseDouble(str); return ret;
|
||||||
Double ret = Double.parseDouble(str);
|
|
||||||
return ret;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
@ -334,13 +296,11 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
if (str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1")) {
|
if (str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean argAsBool(int idx, boolean def) {
|
public Boolean argAsBool(int idx, boolean def) {
|
||||||
String str = this.argAsString(idx);
|
String str = this.argAsString(idx); if (str == null) { return def; }
|
||||||
if (str == null) { return def; }
|
|
||||||
|
|
||||||
return strAsBool(str);
|
return strAsBool(str);
|
||||||
}
|
}
|
||||||
@ -354,8 +314,7 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
Player ret = def;
|
Player ret = def;
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
Player player = Bukkit.getServer().getPlayer(name);
|
Player player = Bukkit.getServer().getPlayer(name); if (player != null) {
|
||||||
if (player != null) {
|
|
||||||
ret = player;
|
ret = player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,8 +343,7 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
Player ret = def;
|
Player ret = def;
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
List<Player> players = Bukkit.getServer().matchPlayer(name);
|
List<Player> players = Bukkit.getServer().matchPlayer(name); if (players.size() > 0) {
|
||||||
if (players.size() > 0) {
|
|
||||||
ret = players.get(0);
|
ret = players.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,10 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
private long timeEnableStart;
|
private long timeEnableStart;
|
||||||
|
|
||||||
public boolean preEnable() {
|
public boolean preEnable() {
|
||||||
log("=== ENABLE START ===");
|
log("=== ENABLE START ==="); timeEnableStart = System.currentTimeMillis();
|
||||||
timeEnableStart = System.currentTimeMillis();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Metrics metrics = new Metrics(this);
|
Metrics metrics = new Metrics(this); metrics.start();
|
||||||
metrics.start();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Failed to submit the stats :-(
|
// Failed to submit the stats :-(
|
||||||
}
|
}
|
||||||
@ -76,15 +74,13 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
this.getDataFolder().mkdirs();
|
this.getDataFolder().mkdirs();
|
||||||
|
|
||||||
// Create Utility Instances
|
// Create Utility Instances
|
||||||
this.perm = new PermUtil(this);
|
this.perm = new PermUtil(this); this.persist = new Persist(this);
|
||||||
this.persist = new Persist(this);
|
|
||||||
|
|
||||||
// GSON 2.1 is now embedded in CraftBukkit, used by the auto-updater: https://github.com/Bukkit/CraftBukkit/commit/0ed1d1fdbb1e0bc09a70bc7bfdf40c1de8411665
|
// GSON 2.1 is now embedded in CraftBukkit, used by the auto-updater: https://github.com/Bukkit/CraftBukkit/commit/0ed1d1fdbb1e0bc09a70bc7bfdf40c1de8411665
|
||||||
// if ( ! lib.require("gson.jar", "http://search.maven.org/remotecontent?filepath=com/google/code/gson/gson/2.1/gson-2.1.jar")) return false;
|
// if ( ! lib.require("gson.jar", "http://search.maven.org/remotecontent?filepath=com/google/code/gson/gson/2.1/gson-2.1.jar")) return false;
|
||||||
this.gson = this.getGsonBuilder().create();
|
this.gson = this.getGsonBuilder().create();
|
||||||
|
|
||||||
this.txt = new TextUtil();
|
this.txt = new TextUtil(); initTXT();
|
||||||
initTXT();
|
|
||||||
|
|
||||||
// attempt to get first command defined in plugin.yml as reference command, if any commands are defined in there
|
// attempt to get first command defined in plugin.yml as reference command, if any commands are defined in there
|
||||||
// reference command will be used to prevent "unknown command" console messages
|
// reference command will be used to prevent "unknown command" console messages
|
||||||
@ -110,8 +106,7 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
loadLang();
|
loadLang();
|
||||||
|
|
||||||
loadSuccessful = true;
|
loadSuccessful = true; return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postEnable() {
|
public void postEnable() {
|
||||||
@ -119,24 +114,16 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadLang() {
|
private void loadLang() {
|
||||||
File lang = new File(getDataFolder(), "lang.yml");
|
File lang = new File(getDataFolder(), "lang.yml"); OutputStream out = null;
|
||||||
OutputStream out = null;
|
InputStream defLangStream = this.getResource("lang.yml"); if (!lang.exists()) {
|
||||||
InputStream defLangStream = this.getResource("lang.yml");
|
|
||||||
if (!lang.exists()) {
|
|
||||||
try {
|
try {
|
||||||
getDataFolder().mkdir();
|
getDataFolder().mkdir(); lang.createNewFile(); if (defLangStream != null) {
|
||||||
lang.createNewFile();
|
out = new FileOutputStream(lang); int read; byte[] bytes = new byte[1024];
|
||||||
if (defLangStream != null) {
|
|
||||||
out = new FileOutputStream(lang);
|
|
||||||
int read;
|
|
||||||
byte[] bytes = new byte[1024];
|
|
||||||
|
|
||||||
while ((read = defLangStream.read(bytes)) != -1) {
|
while ((read = defLangStream.read(bytes)) != -1) {
|
||||||
out.write(bytes, 0, read);
|
out.write(bytes, 0, read);
|
||||||
}
|
} YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defLangStream);
|
||||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defLangStream);
|
TL.setFile(defConfig); return;
|
||||||
TL.setFile(defConfig);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(); // So they notice
|
e.printStackTrace(); // So they notice
|
||||||
@ -150,8 +137,7 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
} if (out != null) {
|
||||||
if (out != null) {
|
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -162,36 +148,30 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang);
|
YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang); for (TL item : TL.values()) {
|
||||||
for (TL item : TL.values()) {
|
|
||||||
if (conf.getString(item.getPath()) == null) {
|
if (conf.getString(item.getPath()) == null) {
|
||||||
conf.set(item.getPath(), item.getDefault());
|
conf.set(item.getPath(), item.getDefault());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TL.setFile(conf);
|
TL.setFile(conf); try {
|
||||||
try {
|
|
||||||
conf.save(lang);
|
conf.save(lang);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getLogger().log(Level.WARNING, "Factions: Failed to save lang.yml.");
|
getLogger().log(Level.WARNING, "Factions: Failed to save lang.yml.");
|
||||||
getLogger().log(Level.WARNING, "Factions: Report this stack trace to drtshock.");
|
getLogger().log(Level.WARNING, "Factions: Report this stack trace to drtshock."); e.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (saveTask != null) {
|
if (saveTask != null) {
|
||||||
this.getServer().getScheduler().cancelTask(saveTask);
|
this.getServer().getScheduler().cancelTask(saveTask); saveTask = null;
|
||||||
saveTask = null;
|
|
||||||
}
|
}
|
||||||
// only save data if plugin actually loaded successfully
|
// only save data if plugin actually loaded successfully
|
||||||
if (loadSuccessful) { EM.saveAllToDisc(); }
|
if (loadSuccessful) { EM.saveAllToDisc(); } log("Disabled");
|
||||||
log("Disabled");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suicide() {
|
public void suicide() {
|
||||||
log("Now I suicide!");
|
log("Now I suicide!"); this.getServer().getPluginManager().disablePlugin(this);
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -201,11 +181,7 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public GsonBuilder getGsonBuilder() {
|
public GsonBuilder getGsonBuilder() {
|
||||||
return new GsonBuilder()
|
return new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().serializeNulls().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE);
|
||||||
.setPrettyPrinting()
|
|
||||||
.disableHtmlEscaping()
|
|
||||||
.serializeNulls()
|
|
||||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -231,12 +207,10 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
public void initTXT() {
|
public void initTXT() {
|
||||||
this.addRawTags();
|
this.addRawTags();
|
||||||
|
|
||||||
Type type = new TypeToken<Map<String, String>>() {
|
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
||||||
}.getType();
|
|
||||||
|
|
||||||
Map<String, String> tagsFromFile = this.persist.load(type, "tags");
|
Map<String, String> tagsFromFile = this.persist.load(type, "tags");
|
||||||
if (tagsFromFile != null) { this.rawTags.putAll(tagsFromFile); }
|
if (tagsFromFile != null) { this.rawTags.putAll(tagsFromFile); } this.persist.save(this.rawTags, "tags");
|
||||||
this.persist.save(this.rawTags, "tags");
|
|
||||||
|
|
||||||
for (Entry<String, String> rawTag : this.rawTags.entrySet()) {
|
for (Entry<String, String> rawTag : this.rawTags.entrySet()) {
|
||||||
this.txt.tags.put(rawTag.getKey(), TextUtil.parseColor(rawTag.getValue()));
|
this.txt.tags.put(rawTag.getKey(), TextUtil.parseColor(rawTag.getValue()));
|
||||||
@ -257,10 +231,8 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleCommand(final CommandSender sender, String commandString, boolean testOnly, boolean async) {
|
public boolean handleCommand(final CommandSender sender, String commandString, boolean testOnly, boolean async) {
|
||||||
boolean noSlash = true;
|
boolean noSlash = true; if (commandString.startsWith("/")) {
|
||||||
if (commandString.startsWith("/")) {
|
noSlash = false; commandString = commandString.substring(1);
|
||||||
noSlash = false;
|
|
||||||
commandString = commandString.substring(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final MCommand<?> command : this.getBaseCommands()) {
|
for (final MCommand<?> command : this.getBaseCommands()) {
|
||||||
@ -283,14 +255,12 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
command.execute(sender, args);
|
command.execute(sender, args);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else { command.execute(sender, args); }
|
||||||
else { command.execute(sender, args); }
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleCommand(CommandSender sender, String commandString) {
|
public boolean handleCommand(CommandSender sender, String commandString) {
|
||||||
|
@ -28,8 +28,7 @@ public class MPluginSecretPlayerListener implements Listener {
|
|||||||
if (p.handleCommand(event.getPlayer(), event.getMessage())) {
|
if (p.handleCommand(event.getPlayer(), event.getMessage())) {
|
||||||
if (p.logPlayerCommands()) {
|
if (p.logPlayerCommands()) {
|
||||||
Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
|
Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
}
|
} event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,12 +37,10 @@ public class MPluginSecretPlayerListener implements Listener {
|
|||||||
if (p.handleCommand(event.getPlayer(), event.getMessage(), false, true)) {
|
if (p.handleCommand(event.getPlayer(), event.getMessage(), false, true)) {
|
||||||
if (p.logPlayerCommands()) {
|
if (p.logPlayerCommands()) {
|
||||||
Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
|
Bukkit.getLogger().info("[PLAYER_COMMAND] " + event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
}
|
} event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player speaker = event.getPlayer();
|
Player speaker = event.getPlayer(); String format = event.getFormat();
|
||||||
String format = event.getFormat();
|
|
||||||
format = format.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(speaker));
|
format = format.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(speaker));
|
||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
}
|
}
|
||||||
|
@ -71,13 +71,8 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public EntityCollection(Class<E> entityClass, Collection<E> entities, Map<String, E> id2entity, File file, Gson gson, boolean creative) {
|
public EntityCollection(Class<E> entityClass, Collection<E> entities, Map<String, E> id2entity, File file, Gson gson, boolean creative) {
|
||||||
this.entityClass = entityClass;
|
this.entityClass = entityClass; this.entities = entities; this.id2entity = id2entity; this.file = file;
|
||||||
this.entities = entities;
|
this.gson = gson; this.creative = creative; this.nextId = 1;
|
||||||
this.id2entity = id2entity;
|
|
||||||
this.file = file;
|
|
||||||
this.gson = gson;
|
|
||||||
this.creative = creative;
|
|
||||||
this.nextId = 1;
|
|
||||||
|
|
||||||
EM.setEntitiesCollectionForEntityClass(this.entityClass, this);
|
EM.setEntitiesCollectionForEntityClass(this.entityClass, this);
|
||||||
}
|
}
|
||||||
@ -99,24 +94,19 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public E get(String id) {
|
public E get(String id) {
|
||||||
if (this.creative) { return this.getCreative(id); }
|
if (this.creative) { return this.getCreative(id); } return id2entity.get(id);
|
||||||
return id2entity.get(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public E getCreative(String id) {
|
public E getCreative(String id) {
|
||||||
E e = id2entity.get(id);
|
E e = id2entity.get(id); if (e != null) { return e; } return this.create(id);
|
||||||
if (e != null) { return e; }
|
|
||||||
return this.create(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exists(String id) {
|
public boolean exists(String id) {
|
||||||
if (id == null) { return false; }
|
if (id == null) { return false; } return id2entity.get(id) != null;
|
||||||
return id2entity.get(id) != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public E getBestIdMatch(String pattern) {
|
public E getBestIdMatch(String pattern) {
|
||||||
String id = TextUtil.getBestStartWithCI(this.id2entity.keySet(), pattern);
|
String id = TextUtil.getBestStartWithCI(this.id2entity.keySet(), pattern); if (id == null) { return null; }
|
||||||
if (id == null) { return null; }
|
|
||||||
return this.id2entity.get(id);
|
return this.id2entity.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,18 +121,13 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
public synchronized E create(String id) {
|
public synchronized E create(String id) {
|
||||||
if (!this.isIdFree(id)) { return null; }
|
if (!this.isIdFree(id)) { return null; }
|
||||||
|
|
||||||
E e = null;
|
E e = null; try {
|
||||||
try {
|
|
||||||
e = this.entityClass.newInstance();
|
e = this.entityClass.newInstance();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
ignored.printStackTrace();
|
ignored.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
e.setId(id);
|
e.setId(id); this.entities.add(e); this.id2entity.put(e.getId(), e); this.updateNextIdForId(id); return e;
|
||||||
this.entities.add(e);
|
|
||||||
this.id2entity.put(e.getId(), e);
|
|
||||||
this.updateNextIdForId(id);
|
|
||||||
return e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -150,23 +135,16 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void attach(E entity) {
|
public void attach(E entity) {
|
||||||
if (entity.getId() != null) { return; }
|
if (entity.getId() != null) { return; } entity.setId(this.getNextId()); this.entities.add(entity);
|
||||||
entity.setId(this.getNextId());
|
|
||||||
this.entities.add(entity);
|
|
||||||
this.id2entity.put(entity.getId(), entity);
|
this.id2entity.put(entity.getId(), entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void detach(E entity) {
|
public void detach(E entity) {
|
||||||
entity.preDetach();
|
entity.preDetach(); this.entities.remove(entity); this.id2entity.remove(entity.getId()); entity.postDetach();
|
||||||
this.entities.remove(entity);
|
|
||||||
this.id2entity.remove(entity.getId());
|
|
||||||
entity.postDetach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void detach(String id) {
|
public void detach(String id) {
|
||||||
E entity = this.id2entity.get(id);
|
E entity = this.id2entity.get(id); if (entity == null) { return; } this.detach(entity);
|
||||||
if (entity == null) { return; }
|
|
||||||
this.detach(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean attached(E entity) {
|
public boolean attached(E entity) {
|
||||||
@ -185,18 +163,15 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
private boolean saveIsRunning = false;
|
private boolean saveIsRunning = false;
|
||||||
|
|
||||||
public boolean saveToDisc() {
|
public boolean saveToDisc() {
|
||||||
if (saveIsRunning) { return true; }
|
if (saveIsRunning) { return true; } saveIsRunning = true;
|
||||||
saveIsRunning = true;
|
|
||||||
|
|
||||||
Map<String, E> entitiesThatShouldBeSaved = new HashMap<String, E>();
|
Map<String, E> entitiesThatShouldBeSaved = new HashMap<String, E>(); for (E entity : this.entities) {
|
||||||
for (E entity : this.entities) {
|
|
||||||
if (entity.shouldBeSaved()) {
|
if (entity.shouldBeSaved()) {
|
||||||
entitiesThatShouldBeSaved.put(entity.getId(), entity);
|
entitiesThatShouldBeSaved.put(entity.getId(), entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveIsRunning = false;
|
saveIsRunning = false; return this.saveCore(this.file, entitiesThatShouldBeSaved);
|
||||||
return this.saveCore(this.file, entitiesThatShouldBeSaved);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveCore(File target, Map<String, E> entities) {
|
private boolean saveCore(File target, Map<String, E> entities) {
|
||||||
@ -204,14 +179,9 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadFromDisc() {
|
public boolean loadFromDisc() {
|
||||||
Map<String, E> id2entity = this.loadCore();
|
Map<String, E> id2entity = this.loadCore(); if (id2entity == null) { return false; } this.entities.clear();
|
||||||
if (id2entity == null) { return false; }
|
this.entities.addAll(id2entity.values()); this.id2entity.clear(); this.id2entity.putAll(id2entity);
|
||||||
this.entities.clear();
|
this.fillIds(); return true;
|
||||||
this.entities.addAll(id2entity.values());
|
|
||||||
this.id2entity.clear();
|
|
||||||
this.id2entity.putAll(id2entity);
|
|
||||||
this.fillIds();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, E> loadCore() {
|
private Map<String, E> loadCore() {
|
||||||
@ -219,45 +189,37 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
return new HashMap<String, E>();
|
return new HashMap<String, E>();
|
||||||
}
|
}
|
||||||
|
|
||||||
String content = DiscUtil.readCatch(this.file);
|
String content = DiscUtil.readCatch(this.file); if (content == null) {
|
||||||
if (content == null) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type type = this.getMapType();
|
Type type = this.getMapType(); if (type.toString().contains("FPlayer")) {
|
||||||
if (type.toString().contains("FPlayer")) {
|
|
||||||
Map<String, FPlayer> data = this.gson.fromJson(content, type);
|
Map<String, FPlayer> data = this.gson.fromJson(content, type);
|
||||||
Set<String> list = whichKeysNeedMigration(data.keySet());
|
Set<String> list = whichKeysNeedMigration(data.keySet());
|
||||||
Set<String> invalidList = whichKeysAreInvalid(list);
|
Set<String> invalidList = whichKeysAreInvalid(list); list.removeAll(invalidList);
|
||||||
list.removeAll(invalidList);
|
|
||||||
|
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
// We've got some converting to do!
|
// We've got some converting to do!
|
||||||
Bukkit.getLogger().log(Level.INFO, "Factions is now updating players.json");
|
Bukkit.getLogger().log(Level.INFO, "Factions is now updating players.json");
|
||||||
|
|
||||||
// First we'll make a backup, because god forbid anybody heed a warning
|
// First we'll make a backup, because god forbid anybody heed a warning
|
||||||
File file = new File(this.file.getParentFile(), "players.json.old");
|
File file = new File(this.file.getParentFile(), "players.json.old"); try {
|
||||||
try {
|
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} saveCore(file, (Map<String, E>) data);
|
||||||
saveCore(file, (Map<String, E>) data);
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath());
|
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath());
|
||||||
|
|
||||||
// Start fetching those UUIDs
|
// Start fetching those UUIDs
|
||||||
Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + list.size() + " old player names to UUID. This may take a while.");
|
Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + list.size() + " old player names to UUID. This may take a while.");
|
||||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list));
|
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list)); try {
|
||||||
try {
|
Map<String, UUID> response = fetcher.call(); for (String s : list) {
|
||||||
Map<String, UUID> response = fetcher.call();
|
|
||||||
for (String s : list) {
|
|
||||||
// Are we missing any responses?
|
// Are we missing any responses?
|
||||||
if (!response.containsKey(s)) {
|
if (!response.containsKey(s)) {
|
||||||
// They don't have a UUID so they should just be removed
|
// They don't have a UUID so they should just be removed
|
||||||
invalidList.add(s);
|
invalidList.add(s);
|
||||||
}
|
}
|
||||||
}
|
} for (String value : response.keySet()) {
|
||||||
for (String value : response.keySet()) {
|
|
||||||
// For all the valid responses, let's replace their old named entry with a UUID key
|
// For all the valid responses, let's replace their old named entry with a UUID key
|
||||||
String id = response.get(value).toString();
|
String id = response.get(value).toString();
|
||||||
|
|
||||||
@ -265,8 +227,7 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
// The player never existed here, and shouldn't persist
|
// The player never existed here, and shouldn't persist
|
||||||
invalidList.add(value);
|
invalidList.add(value); continue;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setId(id); // Update the object so it knows
|
player.setId(id); // Update the object so it knows
|
||||||
@ -276,29 +237,23 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} if (invalidList.size() > 0) {
|
||||||
if (invalidList.size() > 0) {
|
|
||||||
for (String name : invalidList) {
|
for (String name : invalidList) {
|
||||||
// Remove all the invalid names we collected
|
// Remove all the invalid names we collected
|
||||||
data.remove(name);
|
data.remove(name);
|
||||||
}
|
}
|
||||||
Bukkit.getLogger().log(Level.INFO, "While converting we found names that either don't have a UUID or aren't players and removed them from storage.");
|
Bukkit.getLogger().log(Level.INFO, "While converting we found names that either don't have a UUID or aren't players and removed them from storage.");
|
||||||
Bukkit.getLogger().log(Level.INFO, "The following names were detected as being invalid: " + StringUtils.join(invalidList, ", "));
|
Bukkit.getLogger().log(Level.INFO, "The following names were detected as being invalid: " + StringUtils.join(invalidList, ", "));
|
||||||
}
|
} saveCore(this.file, (Map<String, E>) data); // Update the flatfile
|
||||||
saveCore(this.file, (Map<String, E>) data); // Update the flatfile
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
|
Bukkit.getLogger().log(Level.INFO, "Done converting players.json to UUID.");
|
||||||
}
|
} return (Map<String, E>) data;
|
||||||
return (Map<String, E>) data;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
Map<String, Faction> data = this.gson.fromJson(content, type);
|
Map<String, Faction> data = this.gson.fromJson(content, type);
|
||||||
|
|
||||||
// Do we have any names that need updating in claims or invites?
|
// Do we have any names that need updating in claims or invites?
|
||||||
|
|
||||||
int needsUpdate = 0;
|
int needsUpdate = 0; for (String string : data.keySet()) {
|
||||||
for (String string : data.keySet()) {
|
Faction f = data.get(string); needsUpdate += whichKeysNeedMigration(f.getInvites()).size();
|
||||||
Faction f = data.get(string);
|
|
||||||
needsUpdate += whichKeysNeedMigration(f.getInvites()).size();
|
|
||||||
Map<FLocation, Set<String>> claims = f.getClaimOwnership();
|
Map<FLocation, Set<String>> claims = f.getClaimOwnership();
|
||||||
for (FLocation key : f.getClaimOwnership().keySet()) {
|
for (FLocation key : f.getClaimOwnership().keySet()) {
|
||||||
needsUpdate += whichKeysNeedMigration(claims.get(key)).size();
|
needsUpdate += whichKeysNeedMigration(claims.get(key)).size();
|
||||||
@ -310,13 +265,11 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
Bukkit.getLogger().log(Level.INFO, "Factions is now updating factions.json");
|
Bukkit.getLogger().log(Level.INFO, "Factions is now updating factions.json");
|
||||||
|
|
||||||
// First we'll make a backup, because god forbid anybody heed a warning
|
// First we'll make a backup, because god forbid anybody heed a warning
|
||||||
File file = new File(this.file.getParentFile(), "factions.json.old");
|
File file = new File(this.file.getParentFile(), "factions.json.old"); try {
|
||||||
try {
|
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} saveCore(file, (Map<String, E>) data);
|
||||||
saveCore(file, (Map<String, E>) data);
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath());
|
Bukkit.getLogger().log(Level.INFO, "Backed up your old data at " + file.getAbsolutePath());
|
||||||
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + needsUpdate + " old player names to UUID. This may take a while.");
|
Bukkit.getLogger().log(Level.INFO, "Please wait while Factions converts " + needsUpdate + " old player names to UUID. This may take a while.");
|
||||||
@ -324,18 +277,15 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
// Update claim ownership
|
// Update claim ownership
|
||||||
|
|
||||||
for (String string : data.keySet()) {
|
for (String string : data.keySet()) {
|
||||||
Faction f = data.get(string);
|
Faction f = data.get(string); Map<FLocation, Set<String>> claims = f.getClaimOwnership();
|
||||||
Map<FLocation, Set<String>> claims = f.getClaimOwnership();
|
|
||||||
for (FLocation key : claims.keySet()) {
|
for (FLocation key : claims.keySet()) {
|
||||||
Set<String> set = claims.get(key);
|
Set<String> set = claims.get(key);
|
||||||
|
|
||||||
Set<String> list = whichKeysNeedMigration(set);
|
Set<String> list = whichKeysNeedMigration(set);
|
||||||
|
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list));
|
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list)); try {
|
||||||
try {
|
Map<String, UUID> response = fetcher.call(); for (String value : response.keySet()) {
|
||||||
Map<String, UUID> response = fetcher.call();
|
|
||||||
for (String value : response.keySet()) {
|
|
||||||
// Let's replace their old named entry with a UUID key
|
// Let's replace their old named entry with a UUID key
|
||||||
String id = response.get(value).toString();
|
String id = response.get(value).toString();
|
||||||
set.remove(value.toLowerCase()); // Out with the old...
|
set.remove(value.toLowerCase()); // Out with the old...
|
||||||
@ -343,8 +293,7 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} claims.put(key, set); // Update
|
||||||
claims.put(key, set); // Update
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,15 +301,12 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
// Update invites
|
// Update invites
|
||||||
|
|
||||||
for (String string : data.keySet()) {
|
for (String string : data.keySet()) {
|
||||||
Faction f = data.get(string);
|
Faction f = data.get(string); Set<String> invites = f.getInvites();
|
||||||
Set<String> invites = f.getInvites();
|
|
||||||
Set<String> list = whichKeysNeedMigration(invites);
|
Set<String> list = whichKeysNeedMigration(invites);
|
||||||
|
|
||||||
if (list.size() > 0) {
|
if (list.size() > 0) {
|
||||||
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list));
|
UUIDFetcher fetcher = new UUIDFetcher(new ArrayList(list)); try {
|
||||||
try {
|
Map<String, UUID> response = fetcher.call(); for (String value : response.keySet()) {
|
||||||
Map<String, UUID> response = fetcher.call();
|
|
||||||
for (String value : response.keySet()) {
|
|
||||||
// Let's replace their old named entry with a UUID key
|
// Let's replace their old named entry with a UUID key
|
||||||
String id = response.get(value).toString();
|
String id = response.get(value).toString();
|
||||||
invites.remove(value.toLowerCase()); // Out with the old...
|
invites.remove(value.toLowerCase()); // Out with the old...
|
||||||
@ -374,14 +320,12 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
|
|
||||||
saveCore(this.file, (Map<String, E>) data); // Update the flatfile
|
saveCore(this.file, (Map<String, E>) data); // Update the flatfile
|
||||||
Bukkit.getLogger().log(Level.INFO, "Done converting factions.json to UUID.");
|
Bukkit.getLogger().log(Level.INFO, "Done converting factions.json to UUID.");
|
||||||
}
|
} return (Map<String, E>) data;
|
||||||
return (Map<String, E>) data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> whichKeysNeedMigration(Set<String> keys) {
|
private Set<String> whichKeysNeedMigration(Set<String> keys) {
|
||||||
HashSet<String> list = new HashSet<String>();
|
HashSet<String> list = new HashSet<String>(); for (String value : keys) {
|
||||||
for (String value : keys) {
|
|
||||||
if (!value.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")) {
|
if (!value.matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")) {
|
||||||
// Not a valid UUID..
|
// Not a valid UUID..
|
||||||
if (value.matches("[a-zA-Z0-9_]{2,16}")) {
|
if (value.matches("[a-zA-Z0-9_]{2,16}")) {
|
||||||
@ -389,19 +333,16 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
list.add(value);
|
list.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} return list;
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> whichKeysAreInvalid(Set<String> keys) {
|
private Set<String> whichKeysAreInvalid(Set<String> keys) {
|
||||||
Set<String> list = new HashSet<String>();
|
Set<String> list = new HashSet<String>(); for (String value : keys) {
|
||||||
for (String value : keys) {
|
|
||||||
if (!value.matches("[a-zA-Z0-9_]{2,16}")) {
|
if (!value.matches("[a-zA-Z0-9_]{2,16}")) {
|
||||||
// Not a valid player name.. go ahead and mark it for removal
|
// Not a valid player name.. go ahead and mark it for removal
|
||||||
list.add(value);
|
list.add(value);
|
||||||
}
|
}
|
||||||
}
|
} return list;
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -411,8 +352,7 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
public String getNextId() {
|
public String getNextId() {
|
||||||
while (!isIdFree(this.nextId)) {
|
while (!isIdFree(this.nextId)) {
|
||||||
this.nextId += 1;
|
this.nextId += 1;
|
||||||
}
|
} return Integer.toString(this.nextId);
|
||||||
return Integer.toString(this.nextId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdFree(String id) {
|
public boolean isIdFree(String id) {
|
||||||
@ -424,12 +364,8 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void fillIds() {
|
protected synchronized void fillIds() {
|
||||||
this.nextId = 1;
|
this.nextId = 1; for (Entry<String, E> entry : this.id2entity.entrySet()) {
|
||||||
for (Entry<String, E> entry : this.id2entity.entrySet()) {
|
String id = entry.getKey(); E entity = entry.getValue(); entity.id = id; this.updateNextIdForId(id);
|
||||||
String id = entry.getKey();
|
|
||||||
E entity = entry.getValue();
|
|
||||||
entity.id = id;
|
|
||||||
this.updateNextIdForId(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,8 +377,7 @@ public abstract class EntityCollection<E extends Entity> {
|
|||||||
|
|
||||||
protected void updateNextIdForId(String id) {
|
protected void updateNextIdForId(String id) {
|
||||||
try {
|
try {
|
||||||
int idAsInt = Integer.parseInt(id);
|
int idAsInt = Integer.parseInt(id); this.updateNextIdForId(idAsInt);
|
||||||
this.updateNextIdForId(idAsInt);
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ public class PlayerEntity extends Entity {
|
|||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
if (player.getUniqueId().toString().equals(this.getId())) { return player; }
|
if (player.getUniqueId().toString().equals(this.getId())) { return player; }
|
||||||
}
|
} return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnline() {
|
public boolean isOnline() {
|
||||||
@ -19,8 +18,7 @@ public class PlayerEntity extends Entity {
|
|||||||
|
|
||||||
// make sure target player should be able to detect that this player is online
|
// make sure target player should be able to detect that this player is online
|
||||||
public boolean isOnlineAndVisibleTo(Player player) {
|
public boolean isOnlineAndVisibleTo(Player player) {
|
||||||
Player target = this.getPlayer();
|
Player target = this.getPlayer(); return target != null && player.canSee(target);
|
||||||
return target != null && player.canSee(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOffline() {
|
public boolean isOffline() {
|
||||||
@ -32,9 +30,7 @@ public class PlayerEntity extends Entity {
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void sendMessage(String msg) {
|
public void sendMessage(String msg) {
|
||||||
Player player = this.getPlayer();
|
Player player = this.getPlayer(); if (player == null) { return; } player.sendMessage(msg);
|
||||||
if (player == null) { return; }
|
|
||||||
player.sendMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(List<String> msgs) {
|
public void sendMessage(List<String> msgs) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user