Reformat before I go crazy.
This commit is contained in:
parent
0c3ea377dd
commit
814e439705
@ -1,94 +1,75 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
|
||||||
import com.massivecraft.factions.integration.LWCFeatures;
|
import com.massivecraft.factions.integration.LWCFeatures;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.util.AsciiCompass;
|
import com.massivecraft.factions.util.AsciiCompass;
|
||||||
import com.massivecraft.factions.zcore.util.DiscUtil;
|
import com.massivecraft.factions.zcore.util.DiscUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
|
||||||
public class Board
|
public class Board {
|
||||||
{
|
|
||||||
private static transient File file = new File(P.p.getDataFolder(), "board.json");
|
private static transient File file = new File(P.p.getDataFolder(), "board.json");
|
||||||
private static transient HashMap<FLocation, String> flocationIds = new HashMap<FLocation, String>();
|
private static transient HashMap<FLocation, String> flocationIds = new HashMap<FLocation, String>();
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Get and Set
|
// Get and Set
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public static String getIdAt(FLocation flocation)
|
public static String getIdAt(FLocation flocation) {
|
||||||
{
|
if (!flocationIds.containsKey(flocation)) {
|
||||||
if ( ! flocationIds.containsKey(flocation))
|
|
||||||
{
|
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
return flocationIds.get(flocation);
|
return flocationIds.get(flocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Faction getFactionAt(FLocation flocation)
|
public static Faction getFactionAt(FLocation flocation) {
|
||||||
{
|
|
||||||
return Factions.i.get(getIdAt(flocation));
|
return Factions.i.get(getIdAt(flocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setIdAt(String id, FLocation flocation)
|
public static void setIdAt(String id, FLocation flocation) {
|
||||||
{
|
|
||||||
clearOwnershipAt(flocation);
|
clearOwnershipAt(flocation);
|
||||||
|
|
||||||
if (id == "0")
|
if (id == "0") {
|
||||||
{
|
|
||||||
removeAt(flocation);
|
removeAt(flocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
flocationIds.put(flocation, id);
|
flocationIds.put(flocation, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFactionAt(Faction faction, FLocation flocation)
|
public static void setFactionAt(Faction faction, FLocation flocation) {
|
||||||
{
|
|
||||||
setIdAt(faction.getId(), flocation);
|
setIdAt(faction.getId(), flocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
Entry<FLocation, String> entry = iter.next();
|
||||||
if (entry.getValue().equals(factionId))
|
if (entry.getValue().equals(factionId)) {
|
||||||
{
|
if (Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) {
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
|
||||||
{
|
|
||||||
LWCFeatures.clearAllChests(entry.getKey());
|
LWCFeatures.clearAllChests(entry.getKey());
|
||||||
}
|
}
|
||||||
iter.remove();
|
iter.remove();
|
||||||
@ -98,8 +79,7 @@ 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 b = flocation.getRelative(-1, 0);
|
||||||
@ -109,8 +89,7 @@ public class Board
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 c = flocation.getRelative(0, 1);
|
||||||
@ -123,15 +102,12 @@ public class Board
|
|||||||
// Cleaner. Remove orphaned foreign keys
|
// Cleaner. Remove orphaned foreign keys
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
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();
|
Entry<FLocation, String> entry = iter.next();
|
||||||
if ( ! Factions.i.exists(entry.getValue()))
|
if (!Factions.i.exists(entry.getValue())) {
|
||||||
{
|
if (Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) {
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
|
||||||
{
|
|
||||||
LWCFeatures.clearAllChests(entry.getKey());
|
LWCFeatures.clearAllChests(entry.getKey());
|
||||||
}
|
}
|
||||||
P.p.log("Board cleaner removed " + entry.getValue() + " from " + entry.getKey());
|
P.p.log("Board cleaner removed " + entry.getValue() + " from " + entry.getKey());
|
||||||
@ -144,33 +120,27 @@ public class Board
|
|||||||
// Coord count
|
// Coord count
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
return getFactionCoordCount(faction.getId());
|
return getFactionCoordCount(faction.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
Iterator<Entry<FLocation, String>> iter = flocationIds.entrySet().iterator();
|
||||||
while (iter.hasNext()) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,12 +152,10 @@ public class Board
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The map is relative to a coord and a faction
|
* The map is relative to a coord and a faction north is in the direction of decreasing x east is in the direction
|
||||||
* north is in the direction of decreasing x
|
* of decreasing z
|
||||||
* east is in the direction 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)));
|
||||||
@ -198,8 +166,7 @@ public class Board
|
|||||||
int width = halfWidth * 2 + 1;
|
int width = halfWidth * 2 + 1;
|
||||||
int height = halfHeight * 2 + 1;
|
int height = halfHeight * 2 + 1;
|
||||||
|
|
||||||
if (Conf.showMapFactionKey)
|
if (Conf.showMapFactionKey) {
|
||||||
{
|
|
||||||
height--;
|
height--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,34 +174,23 @@ public class Board
|
|||||||
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
|
||||||
else if
|
|
||||||
(
|
(
|
||||||
factionHere == faction
|
factionHere == faction
|
||||||
||
|
||
|
||||||
@ -245,15 +201,12 @@ public class Board
|
|||||||
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
||||||
||
|
||
|
||||||
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
|
(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());
|
char tag = fList.get(factionHere.getTag());
|
||||||
row += factionHere.getColorTo(faction) + "" + tag;
|
row += factionHere.getColorTo(faction) + "" + tag;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
row += ChatColor.GRAY + "-";
|
row += ChatColor.GRAY + "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,11 +223,9 @@ public class Board
|
|||||||
ret.set(3, asciiCompass.get(2) + ret.get(3).substring(3 * 3));
|
ret.set(3, asciiCompass.get(2) + ret.get(3).substring(3 * 3));
|
||||||
|
|
||||||
// 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);
|
||||||
@ -288,20 +239,17 @@ public class Board
|
|||||||
// Persistance
|
// Persistance
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
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();
|
coords = entry.getKey().getCoordString();
|
||||||
id = entry.getValue();
|
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>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,8 +259,7 @@ public class Board
|
|||||||
return worldCoordIds;
|
return worldCoordIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -320,11 +267,9 @@ public class Board
|
|||||||
int x, z;
|
int x, z;
|
||||||
String factionId;
|
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]+");
|
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]);
|
||||||
@ -334,16 +279,12 @@ public class Board
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean save()
|
public static boolean save() {
|
||||||
{
|
|
||||||
//Factions.log("Saving board to disk");
|
//Factions.log("Saving board to disk");
|
||||||
|
|
||||||
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.");
|
P.p.log("Failed to save the board to disk.");
|
||||||
return false;
|
return false;
|
||||||
@ -352,25 +293,21 @@ public class Board
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean load()
|
public static boolean load() {
|
||||||
{
|
|
||||||
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();
|
save();
|
||||||
return true;
|
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.");
|
P.p.log("Failed to load the board from disk.");
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public class Conf
|
import java.util.*;
|
||||||
{
|
|
||||||
|
public class Conf {
|
||||||
public static List<String> baseCommandAliases = new ArrayList<String>();
|
public static List<String> baseCommandAliases = new ArrayList<String>();
|
||||||
public static boolean allowNoSlashCommand = true;
|
public static boolean allowNoSlashCommand = true;
|
||||||
|
|
||||||
@ -289,8 +288,7 @@ public class Conf
|
|||||||
public static transient int mapWidth = 39;
|
public static transient int mapWidth = 39;
|
||||||
public static transient char[] mapKeyChrs = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
|
public static transient char[] mapKeyChrs = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
|
||||||
baseCommandAliases.add("f");
|
baseCommandAliases.add("f");
|
||||||
|
|
||||||
territoryEnemyDenyCommands.add("home");
|
territoryEnemyDenyCommands.add("home");
|
||||||
@ -373,12 +371,12 @@ public class Conf
|
|||||||
// Persistance
|
// Persistance
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
private static transient Conf i = new Conf();
|
private static transient Conf i = new Conf();
|
||||||
public static void load()
|
|
||||||
{
|
public static void load() {
|
||||||
P.p.persist.loadOrSaveDefault(i, Conf.class, "conf");
|
P.p.persist.loadOrSaveDefault(i, Conf.class, "conf");
|
||||||
}
|
}
|
||||||
public static void save()
|
|
||||||
{
|
public static void save() {
|
||||||
P.p.persist.save(i);
|
P.p.persist.save(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class FLocation
|
public class FLocation {
|
||||||
{
|
|
||||||
|
|
||||||
private String worldName = "world";
|
private String worldName = "world";
|
||||||
private int x = 0;
|
private int x = 0;
|
||||||
@ -23,35 +21,29 @@ public class FLocation
|
|||||||
// Constructors
|
// Constructors
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public FLocation()
|
public 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.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation(Location location)
|
public FLocation(Location location) {
|
||||||
{
|
|
||||||
this(location.getWorld().getName(), blockToChunk(location.getBlockX()), blockToChunk(location.getBlockZ()));
|
this(location.getWorld().getName(), blockToChunk(location.getBlockX()), blockToChunk(location.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation(Player player)
|
public FLocation(Player player) {
|
||||||
{
|
|
||||||
this(player.getLocation());
|
this(player.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation(FPlayer fplayer)
|
public FLocation(FPlayer fplayer) {
|
||||||
{
|
|
||||||
this(fplayer.getPlayer());
|
this(fplayer.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation(Block block)
|
public FLocation(Block block) {
|
||||||
{
|
|
||||||
this(block.getLocation());
|
this(block.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,43 +51,35 @@ public class FLocation
|
|||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public String getWorldName()
|
public String getWorldName() {
|
||||||
{
|
|
||||||
return worldName;
|
return worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getWorld()
|
public World getWorld() {
|
||||||
{
|
|
||||||
return Bukkit.getWorld(worldName);
|
return Bukkit.getWorld(worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorldName(String worldName)
|
public void setWorldName(String worldName) {
|
||||||
{
|
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getX()
|
public long getX() {
|
||||||
{
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setX(int x)
|
public void setX(int x) {
|
||||||
{
|
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getZ()
|
public long getZ() {
|
||||||
{
|
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZ(int z)
|
public void setZ(int z) {
|
||||||
{
|
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCoordString()
|
public String getCoordString() {
|
||||||
{
|
|
||||||
return "" + x + "," + z;
|
return "" + x + "," + z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,33 +93,27 @@ public class FLocation
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
// bit-shifting is used because it's much faster than standard division and multiplication
|
// bit-shifting is used because it's much faster than standard division and multiplication
|
||||||
public static int blockToChunk(int blockVal)
|
public static int blockToChunk(int blockVal) { // 1 chunk is 16x16 blocks
|
||||||
{ // 1 chunk is 16x16 blocks
|
|
||||||
return blockVal >> 4; // ">> 4" == "/ 16"
|
return blockVal >> 4; // ">> 4" == "/ 16"
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int blockToRegion(int blockVal)
|
public static int blockToRegion(int blockVal) { // 1 region is 512x512 blocks
|
||||||
{ // 1 region is 512x512 blocks
|
|
||||||
return blockVal >> 9; // ">> 9" == "/ 512"
|
return blockVal >> 9; // ">> 9" == "/ 512"
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int chunkToRegion(int chunkVal)
|
public static int chunkToRegion(int chunkVal) { // 1 region is 32x32 chunks
|
||||||
{ // 1 region is 32x32 chunks
|
|
||||||
return chunkVal >> 5; // ">> 5" == "/ 32"
|
return chunkVal >> 5; // ">> 5" == "/ 32"
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int chunkToBlock(int chunkVal)
|
public static int chunkToBlock(int chunkVal) {
|
||||||
{
|
|
||||||
return chunkVal << 4; // "<< 4" == "* 16"
|
return chunkVal << 4; // "<< 4" == "* 16"
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int regionToBlock(int regionVal)
|
public static int regionToBlock(int regionVal) {
|
||||||
{
|
|
||||||
return regionVal << 9; // "<< 9" == "* 512"
|
return regionVal << 9; // "<< 9" == "* 512"
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int regionToChunk(int regionVal)
|
public static int regionToChunk(int regionVal) {
|
||||||
{
|
|
||||||
return regionVal << 5; // "<< 5" == "* 32"
|
return regionVal << 5; // "<< 5" == "* 32"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +121,11 @@ public class FLocation
|
|||||||
// Misc Geometry
|
// Misc Geometry
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public FLocation getRelative(int dx, int dz)
|
public FLocation getRelative(int dx, int dz) {
|
||||||
{
|
|
||||||
return new FLocation(this.worldName, this.x + dx, this.z + dz);
|
return new FLocation(this.worldName, this.x + dx, this.z + dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
double dz = that.z - this.z;
|
||||||
return Math.sqrt(dx * dx + dz * dz);
|
return Math.sqrt(dx * dx + dz * dz);
|
||||||
@ -158,8 +134,7 @@ public class FLocation
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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;
|
||||||
|
|
||||||
@ -168,10 +143,8 @@ public class FLocation
|
|||||||
int zfrom = (int) Math.floor(this.z - radius);
|
int zfrom = (int) Math.floor(this.z - radius);
|
||||||
int zto = (int) Math.ceil(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++)
|
|
||||||
{
|
|
||||||
FLocation potential = new FLocation(this.worldName, x, z);
|
FLocation potential = new FLocation(this.worldName, x, z);
|
||||||
if (this.getDistanceTo(potential) <= radius)
|
if (this.getDistanceTo(potential) <= radius)
|
||||||
ret.add(potential);
|
ret.add(potential);
|
||||||
@ -181,14 +154,11 @@ public class FLocation
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<FLocation> getArea(FLocation from, FLocation to)
|
public static HashSet<FLocation> getArea(FLocation from, FLocation to) {
|
||||||
{
|
|
||||||
HashSet<FLocation> ret = new HashSet<FLocation>();
|
HashSet<FLocation> ret = new HashSet<FLocation>();
|
||||||
|
|
||||||
for (long x : MiscUtil.range(from.getX(), to.getX()))
|
for (long x : MiscUtil.range(from.getX(), to.getX())) {
|
||||||
{
|
for (long z : MiscUtil.range(from.getZ(), to.getZ())) {
|
||||||
for (long z : MiscUtil.range(from.getZ(), to.getZ()))
|
|
||||||
{
|
|
||||||
ret.add(new FLocation(from.getWorldName(), (int) x, (int) z));
|
ret.add(new FLocation(from.getWorldName(), (int) x, (int) z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,15 +171,13 @@ public class FLocation
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
|
||||||
// should be fast, with good range and few hash collisions: (x * 512) + z + worldName.hashCode
|
// should be fast, with good range and few hash collisions: (x * 512) + z + worldName.hashCode
|
||||||
return (this.x << 9) + this.z + (this.worldName != null ? this.worldName.hashCode() : 0);
|
return (this.x << 9) + this.z + (this.worldName != null ? this.worldName.hashCode() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj) {
|
||||||
{
|
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
if (!(obj instanceof FLocation))
|
if (!(obj instanceof FLocation))
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||||
import com.massivecraft.factions.event.LandClaimEvent;
|
import com.massivecraft.factions.event.LandClaimEvent;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
@ -22,31 +14,49 @@ import com.massivecraft.factions.struct.Relation;
|
|||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logged in players always have exactly one FPlayer instance.
|
* Logged in players always have exactly one FPlayer instance. Logged out players may or may not have an FPlayer
|
||||||
* Logged out players may or may not have an FPlayer instance. They will always have one if they are part of a faction.
|
* instance. They will always have one if they are part of a faction. This is because only players with a faction are
|
||||||
* This is because only players with a faction are saved to disk (in order to not waste disk space).
|
* saved to disk (in order to not waste disk space).
|
||||||
*
|
* <p/>
|
||||||
* The FPlayer is linked to a minecraft player using the player name.
|
* The FPlayer is linked to a minecraft player using the player name.
|
||||||
*
|
* <p/>
|
||||||
* The same instance is always returned for the same player.
|
* The same instance is always returned for the same player. This means you can use the == operator. No .equals method
|
||||||
* This means you can use the == operator. No .equals method necessary.
|
* necessary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FPlayer extends PlayerEntity implements EconomyParticipator
|
public class FPlayer extends PlayerEntity implements EconomyParticipator {
|
||||||
{
|
|
||||||
//private transient String playerName;
|
//private transient String playerName;
|
||||||
private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
|
private transient FLocation lastStoodAt = new FLocation(); // Where did this player stand the last time we checked?
|
||||||
|
|
||||||
// FIELD: factionId
|
// FIELD: factionId
|
||||||
private String factionId;
|
private String factionId;
|
||||||
public Faction getFaction() { if(this.factionId == null) {return null;} return Factions.i.get(this.factionId); }
|
|
||||||
public String getFactionId() { return this.factionId; }
|
public Faction getFaction() {
|
||||||
public boolean hasFaction() { return ! factionId.equals("0"); }
|
if (this.factionId == null) {
|
||||||
public void setFaction(Faction faction)
|
return null;
|
||||||
{
|
}
|
||||||
|
return Factions.i.get(this.factionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFactionId() {
|
||||||
|
return this.factionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasFaction() {
|
||||||
|
return !factionId.equals("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
faction.addFPlayer(this);
|
||||||
@ -56,8 +66,15 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: role
|
// FIELD: role
|
||||||
private Role role;
|
private Role role;
|
||||||
public Role getRole() { return this.role; }
|
|
||||||
public void setRole(Role role) { this.role = role; SpoutFeatures.updateAppearances(this.getPlayer()); }
|
public Role getRole() {
|
||||||
|
return this.role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(Role role) {
|
||||||
|
this.role = role;
|
||||||
|
SpoutFeatures.updateAppearances(this.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: title
|
// FIELD: title
|
||||||
private String title;
|
private String title;
|
||||||
@ -68,8 +85,14 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// FIELD: powerBoost
|
// FIELD: powerBoost
|
||||||
// special increase/decrease to min and max power for this player
|
// special increase/decrease to min and max power for this player
|
||||||
private double powerBoost;
|
private double powerBoost;
|
||||||
public double getPowerBoost() { return this.powerBoost; }
|
|
||||||
public void setPowerBoost(double powerBoost) { this.powerBoost = powerBoost; }
|
public double getPowerBoost() {
|
||||||
|
return this.powerBoost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPowerBoost(double powerBoost) {
|
||||||
|
this.powerBoost = powerBoost;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: lastPowerUpdateTime
|
// FIELD: lastPowerUpdateTime
|
||||||
private long lastPowerUpdateTime;
|
private long lastPowerUpdateTime;
|
||||||
@ -82,15 +105,14 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: autoClaimEnabled
|
// FIELD: autoClaimEnabled
|
||||||
private transient Faction autoClaimFor;
|
private transient Faction autoClaimFor;
|
||||||
public Faction getAutoClaimFor()
|
|
||||||
{
|
public Faction getAutoClaimFor() {
|
||||||
return autoClaimFor;
|
return autoClaimFor;
|
||||||
}
|
}
|
||||||
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;
|
||||||
@ -99,12 +121,14 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: autoSafeZoneEnabled
|
// FIELD: autoSafeZoneEnabled
|
||||||
private transient boolean autoSafeZoneEnabled;
|
private transient boolean autoSafeZoneEnabled;
|
||||||
public boolean isAutoSafeClaimEnabled() { return autoSafeZoneEnabled; }
|
|
||||||
public void setIsAutoSafeClaimEnabled(boolean enabled)
|
public boolean isAutoSafeClaimEnabled() {
|
||||||
{
|
return autoSafeZoneEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAutoSafeClaimEnabled(boolean enabled) {
|
||||||
this.autoSafeZoneEnabled = enabled;
|
this.autoSafeZoneEnabled = enabled;
|
||||||
if (enabled)
|
if (enabled) {
|
||||||
{
|
|
||||||
this.autoClaimFor = null;
|
this.autoClaimFor = null;
|
||||||
this.autoWarZoneEnabled = false;
|
this.autoWarZoneEnabled = false;
|
||||||
}
|
}
|
||||||
@ -112,20 +136,28 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: autoWarZoneEnabled
|
// FIELD: autoWarZoneEnabled
|
||||||
private transient boolean autoWarZoneEnabled;
|
private transient boolean autoWarZoneEnabled;
|
||||||
public boolean isAutoWarClaimEnabled() { return autoWarZoneEnabled; }
|
|
||||||
public void setIsAutoWarClaimEnabled(boolean enabled)
|
public boolean isAutoWarClaimEnabled() {
|
||||||
{
|
return autoWarZoneEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAutoWarClaimEnabled(boolean enabled) {
|
||||||
this.autoWarZoneEnabled = enabled;
|
this.autoWarZoneEnabled = enabled;
|
||||||
if (enabled)
|
if (enabled) {
|
||||||
{
|
|
||||||
this.autoClaimFor = null;
|
this.autoClaimFor = null;
|
||||||
this.autoSafeZoneEnabled = false;
|
this.autoSafeZoneEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private transient boolean isAdminBypassing = false;
|
private transient boolean isAdminBypassing = false;
|
||||||
public boolean isAdminBypassing() { return this.isAdminBypassing; }
|
|
||||||
public void setIsAdminBypassing(boolean val) { this.isAdminBypassing = val; }
|
public boolean isAdminBypassing() {
|
||||||
|
return this.isAdminBypassing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAdminBypassing(boolean val) {
|
||||||
|
this.isAdminBypassing = val;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: loginPvpDisabled
|
// FIELD: loginPvpDisabled
|
||||||
private transient boolean loginPvpDisabled;
|
private transient boolean loginPvpDisabled;
|
||||||
@ -135,11 +167,13 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: chatMode
|
// FIELD: chatMode
|
||||||
private ChatMode chatMode;
|
private ChatMode chatMode;
|
||||||
public void setChatMode(ChatMode chatMode) { this.chatMode = chatMode; }
|
|
||||||
public ChatMode getChatMode()
|
public void setChatMode(ChatMode chatMode) {
|
||||||
{
|
this.chatMode = chatMode;
|
||||||
if(this.factionId.equals("0") || ! Conf.factionOnlyChat)
|
}
|
||||||
{
|
|
||||||
|
public ChatMode getChatMode() {
|
||||||
|
if (this.factionId.equals("0") || !Conf.factionOnlyChat) {
|
||||||
this.chatMode = ChatMode.PUBLIC;
|
this.chatMode = ChatMode.PUBLIC;
|
||||||
}
|
}
|
||||||
return chatMode;
|
return chatMode;
|
||||||
@ -147,19 +181,26 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: chatSpy
|
// FIELD: chatSpy
|
||||||
private transient boolean spyingChat = false;
|
private transient boolean spyingChat = false;
|
||||||
public void setSpyingChat(boolean chatSpying) { this.spyingChat = chatSpying; }
|
|
||||||
public boolean isSpyingChat() { return spyingChat; }
|
public void setSpyingChat(boolean chatSpying) {
|
||||||
|
this.spyingChat = chatSpying;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSpyingChat() {
|
||||||
|
return spyingChat;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: account
|
// FIELD: account
|
||||||
public String getAccountId() { return this.getId(); }
|
public String getAccountId() {
|
||||||
|
return this.getId();
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Construct
|
// Construct
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// 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.lastPowerUpdateTime = System.currentTimeMillis();
|
||||||
@ -172,21 +213,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.getId());
|
currentFaction.clearClaimOwnership(this.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,14 +234,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
this.title = "";
|
this.title = "";
|
||||||
this.autoClaimFor = null;
|
this.autoClaimFor = null;
|
||||||
|
|
||||||
if (doSpoutUpdate)
|
if (doSpoutUpdate) {
|
||||||
{
|
|
||||||
SpoutFeatures.updateAppearances(this.getPlayer());
|
SpoutFeatures.updateAppearances(this.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetFactionData()
|
public void resetFactionData() {
|
||||||
{
|
|
||||||
this.resetFactionData(true);
|
this.resetFactionData(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,62 +248,48 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
public long getLastLoginTime() {
|
||||||
|
|
||||||
public long getLastLoginTime()
|
|
||||||
{
|
|
||||||
return lastLoginTime;
|
return lastLoginTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLastLoginTime(long lastLoginTime) {
|
||||||
public void setLastLoginTime(long lastLoginTime)
|
|
||||||
{
|
|
||||||
losePowerFromBeingOffline();
|
losePowerFromBeingOffline();
|
||||||
this.lastLoginTime = lastLoginTime;
|
this.lastLoginTime = lastLoginTime;
|
||||||
this.lastPowerUpdateTime = lastLoginTime;
|
this.lastPowerUpdateTime = lastLoginTime;
|
||||||
if (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0)
|
if (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) {
|
||||||
{
|
|
||||||
this.loginPvpDisabled = true;
|
this.loginPvpDisabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMapAutoUpdating()
|
public boolean isMapAutoUpdating() {
|
||||||
{
|
|
||||||
return mapAutoUpdating;
|
return mapAutoUpdating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapAutoUpdating(boolean mapAutoUpdating)
|
public void setMapAutoUpdating(boolean mapAutoUpdating) {
|
||||||
{
|
|
||||||
this.mapAutoUpdating = mapAutoUpdating;
|
this.mapAutoUpdating = mapAutoUpdating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLoginPvpDisabled()
|
public boolean hasLoginPvpDisabled() {
|
||||||
{
|
if (!loginPvpDisabled) {
|
||||||
if (!loginPvpDisabled)
|
|
||||||
{
|
|
||||||
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() {
|
||||||
{
|
|
||||||
return this.lastStoodAt;
|
return this.lastStoodAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastStoodAt(FLocation flocation)
|
public void setLastStoodAt(FLocation flocation) {
|
||||||
{
|
|
||||||
this.lastStoodAt = flocation;
|
this.lastStoodAt = flocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markForDeletion(boolean delete)
|
public void markForDeletion(boolean delete) {
|
||||||
{
|
|
||||||
deleteMe = delete;
|
deleteMe = delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,25 +299,20 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// Base:
|
// Base:
|
||||||
|
|
||||||
public String getTitle()
|
public String getTitle() {
|
||||||
{
|
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title)
|
public void setTitle(String title) {
|
||||||
{
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName() {
|
||||||
{
|
|
||||||
return this.getId(); // TODO: ... display name or remove completeley
|
return this.getId(); // TODO: ... display name or remove completeley
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag()
|
public String getTag() {
|
||||||
{
|
if (!this.hasFaction()) {
|
||||||
if ( ! this.hasFaction())
|
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return this.getFaction().getTag();
|
return this.getFaction().getTag();
|
||||||
@ -304,8 +320,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
// 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 + " ";
|
||||||
@ -314,25 +329,22 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameAndTitle()
|
public String getNameAndTitle() {
|
||||||
{
|
|
||||||
return this.getNameAndSomething(this.getTitle());
|
return this.getNameAndSomething(this.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameAndTag()
|
public String getNameAndTag() {
|
||||||
{
|
|
||||||
return this.getNameAndSomething(this.getTag());
|
return this.getNameAndSomething(this.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colored concatenations:
|
// Colored concatenations:
|
||||||
// These are used in information messages
|
// These are used in information messages
|
||||||
|
|
||||||
public String getNameAndTitle(Faction faction)
|
public String getNameAndTitle(Faction faction) {
|
||||||
{
|
|
||||||
return this.getColorTo(faction) + this.getNameAndTitle();
|
return this.getColorTo(faction) + this.getNameAndTitle();
|
||||||
}
|
}
|
||||||
public String getNameAndTitle(FPlayer fplayer)
|
|
||||||
{
|
public String getNameAndTitle(FPlayer fplayer) {
|
||||||
return this.getColorTo(fplayer) + this.getNameAndTitle();
|
return this.getColorTo(fplayer) + this.getNameAndTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,8 +380,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// Chat Tag:
|
// Chat Tag:
|
||||||
// These are injected into the format of global chat messages.
|
// These are injected into the format of global chat messages.
|
||||||
|
|
||||||
public String getChatTag()
|
public String getChatTag() {
|
||||||
{
|
|
||||||
if (!this.hasFaction()) {
|
if (!this.hasFaction()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -378,8 +389,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Colored Chat Tag
|
// Colored Chat Tag
|
||||||
public String getChatTag(Faction faction)
|
public String getChatTag(Faction faction) {
|
||||||
{
|
|
||||||
if (!this.hasFaction()) {
|
if (!this.hasFaction()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -387,10 +397,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return this.getRelationTo(faction).getColor() + getChatTag();
|
return this.getRelationTo(faction).getColor() + getChatTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChatTag(FPlayer fplayer)
|
public String getChatTag(FPlayer fplayer) {
|
||||||
{
|
if (!this.hasFaction()) {
|
||||||
if ( ! this.hasFaction())
|
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,48 +410,40 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeTo(RelationParticipator that, boolean ucfirst)
|
public String describeTo(RelationParticipator that, boolean ucfirst) {
|
||||||
{
|
|
||||||
return RelationUtil.describeThatToMe(this, that, ucfirst);
|
return RelationUtil.describeThatToMe(this, that, ucfirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeTo(RelationParticipator that)
|
public String describeTo(RelationParticipator that) {
|
||||||
{
|
|
||||||
return RelationUtil.describeThatToMe(this, that);
|
return RelationUtil.describeThatToMe(this, that);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp)
|
public Relation getRelationTo(RelationParticipator rp) {
|
||||||
{
|
|
||||||
return RelationUtil.getRelationTo(this, rp);
|
return RelationUtil.getRelationTo(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful)
|
public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful) {
|
||||||
{
|
|
||||||
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Relation getRelationToLocation()
|
public Relation getRelationToLocation() {
|
||||||
{
|
|
||||||
return Board.getFactionAt(new FLocation(this)).getRelationTo(this);
|
return Board.getFactionAt(new FLocation(this)).getRelationTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatColor getColorTo(RelationParticipator rp)
|
public ChatColor getColorTo(RelationParticipator rp) {
|
||||||
{
|
|
||||||
return RelationUtil.getColorOfThatToMe(this, rp);
|
return RelationUtil.getColorOfThatToMe(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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);
|
||||||
@ -453,14 +453,12 @@ 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();
|
||||||
@ -468,38 +466,30 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
this.power = this.getPowerMin();
|
this.power = this.getPowerMin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMax()
|
public double getPowerMax() {
|
||||||
{
|
|
||||||
return Conf.powerPlayerMax + this.powerBoost;
|
return Conf.powerPlayerMax + this.powerBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMin()
|
public double getPowerMin() {
|
||||||
{
|
|
||||||
return Conf.powerPlayerMin + this.powerBoost;
|
return Conf.powerPlayerMin + this.powerBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerRounded()
|
public int getPowerRounded() {
|
||||||
{
|
|
||||||
return (int) Math.round(this.getPower());
|
return (int) Math.round(this.getPower());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerMaxRounded()
|
public int getPowerMaxRounded() {
|
||||||
{
|
|
||||||
return (int) Math.round(this.getPowerMax());
|
return (int) Math.round(this.getPowerMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerMinRounded()
|
public int getPowerMinRounded() {
|
||||||
{
|
|
||||||
return (int) Math.round(this.getPowerMin());
|
return (int) Math.round(this.getPowerMin());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updatePower()
|
protected void updatePower() {
|
||||||
{
|
if (this.isOffline()) {
|
||||||
if (this.isOffline())
|
|
||||||
{
|
|
||||||
losePowerFromBeingOffline();
|
losePowerFromBeingOffline();
|
||||||
if (!Conf.powerRegenOffline)
|
if (!Conf.powerRegenOffline) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,31 +498,28 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
this.lastPowerUpdateTime = now;
|
this.lastPowerUpdateTime = now;
|
||||||
|
|
||||||
Player thisPlayer = this.getPlayer();
|
Player thisPlayer = this.getPlayer();
|
||||||
if (thisPlayer != null && thisPlayer.isDead()) return; // don't let dead players regain power until they respawn
|
if (thisPlayer != null && thisPlayer.isDead())
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@ -540,42 +527,34 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Territory
|
// Territory
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public boolean isInOwnTerritory()
|
public boolean isInOwnTerritory() {
|
||||||
{
|
|
||||||
return Board.getFactionAt(new FLocation(this)) == this.getFaction();
|
return Board.getFactionAt(new FLocation(this)) == this.getFaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInOthersTerritory()
|
public boolean isInOthersTerritory() {
|
||||||
{
|
|
||||||
Faction factionHere = Board.getFactionAt(new FLocation(this));
|
Faction factionHere = Board.getFactionAt(new FLocation(this));
|
||||||
return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction();
|
return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInAllyTerritory()
|
public boolean isInAllyTerritory() {
|
||||||
{
|
|
||||||
return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isAlly();
|
return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isAlly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInNeutralTerritory()
|
public boolean isInNeutralTerritory() {
|
||||||
{
|
|
||||||
return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isNeutral();
|
return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isNeutral();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInEnemyTerritory()
|
public boolean isInEnemyTerritory() {
|
||||||
{
|
|
||||||
return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isEnemy();
|
return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isEnemy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFactionHereMessage()
|
public void sendFactionHereMessage() {
|
||||||
{
|
if (SpoutFeatures.updateTerritoryDisplay(this)) {
|
||||||
if (SpoutFeatures.updateTerritoryDisplay(this))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Faction factionHere = Board.getFactionAt(this.getLastStoodAt());
|
Faction factionHere = Board.getFactionAt(this.getLastStoodAt());
|
||||||
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);
|
||||||
@ -585,27 +564,23 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// Actions
|
// Actions
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -618,20 +593,18 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
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.")) return;
|
if (makePay && !Econ.modifyMoney(this, -Conf.econCostLeave, "to leave your faction.", "for leaving your faction."))
|
||||||
|
return;
|
||||||
|
|
||||||
// Am I the last one in the faction?
|
// Am I the last one in the faction?
|
||||||
if (myFaction.getFPlayers().size() == 1)
|
if (myFaction.getFPlayers().size() == 1) {
|
||||||
{
|
|
||||||
// Transfer all money
|
// Transfer all money
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.shouldBeUsed())
|
||||||
Econ.transferMoney(this, myFaction, this, Econ.getBalance(myFaction.getAccountId()));
|
Econ.transferMoney(this, myFaction, this, Econ.getBalance(myFaction.getAccountId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myFaction.isNormal())
|
if (myFaction.isNormal()) {
|
||||||
{
|
for (FPlayer fplayer : myFaction.getFPlayersWhereOnline(true)) {
|
||||||
for (FPlayer fplayer : myFaction.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
fplayer.msg("%s<i> left %s<i>.", this.describeTo(fplayer, true), myFaction.describeTo(fplayer));
|
fplayer.msg("%s<i> left %s<i>.", this.describeTo(fplayer, true), myFaction.describeTo(fplayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,11 +614,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
this.resetFactionData();
|
this.resetFactionData();
|
||||||
|
|
||||||
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty())
|
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) {
|
||||||
{
|
|
||||||
// Remove this faction
|
// Remove this faction
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
fplayer.msg("<i>%s<i> was disbanded.", myFaction.describeTo(fplayer, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,8 +626,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
|
if
|
||||||
@ -665,123 +635,81 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|
||||||
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|
||||||
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))
|
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
FLocation flocation = new FLocation(location);
|
||||||
Faction myFaction = getFaction();
|
Faction myFaction = getFaction();
|
||||||
Faction currentFaction = Board.getFactionAt(flocation);
|
Faction currentFaction = Board.getFactionAt(flocation);
|
||||||
int ownedLand = forFaction.getLandRounded();
|
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
|
||||||
else if
|
|
||||||
(
|
(
|
||||||
Conf.claimsMustBeConnected
|
Conf.claimsMustBeConnected
|
||||||
&& !this.isAdminBypassing()
|
&& !this.isAdminBypassing()
|
||||||
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
&& myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0
|
||||||
&& !Board.isConnectedLocation(flocation, myFaction)
|
&& !Board.isConnectedLocation(flocation, myFaction)
|
||||||
&& (!Conf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
|
&& (!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
|
||||||
|
|
||||||
@ -796,8 +724,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
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;
|
EconomyParticipator payee = null;
|
||||||
if (mustPay)
|
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))
|
||||||
@ -818,8 +745,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// 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")) return false;
|
if (mustPay && !Econ.modifyMoney(payee, -cost, "to claim this land", "for claiming this land")) return false;
|
||||||
|
|
||||||
if (LWCFeatures.getEnabled() && forFaction.isNormal() && Conf.onCaptureResetLwcLocks)
|
if (LWCFeatures.getEnabled() && forFaction.isNormal() && Conf.onCaptureResetLwcLocks) {
|
||||||
{
|
|
||||||
LWCFeatures.clearOtherChests(flocation, this.getFaction());
|
LWCFeatures.clearOtherChests(flocation, this.getFaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,8 +753,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>();
|
Set<FPlayer> informTheseFPlayers = new HashSet<FPlayer>();
|
||||||
informTheseFPlayers.add(this);
|
informTheseFPlayers.add(this);
|
||||||
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
informTheseFPlayers.addAll(forFaction.getFPlayersWhereOnline(true));
|
||||||
for (FPlayer fp : informTheseFPlayers)
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,8 +771,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldBeSaved()
|
public boolean shouldBeSaved() {
|
||||||
{
|
|
||||||
if (!this.hasFaction() &&
|
if (!this.hasFaction() &&
|
||||||
(this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))
|
(this.getPowerRounded() == this.getPowerMaxRounded() || this.getPowerRounded() == (int) Math.round(Conf.powerPlayerStarting))
|
||||||
)
|
)
|
||||||
@ -855,8 +779,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
return !this.deleteMe;
|
return !this.deleteMe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(String str, Object... args)
|
public void msg(String str, Object... args) {
|
||||||
{
|
|
||||||
this.sendMessage(P.p.txt.parse(str, args));
|
this.sendMessage(P.p.txt.parse(str, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,23 +1,20 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
|
||||||
|
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
public class FPlayers extends PlayerEntityCollection<FPlayer> {
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
|
|
||||||
|
|
||||||
public class FPlayers extends PlayerEntityCollection<FPlayer>
|
|
||||||
{
|
|
||||||
public static FPlayers i = new FPlayers();
|
public static FPlayers i = new FPlayers();
|
||||||
|
|
||||||
P p = P.p;
|
P p = P.p;
|
||||||
|
|
||||||
private FPlayers()
|
private FPlayers() {
|
||||||
{
|
|
||||||
super
|
super
|
||||||
(
|
(
|
||||||
FPlayer.class,
|
FPlayer.class,
|
||||||
@ -31,17 +28,14 @@ public class FPlayers extends PlayerEntityCollection<FPlayer>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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() {
|
||||||
{
|
for (FPlayer fplayer : this.get()) {
|
||||||
for (FPlayer fplayer : this.get())
|
if (!Factions.i.exists(fplayer.getFactionId())) {
|
||||||
{
|
|
||||||
if ( ! Factions.i.exists(fplayer.getFactionId()))
|
|
||||||
{
|
|
||||||
p.log("Reset faction data (invalid faction) for player " + fplayer.getName());
|
p.log("Reset faction data (invalid faction) for player " + fplayer.getName());
|
||||||
fplayer.resetFactionData(false);
|
fplayer.resetFactionData(false);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.iface.RelationParticipator;
|
import com.massivecraft.factions.iface.RelationParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
@ -18,10 +9,16 @@ import com.massivecraft.factions.struct.Relation;
|
|||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.util.*;
|
import com.massivecraft.factions.util.*;
|
||||||
import com.massivecraft.factions.zcore.persist.Entity;
|
import com.massivecraft.factions.zcore.persist.Entity;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
|
||||||
public class Faction extends Entity implements EconomyParticipator
|
public class Faction extends Entity implements EconomyParticipator {
|
||||||
{
|
|
||||||
// FIELD: relationWish
|
// FIELD: relationWish
|
||||||
private Map<String, Relation> relationWish;
|
private Map<String, Relation> relationWish;
|
||||||
|
|
||||||
@ -35,79 +32,133 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
// FIELD: invites
|
// FIELD: invites
|
||||||
// Where string is a lowercase player name
|
// Where string is a lowercase player name
|
||||||
private Set<String> invites;
|
private Set<String> invites;
|
||||||
public void invite(FPlayer fplayer) { this.invites.add(fplayer.getName().toLowerCase()); }
|
|
||||||
public void deinvite(FPlayer fplayer) { this.invites.remove(fplayer.getName().toLowerCase()); }
|
public void invite(FPlayer fplayer) {
|
||||||
public boolean isInvited(FPlayer fplayer) { return this.invites.contains(fplayer.getName().toLowerCase()); }
|
this.invites.add(fplayer.getName().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deinvite(FPlayer fplayer) {
|
||||||
|
this.invites.remove(fplayer.getName().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInvited(FPlayer fplayer) {
|
||||||
|
return this.invites.contains(fplayer.getName().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: open
|
// FIELD: open
|
||||||
private boolean open;
|
private boolean open;
|
||||||
public boolean getOpen() { return open; }
|
|
||||||
public void setOpen(boolean isOpen) { open = isOpen; }
|
public boolean getOpen() {
|
||||||
|
return open;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(boolean isOpen) {
|
||||||
|
open = isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: peaceful
|
// FIELD: peaceful
|
||||||
// "peaceful" status can only be set by server admins/moderators/ops, and prevents PvP and land capture to/from the faction
|
// "peaceful" status can only be set by server admins/moderators/ops, and prevents PvP and land capture to/from the faction
|
||||||
private boolean peaceful;
|
private boolean peaceful;
|
||||||
public boolean isPeaceful() { return this.peaceful; }
|
|
||||||
public void setPeaceful(boolean isPeaceful) { this.peaceful = isPeaceful; }
|
public boolean isPeaceful() {
|
||||||
|
return this.peaceful;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeaceful(boolean isPeaceful) {
|
||||||
|
this.peaceful = isPeaceful;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: peacefulExplosionsEnabled
|
// FIELD: peacefulExplosionsEnabled
|
||||||
private boolean peacefulExplosionsEnabled;
|
private boolean peacefulExplosionsEnabled;
|
||||||
public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; }
|
|
||||||
public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; }
|
|
||||||
|
|
||||||
public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; }
|
public void setPeacefulExplosionsEnabled(boolean val) {
|
||||||
|
peacefulExplosionsEnabled = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPeacefulExplosionsEnabled() {
|
||||||
|
return this.peacefulExplosionsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean noExplosionsInTerritory() {
|
||||||
|
return this.peaceful && !peacefulExplosionsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: permanent
|
// FIELD: permanent
|
||||||
// "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members
|
// "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members
|
||||||
private boolean permanent;
|
private boolean permanent;
|
||||||
public boolean isPermanent() { return permanent || !this.isNormal(); }
|
|
||||||
public void setPermanent(boolean isPermanent) { permanent = isPermanent; }
|
public boolean isPermanent() {
|
||||||
|
return permanent || !this.isNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermanent(boolean isPermanent) {
|
||||||
|
permanent = isPermanent;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: tag
|
// FIELD: tag
|
||||||
private String tag;
|
private String tag;
|
||||||
public String getTag() { return this.tag; }
|
|
||||||
public String getTag(String prefix) { return prefix+this.tag; }
|
public String getTag() {
|
||||||
public String getTag(Faction otherFaction)
|
return this.tag;
|
||||||
{
|
}
|
||||||
if (otherFaction == null)
|
|
||||||
{
|
public String getTag(String prefix) {
|
||||||
|
return prefix + this.tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag(Faction otherFaction) {
|
||||||
|
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() { return MiscUtil.getComparisonString(this.tag); }
|
|
||||||
|
public String getComparisonTag() {
|
||||||
|
return MiscUtil.getComparisonString(this.tag);
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: description
|
// FIELD: description
|
||||||
private String description;
|
private String description;
|
||||||
public String getDescription() { return this.description; }
|
|
||||||
public void setDescription(String value) { this.description = value; }
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String value) {
|
||||||
|
this.description = value;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: home
|
// FIELD: home
|
||||||
private LazyLocation home;
|
private LazyLocation home;
|
||||||
public void setHome(Location home) { this.home = new LazyLocation(home); }
|
|
||||||
public boolean hasHome() { return this.getHome() != null; }
|
public void setHome(Location home) {
|
||||||
public Location getHome()
|
this.home = new LazyLocation(home);
|
||||||
{
|
}
|
||||||
|
|
||||||
|
public boolean hasHome() {
|
||||||
|
return this.getHome() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getFactionAt(new FLocation(this.home.getLocation())) == this))
|
if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getFactionAt(new FLocation(this.home.getLocation())) == this))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -121,8 +172,8 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
// FIELD: account (fake field)
|
// FIELD: account (fake field)
|
||||||
// Bank functions
|
// Bank functions
|
||||||
public double money;
|
public double money;
|
||||||
public String getAccountId()
|
|
||||||
{
|
public String getAccountId() {
|
||||||
String aid = "faction-" + this.getId();
|
String aid = "faction-" + this.getId();
|
||||||
|
|
||||||
// We need to override the default money given to players.
|
// We need to override the default money given to players.
|
||||||
@ -134,23 +185,37 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
|
|
||||||
// FIELD: permanentPower
|
// FIELD: permanentPower
|
||||||
private Integer permanentPower;
|
private Integer permanentPower;
|
||||||
public Integer getPermanentPower() { return this.permanentPower; }
|
|
||||||
public void setPermanentPower(Integer permanentPower) { this.permanentPower = permanentPower; }
|
public Integer getPermanentPower() {
|
||||||
public boolean hasPermanentPower() { return this.permanentPower != null; }
|
return this.permanentPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermanentPower(Integer permanentPower) {
|
||||||
|
this.permanentPower = permanentPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermanentPower() {
|
||||||
|
return this.permanentPower != null;
|
||||||
|
}
|
||||||
|
|
||||||
// FIELD: powerBoost
|
// FIELD: powerBoost
|
||||||
// special increase/decrease to default and max power for this faction
|
// special increase/decrease to default and max power for this faction
|
||||||
private double powerBoost;
|
private double powerBoost;
|
||||||
public double getPowerBoost() { return this.powerBoost; }
|
|
||||||
public void setPowerBoost(double powerBoost) { this.powerBoost = powerBoost; }
|
public double getPowerBoost() {
|
||||||
|
return this.powerBoost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPowerBoost(double powerBoost) {
|
||||||
|
this.powerBoost = powerBoost;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Construct
|
// Construct
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
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.open = Conf.newFactionsDefaultOpen;
|
||||||
@ -168,38 +233,36 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
// Extra Getters And Setters
|
// Extra Getters And Setters
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public boolean noPvPInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); }
|
public boolean noPvPInTerritory() {
|
||||||
|
return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP);
|
||||||
public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); }
|
}
|
||||||
|
|
||||||
|
public boolean noMonstersInTerritory() {
|
||||||
|
return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// Understand the types
|
// Understand the types
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
public boolean isNormal()
|
public boolean isNormal() {
|
||||||
{
|
|
||||||
return !(this.isNone() || this.isSafeZone() || this.isWarZone());
|
return !(this.isNone() || this.isSafeZone() || this.isWarZone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNone()
|
public boolean isNone() {
|
||||||
{
|
|
||||||
return this.getId().equals("0");
|
return this.getId().equals("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSafeZone()
|
public boolean isSafeZone() {
|
||||||
{
|
|
||||||
return this.getId().equals("-1");
|
return this.getId().equals("-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWarZone()
|
public boolean isWarZone() {
|
||||||
{
|
|
||||||
return this.getId().equals("-2");
|
return this.getId().equals("-2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerFreeType()
|
public boolean isPlayerFreeType() {
|
||||||
{
|
|
||||||
return this.isSafeZone() || this.isWarZone();
|
return this.isSafeZone() || this.isWarZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,52 +272,41 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeTo(RelationParticipator that, boolean ucfirst)
|
public String describeTo(RelationParticipator that, boolean ucfirst) {
|
||||||
{
|
|
||||||
return RelationUtil.describeThatToMe(this, that, ucfirst);
|
return RelationUtil.describeThatToMe(this, that, ucfirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String describeTo(RelationParticipator that)
|
public String describeTo(RelationParticipator that) {
|
||||||
{
|
|
||||||
return RelationUtil.describeThatToMe(this, that);
|
return RelationUtil.describeThatToMe(this, that);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp)
|
public Relation getRelationTo(RelationParticipator rp) {
|
||||||
{
|
|
||||||
return RelationUtil.getRelationTo(this, rp);
|
return RelationUtil.getRelationTo(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful)
|
public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful) {
|
||||||
{
|
|
||||||
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatColor getColorTo(RelationParticipator rp)
|
public ChatColor getColorTo(RelationParticipator rp) {
|
||||||
{
|
|
||||||
return RelationUtil.getColorOfThatToMe(this, rp);
|
return RelationUtil.getColorOfThatToMe(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,51 +314,41 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Power
|
// Power
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public double getPower()
|
public double getPower() {
|
||||||
{
|
if (this.hasPermanentPower()) {
|
||||||
if (this.hasPermanentPower())
|
|
||||||
{
|
|
||||||
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() {
|
||||||
{
|
if (this.hasPermanentPower()) {
|
||||||
if (this.hasPermanentPower())
|
|
||||||
{
|
|
||||||
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() {
|
||||||
{
|
|
||||||
return (int) Math.round(this.getPower());
|
return (int) Math.round(this.getPower());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerMaxRounded()
|
public int getPowerMaxRounded() {
|
||||||
{
|
|
||||||
return (int) Math.round(this.getPowerMax());
|
return (int) Math.round(this.getPowerMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,13 +356,11 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
return Board.getFactionCoordCount(this);
|
return Board.getFactionCoordCount(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLandRoundedInWorld(String worldName)
|
public int getLandRoundedInWorld(String worldName) {
|
||||||
{
|
|
||||||
return Board.getFactionCoordCountInWorld(this, worldName);
|
return Board.getFactionCoordCountInWorld(this, worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLandInflation()
|
public boolean hasLandInflation() {
|
||||||
{
|
|
||||||
return this.getLandRounded() > this.getPowerRounded();
|
return this.getLandRounded() > this.getPowerRounded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,47 +369,40 @@ 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)
|
|
||||||
{
|
|
||||||
fplayers.add(fplayer);
|
fplayers.add(fplayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected boolean addFPlayer(FPlayer fplayer)
|
|
||||||
{
|
protected boolean addFPlayer(FPlayer fplayer) {
|
||||||
if (this.isPlayerFreeType()) return false;
|
if (this.isPlayerFreeType()) return false;
|
||||||
|
|
||||||
return fplayers.add(fplayer);
|
return fplayers.add(fplayer);
|
||||||
}
|
}
|
||||||
protected boolean removeFPlayer(FPlayer fplayer)
|
|
||||||
{
|
protected boolean removeFPlayer(FPlayer fplayer) {
|
||||||
if (this.isPlayerFreeType()) return false;
|
if (this.isPlayerFreeType()) return false;
|
||||||
|
|
||||||
return fplayers.remove(fplayer);
|
return fplayers.remove(fplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
Set<FPlayer> ret = new HashSet<FPlayer>();
|
Set<FPlayer> ret = new HashSet<FPlayer>();
|
||||||
|
|
||||||
for (FPlayer fplayer : fplayers)
|
for (FPlayer fplayer : fplayers) {
|
||||||
{
|
if (fplayer.isOnline() == online) {
|
||||||
if (fplayer.isOnline() == online)
|
|
||||||
{
|
|
||||||
ret.add(fplayer);
|
ret.add(fplayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,29 +410,23 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayerAdmin()
|
public FPlayer getFPlayerAdmin() {
|
||||||
{
|
|
||||||
if (!this.isNormal()) return null;
|
if (!this.isNormal()) return null;
|
||||||
|
|
||||||
for (FPlayer fplayer : fplayers)
|
for (FPlayer fplayer : fplayers) {
|
||||||
{
|
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)
|
|
||||||
{
|
|
||||||
ret.add(fplayer);
|
ret.add(fplayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,16 +434,13 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,39 +449,32 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
|
|
||||||
// slightly faster check than getOnlinePlayers() if you just want to see if there are any players online
|
// slightly faster check than getOnlinePlayers() if you just want to see if there are any players online
|
||||||
public boolean hasPlayersOnline()
|
public boolean hasPlayersOnline() {
|
||||||
{
|
|
||||||
// only real factions can have players online, not safe zone / war zone
|
// only real factions can have players online, not safe zone / war zone
|
||||||
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.getFaction() == this)
|
if (fplayer.getFaction() == this) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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() {
|
||||||
{
|
if (this.isNormal()) {
|
||||||
if (this.isNormal())
|
|
||||||
{
|
|
||||||
lastPlayerLoggedOffTime = System.currentTimeMillis();
|
lastPlayerLoggedOffTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// used when current leader is about to be removed from the faction; promotes new leader, or disbands faction if no other members left
|
// used when current leader is about to be removed from the faction; promotes new leader, or disbands faction if no other members left
|
||||||
public void promoteNewLeader()
|
public void promoteNewLeader() {
|
||||||
{
|
|
||||||
if (!this.isNormal()) return;
|
if (!this.isNormal()) return;
|
||||||
if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) return;
|
if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) return;
|
||||||
|
|
||||||
@ -468,10 +485,8 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
if (replacements == null || replacements.isEmpty())
|
if (replacements == null || replacements.isEmpty())
|
||||||
replacements = this.getFPlayersWhereRole(Role.NORMAL);
|
replacements = this.getFPlayersWhereRole(Role.NORMAL);
|
||||||
|
|
||||||
if (replacements == null || replacements.isEmpty())
|
if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction
|
||||||
{ // faction admin is the only member; one-man faction
|
if (this.isPermanent()) {
|
||||||
if (this.isPermanent())
|
|
||||||
{
|
|
||||||
if (oldLeader != null)
|
if (oldLeader != null)
|
||||||
oldLeader.setRole(Role.NORMAL);
|
oldLeader.setRole(Role.NORMAL);
|
||||||
return;
|
return;
|
||||||
@ -481,15 +496,12 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
if (Conf.logFactionDisband)
|
if (Conf.logFactionDisband)
|
||||||
P.p.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left.");
|
P.p.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left.");
|
||||||
|
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
fplayer.msg("The faction %s<i> was disbanded.", this.getTag(fplayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.detach();
|
this.detach();
|
||||||
}
|
} else { // promote new faction admin
|
||||||
else
|
|
||||||
{ // promote new faction admin
|
|
||||||
if (oldLeader != null)
|
if (oldLeader != null)
|
||||||
oldLeader.setRole(Role.NORMAL);
|
oldLeader.setRole(Role.NORMAL);
|
||||||
replacements.get(0).setRole(Role.ADMIN);
|
replacements.get(0).setRole(Role.ADMIN);
|
||||||
@ -502,28 +514,22 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Messages
|
// Messages
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public void msg(String message, Object... args)
|
public void msg(String message, Object... args) {
|
||||||
{
|
|
||||||
message = P.p.txt.parse(message, args);
|
message = P.p.txt.parse(message, args);
|
||||||
|
|
||||||
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
|
for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) {
|
||||||
{
|
|
||||||
fplayer.sendMessage(message);
|
fplayer.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message)
|
public void sendMessage(String message) {
|
||||||
{
|
for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) {
|
||||||
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
fplayer.sendMessage(message);
|
fplayer.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(List<String> messages)
|
public void sendMessage(List<String> messages) {
|
||||||
{
|
for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) {
|
||||||
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
fplayer.sendMessage(messages);
|
fplayer.sendMessage(messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,49 +538,39 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
// Ownership of specific claims
|
// Ownership of specific claims
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public void clearAllClaimOwnership()
|
public void clearAllClaimOwnership() {
|
||||||
{
|
|
||||||
claimOwnership.clear();
|
claimOwnership.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearClaimOwnership(FLocation loc)
|
public void clearClaimOwnership(FLocation loc) {
|
||||||
{
|
if (Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) {
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
|
||||||
{
|
|
||||||
LWCFeatures.clearAllChests(loc);
|
LWCFeatures.clearAllChests(loc);
|
||||||
}
|
}
|
||||||
claimOwnership.remove(loc);
|
claimOwnership.remove(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearClaimOwnership(String playerName)
|
public void clearClaimOwnership(String playerName) {
|
||||||
{
|
if (playerName == null || playerName.isEmpty()) {
|
||||||
if (playerName == null || playerName.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> ownerData;
|
Set<String> ownerData;
|
||||||
String player = playerName.toLowerCase();
|
String player = playerName.toLowerCase();
|
||||||
|
|
||||||
for (Entry<FLocation, Set<String>> entry : claimOwnership.entrySet())
|
for (Entry<FLocation, Set<String>> entry : claimOwnership.entrySet()) {
|
||||||
{
|
|
||||||
ownerData = entry.getValue();
|
ownerData = entry.getValue();
|
||||||
|
|
||||||
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)) {
|
||||||
if (iter.next().equals(player))
|
|
||||||
{
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ownerData.isEmpty())
|
if (ownerData.isEmpty()) {
|
||||||
{
|
if (Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) {
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
|
||||||
{
|
|
||||||
LWCFeatures.clearAllChests(entry.getKey());
|
LWCFeatures.clearAllChests(entry.getKey());
|
||||||
}
|
}
|
||||||
claimOwnership.remove(entry.getKey());
|
claimOwnership.remove(entry.getKey());
|
||||||
@ -582,15 +578,12 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCountOfClaimsWithOwners()
|
public int getCountOfClaimsWithOwners() {
|
||||||
{
|
|
||||||
return claimOwnership.isEmpty() ? 0 : claimOwnership.size();
|
return claimOwnership.isEmpty() ? 0 : claimOwnership.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesLocationHaveOwnersSet(FLocation loc)
|
public boolean doesLocationHaveOwnersSet(FLocation loc) {
|
||||||
{
|
if (claimOwnership.isEmpty() || !claimOwnership.containsKey(loc)) {
|
||||||
if (claimOwnership.isEmpty() || !claimOwnership.containsKey(loc))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,57 +591,46 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
return ownerData != null && !ownerData.isEmpty();
|
return ownerData != null && !ownerData.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerInOwnerList(String playerName, FLocation loc)
|
public boolean isPlayerInOwnerList(String playerName, FLocation loc) {
|
||||||
{
|
if (claimOwnership.isEmpty()) {
|
||||||
if (claimOwnership.isEmpty())
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
Set<String> ownerData = claimOwnership.get(loc);
|
||||||
if (ownerData == null)
|
if (ownerData == null) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (ownerData.contains(playerName.toLowerCase()))
|
if (ownerData.contains(playerName.toLowerCase())) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerAsOwner(String playerName, FLocation loc)
|
public void setPlayerAsOwner(String playerName, 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(playerName.toLowerCase());
|
ownerData.add(playerName.toLowerCase());
|
||||||
claimOwnership.put(loc, ownerData);
|
claimOwnership.put(loc, ownerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayerAsOwner(String playerName, FLocation loc)
|
public void removePlayerAsOwner(String playerName, FLocation loc) {
|
||||||
{
|
|
||||||
Set<String> ownerData = claimOwnership.get(loc);
|
Set<String> ownerData = claimOwnership.get(loc);
|
||||||
if (ownerData == null)
|
if (ownerData == null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ownerData.remove(playerName.toLowerCase());
|
ownerData.remove(playerName.toLowerCase());
|
||||||
claimOwnership.put(loc, ownerData);
|
claimOwnership.put(loc, ownerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getOwnerList(FLocation loc)
|
public Set<String> getOwnerList(FLocation loc) {
|
||||||
{
|
|
||||||
return claimOwnership.get(loc);
|
return claimOwnership.get(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,8 +638,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
|
|
||||||
Iterator<String> iter = ownerData.iterator();
|
Iterator<String> iter = ownerData.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
if (!ownerList.isEmpty())
|
if (!ownerList.isEmpty()) {
|
||||||
{
|
|
||||||
ownerList += ", ";
|
ownerList += ", ";
|
||||||
}
|
}
|
||||||
ownerList += iter.next();
|
ownerList += iter.next();
|
||||||
@ -665,8 +646,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
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
|
if
|
||||||
(
|
(
|
||||||
@ -677,8 +657,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
||
|
||
|
||||||
Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer())
|
Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer())
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,10 +682,8 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postDetach()
|
public void postDetach() {
|
||||||
{
|
if (Econ.shouldBeUsed()) {
|
||||||
if (Econ.shouldBeUsed())
|
|
||||||
{
|
|
||||||
Econ.setBalance(getAccountId(), 0);
|
Econ.setBalance(getAccountId(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,26 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
|
import com.massivecraft.factions.zcore.persist.EntityCollection;
|
||||||
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
public class Factions extends EntityCollection<Faction> {
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
|
||||||
import com.massivecraft.factions.zcore.persist.EntityCollection;
|
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
|
||||||
|
|
||||||
public class Factions extends EntityCollection<Faction>
|
|
||||||
{
|
|
||||||
public static Factions i = new Factions();
|
public static Factions i = new Factions();
|
||||||
|
|
||||||
P p = P.p;
|
P p = P.p;
|
||||||
|
|
||||||
private Factions()
|
private Factions() {
|
||||||
{
|
|
||||||
super
|
super
|
||||||
(
|
(
|
||||||
Faction.class,
|
Faction.class,
|
||||||
@ -33,33 +32,28 @@ 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
|
||||||
public boolean loadFromDisc()
|
public boolean loadFromDisc() {
|
||||||
{
|
|
||||||
if (!super.loadFromDisc()) return false;
|
if (!super.loadFromDisc()) return false;
|
||||||
|
|
||||||
// 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(ChatColor.DARK_GREEN + "Wilderness");
|
faction.setTag(ChatColor.DARK_GREEN + "Wilderness");
|
||||||
faction.setDescription("");
|
faction.setDescription("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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("SafeZone");
|
faction.setTag("SafeZone");
|
||||||
faction.setDescription("Free from PVP and monsters");
|
faction.setDescription("Free from PVP and monsters");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// 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 " "
|
||||||
Faction faction = this.getSafeZone();
|
Faction faction = this.getSafeZone();
|
||||||
if (faction.getTag().contains(" "))
|
if (faction.getTag().contains(" "))
|
||||||
@ -67,14 +61,11 @@ 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("WarZone");
|
faction.setTag("WarZone");
|
||||||
faction.setDescription("Not the safest place to be");
|
faction.setDescription("Not the safest place to be");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// 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 " "
|
||||||
Faction faction = this.getWarZone();
|
Faction faction = this.getWarZone();
|
||||||
if (faction.getTag().contains(" "))
|
if (faction.getTag().contains(" "))
|
||||||
@ -82,8 +73,7 @@ public class Factions extends EntityCollection<Faction>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// populate all faction player lists
|
// populate all faction player lists
|
||||||
for (Faction faction : i.get())
|
for (Faction faction : i.get()) {
|
||||||
{
|
|
||||||
faction.refreshFPlayers();
|
faction.refreshFPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,10 +86,8 @@ 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();
|
||||||
@ -108,18 +96,15 @@ public class Factions extends EntityCollection<Faction>
|
|||||||
return super.get(id);
|
return super.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getNone()
|
public Faction getNone() {
|
||||||
{
|
|
||||||
return this.get("0");
|
return this.get("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getSafeZone()
|
public Faction getSafeZone() {
|
||||||
{
|
|
||||||
return this.get("-1");
|
return this.get("-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getWarZone()
|
public Faction getWarZone() {
|
||||||
{
|
|
||||||
return this.get("-2");
|
return this.get("-2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,24 +113,19 @@ public class Factions extends EntityCollection<Faction>
|
|||||||
// Faction tag
|
// Faction tag
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
public static ArrayList<String> validateTag(String str)
|
public static ArrayList<String> validateTag(String str) {
|
||||||
{
|
|
||||||
ArrayList<String> errors = new ArrayList<String>();
|
ArrayList<String> errors = new ArrayList<String>();
|
||||||
|
|
||||||
if(MiscUtil.getComparisonString(str).length() < Conf.factionTagLengthMin)
|
if (MiscUtil.getComparisonString(str).length() < Conf.factionTagLengthMin) {
|
||||||
{
|
|
||||||
errors.add(P.p.txt.parse("<i>The faction tag can't be shorter than <h>%s<i> chars.", Conf.factionTagLengthMin));
|
errors.add(P.p.txt.parse("<i>The faction tag can't be shorter than <h>%s<i> chars.", Conf.factionTagLengthMin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(str.length() > Conf.factionTagLengthMax)
|
if (str.length() > Conf.factionTagLengthMax) {
|
||||||
{
|
|
||||||
errors.add(P.p.txt.parse("<i>The faction tag can't be longer than <h>%s<i> chars.", Conf.factionTagLengthMax));
|
errors.add(P.p.txt.parse("<i>The faction tag can't be longer than <h>%s<i> chars.", Conf.factionTagLengthMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (char c : str.toCharArray())
|
for (char c : str.toCharArray()) {
|
||||||
{
|
if (!MiscUtil.substanceChars.contains(String.valueOf(c))) {
|
||||||
if ( ! MiscUtil.substanceChars.contains(String.valueOf(c)))
|
|
||||||
{
|
|
||||||
errors.add(P.p.txt.parse("<i>Faction tag must be alphanumeric. \"<h>%s<i>\" is not allowed.", c));
|
errors.add(P.p.txt.parse("<i>Faction tag must be alphanumeric. \"<h>%s<i>\" is not allowed.", c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,26 +133,21 @@ public class Factions extends EntityCollection<Faction>
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
Map<String, Faction> tag2faction = new HashMap<String, Faction>();
|
Map<String, Faction> tag2faction = new HashMap<String, Faction>();
|
||||||
|
|
||||||
// TODO: Slow index building
|
// TODO: Slow index building
|
||||||
for (Faction faction : this.get())
|
for (Faction faction : this.get()) {
|
||||||
{
|
|
||||||
tag2faction.put(ChatColor.stripColor(faction.getTag()), faction);
|
tag2faction.put(ChatColor.stripColor(faction.getTag()), faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +156,7 @@ public class Factions extends EntityCollection<Faction>
|
|||||||
return tag2faction.get(tag);
|
return tag2faction.get(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTagTaken(String str)
|
public boolean isTagTaken(String str) {
|
||||||
{
|
|
||||||
return this.getByTag(str) != null;
|
return this.getByTag(str) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,10 @@
|
|||||||
package com.massivecraft.factions;
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.CmdAutoHelp;
|
import com.massivecraft.factions.cmd.CmdAutoHelp;
|
||||||
import com.massivecraft.factions.cmd.FCmdRoot;
|
import com.massivecraft.factions.cmd.FCmdRoot;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.*;
|
||||||
import com.massivecraft.factions.integration.EssentialsFeatures;
|
|
||||||
import com.massivecraft.factions.integration.LWCFeatures;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.integration.Worldguard;
|
|
||||||
import com.massivecraft.factions.integration.capi.CapiFeatures;
|
import com.massivecraft.factions.integration.capi.CapiFeatures;
|
||||||
import com.massivecraft.factions.listeners.FactionsBlockListener;
|
import com.massivecraft.factions.listeners.*;
|
||||||
import com.massivecraft.factions.listeners.FactionsChatListener;
|
|
||||||
import com.massivecraft.factions.listeners.FactionsEntityListener;
|
|
||||||
import com.massivecraft.factions.listeners.FactionsExploitListener;
|
|
||||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
|
||||||
import com.massivecraft.factions.listeners.FactionsServerListener;
|
|
||||||
import com.massivecraft.factions.struct.ChatMode;
|
import com.massivecraft.factions.struct.ChatMode;
|
||||||
import com.massivecraft.factions.util.AutoLeaveTask;
|
import com.massivecraft.factions.util.AutoLeaveTask;
|
||||||
import com.massivecraft.factions.util.LazyLocation;
|
import com.massivecraft.factions.util.LazyLocation;
|
||||||
@ -36,14 +12,26 @@ import com.massivecraft.factions.util.MapFLocToStringSetTypeAdapter;
|
|||||||
import com.massivecraft.factions.util.MyLocationTypeAdapter;
|
import com.massivecraft.factions.util.MyLocationTypeAdapter;
|
||||||
import com.massivecraft.factions.zcore.MPlugin;
|
import com.massivecraft.factions.zcore.MPlugin;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
|
import org.bukkit.Location;
|
||||||
import java.util.logging.Level;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.GsonBuilder;
|
import org.bukkit.craftbukkit.libs.com.google.gson.GsonBuilder;
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
public class P extends MPlugin
|
public class P extends MPlugin {
|
||||||
{
|
|
||||||
// Our single plugin instance
|
// Our single plugin instance
|
||||||
public static P p;
|
public static P p;
|
||||||
|
|
||||||
@ -57,16 +45,23 @@ public class P extends MPlugin
|
|||||||
|
|
||||||
// Persistance related
|
// Persistance related
|
||||||
private boolean locked = false;
|
private boolean locked = false;
|
||||||
public boolean getLocked() {return this.locked;}
|
|
||||||
public void setLocked(boolean val) {this.locked = val; this.setAutoSave(val);}
|
public boolean getLocked() {
|
||||||
|
return this.locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocked(boolean val) {
|
||||||
|
this.locked = val;
|
||||||
|
this.setAutoSave(val);
|
||||||
|
}
|
||||||
|
|
||||||
private Integer AutoLeaveTask = null;
|
private Integer AutoLeaveTask = null;
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
public FCmdRoot cmdBase;
|
public FCmdRoot cmdBase;
|
||||||
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.chatListener = new FactionsChatListener(this);
|
||||||
@ -78,15 +73,11 @@ public class P extends MPlugin
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable() {
|
||||||
{
|
|
||||||
// bit of (apparently absolutely necessary) idiot-proofing for CB version support due to changed GSON lib package name
|
// bit of (apparently absolutely necessary) idiot-proofing for CB version support due to changed GSON lib package name
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
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;
|
||||||
@ -112,8 +103,7 @@ public class P extends MPlugin
|
|||||||
CapiFeatures.setup();
|
CapiFeatures.setup();
|
||||||
LWCFeatures.setup();
|
LWCFeatures.setup();
|
||||||
|
|
||||||
if(Conf.worldGuardChecking || Conf.worldGuardBuildPriority)
|
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) {
|
||||||
{
|
|
||||||
Worldguard.init(this);
|
Worldguard.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,9 +126,9 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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()
|
.setPrettyPrinting()
|
||||||
@ -149,62 +139,53 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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();
|
||||||
}
|
}
|
||||||
EssentialsFeatures.unhookChat();
|
EssentialsFeatures.unhookChat();
|
||||||
if (AutoLeaveTask != null)
|
if (AutoLeaveTask != null) {
|
||||||
{
|
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||||
AutoLeaveTask = null;
|
AutoLeaveTask = null;
|
||||||
}
|
}
|
||||||
super.onDisable();
|
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) {
|
||||||
{
|
|
||||||
long ticks = (long) (20 * 60 * Conf.autoLeaveRoutineRunsEveryXMinutes);
|
long ticks = (long) (20 * 60 * Conf.autoLeaveRoutineRunsEveryXMinutes);
|
||||||
AutoLeaveTask = getServer().getScheduler().scheduleSyncRepeatingTask(this, new AutoLeaveTask(), ticks, ticks);
|
AutoLeaveTask = getServer().getScheduler().scheduleSyncRepeatingTask(this, new AutoLeaveTask(), ticks, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postAutoSave()
|
public void postAutoSave() {
|
||||||
{
|
|
||||||
Board.save();
|
Board.save();
|
||||||
Conf.save();
|
Conf.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean logPlayerCommands()
|
public boolean logPlayerCommands() {
|
||||||
{
|
|
||||||
return Conf.logPlayerCommands;
|
return Conf.logPlayerCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly)
|
public boolean handleCommand(CommandSender sender, String commandString, boolean testOnly) {
|
||||||
{
|
if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player) sender))
|
||||||
if (sender instanceof Player && FactionsPlayerListener.preventCommand(commandString, (Player)sender)) return true;
|
return true;
|
||||||
|
|
||||||
return super.handleCommand(sender, commandString, testOnly);
|
return super.handleCommand(sender, commandString, testOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] split)
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
|
||||||
{
|
|
||||||
// if bare command at this point, it has already been handled by MPlugin's command listeners
|
// if bare command at this point, it has already been handled by MPlugin's command listeners
|
||||||
if (split == null || split.length == 0) return true;
|
if (split == null || split.length == 0) return true;
|
||||||
|
|
||||||
@ -214,36 +195,31 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Functions for other plugins to hook into
|
// Functions for other plugins to hook into
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// This value will be updated whenever new hooks are added
|
// This value will be updated whenever new hooks are added
|
||||||
public int hookSupportVersion()
|
public int hookSupportVersion() {
|
||||||
{
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If another plugin is handling insertion of chat tags, this should be used to notify Factions
|
// If another plugin is handling insertion of chat tags, this should be used to notify Factions
|
||||||
public void handleFactionTagExternally(boolean notByFactions)
|
public void handleFactionTagExternally(boolean notByFactions) {
|
||||||
{
|
|
||||||
Conf.chatTagHandledByAnotherPlugin = notByFactions;
|
Conf.chatTagHandledByAnotherPlugin = notByFactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat
|
// Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat
|
||||||
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
|
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
|
||||||
|
|
||||||
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event)
|
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) {
|
||||||
{
|
|
||||||
if (event == null) return false;
|
if (event == null) return false;
|
||||||
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
@ -255,21 +231,18 @@ 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
|
||||||
public String getPlayerFactionTag(Player player)
|
public String getPlayerFactionTag(Player player) {
|
||||||
{
|
|
||||||
return getPlayerFactionTagRelation(player, null);
|
return getPlayerFactionTagRelation(player, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag
|
// Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag
|
||||||
public String getPlayerFactionTagRelation(Player speaker, Player listener)
|
public String getPlayerFactionTagRelation(Player speaker, Player listener) {
|
||||||
{
|
|
||||||
String tag = "~";
|
String tag = "~";
|
||||||
|
|
||||||
if (speaker == null)
|
if (speaker == null)
|
||||||
@ -296,8 +269,7 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
||||||
public String getPlayerTitle(Player player)
|
public String getPlayerTitle(Player player) {
|
||||||
{
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@ -309,25 +281,20 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,14 +302,11 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,20 +314,17 @@ public class P extends MPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if player is allowed to build/destroy in a particular location
|
// check if player is allowed to build/destroy in a particular location
|
||||||
public boolean isPlayerAllowedToBuildHere(Player player, Location location)
|
public boolean isPlayerAllowedToBuildHere(Player player, Location location) {
|
||||||
{
|
|
||||||
return FactionsBlockListener.playerCanBuildDestroyBlock(player, location, "", true);
|
return FactionsBlockListener.playerCanBuildDestroyBlock(player, location, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if player is allowed to interact with the specified block (doors/chests/whatever)
|
// check if player is allowed to interact with the specified block (doors/chests/whatever)
|
||||||
public boolean isPlayerAllowedToInteractWith(Player player, Block block)
|
public boolean isPlayerAllowedToInteractWith(Player player, Block block) {
|
||||||
{
|
|
||||||
return FactionsPlayerListener.canPlayerUseBlock(player, block, true);
|
return FactionsPlayerListener.canPlayerUseBlock(player, block, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if player is allowed to use a specified item (flint&steel, buckets, etc) in a particular location
|
// check if player is allowed to use a specified item (flint&steel, buckets, etc) in a particular location
|
||||||
public boolean isPlayerAllowedToUseThisHere(Player player, Location location, Material material)
|
public boolean isPlayerAllowedToUseThisHere(Player player, Location location, Material material) {
|
||||||
{
|
|
||||||
return FactionsPlayerListener.playerCanUseItemHere(player, location, material, true);
|
return FactionsPlayerListener.playerCanUseItemHere(player, location, material, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -29,35 +26,30 @@ public class CmdAdmin extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
@ -66,8 +58,7 @@ public class CmdAdmin extends FCommand
|
|||||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||||
|
|
||||||
// if target player is currently admin, demote and replace him
|
// if target player is currently admin, demote and replace him
|
||||||
if (fyou == admin)
|
if (fyou == admin) {
|
||||||
{
|
|
||||||
targetFaction.promoteNewLeader();
|
targetFaction.promoteNewLeader();
|
||||||
msg("<i>You have demoted %s<i> from the position of faction admin.", fyou.describeTo(fme, true));
|
msg("<i>You have demoted %s<i> from the position of faction admin.", fyou.describeTo(fme, true));
|
||||||
fyou.msg("<i>You have been demoted from the position of faction admin by %s<i>.", senderIsConsole ? "a server admin" : fme.describeTo(fyou, true));
|
fyou.msg("<i>You have been demoted from the position of faction admin by %s<i>.", senderIsConsole ? "a server admin" : fme.describeTo(fyou, true));
|
||||||
@ -81,8 +72,7 @@ public class CmdAdmin extends FCommand
|
|||||||
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
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : fme.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
fplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : fme.describeTo(fplayer, true), fyou.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,8 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
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");
|
||||||
|
|
||||||
@ -24,18 +22,15 @@ public class CmdAutoClaim extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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.");
|
msg("<i>Auto-claiming of land disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! fme.canClaimForFaction(forFaction))
|
if (!fme.canClaimForFaction(forFaction)) {
|
||||||
{
|
|
||||||
if (myFaction == forFaction)
|
if (myFaction == forFaction)
|
||||||
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
||||||
else
|
else
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.zcore.CommandVisibility;
|
import com.massivecraft.factions.zcore.CommandVisibility;
|
||||||
import com.massivecraft.factions.zcore.MCommand;
|
import com.massivecraft.factions.zcore.MCommand;
|
||||||
|
|
||||||
public class CmdAutoHelp extends MCommand<P>
|
import java.util.ArrayList;
|
||||||
{
|
|
||||||
public CmdAutoHelp()
|
public class CmdAutoHelp extends MCommand<P> {
|
||||||
{
|
public CmdAutoHelp() {
|
||||||
super(P.p);
|
super(P.p);
|
||||||
this.aliases.add("?");
|
this.aliases.add("?");
|
||||||
this.aliases.add("h");
|
this.aliases.add("h");
|
||||||
@ -21,8 +19,7 @@ public class CmdAutoHelp extends MCommand<P>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
if (this.commandChain.size() == 0) return;
|
if (this.commandChain.size() == 0) return;
|
||||||
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
||||||
|
|
||||||
@ -30,15 +27,13 @@ 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.VISIBLE
|
||||||
||
|
||
|
||||||
(scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))
|
(scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -23,10 +21,8 @@ public class CmdBoom extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -23,18 +21,14 @@ public class CmdBypass extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing()));
|
fme.setIsAdminBypassing(this.argAsBool(0, !fme.isAdminBypassing()));
|
||||||
|
|
||||||
// TODO: Move this to a transient field in the model??
|
// TODO: Move this to a transient field in the model??
|
||||||
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.");
|
fme.msg("<i>You have disabled admin bypass mode.");
|
||||||
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.struct.ChatMode;
|
import com.massivecraft.factions.struct.ChatMode;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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("c");
|
||||||
this.aliases.add("chat");
|
this.aliases.add("chat");
|
||||||
@ -26,10 +24,8 @@ public class CmdChat extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
@ -37,23 +33,15 @@ public class CmdChat extends FCommand
|
|||||||
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'");
|
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,16 +49,11 @@ public class CmdChat extends FCommand
|
|||||||
|
|
||||||
fme.setChatMode(modeTarget);
|
fme.setChatMode(modeTarget);
|
||||||
|
|
||||||
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -22,17 +20,13 @@ public class CmdChatSpy extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
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 {
|
||||||
else
|
|
||||||
{
|
|
||||||
fme.msg("<i>You have disabled chat spying mode.");
|
fme.msg("<i>You have disabled chat spying mode.");
|
||||||
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.SpiralTask;
|
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");
|
||||||
|
|
||||||
@ -29,45 +27,36 @@ public class CmdClaim extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
{
|
|
||||||
private int failCount = 0;
|
private int failCount = 0;
|
||||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||||
|
|
||||||
@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)
|
if (success)
|
||||||
failCount = 0;
|
failCount = 0;
|
||||||
else if ( ! success && failCount++ >= limit)
|
else if (!success && failCount++ >= limit) {
|
||||||
{
|
|
||||||
this.stop();
|
this.stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,23 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CmdConfig extends FCommand
|
import java.lang.reflect.Field;
|
||||||
{
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
@ -38,28 +35,23 @@ public class CmdConfig extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -67,116 +59,88 @@ public class CmdConfig extends FCommand
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Field target = Conf.class.getField(fieldName);
|
Field target = Conf.class.getField(fieldName);
|
||||||
|
|
||||||
// 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).";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -185,32 +149,25 @@ public class CmdConfig extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set<?> or other parameterized collection
|
// Set<?> or other parameterized collection
|
||||||
else if (target.getGenericType() instanceof ParameterizedType)
|
else if (target.getGenericType() instanceof ParameterizedType) {
|
||||||
{
|
|
||||||
ParameterizedType targSet = (ParameterizedType) target.getGenericType();
|
ParameterizedType targSet = (ParameterizedType) target.getGenericType();
|
||||||
Type innerType = targSet.getActualTypeArguments()[0];
|
Type innerType = targSet.getActualTypeArguments()[0];
|
||||||
|
|
||||||
// not a Set, somehow, and that should be the only collection we're using in Conf.java
|
// not a Set, somehow, and that should be the only collection we're using in Conf.java
|
||||||
if (targSet.getRawType() != Set.class)
|
if (targSet.getRawType() != Set.class) {
|
||||||
{
|
|
||||||
sendMessage("\"" + fieldName + "\" is not a data collection type which can be modified with this command.");
|
sendMessage("\"" + fieldName + "\" is not a data collection type which can be modified with this command.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -219,15 +176,13 @@ public class CmdConfig extends FCommand
|
|||||||
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.";
|
||||||
@ -235,21 +190,18 @@ public class CmdConfig extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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.";
|
||||||
@ -257,39 +209,30 @@ public class CmdConfig extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set of unknown type
|
// Set of unknown type
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
sendMessage("\"" + fieldName + "\" is not a data type set which can be modified with this command.");
|
sendMessage("\"" + fieldName + "\" is not a data type set which can be modified with this command.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown type
|
// unknown type
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
sendMessage("\"" + fieldName + "\" is not a data type which can be modified with this command.");
|
sendMessage("\"" + fieldName + "\" is not a data type which can be modified with this command.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} catch (NoSuchFieldException ex) {
|
||||||
catch (NoSuchFieldException ex)
|
|
||||||
{
|
|
||||||
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
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.massivecraft.factions.*;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||||
import com.massivecraft.factions.event.FactionCreateEvent;
|
import com.massivecraft.factions.event.FactionCreateEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
@ -36,25 +28,21 @@ public class CmdCreate extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
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);
|
sendMessage(tagValidationErrors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,8 +61,7 @@ public class CmdCreate extends FCommand
|
|||||||
Faction faction = Factions.i.create();
|
Faction faction = Factions.i.create();
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -91,8 +78,7 @@ public class CmdCreate extends FCommand
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,9 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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("deinvite");
|
||||||
this.aliases.add("deinv");
|
this.aliases.add("deinv");
|
||||||
@ -25,13 +23,11 @@ public class CmdDeinvite extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
@ -6,10 +6,8 @@ import com.massivecraft.factions.FPlayers;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
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");
|
||||||
|
|
||||||
@ -27,23 +25,21 @@ public class CmdDescription extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
// 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.econCostDesc, "to change faction description", "for changing faction description")) return;
|
if (!payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description"))
|
||||||
|
return;
|
||||||
|
|
||||||
myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("(&([a-f0-9]))", "& $2")); // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
|
myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("(&([a-f0-9]))", "& $2")); // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up
|
||||||
|
|
||||||
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
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
fplayer.msg("<i>The faction %s<i> changed their description to:", myFaction.describeTo(fplayer));
|
fplayer.msg("<i>The faction %s<i> changed their description to:", myFaction.describeTo(fplayer));
|
||||||
fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking
|
fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "<i>" or whatever in their description; &k is particularly interesting looking
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,17 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import com.massivecraft.factions.*;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||||
import com.massivecraft.factions.event.FactionDisbandEvent;
|
import com.massivecraft.factions.event.FactionDisbandEvent;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -35,33 +28,26 @@ public class CmdDisband extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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())
|
if (faction.isPermanent()) {
|
||||||
{
|
|
||||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -71,35 +57,28 @@ public class CmdDisband extends FCommand
|
|||||||
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()) {
|
||||||
{
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, faction, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND));
|
Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, faction, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
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()) + ".");
|
||||||
|
|
||||||
if (Econ.shouldBeUsed() && ! senderIsConsole)
|
if (Econ.shouldBeUsed() && !senderIsConsole) {
|
||||||
{
|
|
||||||
//Give all the faction's money to the disbander
|
//Give all the faction's money to the disbander
|
||||||
double amount = Econ.getBalance(faction.getAccountId());
|
double amount = Econ.getBalance(faction.getAccountId());
|
||||||
Econ.transferMoney(fme, faction, fme, amount, false);
|
Econ.transferMoney(fme, faction, fme, amount, false);
|
||||||
|
|
||||||
if (amount > 0.0)
|
if (amount > 0.0) {
|
||||||
{
|
|
||||||
String amountString = Econ.moneyString(amount);
|
String amountString = Econ.moneyString(amount);
|
||||||
msg("<i>You have been given the disbanded faction's bank, totaling %s.", amountString);
|
msg("<i>You have been given the disbanded faction's bank, totaling %s.", amountString);
|
||||||
P.p.log(fme.getName() + " has been given bank holdings of " + amountString + " from disbanding " + faction.getTag() + ".");
|
P.p.log(fme.getName() + " has been given bank holdings of " + amountString + " from disbanding " + faction.getTag() + ".");
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CmdHelp extends FCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
public CmdHelp()
|
public class CmdHelp extends FCommand {
|
||||||
{
|
|
||||||
|
public CmdHelp() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("help");
|
this.aliases.add("help");
|
||||||
this.aliases.add("h");
|
this.aliases.add("h");
|
||||||
@ -31,8 +29,7 @@ public class CmdHelp extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
if (helpPages == null) updateHelp();
|
if (helpPages == null) updateHelp();
|
||||||
|
|
||||||
int page = this.argAsInt(0, 1);
|
int page = this.argAsInt(0, 1);
|
||||||
@ -41,8 +38,7 @@ 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;
|
||||||
}
|
}
|
||||||
@ -55,8 +51,7 @@ 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;
|
||||||
|
|
||||||
@ -84,8 +79,7 @@ public class CmdHelp extends FCommand
|
|||||||
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"));
|
||||||
|
@ -1,30 +1,22 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.massivecraft.factions.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.integration.EssentialsFeatures;
|
import com.massivecraft.factions.integration.EssentialsFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -41,36 +33,30 @@ public class CmdHome extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
@ -94,15 +80,13 @@ public class CmdHome extends FCommand
|
|||||||
!Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory
|
!Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
World w = loc.getWorld();
|
World w = loc.getWorld();
|
||||||
double x = loc.getX();
|
double x = loc.getX();
|
||||||
double y = loc.getY();
|
double y = loc.getY();
|
||||||
double z = loc.getZ();
|
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)
|
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -129,11 +113,11 @@ public class CmdHome extends FCommand
|
|||||||
if (EssentialsFeatures.handleTeleport(me, myFaction.getHome())) return;
|
if (EssentialsFeatures.handleTeleport(me, myFaction.getHome())) 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
|
||||||
if ( ! payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home")) return;
|
if (!payForCommand(Conf.econCostHome, "to teleport to your faction home", "for teleporting to your faction home"))
|
||||||
|
return;
|
||||||
|
|
||||||
// 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(loc.add(0, 1, 0));
|
||||||
|
@ -4,10 +4,8 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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("invite");
|
||||||
this.aliases.add("inv");
|
this.aliases.add("inv");
|
||||||
@ -25,13 +23,11 @@ public class CmdInvite extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import com.massivecraft.factions.*;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -30,52 +23,44 @@ public class CmdJoin extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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()) {
|
||||||
{
|
|
||||||
msg("<b>%s %s already a member of %s", fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme));
|
msg("<b>%s %s already a member of %s", fplayer.describeTo(fme, true), (samePlayer ? "are" : "is"), faction.getTag(fme));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit)
|
if (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit) {
|
||||||
{
|
|
||||||
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false));
|
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fplayer.hasFaction())
|
if (fplayer.hasFaction()) {
|
||||||
{
|
|
||||||
msg("<b>%s must leave %s current faction first.", fplayer.describeTo(fme, true), (samePlayer ? "your" : "their"));
|
msg("<b>%s must leave %s current faction first.", fplayer.describeTo(fme, true), (samePlayer ? "your" : "their"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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))) {
|
||||||
{
|
|
||||||
msg("<i>This faction requires invitation.");
|
msg("<i>This faction requires invitation.");
|
||||||
if (samePlayer)
|
if (samePlayer)
|
||||||
faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true));
|
faction.msg("%s<i> tried to join your faction.", fplayer.describeTo(faction, true));
|
||||||
@ -103,8 +88,7 @@ public class CmdJoin extends FCommand
|
|||||||
fplayer.setFaction(faction);
|
fplayer.setFaction(faction);
|
||||||
faction.deinvite(fplayer);
|
faction.deinvite(fplayer);
|
||||||
|
|
||||||
if (Conf.logFactionJoin)
|
if (Conf.logFactionJoin) {
|
||||||
{
|
|
||||||
if (samePlayer)
|
if (samePlayer)
|
||||||
P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag());
|
P.p.log("%s joined the faction %s.", fplayer.getName(), faction.getTag());
|
||||||
else
|
else
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
@ -9,12 +7,11 @@ import com.massivecraft.factions.P;
|
|||||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -31,13 +28,11 @@ public class CmdKick extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
@ -46,23 +41,19 @@ public class CmdKick extends FCommand
|
|||||||
Faction yourFaction = you.getFaction();
|
Faction yourFaction = you.getFaction();
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -77,12 +68,12 @@ public class CmdKick extends FCommand
|
|||||||
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")) return;
|
if (!payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction"))
|
||||||
|
return;
|
||||||
|
|
||||||
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
|
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
|
||||||
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
|
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
|
||||||
if (yourFaction != myFaction)
|
if (yourFaction != myFaction) {
|
||||||
{
|
|
||||||
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
|
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ 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");
|
||||||
|
|
||||||
@ -22,8 +21,7 @@ public class CmdLeave extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
fme.leave(true);
|
fme.leave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class CmdList extends FCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
public CmdList()
|
public class CmdList extends FCommand {
|
||||||
{
|
|
||||||
|
public CmdList() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("list");
|
this.aliases.add("list");
|
||||||
this.aliases.add("ls");
|
this.aliases.add("ls");
|
||||||
@ -32,8 +30,7 @@ public class CmdList extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
// 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.econCostList, "to list the factions", "for listing the factions")) return;
|
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return;
|
||||||
|
|
||||||
@ -105,10 +102,8 @@ public class CmdList extends FCommand
|
|||||||
|
|
||||||
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
|
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount));
|
||||||
|
|
||||||
for (Faction faction : factionList.subList(start, end))
|
for (Faction faction : factionList.subList(start, end)) {
|
||||||
{
|
if (faction.isNone()) {
|
||||||
if (faction.isNone())
|
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ public class CmdLock extends FCommand {
|
|||||||
default: op
|
default: op
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdLock()
|
public CmdLock() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
this.aliases.add("lock");
|
this.aliases.add("lock");
|
||||||
|
|
||||||
@ -29,16 +28,12 @@ public class CmdLock extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
p.setLocked(this.argAsBool(0, !p.getLocked()));
|
p.setLocked(this.argAsBool(0, !p.getLocked()));
|
||||||
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,8 @@ import com.massivecraft.factions.FLocation;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -26,12 +24,9 @@ public class CmdMap extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (this.argIsSet(0)) {
|
||||||
if (this.argIsSet(0))
|
if (this.argAsBool(0, !fme.isMapAutoUpdating())) {
|
||||||
{
|
|
||||||
if (this.argAsBool(0, ! fme.isMapAutoUpdating()))
|
|
||||||
{
|
|
||||||
// Turn on
|
// Turn on
|
||||||
|
|
||||||
// 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
|
||||||
@ -42,16 +37,12 @@ public class CmdMap extends FCommand
|
|||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
@ -59,8 +50,7 @@ public class CmdMap extends FCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMap()
|
public void showMap() {
|
||||||
{
|
|
||||||
sendMessage(Board.getMap(myFaction, new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
|
sendMessage(Board.getMap(myFaction, new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
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");
|
||||||
|
|
||||||
@ -26,47 +24,39 @@ public class CmdMod extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
{
|
|
||||||
// Revoke
|
// Revoke
|
||||||
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));
|
||||||
|
@ -2,8 +2,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
|
||||||
public class CmdMoney extends FCommand
|
public class CmdMoney extends FCommand {
|
||||||
{
|
|
||||||
public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance();
|
public CmdMoneyBalance cmdMoneyBalance = new CmdMoneyBalance();
|
||||||
public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit();
|
public CmdMoneyDeposit cmdMoneyDeposit = new CmdMoneyDeposit();
|
||||||
public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw();
|
public CmdMoneyWithdraw cmdMoneyWithdraw = new CmdMoneyWithdraw();
|
||||||
@ -11,8 +10,7 @@ public class CmdMoney extends FCommand
|
|||||||
public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp();
|
public CmdMoneyTransferFp cmdMoneyTransferFp = new CmdMoneyTransferFp();
|
||||||
public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf();
|
public CmdMoneyTransferPf cmdMoneyTransferPf = new CmdMoneyTransferPf();
|
||||||
|
|
||||||
public CmdMoney()
|
public CmdMoney() {
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
this.aliases.add("money");
|
this.aliases.add("money");
|
||||||
|
|
||||||
@ -38,8 +36,7 @@ public class CmdMoney extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
public class CmdMoneyBalance extends FCommand
|
public class CmdMoneyBalance extends FCommand {
|
||||||
{
|
public CmdMoneyBalance() {
|
||||||
public CmdMoneyBalance()
|
|
||||||
{
|
|
||||||
super();
|
super();
|
||||||
this.aliases.add("b");
|
this.aliases.add("b");
|
||||||
this.aliases.add("balance");
|
this.aliases.add("balance");
|
||||||
@ -25,11 +23,9 @@ public class CmdMoneyBalance extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,12 @@ import com.massivecraft.factions.P;
|
|||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
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("d");
|
||||||
this.aliases.add("deposit");
|
this.aliases.add("deposit");
|
||||||
@ -31,8 +28,7 @@ public class CmdMoneyDeposit extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
if (faction == null) return;
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
|
||||||
public class CmdMoneyTransferFf extends FCommand
|
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");
|
||||||
@ -31,8 +28,7 @@ public class CmdMoneyTransferFf extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
if (from == null) return;
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
|
||||||
public class CmdMoneyTransferFp extends FCommand
|
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");
|
||||||
@ -31,8 +28,7 @@ public class CmdMoneyTransferFp extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
if (from == null) return;
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
|
||||||
public class CmdMoneyTransferPf extends FCommand
|
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");
|
||||||
@ -31,8 +28,7 @@ public class CmdMoneyTransferPf extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
if (from == null) return;
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
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");
|
||||||
|
|
||||||
@ -29,8 +26,7 @@ public class CmdMoneyWithdraw extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
if (faction == null) return;
|
||||||
|
@ -5,10 +5,8 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -25,10 +23,10 @@ public class CmdOpen extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
// 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.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return;
|
if (!payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction"))
|
||||||
|
return;
|
||||||
|
|
||||||
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
||||||
|
|
||||||
@ -36,10 +34,8 @@ public class CmdOpen extends FCommand
|
|||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), open);
|
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), open);
|
||||||
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);
|
||||||
|
@ -1,20 +1,14 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
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");
|
||||||
|
|
||||||
@ -33,44 +27,37 @@ public class CmdOwner extends FCommand
|
|||||||
// TODO: Fix colors!
|
// TODO: Fix colors!
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
boolean hasBypass = fme.isAdminBypassing();
|
boolean hasBypass = fme.isAdminBypassing();
|
||||||
|
|
||||||
if (!hasBypass && !assertHasFaction()) {
|
if (!hasBypass && !assertHasFaction()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
fme.msg("<b>Sorry, but you have reached the server's <h>limit of %d <b>owned areas per faction.", Conf.ownedAreasLimitPerFaction);
|
fme.msg("<b>Sorry, but you have reached the server's <h>limit of %d <b>owned areas per faction.", Conf.ownedAreasLimitPerFaction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN))
|
if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -81,23 +68,20 @@ public class CmdOwner extends FCommand
|
|||||||
|
|
||||||
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);
|
||||||
SpoutFeatures.updateOwnerListLoc(flocation);
|
SpoutFeatures.updateOwnerListLoc(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(playerName, flocation))
|
if (myFaction.isPlayerInOwnerList(playerName, flocation)) {
|
||||||
{
|
|
||||||
myFaction.removePlayerAsOwner(playerName, flocation);
|
myFaction.removePlayerAsOwner(playerName, flocation);
|
||||||
SpoutFeatures.updateOwnerListLoc(flocation);
|
SpoutFeatures.updateOwnerListLoc(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);
|
||||||
@ -105,7 +89,8 @@ public class CmdOwner 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.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) return;
|
if (!payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land"))
|
||||||
|
return;
|
||||||
|
|
||||||
myFaction.setPlayerAsOwner(playerName, flocation);
|
myFaction.setPlayerAsOwner(playerName, flocation);
|
||||||
SpoutFeatures.updateOwnerListLoc(flocation);
|
SpoutFeatures.updateOwnerListLoc(flocation);
|
||||||
|
@ -6,11 +6,9 @@ import com.massivecraft.factions.FLocation;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -27,34 +25,28 @@ public class CmdOwnerList extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
boolean hasBypass = fme.isAdminBypassing();
|
boolean hasBypass = fme.isAdminBypassing();
|
||||||
|
|
||||||
if ( ! hasBypass && ! assertHasFaction())
|
if (!hasBypass && !assertHasFaction()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.");
|
fme.msg("<i>This land is not claimed by any faction, thus no owners.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,8 +54,7 @@ public class CmdOwnerList extends FCommand
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -27,32 +25,24 @@ public class CmdPeaceful extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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";
|
change = "removed peaceful status from";
|
||||||
faction.setPeaceful(false);
|
faction.setPeaceful(false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
change = "granted peaceful status to";
|
change = "granted peaceful status to";
|
||||||
faction.setPeaceful(true);
|
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>\".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -27,19 +25,15 @@ public class CmdPermanent extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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";
|
change = "removed permanent status from";
|
||||||
faction.setPermanent(false);
|
faction.setPermanent(false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
change = "added permanent status to";
|
change = "added permanent status to";
|
||||||
faction.setPermanent(true);
|
faction.setPermanent(true);
|
||||||
}
|
}
|
||||||
@ -47,14 +41,10 @@ public class CmdPermanent extends FCommand
|
|||||||
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() + "\".");
|
||||||
|
|
||||||
// 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> " + 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) + "\".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -24,8 +22,7 @@ public class CmdPermanentPower extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
@ -34,16 +31,14 @@ public class CmdPermanentPower extends FCommand
|
|||||||
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";
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("<i>You %s <h>%s<i>.", change, targetFaction.describeTo(fme));
|
msg("<i>You %s <h>%s<i>.", change, targetFaction.describeTo(fme));
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true))
|
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true)) {
|
||||||
{
|
|
||||||
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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("power");
|
||||||
this.aliases.add("pow");
|
this.aliases.add("pow");
|
||||||
@ -26,8 +24,7 @@ public class CmdPower extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -26,39 +24,31 @@ public class CmdPowerBoost extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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.");
|
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount.");
|
||||||
return;
|
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);
|
targetPlayer.setPowerBoost(targetPower);
|
||||||
target = "Player \"" + targetPlayer.getName() + "\"";
|
target = "Player \"" + targetPlayer.getName() + "\"";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Faction targetFaction = this.argAsFaction(1);
|
Faction targetFaction = this.argAsFaction(1);
|
||||||
if (targetFaction == null) return;
|
if (targetFaction == null) return;
|
||||||
targetFaction.setPowerBoost(targetPower);
|
targetFaction.setPowerBoost(targetPower);
|
||||||
|
@ -2,10 +2,8 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,8 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,8 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.*;
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -28,43 +22,31 @@ public class CmdReload extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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")) {
|
||||||
else if (file.startsWith("b"))
|
|
||||||
{
|
|
||||||
Board.load();
|
Board.load();
|
||||||
fileName = "board.json";
|
fileName = "board.json";
|
||||||
}
|
} else if (file.startsWith("f")) {
|
||||||
else if (file.startsWith("f"))
|
|
||||||
{
|
|
||||||
Factions.i.loadFromDisc();
|
Factions.i.loadFromDisc();
|
||||||
fileName = "factions.json";
|
fileName = "factions.json";
|
||||||
}
|
} else if (file.startsWith("p")) {
|
||||||
else if (file.startsWith("p"))
|
|
||||||
{
|
|
||||||
FPlayers.i.loadFromDisc();
|
FPlayers.i.loadFromDisc();
|
||||||
fileName = "players.json";
|
fileName = "players.json";
|
||||||
}
|
} else if (file.startsWith("a")) {
|
||||||
else if (file.startsWith("a"))
|
|
||||||
{
|
|
||||||
fileName = "all";
|
fileName = "all";
|
||||||
Conf.load();
|
Conf.load();
|
||||||
FPlayers.i.loadFromDisc();
|
FPlayers.i.loadFromDisc();
|
||||||
Factions.i.loadFromDisc();
|
Factions.i.loadFromDisc();
|
||||||
Board.load();
|
Board.load();
|
||||||
}
|
} else {
|
||||||
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;
|
||||||
|
@ -6,11 +6,9 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -29,8 +27,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.");
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ import com.massivecraft.factions.FPlayers;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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("saveall");
|
||||||
this.aliases.add("save");
|
this.aliases.add("save");
|
||||||
@ -28,8 +26,7 @@ public class CmdSaveAll extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
FPlayers.i.saveToDisc();
|
FPlayers.i.saveToDisc();
|
||||||
Factions.i.saveToDisc();
|
Factions.i.saveToDisc();
|
||||||
Board.save();
|
Board.save();
|
||||||
|
@ -7,10 +7,8 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
|
||||||
public class CmdSethome extends FCommand
|
public class CmdSethome extends FCommand {
|
||||||
{
|
public CmdSethome() {
|
||||||
public CmdSethome()
|
|
||||||
{
|
|
||||||
this.aliases.add("sethome");
|
this.aliases.add("sethome");
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
@ -26,10 +24,8 @@ public class CmdSethome extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
@ -38,12 +34,9 @@ public class CmdSethome extends FCommand
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +48,7 @@ public class CmdSethome extends FCommand
|
|||||||
Conf.homesMustBeInClaimedTerritory
|
Conf.homesMustBeInClaimedTerritory
|
||||||
&&
|
&&
|
||||||
Board.getFactionAt(new FLocation(me)) != faction
|
Board.getFactionAt(new FLocation(me)) != faction
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
fme.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -68,8 +60,7 @@ public class CmdSethome extends FCommand
|
|||||||
|
|
||||||
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
|
||||||
public class CmdShow extends FCommand
|
import java.util.Collection;
|
||||||
{
|
|
||||||
|
|
||||||
public CmdShow()
|
public class CmdShow extends FCommand {
|
||||||
{
|
|
||||||
|
public CmdShow() {
|
||||||
this.aliases.add("show");
|
this.aliases.add("show");
|
||||||
this.aliases.add("who");
|
this.aliases.add("who");
|
||||||
|
|
||||||
@ -32,11 +30,9 @@ public class CmdShow extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
}
|
}
|
||||||
@ -50,14 +46,12 @@ public class CmdShow extends FCommand
|
|||||||
|
|
||||||
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";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,18 +61,15 @@ public class CmdShow extends FCommand
|
|||||||
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
||||||
|
|
||||||
if (faction.isPermanent())
|
if (faction.isPermanent()) {
|
||||||
{
|
|
||||||
msg("<a>This faction is permanent, remaining even with no members.");
|
msg("<a>This faction is permanent, remaining even with no members.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
@ -95,12 +86,12 @@ public class CmdShow extends FCommand
|
|||||||
// 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()) continue; // if not ally or enemy, drop out now so we're not wasting time on it; good performance boost
|
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
|
||||||
|
|
||||||
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
||||||
if (rel.isAlly())
|
if (rel.isAlly())
|
||||||
@ -119,24 +110,18 @@ public class CmdShow extends FCommand
|
|||||||
// 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>") + ", ";
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
if
|
if
|
||||||
(follower.isOnlineAndVisibleTo(me))
|
(follower.isOnlineAndVisibleTo(me)) {
|
||||||
{
|
|
||||||
onlineList += listpart;
|
onlineList += listpart;
|
||||||
} else {
|
} else {
|
||||||
offlineList += listpart;
|
offlineList += listpart;
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
@ -11,12 +7,13 @@ import com.massivecraft.factions.event.FactionRenameEvent;
|
|||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class CmdTag extends FCommand
|
import java.util.ArrayList;
|
||||||
{
|
|
||||||
|
|
||||||
public CmdTag()
|
public class CmdTag extends FCommand {
|
||||||
{
|
|
||||||
|
public CmdTag() {
|
||||||
this.aliases.add("tag");
|
this.aliases.add("tag");
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
@ -32,21 +29,18 @@ public class CmdTag extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
String tag = this.argAsString(0);
|
String tag = this.argAsString(0);
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -67,17 +61,14 @@ public class CmdTag extends FCommand
|
|||||||
|
|
||||||
// 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));
|
||||||
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> changed their name to %s.", fme.getColorTo(faction) + oldtag, myFaction.getTag(faction));
|
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction) + oldtag, myFaction.getTag(faction));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.spoutFactionTagsOverNames)
|
if (Conf.spoutFactionTagsOverNames) {
|
||||||
{
|
|
||||||
SpoutFeatures.updateAppearances(myFaction);
|
SpoutFeatures.updateAppearances(myFaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,8 @@ import com.massivecraft.factions.integration.SpoutFeatures;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
|
|
||||||
public class CmdTitle extends FCommand
|
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");
|
||||||
@ -25,8 +23,7 @@ public class CmdTitle extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
@ -43,8 +40,7 @@ public class CmdTitle extends FCommand
|
|||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true));
|
myFaction.msg("%s<i> changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true));
|
||||||
|
|
||||||
if (Conf.spoutFactionTitlesOverNames)
|
if (Conf.spoutFactionTitlesOverNames) {
|
||||||
{
|
|
||||||
SpoutFeatures.updateAppearances(me);
|
SpoutFeatures.updateAppearances(me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import com.massivecraft.factions.*;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.event.LandUnclaimEvent;
|
import com.massivecraft.factions.event.LandUnclaimEvent;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -33,48 +26,37 @@ public class CmdUnclaim extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
SpoutFeatures.updateTerritoryDisplayLoc(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);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
SpoutFeatures.updateTerritoryDisplayLoc(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()) {
|
||||||
{
|
|
||||||
Board.removeAt(flocation);
|
Board.removeAt(flocation);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||||
|
|
||||||
@ -87,19 +69,16 @@ public class CmdUnclaim extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! assertHasFaction())
|
if (!assertHasFaction()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! assertMinRole(Role.MODERATOR))
|
if (!assertMinRole(Role.MODERATOR)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( myFaction != otherFaction)
|
if (myFaction != otherFaction) {
|
||||||
{
|
|
||||||
msg("<b>You don't own this land.");
|
msg("<b>You don't own this land.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -108,16 +87,12 @@ public class CmdUnclaim extends FCommand
|
|||||||
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());
|
||||||
|
|
||||||
if(Conf.bankEnabled && Conf.bankFactionPaysLandCosts)
|
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||||
{
|
|
||||||
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) return;
|
if (!Econ.modifyMoney(myFaction, refund, "to unclaim this land", "for unclaiming this land")) 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import com.massivecraft.factions.Board;
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
@ -9,11 +7,10 @@ import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
|||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
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");
|
||||||
|
|
||||||
@ -30,18 +27,15 @@ public class CmdUnclaimall extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (Econ.shouldBeUsed()) {
|
||||||
if (Econ.shouldBeUsed())
|
|
||||||
{
|
|
||||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
||||||
if(Conf.bankEnabled && Conf.bankFactionPaysLandCosts)
|
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||||
{
|
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"))
|
||||||
{
|
return;
|
||||||
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,8 @@ import com.massivecraft.factions.P;
|
|||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
|
|
||||||
public class CmdVersion extends FCommand
|
public class CmdVersion extends FCommand {
|
||||||
{
|
public CmdVersion() {
|
||||||
public CmdVersion()
|
|
||||||
{
|
|
||||||
this.aliases.add("version");
|
this.aliases.add("version");
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
@ -23,8 +21,7 @@ public class CmdVersion extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
|
||||||
msg("<i>You are running " + P.p.getDescription().getFullName());
|
msg("<i>You are running " + P.p.getDescription().getFullName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,9 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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");
|
||||||
|
|
||||||
@ -29,8 +27,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.");
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
|
|
||||||
public class FCmdRoot extends FCommand
|
import java.util.Collections;
|
||||||
{
|
|
||||||
|
public class FCmdRoot extends FCommand {
|
||||||
public CmdAdmin cmdAdmin = new CmdAdmin();
|
public CmdAdmin cmdAdmin = new CmdAdmin();
|
||||||
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
||||||
public CmdBoom cmdBoom = new CmdBoom();
|
public CmdBoom cmdBoom = new CmdBoom();
|
||||||
@ -52,8 +51,7 @@ public class FCmdRoot extends FCommand
|
|||||||
public CmdVersion cmdVersion = new CmdVersion();
|
public CmdVersion cmdVersion = new CmdVersion();
|
||||||
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
|
||||||
@ -122,8 +120,7 @@ public class FCmdRoot extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.List;
|
import com.massivecraft.factions.*;
|
||||||
|
import com.massivecraft.factions.integration.Econ;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import com.massivecraft.factions.zcore.MCommand;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import java.util.List;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.zcore.MCommand;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class FCommand extends MCommand<P>
|
public abstract class FCommand extends MCommand<P> {
|
||||||
{
|
|
||||||
public boolean disableOnLock;
|
public boolean disableOnLock;
|
||||||
|
|
||||||
public FPlayer fme;
|
public FPlayer fme;
|
||||||
@ -28,8 +21,7 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
|
|
||||||
public boolean isMoneyCommand;
|
public boolean isMoneyCommand;
|
||||||
|
|
||||||
public FCommand()
|
public FCommand() {
|
||||||
{
|
|
||||||
super(P.p);
|
super(P.p);
|
||||||
|
|
||||||
// Due to safety reasons it defaults to disable on lock.
|
// Due to safety reasons it defaults to disable on lock.
|
||||||
@ -44,15 +36,11 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fme = null;
|
this.fme = null;
|
||||||
this.myFaction = null;
|
this.myFaction = null;
|
||||||
}
|
}
|
||||||
@ -60,22 +48,18 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
@ -84,8 +68,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;
|
||||||
|
|
||||||
@ -95,20 +78,17 @@ 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;
|
||||||
}
|
}
|
||||||
@ -120,24 +100,20 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
// Assertions
|
// Assertions
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public boolean assertHasFaction()
|
public boolean assertHasFaction() {
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -149,127 +125,111 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// FPLAYER ======================
|
// FPLAYER ======================
|
||||||
public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg)
|
public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg) {
|
||||||
{
|
|
||||||
FPlayer ret = def;
|
FPlayer ret = def;
|
||||||
|
|
||||||
if (name != null)
|
if (name != null) {
|
||||||
{
|
|
||||||
FPlayer fplayer = FPlayers.i.get(name);
|
FPlayer fplayer = FPlayers.i.get(name);
|
||||||
if (fplayer != null)
|
if (fplayer != null) {
|
||||||
{
|
|
||||||
ret = fplayer;
|
ret = fplayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg && ret == null)
|
if (msg && ret == null) {
|
||||||
{
|
|
||||||
this.msg("<b>No player \"<p>%s<b>\" could be found.", name);
|
this.msg("<b>No player \"<p>%s<b>\" could be found.", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg)
|
|
||||||
{
|
public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg) {
|
||||||
return this.strAsFPlayer(this.argAsString(idx), def, msg);
|
return this.strAsFPlayer(this.argAsString(idx), def, msg);
|
||||||
}
|
}
|
||||||
public FPlayer argAsFPlayer(int idx, FPlayer def)
|
|
||||||
{
|
public FPlayer argAsFPlayer(int idx, FPlayer def) {
|
||||||
return this.argAsFPlayer(idx, def, true);
|
return this.argAsFPlayer(idx, def, true);
|
||||||
}
|
}
|
||||||
public FPlayer argAsFPlayer(int idx)
|
|
||||||
{
|
public FPlayer argAsFPlayer(int idx) {
|
||||||
return this.argAsFPlayer(idx, null);
|
return this.argAsFPlayer(idx, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BEST FPLAYER MATCH ======================
|
// BEST FPLAYER MATCH ======================
|
||||||
public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg)
|
public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg) {
|
||||||
{
|
|
||||||
FPlayer ret = def;
|
FPlayer ret = def;
|
||||||
|
|
||||||
if (name != null)
|
if (name != null) {
|
||||||
{
|
|
||||||
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
||||||
if (fplayer != null)
|
if (fplayer != null) {
|
||||||
{
|
|
||||||
ret = fplayer;
|
ret = fplayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg && ret == null)
|
if (msg && ret == null) {
|
||||||
{
|
|
||||||
this.msg("<b>No player match found for \"<p>%s<b>\".", name);
|
this.msg("<b>No player match found for \"<p>%s<b>\".", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg)
|
|
||||||
{
|
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg) {
|
||||||
return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg);
|
return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg);
|
||||||
}
|
}
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def)
|
|
||||||
{
|
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def) {
|
||||||
return this.argAsBestFPlayerMatch(idx, def, true);
|
return this.argAsBestFPlayerMatch(idx, def, true);
|
||||||
}
|
}
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx)
|
|
||||||
{
|
public FPlayer argAsBestFPlayerMatch(int idx) {
|
||||||
return this.argAsBestFPlayerMatch(idx, null);
|
return this.argAsBestFPlayerMatch(idx, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FACTION ======================
|
// FACTION ======================
|
||||||
public Faction strAsFaction(String name, Faction def, boolean msg)
|
public Faction strAsFaction(String name, Faction def, boolean msg) {
|
||||||
{
|
|
||||||
Faction ret = def;
|
Faction ret = def;
|
||||||
|
|
||||||
if (name != null)
|
if (name != null) {
|
||||||
{
|
|
||||||
Faction faction = null;
|
Faction faction = null;
|
||||||
|
|
||||||
// First we try an exact match
|
// First we try an exact match
|
||||||
if (faction == null)
|
if (faction == null) {
|
||||||
{
|
|
||||||
faction = Factions.i.getByTag(name);
|
faction = Factions.i.getByTag(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next we match faction tags
|
// Next we match faction tags
|
||||||
if (faction == null)
|
if (faction == null) {
|
||||||
{
|
|
||||||
faction = Factions.i.getBestTagMatch(name);
|
faction = Factions.i.getBestTagMatch(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next we match player names
|
// Next we match player names
|
||||||
if (faction == null)
|
if (faction == null) {
|
||||||
{
|
|
||||||
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
||||||
if (fplayer != null)
|
if (fplayer != null) {
|
||||||
{
|
|
||||||
faction = fplayer.getFaction();
|
faction = fplayer.getFaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (faction != null)
|
if (faction != null) {
|
||||||
{
|
|
||||||
ret = faction;
|
ret = faction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg && ret == null)
|
if (msg && ret == null) {
|
||||||
{
|
|
||||||
this.msg("<b>The faction or player \"<p>%s<b>\" could not be found.", name);
|
this.msg("<b>The faction or player \"<p>%s<b>\" could not be found.", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
public Faction argAsFaction(int idx, Faction def, boolean msg)
|
|
||||||
{
|
public Faction argAsFaction(int idx, Faction def, boolean msg) {
|
||||||
return this.strAsFaction(this.argAsString(idx), def, msg);
|
return this.strAsFaction(this.argAsString(idx), def, msg);
|
||||||
}
|
}
|
||||||
public Faction argAsFaction(int idx, Faction def)
|
|
||||||
{
|
public Faction argAsFaction(int idx, Faction def) {
|
||||||
return this.argAsFaction(idx, def, true);
|
return this.argAsFaction(idx, def, true);
|
||||||
}
|
}
|
||||||
public Faction argAsFaction(int idx)
|
|
||||||
{
|
public Faction argAsFaction(int idx) {
|
||||||
return this.argAsFaction(idx, null);
|
return this.argAsFaction(idx, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,36 +237,25 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
// Commonly used logic
|
// Commonly used logic
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public boolean canIAdministerYou(FPlayer i, FPlayer you)
|
public boolean canIAdministerYou(FPlayer i, FPlayer you) {
|
||||||
{
|
if (!i.getFaction().equals(you.getFaction())) {
|
||||||
if ( ! i.getFaction().equals(you.getFaction()))
|
|
||||||
{
|
|
||||||
i.sendMessage(p.txt.parse("%s <b>is not in the same faction as you.", you.describeTo(i, true)));
|
i.sendMessage(p.txt.parse("%s <b>is not in the same faction as you.", you.describeTo(i, true)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN) )
|
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,8 +263,7 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
||||||
public boolean payForCommand(double cost, String toDoThis, String forDoingThis)
|
public boolean payForCommand(double cost, String toDoThis, String forDoingThis) {
|
||||||
{
|
|
||||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||||
|
|
||||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
||||||
@ -325,8 +273,7 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
public boolean canAffordCommand(double cost, String toDoThis)
|
public boolean canAffordCommand(double cost, String toDoThis) {
|
||||||
{
|
|
||||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||||
|
|
||||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.event.FactionRelationEvent;
|
import com.massivecraft.factions.event.FactionRelationEvent;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public abstract class FRelationCommand extends FCommand
|
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");
|
||||||
@ -30,31 +27,28 @@ public abstract class FRelationCommand extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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
|
||||||
if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return;
|
if (!payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish"))
|
||||||
|
return;
|
||||||
|
|
||||||
// try to set the new relation
|
// try to set the new relation
|
||||||
Relation oldRelation = myFaction.getRelationTo(them, true);
|
Relation oldRelation = myFaction.getRelationTo(them, true);
|
||||||
@ -63,8 +57,7 @@ public abstract class FRelationCommand extends FCommand
|
|||||||
ChatColor currentRelationColor = currentRelation.getColor();
|
ChatColor currentRelationColor = currentRelation.getColor();
|
||||||
|
|
||||||
// if the relation change was successful
|
// if the relation change was successful
|
||||||
if (targetRelation.value == currentRelation.value)
|
if (targetRelation.value == currentRelation.value) {
|
||||||
{
|
|
||||||
// trigger the faction relation event
|
// trigger the faction relation event
|
||||||
FactionRelationEvent relationEvent = new FactionRelationEvent(myFaction, them, oldRelation, currentRelation);
|
FactionRelationEvent relationEvent = new FactionRelationEvent(myFaction, them, oldRelation, currentRelation);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
|
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
|
||||||
@ -73,21 +66,18 @@ public abstract class FRelationCommand extends FCommand
|
|||||||
myFaction.msg("<i>Your faction is now " + currentRelationColor + targetRelation.toString() + "<i> to " + currentRelationColor + them.getTag());
|
myFaction.msg("<i>Your faction is now " + currentRelationColor + targetRelation.toString() + "<i> to " + currentRelationColor + them.getTag());
|
||||||
}
|
}
|
||||||
// inform the other faction of your request
|
// inform the other faction of your request
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
them.msg(currentRelationColor + myFaction.getTag() + "<i> wishes to be your " + targetRelation.getColor() + targetRelation.toString());
|
them.msg(currentRelationColor + myFaction.getTag() + "<i> wishes to be your " + targetRelation.getColor() + targetRelation.toString());
|
||||||
them.msg("<i>Type <c>/" + Conf.baseCommandAliases.get(0) + " " + targetRelation + " " + myFaction.getTag() + "<i> to accept.");
|
them.msg("<i>Type <c>/" + Conf.baseCommandAliases.get(0) + " " + targetRelation + " " + myFaction.getTag() + "<i> to accept.");
|
||||||
myFaction.msg(currentRelationColor + them.getTag() + "<i> were informed that you wish to be " + targetRelation.getColor() + targetRelation);
|
myFaction.msg(currentRelationColor + them.getTag() + "<i> were informed that you wish to be " + targetRelation.getColor() + targetRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! targetRelation.isNeutral() && them.isPeaceful())
|
if (!targetRelation.isNeutral() && them.isPeaceful()) {
|
||||||
{
|
|
||||||
them.msg("<i>This will have no effect while your faction is peaceful.");
|
them.msg("<i>This will have no effect while your faction is peaceful.");
|
||||||
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! targetRelation.isNeutral() && myFaction.isPeaceful())
|
if (!targetRelation.isNeutral() && myFaction.isPeaceful()) {
|
||||||
{
|
|
||||||
them.msg("<i>This will have no effect while their faction is peaceful.");
|
them.msg("<i>This will have no effect while their faction is peaceful.");
|
||||||
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
||||||
}
|
}
|
||||||
|
@ -1,60 +1,56 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
public class FPlayerJoinEvent extends Event implements Cancellable {
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
public class FPlayerJoinEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
FPlayer fplayer;
|
FPlayer fplayer;
|
||||||
Faction faction;
|
Faction faction;
|
||||||
PlayerJoinReason reason;
|
PlayerJoinReason reason;
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
public enum PlayerJoinReason
|
|
||||||
{
|
public enum PlayerJoinReason {
|
||||||
CREATE, LEADER, COMMAND
|
CREATE, LEADER, COMMAND
|
||||||
}
|
}
|
||||||
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r)
|
|
||||||
{
|
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) {
|
||||||
fplayer = fp;
|
fplayer = fp;
|
||||||
faction = f;
|
faction = f;
|
||||||
reason = r;
|
reason = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
public Faction getFaction()
|
|
||||||
{
|
public Faction getFaction() {
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
public PlayerJoinReason getReason()
|
|
||||||
{
|
public PlayerJoinReason getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c)
|
public void setCancelled(boolean c) {
|
||||||
{
|
|
||||||
cancelled = c;
|
cancelled = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,68 +1,56 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
public class FPlayerLeaveEvent extends Event implements Cancellable {
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
public class FPlayerLeaveEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private PlayerLeaveReason reason;
|
private PlayerLeaveReason reason;
|
||||||
FPlayer FPlayer;
|
FPlayer FPlayer;
|
||||||
Faction Faction;
|
Faction Faction;
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
|
|
||||||
public enum PlayerLeaveReason
|
public enum PlayerLeaveReason {
|
||||||
{
|
|
||||||
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
|
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r)
|
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
|
||||||
{
|
|
||||||
FPlayer = p;
|
FPlayer = p;
|
||||||
Faction = f;
|
Faction = f;
|
||||||
reason = r;
|
reason = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerLeaveReason getReason()
|
public PlayerLeaveReason getReason() {
|
||||||
{
|
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return FPlayer;
|
return FPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return Faction;
|
return Faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,53 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.FPlayers;
|
||||||
|
import com.massivecraft.factions.Factions;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
public class FactionCreateEvent extends Event implements Cancellable {
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
|
|
||||||
public class FactionCreateEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private String factionTag;
|
private String factionTag;
|
||||||
private Player sender;
|
private Player sender;
|
||||||
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.sender = sender;
|
||||||
this.cancelled = false;
|
this.cancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return FPlayers.i.get(sender);
|
return FPlayers.i.get(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionId() {
|
||||||
{
|
|
||||||
return Factions.i.getNextId();
|
return Factions.i.getNextId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
|
||||||
return factionTag;
|
return factionTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c)
|
public void setCancelled(boolean c) {
|
||||||
{
|
|
||||||
this.cancelled = c;
|
this.cancelled = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,64 +1,54 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class FactionDisbandEvent extends Event implements Cancellable
|
public class FactionDisbandEvent extends Event implements Cancellable {
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private String id;
|
private String id;
|
||||||
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.sender = sender;
|
||||||
this.id = factionId;
|
this.id = factionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return Factions.i.get(id);
|
return Factions.i.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return FPlayers.i.get(sender);
|
return FPlayers.i.get(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer() {
|
||||||
{
|
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c)
|
public void setCancelled(boolean c) {
|
||||||
{
|
|
||||||
cancelled = c;
|
cancelled = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
|
public class FactionRelationEvent extends Event {
|
||||||
public class FactionRelationEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Faction fsender;
|
private Faction fsender;
|
||||||
@ -16,41 +14,34 @@ public class FactionRelationEvent extends Event
|
|||||||
private Relation foldrel;
|
private Relation foldrel;
|
||||||
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;
|
ftarget = target;
|
||||||
foldrel = oldrel;
|
foldrel = oldrel;
|
||||||
frel = rel;
|
frel = rel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Relation getOldRelation()
|
public Relation getOldRelation() {
|
||||||
{
|
|
||||||
return foldrel;
|
return foldrel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Relation getRelation()
|
public Relation getRelation() {
|
||||||
{
|
|
||||||
return frel;
|
return frel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return fsender;
|
return fsender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getTargetFaction()
|
public Faction getTargetFaction() {
|
||||||
{
|
|
||||||
return ftarget;
|
return ftarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
public class FactionRenameEvent extends Event implements Cancellable {
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
public class FactionRenameEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -17,58 +15,48 @@ public class FactionRenameEvent extends Event implements Cancellable
|
|||||||
private Faction faction;
|
private Faction faction;
|
||||||
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();
|
faction = sender.getFaction();
|
||||||
tag = newTag;
|
tag = newTag;
|
||||||
this.cancelled = false;
|
this.cancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return (faction);
|
return (faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return (fplayer);
|
return (fplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer() {
|
||||||
{
|
|
||||||
return (fplayer.getPlayer());
|
return (fplayer.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOldFactionTag()
|
public String getOldFactionTag() {
|
||||||
{
|
|
||||||
return (faction.getTag());
|
return (faction.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
|
||||||
return (tag);
|
return (tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c)
|
public void setCancelled(boolean c) {
|
||||||
{
|
|
||||||
this.cancelled = c;
|
this.cancelled = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FLocation;
|
public class LandClaimEvent extends Event implements Cancellable {
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LandClaimEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -18,63 +16,52 @@ public class LandClaimEvent extends Event implements Cancellable
|
|||||||
private Faction faction;
|
private Faction faction;
|
||||||
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;
|
location = loc;
|
||||||
faction = f;
|
faction = f;
|
||||||
fplayer = p;
|
fplayer = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation getLocation()
|
public FLocation getLocation() {
|
||||||
{
|
|
||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionId() {
|
||||||
{
|
|
||||||
return faction.getId();
|
return faction.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
|
||||||
return faction.getTag();
|
return faction.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer() {
|
||||||
{
|
|
||||||
return fplayer.getPlayer();
|
return fplayer.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c)
|
public void setCancelled(boolean c) {
|
||||||
{
|
|
||||||
this.cancelled = c;
|
this.cancelled = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,47 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
public class LandUnclaimAllEvent extends Event {
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LandUnclaimAllEvent extends Event
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Faction faction;
|
private Faction faction;
|
||||||
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() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionId() {
|
||||||
{
|
|
||||||
return faction.getId();
|
return faction.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
|
||||||
return faction.getTag();
|
return faction.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer() {
|
||||||
{
|
|
||||||
return fplayer.getPlayer();
|
return fplayer.getPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FLocation;
|
public class LandUnclaimEvent extends Event implements Cancellable {
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LandUnclaimEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -18,57 +16,47 @@ public class LandUnclaimEvent extends Event implements Cancellable
|
|||||||
private Faction faction;
|
private Faction faction;
|
||||||
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;
|
location = loc;
|
||||||
faction = f;
|
faction = f;
|
||||||
fplayer = p;
|
fplayer = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLocation getLocation()
|
public FLocation getLocation() {
|
||||||
{
|
|
||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionId() {
|
||||||
{
|
|
||||||
return faction.getId();
|
return faction.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
|
||||||
return faction.getTag();
|
return faction.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer() {
|
||||||
{
|
|
||||||
return fplayer.getPlayer();
|
return fplayer.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package com.massivecraft.factions.event;
|
package com.massivecraft.factions.event;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
public class PowerLossEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
|
||||||
public class PowerLossEvent extends Event implements Cancellable
|
|
||||||
{
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@ -19,46 +16,38 @@ public class PowerLossEvent extends Event implements Cancellable
|
|||||||
private FPlayer fplayer;
|
private FPlayer fplayer;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public PowerLossEvent(Faction f, FPlayer p)
|
public PowerLossEvent(Faction f, FPlayer p) {
|
||||||
{
|
|
||||||
cancelled = false;
|
cancelled = false;
|
||||||
faction = f;
|
faction = f;
|
||||||
fplayer = p;
|
fplayer = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getFaction() {
|
||||||
{
|
|
||||||
return faction;
|
return faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionId() {
|
||||||
{
|
|
||||||
return faction.getId();
|
return faction.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
|
||||||
return faction.getTag();
|
return faction.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayer getFPlayer() {
|
||||||
{
|
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer()
|
public Player getPlayer() {
|
||||||
{
|
|
||||||
return fplayer.getPlayer();
|
return fplayer.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,14 +60,12 @@ public class PowerLossEvent extends Event implements Cancellable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public boolean isCancelled() {
|
||||||
{
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCancelled(boolean c)
|
public void setCancelled(boolean c) {
|
||||||
{
|
|
||||||
this.cancelled = c;
|
this.cancelled = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.iface;
|
package com.massivecraft.factions.iface;
|
||||||
|
|
||||||
public interface EconomyParticipator extends RelationParticipator
|
public interface EconomyParticipator extends RelationParticipator {
|
||||||
{
|
|
||||||
public String getAccountId();
|
public String getAccountId();
|
||||||
|
|
||||||
public void msg(String str, Object... args);
|
public void msg(String str, Object... args);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package com.massivecraft.factions.iface;
|
package com.massivecraft.factions.iface;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
public interface RelationParticipator {
|
||||||
|
|
||||||
public interface RelationParticipator
|
|
||||||
{
|
|
||||||
public String describeTo(RelationParticipator that);
|
public String describeTo(RelationParticipator that);
|
||||||
|
|
||||||
public String describeTo(RelationParticipator that, boolean ucfirst);
|
public String describeTo(RelationParticipator that, boolean ucfirst);
|
||||||
|
|
||||||
public Relation getRelationTo(RelationParticipator that);
|
public Relation getRelationTo(RelationParticipator that);
|
||||||
|
|
||||||
public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
|
public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
|
||||||
|
|
||||||
public ChatColor getColorTo(RelationParticipator to);
|
public ChatColor getColorTo(RelationParticipator to);
|
||||||
|
@ -1,45 +1,35 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.*;
|
||||||
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
public class Econ {
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
|
||||||
|
|
||||||
|
|
||||||
public class Econ
|
|
||||||
{
|
|
||||||
private static Economy econ = null;
|
private static Economy econ = null;
|
||||||
|
|
||||||
public static void setup()
|
public static void setup() {
|
||||||
{
|
|
||||||
if (isSetup()) return;
|
if (isSetup()) return;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -55,19 +45,16 @@ public class Econ
|
|||||||
oldMoneyDoTransfer();
|
oldMoneyDoTransfer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldBeUsed()
|
public static boolean shouldBeUsed() {
|
||||||
{
|
|
||||||
return Conf.econEnabled && econ != null && econ.isEnabled();
|
return Conf.econEnabled && econ != null && econ.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSetup()
|
public static boolean isSetup() {
|
||||||
{
|
|
||||||
return econ != null;
|
return econ != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@ -77,18 +64,15 @@ public class Econ
|
|||||||
modifyBalance(Conf.econUniverseAccount, delta);
|
modifyBalance(Conf.econUniverseAccount, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -110,25 +94,24 @@ public class Econ
|
|||||||
if (i == fI && fI == fYou) return true;
|
if (i == fI && fI == fYou) return true;
|
||||||
|
|
||||||
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
||||||
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer)i).getRole().value >= Role.MODERATOR.value)) return true;
|
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer) i).getRole().value >= Role.MODERATOR.value))
|
||||||
|
return true;
|
||||||
|
|
||||||
// Otherwise you may not! ;,,;
|
// Otherwise you may not! ;,,;
|
||||||
i.msg("<h>%s<i> lacks permission to control <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
i.msg("<h>%s<i> lacks permission to control <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount)
|
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
|
||||||
{
|
|
||||||
return transferMoney(invoker, from, to, amount, true);
|
return transferMoney(invoker, from, to, amount, true);
|
||||||
}
|
}
|
||||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify)
|
|
||||||
{
|
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) {
|
||||||
if (!shouldBeUsed()) return false;
|
if (!shouldBeUsed()) return false;
|
||||||
|
|
||||||
// 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;
|
EconomyParticipator temp = from;
|
||||||
from = to;
|
from = to;
|
||||||
@ -139,8 +122,7 @@ public class Econ
|
|||||||
if (!canIControllYou(invoker, from)) return false;
|
if (!canIControllYou(invoker, from)) return false;
|
||||||
|
|
||||||
// Is there enough money for the transaction to happen?
|
// Is there enough money for the transaction to happen?
|
||||||
if ( ! econ.has(from.getAccountId(), amount))
|
if (!econ.has(from.getAccountId(), amount)) {
|
||||||
{
|
|
||||||
// There was not enough money to pay
|
// There was not enough money to pay
|
||||||
if (invoker != null && notify)
|
if (invoker != null && notify)
|
||||||
invoker.msg("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
invoker.msg("<h>%s<b> can't afford to transfer <h>%s<b> to %s<b>.", from.describeTo(invoker, true), moneyString(amount), to.describeTo(invoker));
|
||||||
@ -169,69 +151,49 @@ public class Econ
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<FPlayer> getFplayers(EconomyParticipator ep)
|
public static Set<FPlayer> getFplayers(EconomyParticipator ep) {
|
||||||
{
|
|
||||||
Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
return fplayers;
|
return fplayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(from));
|
||||||
recipients.addAll(getFplayers(to));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis)
|
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) {
|
||||||
{
|
|
||||||
if (!shouldBeUsed()) return true;
|
if (!shouldBeUsed()) return true;
|
||||||
|
|
||||||
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;
|
||||||
@ -239,22 +201,19 @@ public class Econ
|
|||||||
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?
|
||||||
// ep.msg("<h>%s<i> didn't have to pay anything %s.", You, forDoingThis); // might be for gains, might be for losses
|
// ep.msg("<h>%s<i> didn't have to pay anything %s.", You, forDoingThis); // might be for gains, might be for losses
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -269,22 +228,17 @@ public class Econ
|
|||||||
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);
|
||||||
@ -294,19 +248,15 @@ public class Econ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// format money string based on server's set currency type, like "24 gold" or "$24.50"
|
// format money string based on server's set currency type, like "24 gold" or "$24.50"
|
||||||
public static String moneyString(double amount)
|
public static String moneyString(double amount) {
|
||||||
{
|
|
||||||
return econ.format(amount);
|
return econ.format(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void oldMoneyDoTransfer()
|
public static void oldMoneyDoTransfer() {
|
||||||
{
|
|
||||||
if (!shouldBeUsed()) return;
|
if (!shouldBeUsed()) return;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -314,10 +264,8 @@ public class Econ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate the cost for claiming land
|
// calculate the cost for claiming land
|
||||||
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction)
|
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) {
|
||||||
{
|
if (!shouldBeUsed()) {
|
||||||
if ( ! shouldBeUsed())
|
|
||||||
{
|
|
||||||
return 0d;
|
return 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,14 +276,12 @@ public class Econ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate refund amount for unclaiming land
|
// calculate refund amount for unclaiming land
|
||||||
public static double calculateClaimRefund(int ownedLand)
|
public static double calculateClaimRefund(int ownedLand) {
|
||||||
{
|
|
||||||
return calculateClaimCost(ownedLand - 1, false) * Conf.econClaimRefundMultiplier;
|
return calculateClaimCost(ownedLand - 1, false) * Conf.econClaimRefundMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
@ -344,8 +290,7 @@ public class Econ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate refund amount for all owned land
|
// calculate refund amount for all owned land
|
||||||
public static double calculateTotalLandRefund(int ownedLand)
|
public static double calculateTotalLandRefund(int ownedLand) {
|
||||||
{
|
|
||||||
return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier;
|
return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,18 +299,15 @@ public class Econ
|
|||||||
// Standard account management methods
|
// Standard account management methods
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static boolean hasAccount(String name)
|
public static boolean hasAccount(String name) {
|
||||||
{
|
|
||||||
return econ.hasAccount(name);
|
return econ.hasAccount(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getBalance(String account)
|
public static double getBalance(String account) {
|
||||||
{
|
|
||||||
return econ.getBalance(account);
|
return econ.getBalance(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (current > amount)
|
||||||
return econ.withdrawPlayer(account, current - amount).transactionSuccess();
|
return econ.withdrawPlayer(account, current - amount).transactionSuccess();
|
||||||
@ -373,21 +315,18 @@ public class Econ
|
|||||||
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)
|
if (amount < 0)
|
||||||
return econ.withdrawPlayer(account, -amount).transactionSuccess();
|
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) {
|
||||||
{
|
|
||||||
return econ.depositPlayer(account, amount).transactionSuccess();
|
return econ.depositPlayer(account, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean withdraw(String account, double amount)
|
public static boolean withdraw(String account, double amount) {
|
||||||
{
|
|
||||||
return econ.withdrawPlayer(account, amount).transactionSuccess();
|
return econ.withdrawPlayer(account, amount).transactionSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.IEssentials;
|
import com.earth2me.essentials.IEssentials;
|
||||||
import com.earth2me.essentials.Teleport;
|
import com.earth2me.essentials.Teleport;
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.chat.EssentialsChat;
|
import com.earth2me.essentials.chat.EssentialsChat;
|
||||||
import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
|
import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -26,17 +24,14 @@ import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
|
|||||||
|
|
||||||
// silence deprecation warnings with this old interface
|
// silence deprecation warnings with this old interface
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class EssentialsFeatures
|
public class EssentialsFeatures {
|
||||||
{
|
|
||||||
private static EssentialsChat essChat;
|
private static EssentialsChat essChat;
|
||||||
private static IEssentials essentials;
|
private static IEssentials essentials;
|
||||||
|
|
||||||
public static void setup()
|
public static void setup() {
|
||||||
{
|
|
||||||
// integrate main essentials plugin
|
// integrate main essentials plugin
|
||||||
// TODO: this is the old Essentials method not supported in 3.0... probably needs to eventually be moved to EssentialsOldVersionFeatures and new method implemented
|
// TODO: this is the old Essentials method not supported in 3.0... probably needs to eventually be moved to EssentialsOldVersionFeatures and new method implemented
|
||||||
if (essentials == null)
|
if (essentials == null) {
|
||||||
{
|
|
||||||
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
|
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
|
||||||
if (ess != null && ess.isEnabled())
|
if (ess != null && ess.isEnabled())
|
||||||
essentials = (IEssentials) ess;
|
essentials = (IEssentials) ess;
|
||||||
@ -51,80 +46,62 @@ public class EssentialsFeatures
|
|||||||
essChat = (EssentialsChat) test;
|
essChat = (EssentialsChat) test;
|
||||||
|
|
||||||
// try newer Essentials 3.x integration method
|
// try newer Essentials 3.x integration method
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Class.forName("com.earth2me.essentials.chat.EssentialsLocalChatEvent");
|
Class.forName("com.earth2me.essentials.chat.EssentialsLocalChatEvent");
|
||||||
integrateChat(essChat);
|
integrateChat(essChat);
|
||||||
}
|
} catch (ClassNotFoundException ex) {
|
||||||
catch (ClassNotFoundException ex)
|
|
||||||
{
|
|
||||||
// no? try older Essentials 2.x integration method
|
// no? try older Essentials 2.x integration method
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
EssentialsOldVersionFeatures.integrateChat(essChat);
|
EssentialsOldVersionFeatures.integrateChat(essChat);
|
||||||
}
|
} catch (NoClassDefFoundError ex2) { /* no known integration method, then */ }
|
||||||
catch (NoClassDefFoundError ex2) { /* no known integration method, then */ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unhookChat()
|
public static void unhookChat() {
|
||||||
{
|
|
||||||
if (essChat == null) return;
|
if (essChat == null) return;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
EssentialsOldVersionFeatures.unhookChat();
|
EssentialsOldVersionFeatures.unhookChat();
|
||||||
|
} catch (NoClassDefFoundError ex) {
|
||||||
}
|
}
|
||||||
catch (NoClassDefFoundError ex) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// return false if feature is disabled or Essentials isn't available
|
// return false if feature is disabled or Essentials isn't available
|
||||||
public static boolean handleTeleport(Player player, Location loc)
|
public static boolean handleTeleport(Player player, Location loc) {
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void integrateChat(EssentialsChat instance)
|
public static void integrateChat(EssentialsChat instance) {
|
||||||
{
|
|
||||||
essChat = instance;
|
essChat = instance;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new LocalChatListener(), P.p);
|
Bukkit.getServer().getPluginManager().registerEvents(new LocalChatListener(), P.p);
|
||||||
P.p.log("Found and will integrate chat with newer " + essChat.getDescription().getFullName());
|
P.p.log("Found and will integrate chat with newer " + essChat.getDescription().getFullName());
|
||||||
|
|
||||||
// curly braces used to be accepted by the format string EssentialsChat but no longer are, so... deal with chatTagReplaceString which might need updating
|
// curly braces used to be accepted by the format string EssentialsChat but no longer are, so... deal with chatTagReplaceString which might need updating
|
||||||
if (Conf.chatTagReplaceString.contains("{"))
|
if (Conf.chatTagReplaceString.contains("{")) {
|
||||||
{
|
|
||||||
Conf.chatTagReplaceString = Conf.chatTagReplaceString.replace("{", "[").replace("}", "]");
|
Conf.chatTagReplaceString = Conf.chatTagReplaceString.replace("{", "[").replace("}", "]");
|
||||||
P.p.log("NOTE: as of Essentials 2.8+, we've had to switch the default chat replacement tag from \"{FACTION}\" to \"[FACTION]\". This has automatically been updated for you.");
|
P.p.log("NOTE: as of Essentials 2.8+, we've had to switch the default chat replacement tag from \"{FACTION}\" to \"[FACTION]\". This has automatically been updated for you.");
|
||||||
}
|
}
|
||||||
}
|
} catch (NoSuchMethodError ex) {
|
||||||
catch (NoSuchMethodError ex)
|
|
||||||
{
|
|
||||||
essChat = null;
|
essChat = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LocalChatListener implements Listener
|
private static class LocalChatListener implements Listener {
|
||||||
{
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerChat(EssentialsLocalChatEvent event)
|
public void onPlayerChat(EssentialsLocalChatEvent event) {
|
||||||
{
|
|
||||||
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));
|
||||||
|
@ -1,58 +1,46 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
import com.earth2me.essentials.chat.EssentialsChat;
|
import com.earth2me.essentials.chat.EssentialsChat;
|
||||||
import com.earth2me.essentials.chat.IEssentialsChatListener;
|
import com.earth2me.essentials.chat.IEssentialsChatListener;
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Essentials integration handler is for older 2.x.x versions of Essentials which have "IEssentialsChatListener"
|
* This Essentials integration handler is for older 2.x.x versions of Essentials which have "IEssentialsChatListener"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EssentialsOldVersionFeatures
|
public class EssentialsOldVersionFeatures {
|
||||||
{
|
|
||||||
private static EssentialsChat essChat;
|
private static EssentialsChat essChat;
|
||||||
|
|
||||||
public static void integrateChat(EssentialsChat instance)
|
public static void integrateChat(EssentialsChat instance) {
|
||||||
{
|
|
||||||
essChat = instance;
|
essChat = instance;
|
||||||
try
|
try {
|
||||||
{
|
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() {
|
||||||
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener()
|
public boolean shouldHandleThisChat(AsyncPlayerChatEvent event) {
|
||||||
{
|
|
||||||
public boolean shouldHandleThisChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
|
||||||
return P.p.shouldLetFactionsHandleThisChat(event);
|
return P.p.shouldLetFactionsHandleThisChat(event);
|
||||||
}
|
}
|
||||||
public String modifyMessage(AsyncPlayerChatEvent event, Player target, String message)
|
|
||||||
{
|
public String modifyMessage(AsyncPlayerChatEvent event, Player target, String message) {
|
||||||
return message.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTagRelation(event.getPlayer(), target)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(event.getPlayer()));
|
return message.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTagRelation(event.getPlayer(), target)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(event.getPlayer()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
P.p.log("Found and will integrate chat with " + essChat.getDescription().getFullName());
|
P.p.log("Found and will integrate chat with " + essChat.getDescription().getFullName());
|
||||||
|
|
||||||
// As of Essentials 2.8+, curly braces are not accepted and are instead replaced with square braces, so... deal with it
|
// As of Essentials 2.8+, curly braces are not accepted and are instead replaced with square braces, so... deal with it
|
||||||
if (essChat.getDescription().getVersion().startsWith("2.8.") && Conf.chatTagReplaceString.contains("{"))
|
if (essChat.getDescription().getVersion().startsWith("2.8.") && Conf.chatTagReplaceString.contains("{")) {
|
||||||
{
|
|
||||||
Conf.chatTagReplaceString = Conf.chatTagReplaceString.replace("{", "[").replace("}", "]");
|
Conf.chatTagReplaceString = Conf.chatTagReplaceString.replace("{", "[").replace("}", "]");
|
||||||
P.p.log("NOTE: as of Essentials 2.8+, we've had to switch the default chat replacement tag from \"{FACTION}\" to \"[FACTION]\". This has automatically been updated for you.");
|
P.p.log("NOTE: as of Essentials 2.8+, we've had to switch the default chat replacement tag from \"{FACTION}\" to \"[FACTION]\". This has automatically been updated for you.");
|
||||||
}
|
}
|
||||||
}
|
} catch (NoSuchMethodError ex) {
|
||||||
catch (NoSuchMethodError ex)
|
|
||||||
{
|
|
||||||
essChat = null;
|
essChat = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unhookChat()
|
public static void unhookChat() {
|
||||||
{
|
if (essChat != null) {
|
||||||
if (essChat != null)
|
|
||||||
{
|
|
||||||
essChat.removeEssentialsChatListener("Factions");
|
essChat.removeEssentialsChatListener("Factions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,23 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
|
import com.griefcraft.lwc.LWC;
|
||||||
|
import com.griefcraft.lwc.LWCPlugin;
|
||||||
|
import com.massivecraft.factions.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
public class LWCFeatures {
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
|
|
||||||
import com.griefcraft.lwc.LWC;
|
|
||||||
import com.griefcraft.lwc.LWCPlugin;
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
public class LWCFeatures
|
|
||||||
{
|
|
||||||
private static LWC lwc;
|
private static LWC lwc;
|
||||||
|
|
||||||
public static void setup()
|
public static void setup() {
|
||||||
{
|
|
||||||
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("LWC");
|
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("LWC");
|
||||||
if (test == null || !test.isEnabled()) return;
|
if (test == null || !test.isEnabled()) return;
|
||||||
|
|
||||||
@ -32,57 +25,46 @@ public class LWCFeatures
|
|||||||
P.p.log("Successfully hooked into LWC!" + (Conf.lwcIntegration ? "" : " Integration is currently disabled, though (\"lwcIntegration\")."));
|
P.p.log("Successfully hooked into LWC!" + (Conf.lwcIntegration ? "" : " Integration is currently disabled, though (\"lwcIntegration\")."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getEnabled()
|
public static boolean getEnabled() {
|
||||||
{
|
|
||||||
return Conf.lwcIntegration && lwc != null;
|
return Conf.lwcIntegration && lwc != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearOtherChests(FLocation flocation, Faction faction)
|
public static void clearOtherChests(FLocation flocation, Faction faction) {
|
||||||
{
|
|
||||||
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
||||||
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
||||||
Chunk chunk = location.getChunk();
|
Chunk chunk = location.getChunk();
|
||||||
BlockState[] blocks = chunk.getTileEntities();
|
BlockState[] blocks = chunk.getTileEntities();
|
||||||
List<Block> chests = new LinkedList<Block>();
|
List<Block> chests = new LinkedList<Block>();
|
||||||
|
|
||||||
for(int x = 0; x < blocks.length; x++)
|
for (int x = 0; x < blocks.length; x++) {
|
||||||
{
|
if (blocks[x].getType() == Material.CHEST) {
|
||||||
if(blocks[x].getType() == Material.CHEST)
|
|
||||||
{
|
|
||||||
chests.add(blocks[x].getBlock());
|
chests.add(blocks[x].getBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < chests.size(); x++)
|
for (int x = 0; x < chests.size(); x++) {
|
||||||
{
|
if (lwc.findProtection(chests.get(x)) != null) {
|
||||||
if(lwc.findProtection(chests.get(x)) != null)
|
|
||||||
{
|
|
||||||
if (!faction.getFPlayers().contains(FPlayers.i.get(lwc.findProtection(chests.get(x)).getOwner())))
|
if (!faction.getFPlayers().contains(FPlayers.i.get(lwc.findProtection(chests.get(x)).getOwner())))
|
||||||
lwc.findProtection(chests.get(x)).remove();
|
lwc.findProtection(chests.get(x)).remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearAllChests(FLocation flocation)
|
public static void clearAllChests(FLocation flocation) {
|
||||||
{
|
|
||||||
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
||||||
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
||||||
Chunk chunk = location.getChunk();
|
Chunk chunk = location.getChunk();
|
||||||
BlockState[] blocks = chunk.getTileEntities();
|
BlockState[] blocks = chunk.getTileEntities();
|
||||||
List<Block> chests = new LinkedList<Block>();
|
List<Block> chests = new LinkedList<Block>();
|
||||||
|
|
||||||
for(int x = 0; x < blocks.length; x++)
|
for (int x = 0; x < blocks.length; x++) {
|
||||||
{
|
if (blocks[x].getType() == Material.CHEST) {
|
||||||
if(blocks[x].getType() == Material.CHEST)
|
|
||||||
{
|
|
||||||
chests.add(blocks[x].getBlock());
|
chests.add(blocks[x].getBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int x = 0; x < chests.size(); x++)
|
for (int x = 0; x < chests.size(); x++) {
|
||||||
{
|
if (lwc.findProtection(chests.get(x)) != null) {
|
||||||
if(lwc.findProtection(chests.get(x)) != null)
|
|
||||||
{
|
|
||||||
lwc.findProtection(chests.get(x)).remove();
|
lwc.findProtection(chests.get(x)).remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,25 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.*;
|
||||||
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
|
import org.getspout.spoutapi.gui.Color;
|
||||||
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
public class SpoutFeatures {
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
|
|
||||||
import org.getspout.spoutapi.gui.Color;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
|
|
||||||
|
|
||||||
public class SpoutFeatures
|
|
||||||
{
|
|
||||||
private transient static boolean spoutMe = false;
|
private transient static boolean spoutMe = false;
|
||||||
private transient static SpoutMainListener mainListener;
|
private transient static SpoutMainListener mainListener;
|
||||||
private transient static boolean listenersHooked;
|
private transient static boolean listenersHooked;
|
||||||
|
|
||||||
public static void setup()
|
public static void setup() {
|
||||||
{
|
|
||||||
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Spout");
|
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Spout");
|
||||||
if (test == null || !test.isEnabled()) return;
|
if (test == null || !test.isEnabled()) return;
|
||||||
|
|
||||||
@ -37,15 +27,13 @@ public class SpoutFeatures
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set integration availability
|
// set integration availability
|
||||||
public static void setAvailable(boolean enable, String pluginName)
|
public static void setAvailable(boolean enable, String pluginName) {
|
||||||
{
|
|
||||||
spoutMe = enable;
|
spoutMe = enable;
|
||||||
if (!spoutMe) return;
|
if (!spoutMe) return;
|
||||||
|
|
||||||
P.p.log("Found and will use features of " + pluginName);
|
P.p.log("Found and will use features of " + pluginName);
|
||||||
|
|
||||||
if (!listenersHooked)
|
if (!listenersHooked) {
|
||||||
{
|
|
||||||
listenersHooked = true;
|
listenersHooked = true;
|
||||||
mainListener = new SpoutMainListener();
|
mainListener = new SpoutMainListener();
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
|
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
|
||||||
@ -53,28 +41,24 @@ public class SpoutFeatures
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we're successfully hooked into Spout
|
// If we're successfully hooked into Spout
|
||||||
public static boolean enabled()
|
public static boolean enabled() {
|
||||||
{
|
|
||||||
return spoutMe;
|
return spoutMe;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Spout is available and the specified Player is running the Spoutcraft client
|
// If Spout is available and the specified Player is running the Spoutcraft client
|
||||||
public static boolean availableFor(Player player)
|
public static boolean availableFor(Player player) {
|
||||||
{
|
|
||||||
return spoutMe && SpoutManager.getPlayer(player).isSpoutCraftEnabled();
|
return spoutMe && SpoutManager.getPlayer(player).isSpoutCraftEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update displayed current territory for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
// update displayed current territory for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
||||||
public static void updateTerritoryDisplayLoc(FLocation fLoc)
|
public static void updateTerritoryDisplayLoc(FLocation fLoc) {
|
||||||
{
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
|
|
||||||
for (FPlayer player : players)
|
for (FPlayer player : players) {
|
||||||
{
|
|
||||||
if (fLoc == null)
|
if (fLoc == null)
|
||||||
mainListener.updateTerritoryDisplay(player, false);
|
mainListener.updateTerritoryDisplay(player, false);
|
||||||
else if (player.getLastStoodAt().equals(fLoc))
|
else if (player.getLastStoodAt().equals(fLoc))
|
||||||
@ -83,8 +67,7 @@ public class SpoutFeatures
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update displayed current territory for specified player; returns false if unsuccessful
|
// update displayed current territory for specified player; returns false if unsuccessful
|
||||||
public static boolean updateTerritoryDisplay(FPlayer player)
|
public static boolean updateTerritoryDisplay(FPlayer player) {
|
||||||
{
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -92,31 +75,27 @@ public class SpoutFeatures
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update owner list for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
// update owner list for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
||||||
public static void updateOwnerListLoc(FLocation fLoc)
|
public static void updateOwnerListLoc(FLocation fLoc) {
|
||||||
{
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
|
|
||||||
for (FPlayer player : players)
|
for (FPlayer player : players) {
|
||||||
{
|
|
||||||
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
|
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
|
||||||
mainListener.updateOwnerList(player);
|
mainListener.updateOwnerList(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update owner list for specified player
|
// update owner list for specified player
|
||||||
public static void updateOwnerList(FPlayer player)
|
public static void updateOwnerList(FPlayer player) {
|
||||||
{
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mainListener.updateOwnerList(player);
|
mainListener.updateOwnerList(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playerDisconnect(FPlayer player)
|
public static void playerDisconnect(FPlayer player) {
|
||||||
{
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -125,66 +104,55 @@ public class SpoutFeatures
|
|||||||
|
|
||||||
|
|
||||||
// update all appearances between every player
|
// update all appearances between every player
|
||||||
public static void updateAppearances()
|
public static void updateAppearances() {
|
||||||
{
|
|
||||||
if (!enabled())
|
if (!enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
|
|
||||||
for (FPlayer playerA : players)
|
for (FPlayer playerA : players) {
|
||||||
{
|
for (FPlayer playerB : players) {
|
||||||
for (FPlayer playerB : players)
|
|
||||||
{
|
|
||||||
updateSingle(playerB, playerA);
|
updateSingle(playerB, playerA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update all appearances related to a specific player
|
// update all appearances related to a specific player
|
||||||
public static void updateAppearances(Player player)
|
public static void updateAppearances(Player player) {
|
||||||
{
|
|
||||||
if (!enabled() || player == null)
|
if (!enabled() || player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
FPlayer playerA = FPlayers.i.get(player);
|
FPlayer playerA = FPlayers.i.get(player);
|
||||||
|
|
||||||
for (FPlayer playerB : players)
|
for (FPlayer playerB : players) {
|
||||||
{
|
|
||||||
updateSingle(playerB, playerA);
|
updateSingle(playerB, playerA);
|
||||||
updateSingle(playerA, playerB);
|
updateSingle(playerA, playerB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// as above method, but with a delay added; useful for after-login update which doesn't always propagate if done immediately
|
// as above method, but with a delay added; useful for after-login update which doesn't always propagate if done immediately
|
||||||
public static void updateAppearancesShortly(final Player player)
|
public static void updateAppearancesShortly(final Player player) {
|
||||||
{
|
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
|
||||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
updateAppearances(player);
|
updateAppearances(player);
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update all appearances related to a single faction
|
// update all appearances related to a single faction
|
||||||
public static void updateAppearances(Faction faction)
|
public static void updateAppearances(Faction faction) {
|
||||||
{
|
|
||||||
if (!enabled() || faction == null)
|
if (!enabled() || faction == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
Faction factionA;
|
Faction factionA;
|
||||||
|
|
||||||
for (FPlayer playerA : players)
|
for (FPlayer playerA : players) {
|
||||||
{
|
|
||||||
factionA = playerA.getFaction();
|
factionA = playerA.getFaction();
|
||||||
|
|
||||||
for (FPlayer playerB : players)
|
for (FPlayer playerB : players) {
|
||||||
{
|
|
||||||
if (factionA != faction && playerB.getFaction() != faction)
|
if (factionA != faction && playerB.getFaction() != faction)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -194,15 +162,12 @@ public class SpoutFeatures
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update all appearances between two factions
|
// update all appearances between two factions
|
||||||
public static void updateAppearances(Faction factionA, Faction factionB)
|
public static void updateAppearances(Faction factionA, Faction factionB) {
|
||||||
{
|
|
||||||
if (!enabled() || factionA == null || factionB == null)
|
if (!enabled() || factionA == null || factionB == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true))
|
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true)) {
|
||||||
{
|
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true)) {
|
||||||
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
updateSingle(playerB, playerA);
|
updateSingle(playerB, playerA);
|
||||||
updateSingle(playerA, playerB);
|
updateSingle(playerA, playerB);
|
||||||
}
|
}
|
||||||
@ -211,8 +176,7 @@ public class SpoutFeatures
|
|||||||
|
|
||||||
|
|
||||||
// update a single appearance; internal use only by above public methods
|
// update a single appearance; internal use only by above public methods
|
||||||
private static void updateSingle(FPlayer viewer, FPlayer viewed)
|
private static void updateSingle(FPlayer viewer, FPlayer viewed) {
|
||||||
{
|
|
||||||
if (viewer == null || viewed == null)
|
if (viewer == null || viewed == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -232,10 +196,8 @@ public class SpoutFeatures
|
|||||||
String viewedTitle = viewed.getTitle();
|
String viewedTitle = viewed.getTitle();
|
||||||
Role viewedRole = viewed.getRole();
|
Role viewedRole = viewed.getRole();
|
||||||
|
|
||||||
if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed)
|
if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed) {
|
||||||
{
|
if (viewedFaction.isNormal()) {
|
||||||
if (viewedFaction.isNormal())
|
|
||||||
{
|
|
||||||
String addTag = "";
|
String addTag = "";
|
||||||
if (Conf.spoutFactionTagsOverNames)
|
if (Conf.spoutFactionTagsOverNames)
|
||||||
addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
|
addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
|
||||||
@ -245,9 +207,7 @@ public class SpoutFeatures
|
|||||||
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
||||||
|
|
||||||
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
|
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
|
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,15 +225,12 @@ public class SpoutFeatures
|
|||||||
&&
|
&&
|
||||||
viewedRole.equals(Role.MODERATOR)
|
viewedRole.equals(Role.MODERATOR)
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
Relation relation = viewer.getRelationTo(viewed);
|
Relation relation = viewer.getRelationTo(viewed);
|
||||||
String cape = "";
|
String cape = "";
|
||||||
if (!viewedFaction.isNormal())
|
if (!viewedFaction.isNormal()) {
|
||||||
{
|
|
||||||
// yeah, no cape if no faction
|
// yeah, no cape if no faction
|
||||||
}
|
} else if (viewedFaction.isPeaceful())
|
||||||
else if (viewedFaction.isPeaceful())
|
|
||||||
cape = Conf.capePeaceful;
|
cape = Conf.capePeaceful;
|
||||||
else if (relation.isNeutral())
|
else if (relation.isNeutral())
|
||||||
cape = Conf.capeNeutral;
|
cape = Conf.capeNeutral;
|
||||||
@ -288,42 +245,54 @@ public class SpoutFeatures
|
|||||||
pViewed.resetCapeFor(pViewer);
|
pViewed.resetCapeFor(pViewer);
|
||||||
else
|
else
|
||||||
pViewed.setCapeFor(pViewer, cape);
|
pViewed.setCapeFor(pViewer, cape);
|
||||||
}
|
} else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes) {
|
||||||
else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes)
|
|
||||||
{
|
|
||||||
pViewed.resetCapeFor(pViewer);
|
pViewed.resetCapeFor(pViewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// method to convert a Bukkit ChatColor to a Spout Color
|
// method to convert a Bukkit ChatColor to a Spout Color
|
||||||
protected static Color getSpoutColor(ChatColor inColor, int alpha)
|
protected static Color getSpoutColor(ChatColor inColor, int alpha) {
|
||||||
{
|
|
||||||
if (inColor == null)
|
if (inColor == null)
|
||||||
return SpoutFixedColor(191, 191, 191, alpha);
|
return SpoutFixedColor(191, 191, 191, alpha);
|
||||||
|
|
||||||
switch (inColor.getChar())
|
switch (inColor.getChar()) {
|
||||||
{
|
case 0x1:
|
||||||
case 0x1: return SpoutFixedColor(0, 0, 191, alpha);
|
return SpoutFixedColor(0, 0, 191, alpha);
|
||||||
case 0x2: return SpoutFixedColor(0, 191, 0, alpha);
|
case 0x2:
|
||||||
case 0x3: return SpoutFixedColor(0, 191, 191, alpha);
|
return SpoutFixedColor(0, 191, 0, alpha);
|
||||||
case 0x4: return SpoutFixedColor(191, 0, 0, alpha);
|
case 0x3:
|
||||||
case 0x5: return SpoutFixedColor(191, 0, 191, alpha);
|
return SpoutFixedColor(0, 191, 191, alpha);
|
||||||
case 0x6: return SpoutFixedColor(191, 191, 0, alpha);
|
case 0x4:
|
||||||
case 0x7: return SpoutFixedColor(191, 191, 191, alpha);
|
return SpoutFixedColor(191, 0, 0, alpha);
|
||||||
case 0x8: return SpoutFixedColor(64, 64, 64, alpha);
|
case 0x5:
|
||||||
case 0x9: return SpoutFixedColor(64, 64, 255, alpha);
|
return SpoutFixedColor(191, 0, 191, alpha);
|
||||||
case 0xA: return SpoutFixedColor(64, 255, 64, alpha);
|
case 0x6:
|
||||||
case 0xB: return SpoutFixedColor(64, 255, 255, alpha);
|
return SpoutFixedColor(191, 191, 0, alpha);
|
||||||
case 0xC: return SpoutFixedColor(255, 64, 64, alpha);
|
case 0x7:
|
||||||
case 0xD: return SpoutFixedColor(255, 64, 255, alpha);
|
return SpoutFixedColor(191, 191, 191, alpha);
|
||||||
case 0xE: return SpoutFixedColor(255, 255, 64, alpha);
|
case 0x8:
|
||||||
case 0xF: return SpoutFixedColor(255, 255, 255, alpha);
|
return SpoutFixedColor(64, 64, 64, alpha);
|
||||||
default: return SpoutFixedColor(0, 0, 0, alpha);
|
case 0x9:
|
||||||
|
return SpoutFixedColor(64, 64, 255, alpha);
|
||||||
|
case 0xA:
|
||||||
|
return SpoutFixedColor(64, 255, 64, alpha);
|
||||||
|
case 0xB:
|
||||||
|
return SpoutFixedColor(64, 255, 255, alpha);
|
||||||
|
case 0xC:
|
||||||
|
return SpoutFixedColor(255, 64, 64, alpha);
|
||||||
|
case 0xD:
|
||||||
|
return SpoutFixedColor(255, 64, 255, alpha);
|
||||||
|
case 0xE:
|
||||||
|
return SpoutFixedColor(255, 255, 64, alpha);
|
||||||
|
case 0xF:
|
||||||
|
return SpoutFixedColor(255, 255, 255, alpha);
|
||||||
|
default:
|
||||||
|
return SpoutFixedColor(0, 0, 0, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static Color SpoutFixedColor(int r, int g, int b, int a)
|
|
||||||
{
|
private static Color SpoutFixedColor(int r, int g, int b, int a) {
|
||||||
return new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
return new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,22 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.massivecraft.factions.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
import com.massivecraft.factions.Board;
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||||
import org.getspout.spoutapi.gui.GenericLabel;
|
import org.getspout.spoutapi.gui.GenericLabel;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class SpoutMainListener implements Listener
|
public class SpoutMainListener implements Listener {
|
||||||
{
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
||||||
{
|
|
||||||
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||||
|
|
||||||
SpoutFeatures.updateAppearances(me.getPlayer());
|
SpoutFeatures.updateAppearances(me.getPlayer());
|
||||||
@ -44,8 +34,7 @@ public class SpoutMainListener implements Listener
|
|||||||
// private final static int SCREEN_HEIGHT = 240;
|
// private final static int SCREEN_HEIGHT = 240;
|
||||||
|
|
||||||
|
|
||||||
public boolean updateTerritoryDisplay(FPlayer player, boolean notify)
|
public boolean updateTerritoryDisplay(FPlayer player, boolean notify) {
|
||||||
{
|
|
||||||
Player p = player.getPlayer();
|
Player p = player.getPlayer();
|
||||||
if (p == null)
|
if (p == null)
|
||||||
return false;
|
return false;
|
||||||
@ -59,8 +48,7 @@ public class SpoutMainListener implements Listener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOwnerList(FPlayer player)
|
public void updateOwnerList(FPlayer player) {
|
||||||
{
|
|
||||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player.getPlayer());
|
SpoutPlayer sPlayer = SpoutManager.getPlayer(player.getPlayer());
|
||||||
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow))
|
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow))
|
||||||
return;
|
return;
|
||||||
@ -73,16 +61,14 @@ public class SpoutMainListener implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeTerritoryLabels(String playerName)
|
public void removeTerritoryLabels(String playerName) {
|
||||||
{
|
|
||||||
territoryLabels.remove(playerName);
|
territoryLabels.remove(playerName);
|
||||||
territoryChangeLabels.remove(playerName);
|
territoryChangeLabels.remove(playerName);
|
||||||
ownerLabels.remove(playerName);
|
ownerLabels.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify)
|
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify) {
|
||||||
{
|
|
||||||
FLocation here = player.getLastStoodAt();
|
FLocation here = player.getLastStoodAt();
|
||||||
Faction factionHere = Board.getFactionAt(here);
|
Faction factionHere = Board.getFactionAt(here);
|
||||||
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
|
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
|
||||||
@ -90,13 +76,11 @@ public class SpoutMainListener implements Listener
|
|||||||
// ----------------------
|
// ----------------------
|
||||||
// Main territory display
|
// Main territory display
|
||||||
// ----------------------
|
// ----------------------
|
||||||
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0)
|
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0) {
|
||||||
{
|
|
||||||
GenericLabel label;
|
GenericLabel label;
|
||||||
if (territoryLabels.containsKey(player.getName()))
|
if (territoryLabels.containsKey(player.getName()))
|
||||||
label = territoryLabels.get(player.getName());
|
label = territoryLabels.get(player.getName());
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
label = new GenericLabel();
|
label = new GenericLabel();
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
label.setScale(Conf.spoutTerritoryDisplaySize);
|
||||||
@ -118,13 +102,11 @@ public class SpoutMainListener implements Listener
|
|||||||
// -----------------------
|
// -----------------------
|
||||||
// Fading territory notice
|
// Fading territory notice
|
||||||
// -----------------------
|
// -----------------------
|
||||||
if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0)
|
if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0) {
|
||||||
{
|
|
||||||
NoticeLabel label;
|
NoticeLabel label;
|
||||||
if (territoryChangeLabels.containsKey(player.getName()))
|
if (territoryChangeLabels.containsKey(player.getName()))
|
||||||
label = territoryChangeLabels.get(player.getName());
|
label = territoryChangeLabels.get(player.getName());
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds);
|
label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds);
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
label.setScale(Conf.spoutTerritoryNoticeSize);
|
label.setScale(Conf.spoutTerritoryNoticeSize);
|
||||||
@ -148,18 +130,15 @@ public class SpoutMainListener implements Listener
|
|||||||
doOwnerList(player, sPlayer, here, factionHere);
|
doOwnerList(player, sPlayer, here, factionHere);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doOwnerList(FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere)
|
private void doOwnerList(FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere) {
|
||||||
{
|
|
||||||
// ----------
|
// ----------
|
||||||
// Owner list
|
// Owner list
|
||||||
// ----------
|
// ----------
|
||||||
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0 && Conf.spoutTerritoryOwnersShow && Conf.ownedAreasEnabled)
|
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0 && Conf.spoutTerritoryOwnersShow && Conf.ownedAreasEnabled) {
|
||||||
{
|
|
||||||
GenericLabel label;
|
GenericLabel label;
|
||||||
if (ownerLabels.containsKey(player.getName()))
|
if (ownerLabels.containsKey(player.getName()))
|
||||||
label = ownerLabels.get(player.getName());
|
label = ownerLabels.get(player.getName());
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
label = new GenericLabel();
|
label = new GenericLabel();
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
label.setScale(Conf.spoutTerritoryDisplaySize);
|
||||||
@ -170,8 +149,7 @@ public class SpoutMainListener implements Listener
|
|||||||
|
|
||||||
String msg = "";
|
String msg = "";
|
||||||
|
|
||||||
if (player.getFaction() == factionHere)
|
if (player.getFaction() == factionHere) {
|
||||||
{
|
|
||||||
msg = factionHere.getOwnerListString(here);
|
msg = factionHere.getOwnerListString(here);
|
||||||
|
|
||||||
if (!msg.isEmpty())
|
if (!msg.isEmpty())
|
||||||
@ -186,21 +164,18 @@ public class SpoutMainListener implements Listener
|
|||||||
|
|
||||||
|
|
||||||
// this is only necessary because Spout text size scaling is currently bugged and breaks their built-in alignment methods
|
// this is only necessary because Spout text size scaling is currently bugged and breaks their built-in alignment methods
|
||||||
public void alignLabel(GenericLabel label, String text)
|
public void alignLabel(GenericLabel label, String text) {
|
||||||
{
|
|
||||||
alignLabel(label, text, Conf.spoutTerritoryDisplayPosition);
|
alignLabel(label, text, Conf.spoutTerritoryDisplayPosition);
|
||||||
}
|
}
|
||||||
public void alignLabel(GenericLabel label, String text, int alignment)
|
|
||||||
{
|
public void alignLabel(GenericLabel label, String text, int alignment) {
|
||||||
int labelWidth = (int) ((float) GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize);
|
int labelWidth = (int) ((float) GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize);
|
||||||
if (labelWidth > SCREEN_WIDTH)
|
if (labelWidth > SCREEN_WIDTH) {
|
||||||
{
|
|
||||||
label.setX(0);
|
label.setX(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (alignment)
|
switch (alignment) {
|
||||||
{
|
|
||||||
case 1: // left aligned
|
case 1: // left aligned
|
||||||
label.setX(0);
|
label.setX(0);
|
||||||
break;
|
break;
|
||||||
@ -213,32 +188,27 @@ public class SpoutMainListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class NoticeLabel extends GenericLabel
|
private static class NoticeLabel extends GenericLabel {
|
||||||
{
|
|
||||||
private int initial;
|
private int initial;
|
||||||
private int countdown; // current delay countdown
|
private int countdown; // current delay countdown
|
||||||
|
|
||||||
public NoticeLabel(float secondsOfLife)
|
public NoticeLabel(float secondsOfLife) {
|
||||||
{
|
|
||||||
initial = (int) (secondsOfLife * 20);
|
initial = (int) (secondsOfLife * 20);
|
||||||
resetNotice();
|
resetNotice();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void resetNotice()
|
public final void resetNotice() {
|
||||||
{
|
|
||||||
countdown = initial;
|
countdown = initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick()
|
public void onTick() {
|
||||||
{
|
|
||||||
if (countdown <= 0)
|
if (countdown <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.countdown -= 1;
|
this.countdown -= 1;
|
||||||
|
|
||||||
if (this.countdown <= 0)
|
if (this.countdown <= 0) {
|
||||||
{
|
|
||||||
this.setText("");
|
this.setText("");
|
||||||
this.setDirty(true);
|
this.setDirty(true);
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,49 @@
|
|||||||
package com.massivecraft.factions.integration;
|
package com.massivecraft.factions.integration;
|
||||||
|
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.sk89q.worldedit.BlockVector;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
||||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Worldguard Region Checking
|
* Worldguard Region Checking
|
||||||
* Author: Spathizilla
|
* Author: Spathizilla
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Worldguard
|
public class Worldguard {
|
||||||
{
|
|
||||||
private static WorldGuardPlugin wg;
|
private static WorldGuardPlugin wg;
|
||||||
private static boolean enabled = false;
|
private static boolean enabled = false;
|
||||||
|
|
||||||
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;
|
wg = null;
|
||||||
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
wg = (WorldGuardPlugin) wgplug;
|
wg = (WorldGuardPlugin) wgplug;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
P.p.log("Successfully hooked to WorldGuard.");
|
P.p.log("Successfully hooked to WorldGuard.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled()
|
public static boolean isEnabled() {
|
||||||
{
|
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,10 +51,8 @@ public class Worldguard
|
|||||||
// Returns:
|
// Returns:
|
||||||
// True: PVP is allowed
|
// True: PVP is allowed
|
||||||
// False: PVP is disallowed
|
// False: PVP is disallowed
|
||||||
public static boolean isPVP(Player player)
|
public static boolean isPVP(Player player) {
|
||||||
{
|
if (!enabled) {
|
||||||
if( ! enabled)
|
|
||||||
{
|
|
||||||
// No WG hooks so we'll always bypass this check.
|
// No WG hooks so we'll always bypass this check.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -79,10 +70,8 @@ public class Worldguard
|
|||||||
// Returns:
|
// Returns:
|
||||||
// True: Player can build in the region.
|
// True: Player can build in the region.
|
||||||
// False: Player can not build in the region.
|
// False: Player can not build in the region.
|
||||||
public static boolean playerCanBuild(Player player, Location loc)
|
public static boolean playerCanBuild(Player player, Location loc) {
|
||||||
{
|
if (!enabled) {
|
||||||
if( ! enabled)
|
|
||||||
{
|
|
||||||
// No WG hooks so we'll always bypass this check.
|
// No WG hooks so we'll always bypass this check.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,10 +88,8 @@ public class Worldguard
|
|||||||
// Returns:
|
// Returns:
|
||||||
// True: Regions found within chunk
|
// True: Regions found within chunk
|
||||||
// False: No regions found within chunk
|
// False: No regions found within chunk
|
||||||
public static boolean checkForRegionsInChunk(Location loc)
|
public static boolean checkForRegionsInChunk(Location loc) {
|
||||||
{
|
if (!enabled) {
|
||||||
if( ! enabled)
|
|
||||||
{
|
|
||||||
// No WG hooks so we'll always bypass this check.
|
// No WG hooks so we'll always bypass this check.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -126,20 +113,14 @@ public class Worldguard
|
|||||||
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)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package com.massivecraft.factions.integration.capi;
|
package com.massivecraft.factions.integration.capi;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.massivecraft.factions.P;
|
public class CapiFeatures {
|
||||||
|
public static void setup() {
|
||||||
public class CapiFeatures
|
|
||||||
{
|
|
||||||
public static void setup()
|
|
||||||
{
|
|
||||||
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
|
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
|
||||||
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P"))
|
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P")) {
|
||||||
{
|
|
||||||
P.p.log("Integration with the CAPI plugin was successful");
|
P.p.log("Integration with the CAPI plugin was successful");
|
||||||
Bukkit.getPluginManager().registerEvents(new PluginCapiListener(P.p), P.p);
|
Bukkit.getPluginManager().registerEvents(new PluginCapiListener(P.p), P.p);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
package com.massivecraft.factions.integration.capi;
|
package com.massivecraft.factions.integration.capi;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import com.massivecraft.capi.Channel;
|
import com.massivecraft.capi.Channel;
|
||||||
import com.massivecraft.capi.Channels;
|
import com.massivecraft.capi.Channels;
|
||||||
import com.massivecraft.capi.events.CAPIListChannelsEvent;
|
import com.massivecraft.capi.events.CAPIListChannelsEvent;
|
||||||
@ -20,23 +11,28 @@ import com.massivecraft.factions.FPlayers;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class PluginCapiListener implements Listener
|
import java.util.LinkedHashSet;
|
||||||
{
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class PluginCapiListener implements Listener {
|
||||||
P p;
|
P p;
|
||||||
|
|
||||||
Set<String> myChannelIds = new LinkedHashSet<String>();
|
Set<String> myChannelIds = new LinkedHashSet<String>();
|
||||||
|
|
||||||
public PluginCapiListener(P p)
|
public PluginCapiListener(P p) {
|
||||||
{
|
|
||||||
this.p = p;
|
this.p = p;
|
||||||
|
|
||||||
myChannelIds.add("faction");
|
myChannelIds.add("faction");
|
||||||
myChannelIds.add("allies");
|
myChannelIds.add("allies");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String replacePlayerTags(String format, FPlayer me, FPlayer you)
|
private String replacePlayerTags(String format, FPlayer me, FPlayer you) {
|
||||||
{
|
|
||||||
String meFactionTag = me.getChatTag(you);
|
String meFactionTag = me.getChatTag(you);
|
||||||
format = format.replace("{ME_FACTIONTAG}", meFactionTag.length() == 0 ? "" : meFactionTag);
|
format = format.replace("{ME_FACTIONTAG}", meFactionTag.length() == 0 ? "" : meFactionTag);
|
||||||
format = format.replace("{ME_FACTIONTAG_PADR}", meFactionTag.length() == 0 ? "" : meFactionTag + " ");
|
format = format.replace("{ME_FACTIONTAG_PADR}", meFactionTag.length() == 0 ? "" : meFactionTag + " ");
|
||||||
@ -53,20 +49,16 @@ public class PluginCapiListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onListChannelsEvent(CAPIListChannelsEvent event)
|
public void onListChannelsEvent(CAPIListChannelsEvent event) {
|
||||||
{
|
for (Channel c : Channels.i.getAll()) {
|
||||||
for (Channel c : Channels.i.getAll())
|
if (myChannelIds.contains(c.getId())) {
|
||||||
{
|
|
||||||
if (myChannelIds.contains(c.getId()))
|
|
||||||
{
|
|
||||||
event.getChannels().add(c);
|
event.getChannels().add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onMessageToChannel(CAPIMessageToChannelEvent event)
|
public void onMessageToChannel(CAPIMessageToChannelEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
if (!myChannelIds.contains(event.getChannel().getId())) return;
|
if (!myChannelIds.contains(event.getChannel().getId())) return;
|
||||||
|
|
||||||
@ -74,21 +66,16 @@ public class PluginCapiListener implements Listener
|
|||||||
FPlayer fme = FPlayers.i.get(me);
|
FPlayer fme = FPlayers.i.get(me);
|
||||||
Faction myFaction = fme.getFaction();
|
Faction myFaction = fme.getFaction();
|
||||||
|
|
||||||
if (event.getChannel().getId().equals("faction") && myFaction.isNormal())
|
if (event.getChannel().getId().equals("faction") && myFaction.isNormal()) {
|
||||||
{
|
|
||||||
event.getThem().addAll(myFaction.getOnlinePlayers());
|
event.getThem().addAll(myFaction.getOnlinePlayers());
|
||||||
|
|
||||||
// Send to any players who are spying chat... could probably be implemented better than this
|
// Send to any players who are spying chat... could probably be implemented better than this
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
||||||
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + event.getMessage());
|
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + event.getMessage());
|
||||||
}
|
}
|
||||||
}
|
} else if (event.getChannel().getId().equals("allies")) {
|
||||||
else if (event.getChannel().getId().equals("allies"))
|
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
{
|
|
||||||
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers())
|
|
||||||
{
|
|
||||||
FPlayer someFPlayer = FPlayers.i.get(somePlayer);
|
FPlayer someFPlayer = FPlayers.i.get(somePlayer);
|
||||||
if (someFPlayer.getRelationTo(fme).isAtLeast(Relation.ALLY))
|
if (someFPlayer.getRelationTo(fme).isAtLeast(Relation.ALLY))
|
||||||
event.getThem().add(somePlayer);
|
event.getThem().add(somePlayer);
|
||||||
@ -100,15 +87,13 @@ public class PluginCapiListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onMessageToPlayer(CAPIMessageToPlayerEvent event)
|
public void onMessageToPlayer(CAPIMessageToPlayerEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
event.setFormat(this.replacePlayerTags(event.getFormat(), FPlayers.i.get(event.getMe()), FPlayers.i.get(event.getYou())));
|
event.setFormat(this.replacePlayerTags(event.getFormat(), FPlayers.i.get(event.getMe()), FPlayers.i.get(event.getYou())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSelectChannel(CAPISelectChannelEvent event)
|
public void onSelectChannel(CAPISelectChannelEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
String channelId = event.getChannel().getId();
|
String channelId = event.getChannel().getId();
|
||||||
if (!myChannelIds.contains(channelId)) return;
|
if (!myChannelIds.contains(channelId)) return;
|
||||||
@ -116,8 +101,7 @@ public class PluginCapiListener implements Listener
|
|||||||
Player me = event.getMe();
|
Player me = event.getMe();
|
||||||
FPlayer fme = FPlayers.i.get(me);
|
FPlayer fme = FPlayers.i.get(me);
|
||||||
|
|
||||||
if ( ! fme.hasFaction())
|
if (!fme.hasFaction()) {
|
||||||
{
|
|
||||||
event.setFailMessage(p.txt.parse("<b>You must be member in a faction to use this channel."));
|
event.setFailMessage(p.txt.parse("<b>You must be member in a faction to use this channel."));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.*;
|
||||||
|
import com.massivecraft.factions.integration.Worldguard;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -7,41 +11,23 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.integration.Worldguard;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsBlockListener implements Listener
|
public class FactionsBlockListener implements Listener {
|
||||||
{
|
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsBlockListener(P p)
|
|
||||||
{
|
public FactionsBlockListener(P p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,30 +36,25 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false))
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
if (event.getInstaBreak() && ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false))
|
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
|
||||||
@ -83,8 +64,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -97,55 +77,45 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
{
|
|
||||||
// if not a sticky piston, retraction should be fine
|
// if not a sticky piston, retraction should be fine
|
||||||
if (event.isCancelled() || !event.isSticky() || !Conf.pistonProtectionThroughDenyBuild)
|
if (event.isCancelled() || !event.isSticky() || !Conf.pistonProtectionThroughDenyBuild) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location targetLoc = event.getRetractLocation();
|
Location targetLoc = event.getRetractLocation();
|
||||||
|
|
||||||
// if potentially retracted block is just air/water/lava, no worries
|
// if potentially retracted block is just air/water/lava, no worries
|
||||||
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid())
|
if (targetLoc.getBlock().isEmpty() || targetLoc.getBlock().isLiquid()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target)
|
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||||
{
|
|
||||||
|
|
||||||
Faction otherFaction = Board.getFactionAt(new FLocation(target));
|
Faction otherFaction = Board.getFactionAt(new FLocation(target));
|
||||||
|
|
||||||
if (pistonFaction == otherFaction)
|
if (pistonFaction == otherFaction)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (otherFaction.isNone())
|
if (otherFaction.isNone()) {
|
||||||
{
|
|
||||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()))
|
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isSafeZone()) {
|
||||||
else if (otherFaction.isSafeZone())
|
|
||||||
{
|
|
||||||
if (!Conf.safeZoneDenyBuild)
|
if (!Conf.safeZoneDenyBuild)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
else if (otherFaction.isWarZone())
|
|
||||||
{
|
|
||||||
if (!Conf.warZoneDenyBuild)
|
if (!Conf.warZoneDenyBuild)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -160,8 +130,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -171,8 +140,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
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))
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -183,9 +151,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
me.msg("<b>You can't " + action + " in the wilderness.");
|
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))
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -196,9 +162,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
me.msg("<b>You can't " + action + " in a safe zone.");
|
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))
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -218,8 +182,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
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?
|
||||||
if (pain)
|
if (pain) {
|
||||||
{
|
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
|
|
||||||
if (!deny)
|
if (!deny)
|
||||||
@ -227,8 +190,7 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cancel building/destroying in other territory?
|
// cancel building/destroying in other territory?
|
||||||
if (deny)
|
if (deny) {
|
||||||
{
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg("<b>You can't " + action + " in the territory of " + otherFaction.getTag(myFaction));
|
me.msg("<b>You can't " + action + " in the territory of " + otherFaction.getTag(myFaction));
|
||||||
|
|
||||||
@ -236,17 +198,14 @@ public class FactionsBlockListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also cancel and/or cause pain if player doesn't have ownership rights for this claim
|
// Also cancel and/or cause pain if player doesn't have ownership rights for this claim
|
||||||
if (Conf.ownedAreasEnabled && (Conf.ownedAreaDenyBuild || Conf.ownedAreaPainBuild) && !otherFaction.playerHasOwnershipRights(me, loc))
|
if (Conf.ownedAreasEnabled && (Conf.ownedAreaDenyBuild || Conf.ownedAreaPainBuild) && !otherFaction.playerHasOwnershipRights(me, loc)) {
|
||||||
{
|
if (!pain && Conf.ownedAreaPainBuild && !justCheck) {
|
||||||
if (!pain && Conf.ownedAreaPainBuild && !justCheck)
|
|
||||||
{
|
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import com.massivecraft.factions.*;
|
||||||
import java.util.UnknownFormatConversionException;
|
import com.massivecraft.factions.struct.ChatMode;
|
||||||
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,27 +11,20 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import java.util.UnknownFormatConversionException;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import java.util.logging.Level;
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.struct.ChatMode;
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsChatListener implements Listener
|
public class FactionsChatListener implements Listener {
|
||||||
{
|
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsChatListener(P p)
|
|
||||||
{
|
public FactionsChatListener(P p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
|
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
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();
|
||||||
@ -40,8 +33,7 @@ public class FactionsChatListener implements Listener
|
|||||||
ChatMode chat = me.getChatMode();
|
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);
|
event.setCancelled(true);
|
||||||
@ -49,8 +41,7 @@ public class FactionsChatListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is it a faction chat message?
|
// Is it a faction chat message?
|
||||||
if (chat == ChatMode.FACTION)
|
if (chat == ChatMode.FACTION) {
|
||||||
{
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg);
|
String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg);
|
||||||
@ -59,17 +50,14 @@ public class FactionsChatListener implements Listener
|
|||||||
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("FactionChat " + myFaction.getTag() + ": " + message));
|
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("FactionChat " + myFaction.getTag() + ": " + message));
|
||||||
|
|
||||||
//Send to any players who are spying chat
|
//Send to any players who are spying chat
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
||||||
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
|
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +66,7 @@ public class FactionsChatListener implements Listener
|
|||||||
myFaction.sendMessage(message);
|
myFaction.sendMessage(message);
|
||||||
|
|
||||||
//Send to all our allies
|
//Send to all our allies
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
|
||||||
if (myFaction.getRelationTo(fplayer) == Relation.ALLY)
|
if (myFaction.getRelationTo(fplayer) == Relation.ALLY)
|
||||||
fplayer.sendMessage(message);
|
fplayer.sendMessage(message);
|
||||||
|
|
||||||
@ -97,8 +84,7 @@ public class FactionsChatListener implements Listener
|
|||||||
|
|
||||||
// this is for handling insertion of the player's faction tag, set at highest priority to give other plugins a chance to modify chat first
|
// this is for handling insertion of the player's faction tag, set at highest priority to give other plugins a chance to modify chat first
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
// Are we to insert the Faction tag into the format?
|
// Are we to insert the Faction tag into the format?
|
||||||
@ -111,31 +97,23 @@ public class FactionsChatListener implements Listener
|
|||||||
FPlayer me = FPlayers.i.get(talkingPlayer);
|
FPlayer me = FPlayers.i.get(talkingPlayer);
|
||||||
int InsertIndex = 0;
|
int InsertIndex = 0;
|
||||||
|
|
||||||
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, "");
|
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
|
||||||
Conf.chatTagPadAfter = false;
|
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())
|
if (InsertIndex > eventFormat.length())
|
||||||
@ -148,22 +126,17 @@ public class FactionsChatListener implements Listener
|
|||||||
String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd;
|
String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd;
|
||||||
|
|
||||||
// Relation Colored?
|
// Relation Colored?
|
||||||
if (Conf.chatTagRelationColored)
|
if (Conf.chatTagRelationColored) {
|
||||||
{
|
|
||||||
// We must choke the standard message and send out individual messages to all players
|
// We must choke the standard message and send out individual messages to all players
|
||||||
// Why? Because the relations will differ.
|
// Why? Because the relations will differ.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
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.");
|
||||||
@ -175,9 +148,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);
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,18 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.massivecraft.factions.*;
|
||||||
import java.util.Arrays;
|
import com.massivecraft.factions.event.PowerLossEvent;
|
||||||
import java.util.Iterator;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import java.util.LinkedHashSet;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
import java.util.List;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.Enderman;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Fireball;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.entity.Wither;
|
|
||||||
import org.bukkit.entity.WitherSkull;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
|
||||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||||
@ -41,32 +20,21 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import java.text.MessageFormat;
|
||||||
import com.massivecraft.factions.Conf;
|
import java.util.*;
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.event.PowerLossEvent;
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsEntityListener implements Listener
|
public class FactionsEntityListener implements Listener {
|
||||||
{
|
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsEntityListener(P p)
|
|
||||||
{
|
public FactionsEntityListener(P p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,35 +44,25 @@ public class FactionsEntityListener implements Listener
|
|||||||
|
|
||||||
PowerLossEvent powerLossEvent = new PowerLossEvent(faction, fplayer);
|
PowerLossEvent powerLossEvent = new PowerLossEvent(faction, fplayer);
|
||||||
// Check for no power loss conditions
|
// Check for no power loss conditions
|
||||||
if (faction.isWarZone())
|
if (faction.isWarZone()) {
|
||||||
{
|
|
||||||
// war zones always override worldsNoPowerLoss either way, thus this layout
|
// war zones always override worldsNoPowerLoss either way, thus this layout
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,55 +70,44 @@ public class FactionsEntityListener implements Listener
|
|||||||
Bukkit.getPluginManager().callEvent(powerLossEvent);
|
Bukkit.getPluginManager().callEvent(powerLossEvent);
|
||||||
|
|
||||||
// Call player onDeath if the event is not cancelled
|
// Call player onDeath if the event is not cancelled
|
||||||
if(!powerLossEvent.isCancelled())
|
if (!powerLossEvent.isCancelled()) {
|
||||||
{
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Who can I hurt?
|
* Who can I hurt? I can never hurt members or allies. I can always hurt enemies. I can hurt neutrals as long as
|
||||||
* I can never hurt members or allies.
|
* they are outside their own territory.
|
||||||
* I can always hurt enemies.
|
|
||||||
* I can hurt neutrals as long as they are outside their own territory.
|
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
if (event instanceof EntityDamageByEntityEvent)
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
{
|
|
||||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
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;
|
||||||
@ -181,12 +128,10 @@ public class FactionsEntityListener implements Listener
|
|||||||
||
|
||
|
||||||
faction.isSafeZone()
|
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)
|
||||||
@ -200,12 +145,10 @@ public class FactionsEntityListener implements Listener
|
|||||||
||
|
||
|
||||||
faction.isSafeZone()
|
faction.isSafeZone()
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
// ghast fireball which needs prevention
|
// ghast fireball which needs prevention
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
} else if
|
||||||
else if
|
|
||||||
(
|
(
|
||||||
(boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart)
|
(boomer instanceof TNTPrimed || boomer instanceof ExplosiveMinecart)
|
||||||
&&
|
&&
|
||||||
@ -218,19 +161,15 @@ public class FactionsEntityListener implements Listener
|
|||||||
||
|
||
|
||||||
(faction.isSafeZone() && Conf.safeZoneBlockTNT)
|
(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));
|
||||||
@ -239,8 +178,7 @@ public class FactionsEntityListener implements Listener
|
|||||||
targets.add(center.getRelative(0, -1, 0));
|
targets.add(center.getRelative(0, -1, 0));
|
||||||
targets.add(center.getRelative(1, 0, 0));
|
targets.add(center.getRelative(1, 0, 0));
|
||||||
targets.add(center.getRelative(-1, 0, 0));
|
targets.add(center.getRelative(-1, 0, 0));
|
||||||
for (Block target : targets)
|
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)
|
||||||
@ -252,8 +190,7 @@ public class FactionsEntityListener implements Listener
|
|||||||
|
|
||||||
// mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled
|
// mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event)
|
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||||
{
|
|
||||||
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);
|
||||||
@ -269,16 +206,13 @@ public class FactionsEntityListener implements Listener
|
|||||||
));
|
));
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
@ -289,8 +223,7 @@ public class FactionsEntityListener implements Listener
|
|||||||
|
|
||||||
// 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(thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, target, EntityDamageEvent.DamageCause.CUSTOM, 0);
|
||||||
if (!this.canDamagerHurtDamagee(sub, true))
|
if (!this.canDamagerHurtDamagee(sub, true))
|
||||||
@ -299,26 +232,21 @@ public class FactionsEntityListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
return canDamagerHurtDamagee(sub, true);
|
return canDamagerHurtDamagee(sub, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
Entity damagee = sub.getEntity();
|
||||||
int damage = sub.getDamage();
|
int damage = sub.getDamage();
|
||||||
@ -343,10 +271,8 @@ public class FactionsEntityListener implements Listener
|
|||||||
|
|
||||||
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
||||||
if (defLocFaction.noPvPInTerritory()) {
|
if (defLocFaction.noPvPInTerritory()) {
|
||||||
if (damager instanceof Player)
|
if (damager instanceof Player) {
|
||||||
{
|
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."));
|
||||||
}
|
}
|
||||||
@ -365,18 +291,18 @@ public class FactionsEntityListener implements Listener
|
|||||||
|
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
if (Conf.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
|
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,32 +315,23 @@ public class FactionsEntityListener implements Listener
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@ -422,8 +339,7 @@ public class FactionsEntityListener implements Listener
|
|||||||
Relation relation = defendFaction.getRelationTo(attackFaction);
|
Relation relation = defendFaction.getRelationTo(attackFaction);
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -433,8 +349,7 @@ public class FactionsEntityListener implements Listener
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@ -442,10 +357,8 @@ public class FactionsEntityListener implements Listener
|
|||||||
boolean ownTerritory = defender.isInOwnTerritory();
|
boolean ownTerritory = defender.isInOwnTerritory();
|
||||||
|
|
||||||
// You can not hurt neutrals in their own territory.
|
// You can not hurt neutrals in their own territory.
|
||||||
if (ownTerritory && relation.isNeutral())
|
if (ownTerritory && relation.isNeutral()) {
|
||||||
{
|
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));
|
||||||
}
|
}
|
||||||
@ -453,14 +366,12 @@ public class FactionsEntityListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
{
|
|
||||||
String perc = MessageFormat.format("{0,number,#%}", (Conf.territoryShieldFactor)); // TODO does this display correctly??
|
String perc = MessageFormat.format("{0,number,#%}", (Conf.territoryShieldFactor)); // TODO does this display correctly??
|
||||||
defender.msg("<i>Enemy damage reduced by <rose>%s<i>.", perc);
|
defender.msg("<i>Enemy damage reduced by <rose>%s<i>.", perc);
|
||||||
}
|
}
|
||||||
@ -470,54 +381,44 @@ public class FactionsEntityListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
{
|
if (event.isCancelled() || event.getLocation() == null) {
|
||||||
if (event.isCancelled() || event.getLocation() == null)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory())
|
if (Conf.safeZoneNerfedCreatureTypes.contains(event.getEntityType()) && Board.getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityTarget(EntityTargetEvent event)
|
public void onEntityTarget(EntityTargetEvent event) {
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are interested in blocking targeting for certain mobs:
|
// We are interested in blocking targeting for certain mobs:
|
||||||
if ( ! Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity())))
|
if (!Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case the target is in a safe zone.
|
// in case the target is in a safe zone.
|
||||||
if (Board.getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory())
|
if (Board.getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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();
|
Location loc = event.getEntity().getLocation();
|
||||||
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;
|
||||||
@ -548,44 +449,37 @@ public class FactionsEntityListener implements Listener
|
|||||||
)
|
)
|
||||||
||
|
||
|
||||||
faction.isSafeZone()
|
faction.isSafeZone()
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
// explosion which needs prevention
|
// explosion which needs prevention
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (event instanceof HangingBreakByEntityEvent))
|
if (!(event instanceof HangingBreakByEntityEvent)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity breaker = ((HangingBreakByEntityEvent) event).getRemover();
|
Entity breaker = ((HangingBreakByEntityEvent) event).getRemover();
|
||||||
if (! (breaker instanceof Player))
|
if (!(breaker instanceof Player)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! FactionsBlockListener.playerCanBuildDestroyBlock((Player)breaker, event.getEntity().getLocation(), "remove paintings", false))
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock((Player) breaker, event.getEntity().getLocation(), "remove paintings", false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPaintingPlace(HangingPlaceEvent event)
|
public void onPaintingPlace(HangingPlaceEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
if ( ! FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false) )
|
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "place paintings", false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event)
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
@ -595,13 +489,10 @@ public class FactionsEntityListener implements Listener
|
|||||||
|
|
||||||
Location loc = event.getBlock().getLocation();
|
Location loc = event.getBlock().getLocation();
|
||||||
|
|
||||||
if (entity instanceof Enderman)
|
if (entity instanceof Enderman) {
|
||||||
{
|
|
||||||
if (stopEndermanBlockManipulation(loc))
|
if (stopEndermanBlockManipulation(loc))
|
||||||
event.setCancelled(true);
|
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
|
||||||
@ -618,10 +509,8 @@ public class FactionsEntityListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean stopEndermanBlockManipulation(Location loc)
|
private boolean stopEndermanBlockManipulation(Location loc) {
|
||||||
{
|
if (loc == null) {
|
||||||
if (loc == null)
|
|
||||||
{
|
|
||||||
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
|
||||||
@ -636,28 +525,20 @@ public class FactionsEntityListener implements Listener
|
|||||||
Conf.safeZoneDenyEndermanBlocks
|
Conf.safeZoneDenyEndermanBlocks
|
||||||
&&
|
&&
|
||||||
Conf.warZoneDenyEndermanBlocks
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsExploitListener implements Listener
|
public class FactionsExploitListener implements Listener {
|
||||||
{
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void obsidianGenerator(BlockFromToEvent event)
|
public void obsidianGenerator(BlockFromToEvent event) {
|
||||||
{
|
|
||||||
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
|
||||||
@ -29,8 +26,7 @@ public class FactionsExploitListener implements Listener
|
|||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void enderPearlTeleport(PlayerTeleportEvent event)
|
public void enderPearlTeleport(PlayerTeleportEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled() == true || !Conf.handleExploitEnderPearlClipping) return;
|
if (event.isCancelled() == true || !Conf.handleExploitEnderPearlClipping) return;
|
||||||
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return;
|
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) return;
|
||||||
|
|
||||||
@ -43,8 +39,7 @@ public class FactionsExploitListener implements Listener
|
|||||||
if (
|
if (
|
||||||
((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65))
|
((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.FENCE || mat == Material.NETHER_FENCE) && clippingThrough(target, from, 0.45))
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -56,8 +51,7 @@ public class FactionsExploitListener implements Listener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
(from.getX() > target.getX() && (from.getX() - target.getX() < thickness))
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.massivecraft.factions.*;
|
||||||
import java.util.Iterator;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import java.util.Map;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
import com.massivecraft.factions.struct.Relation;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -12,42 +14,23 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
|
||||||
import org.bukkit.util.NumberConversions;
|
import org.bukkit.util.NumberConversions;
|
||||||
|
|
||||||
import com.massivecraft.factions.Board;
|
import java.util.HashMap;
|
||||||
import com.massivecraft.factions.Conf;
|
import java.util.Iterator;
|
||||||
import com.massivecraft.factions.FLocation;
|
import java.util.Map;
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.struct.Permission;
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsPlayerListener implements Listener
|
public class FactionsPlayerListener implements Listener {
|
||||||
{
|
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsPlayerListener(P p)
|
|
||||||
{
|
public FactionsPlayerListener(P p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
{
|
|
||||||
// Make sure that all online players do have a fplayer.
|
// Make sure that all online players do have a fplayer.
|
||||||
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||||
|
|
||||||
@ -63,8 +46,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
{
|
|
||||||
FPlayer me = FPlayers.i.get(event.getPlayer());
|
FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||||
|
|
||||||
// Make sure player's power is up to date when they log off.
|
// Make sure player's power is up to date when they log off.
|
||||||
@ -73,16 +55,14 @@ public class FactionsPlayerListener implements Listener
|
|||||||
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();
|
||||||
}
|
}
|
||||||
SpoutFeatures.playerDisconnect(me);
|
SpoutFeatures.playerDisconnect(me);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
{
|
|
||||||
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
|
||||||
@ -103,8 +83,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,20 +100,16 @@ public class FactionsPlayerListener implements Listener
|
|||||||
if (changedFaction && SpoutFeatures.updateTerritoryDisplay(me))
|
if (changedFaction && SpoutFeatures.updateTerritoryDisplay(me))
|
||||||
changedFaction = false;
|
changedFaction = false;
|
||||||
|
|
||||||
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()));
|
||||||
|
|
||||||
if (spoutClient && Conf.spoutTerritoryOwnersShow)
|
if (spoutClient && Conf.spoutTerritoryOwnersShow)
|
||||||
SpoutFeatures.updateOwnerList(me);
|
SpoutFeatures.updateOwnerList(me);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
String ownersTo = myFaction.getOwnerListString(to);
|
String ownersTo = myFaction.getOwnerListString(to);
|
||||||
|
|
||||||
if (changedFaction)
|
if (changedFaction) {
|
||||||
{
|
|
||||||
me.sendFactionHereMessage();
|
me.sendFactionHereMessage();
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -151,16 +126,12 @@ public class FactionsPlayerListener implements Listener
|
|||||||
myFaction == factionTo
|
myFaction == factionTo
|
||||||
&&
|
&&
|
||||||
!ownersTo.isEmpty()
|
!ownersTo.isEmpty()
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
||||||
}
|
}
|
||||||
}
|
} else if (spoutClient && Conf.spoutTerritoryOwnersShow) {
|
||||||
else if (spoutClient && Conf.spoutTerritoryOwnersShow)
|
|
||||||
{
|
|
||||||
SpoutFeatures.updateOwnerList(me);
|
SpoutFeatures.updateOwnerList(me);
|
||||||
}
|
} else if
|
||||||
else if
|
|
||||||
(
|
(
|
||||||
Conf.ownedAreasEnabled
|
Conf.ownedAreasEnabled
|
||||||
&&
|
&&
|
||||||
@ -169,11 +140,9 @@ public class FactionsPlayerListener implements Listener
|
|||||||
factionFrom == factionTo
|
factionFrom == factionTo
|
||||||
&&
|
&&
|
||||||
myFaction == 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())
|
if (!ownersTo.isEmpty())
|
||||||
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
me.sendMessage(Conf.ownedLandMessage + ownersTo);
|
||||||
else if (!Conf.publicLandMessage.isEmpty())
|
else if (!Conf.publicLandMessage.isEmpty())
|
||||||
@ -182,35 +151,22 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.");
|
||||||
}
|
}
|
||||||
@ -219,8 +175,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
// 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;
|
||||||
@ -230,21 +185,17 @@ public class FactionsPlayerListener implements Listener
|
|||||||
|
|
||||||
if (block == null) return; // clicked in air, apparently
|
if (block == null) 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();
|
String name = player.getName();
|
||||||
InteractAttemptSpam attempt = interactSpammers.get(name);
|
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();
|
int count = attempt.increment();
|
||||||
if (count >= 10)
|
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));
|
||||||
@ -255,8 +206,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
|
|
||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; // only interested on right-clicks for below
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; // only interested on right-clicks for below
|
||||||
|
|
||||||
if ( ! playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false))
|
if (!playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -265,14 +215,13 @@ public class FactionsPlayerListener implements Listener
|
|||||||
|
|
||||||
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
|
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
|
||||||
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<String, InteractAttemptSpam>();
|
private Map<String, InteractAttemptSpam> interactSpammers = new HashMap<String, InteractAttemptSpam>();
|
||||||
private static class InteractAttemptSpam
|
|
||||||
{
|
private static class InteractAttemptSpam {
|
||||||
private int attempts = 0;
|
private int attempts = 0;
|
||||||
private long lastAttempt = System.currentTimeMillis();
|
private long lastAttempt = System.currentTimeMillis();
|
||||||
|
|
||||||
// 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)
|
if (Now > lastAttempt + 2000)
|
||||||
attempts = 1;
|
attempts = 1;
|
||||||
@ -284,8 +233,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -295,19 +243,15 @@ public class FactionsPlayerListener implements Listener
|
|||||||
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherFaction.isNone())
|
if (otherFaction.isNone()) {
|
||||||
{
|
|
||||||
if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
||||||
return true; // This is not faction territory. Use whatever you like here.
|
return true; // This is not faction territory. Use whatever you like here.
|
||||||
|
|
||||||
@ -315,9 +259,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
me.msg("<b>You can't use <h>%s<b> in the wilderness.", TextUtil.getMaterialName(material));
|
me.msg("<b>You can't use <h>%s<b> in the wilderness.", TextUtil.getMaterialName(material));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isSafeZone()) {
|
||||||
else if (otherFaction.isSafeZone())
|
|
||||||
{
|
|
||||||
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player))
|
if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -325,9 +267,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
me.msg("<b>You can't use <h>%s<b> in a safe zone.", TextUtil.getMaterialName(material));
|
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))
|
if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -341,8 +281,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
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()) {
|
||||||
{
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg("<b>You can't use <h>%s<b> in the territory of <h>%s<b>.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
me.msg("<b>You can't use <h>%s<b> in the territory of <h>%s<b>.", TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
||||||
|
|
||||||
@ -350,8 +289,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also cancel if player doesn't have ownership rights for this claim
|
// Also cancel if player doesn't have ownership rights for this claim
|
||||||
if (Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc))
|
if (Conf.ownedAreasEnabled && Conf.ownedAreaDenyUseage && !otherFaction.playerHasOwnershipRights(me, loc)) {
|
||||||
{
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
||||||
|
|
||||||
@ -361,8 +299,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck)
|
public static boolean canPlayerUseBlock(Player player, Block block, boolean justCheck) {
|
||||||
{
|
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
|
if (Conf.playersWhoBypassAllProtection.contains(name)) return true;
|
||||||
|
|
||||||
@ -378,13 +315,10 @@ public class FactionsPlayerListener implements Listener
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// 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))
|
if (!Conf.territoryProtectedMaterials.contains(material))
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material))
|
if (!Conf.territoryProtectedMaterialsWhenOffline.contains(material))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -393,8 +327,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
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)) {
|
||||||
{
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg("<b>You can't %s <h>%s<b> in the territory of <h>%s<b>.", (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
me.msg("<b>You can't %s <h>%s<b> in the territory of <h>%s<b>.", (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction));
|
||||||
|
|
||||||
@ -402,8 +335,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also cancel if player doesn't have ownership rights for this claim
|
// Also cancel if player doesn't have ownership rights for this claim
|
||||||
if (Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc))
|
if (Conf.ownedAreasEnabled && Conf.ownedAreaProtectMaterials && !otherFaction.playerHasOwnershipRights(me, loc)) {
|
||||||
{
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
me.msg("<b>You can't use <h>%s<b> in this territory, it is owned by: %s<b>.", TextUtil.getMaterialName(material), otherFaction.getOwnerListString(loc));
|
||||||
|
|
||||||
@ -414,8 +346,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
{
|
|
||||||
FPlayer me = FPlayers.i.get(event.getPlayer());
|
FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||||
|
|
||||||
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
|
||||||
@ -434,8 +365,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
||
|
||
|
||||||
!Conf.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName())
|
!Conf.worldsNoPowerLoss.contains(event.getPlayer().getWorld().getName())
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
event.setRespawnLocation(home);
|
event.setRespawnLocation(home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,36 +373,32 @@ public class FactionsPlayerListener implements Listener
|
|||||||
// For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected),
|
// For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected),
|
||||||
// but these separate bucket events below always fire without fail
|
// but these separate bucket events below always fire without fail
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean preventCommand(String fullCmd, Player player)
|
public static boolean preventCommand(String fullCmd, Player player) {
|
||||||
{
|
|
||||||
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty()))
|
if ((Conf.territoryNeutralDenyCommands.isEmpty() && Conf.territoryEnemyDenyCommands.isEmpty() && Conf.permanentFactionMemberDenyCommands.isEmpty()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -483,8 +409,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
String shortCmd; // command without the slash at the beginning
|
String shortCmd; // command without the slash at the beginning
|
||||||
if (fullCmd.startsWith("/"))
|
if (fullCmd.startsWith("/"))
|
||||||
shortCmd = fullCmd.substring(1);
|
shortCmd = fullCmd.substring(1);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
shortCmd = fullCmd;
|
shortCmd = fullCmd;
|
||||||
fullCmd = "/" + fullCmd;
|
fullCmd = "/" + fullCmd;
|
||||||
}
|
}
|
||||||
@ -500,20 +425,17 @@ public class FactionsPlayerListener implements Listener
|
|||||||
me.getFaction().isPermanent()
|
me.getFaction().isPermanent()
|
||||||
&&
|
&&
|
||||||
isCommandInList(fullCmd, shortCmd, Conf.permanentFactionMemberDenyCommands.iterator())
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!me.isInOthersTerritory())
|
if (!me.isInOthersTerritory()) {
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,8 +448,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
!me.isAdminBypassing()
|
!me.isAdminBypassing()
|
||||||
&&
|
&&
|
||||||
isCommandInList(fullCmd, shortCmd, Conf.territoryNeutralDenyCommands.iterator())
|
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;
|
||||||
}
|
}
|
||||||
@ -541,8 +462,7 @@ public class FactionsPlayerListener implements Listener
|
|||||||
!me.isAdminBypassing()
|
!me.isAdminBypassing()
|
||||||
&&
|
&&
|
||||||
isCommandInList(fullCmd, shortCmd, Conf.territoryEnemyDenyCommands.iterator())
|
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;
|
||||||
}
|
}
|
||||||
@ -550,14 +470,11 @@ public class FactionsPlayerListener implements Listener
|
|||||||
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();
|
cmdCheck = iter.next();
|
||||||
if (cmdCheck == null)
|
if (cmdCheck == null) {
|
||||||
{
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -570,21 +487,18 @@ public class FactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpoutFeatures.playerDisconnect(badGuy);
|
SpoutFeatures.playerDisconnect(badGuy);
|
||||||
|
|
||||||
// if player was banned (not just kicked), get rid of their stored info
|
// if player was banned (not just kicked), get rid of their stored info
|
||||||
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin."))
|
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
|
||||||
{
|
|
||||||
if (badGuy.getRole() == Role.ADMIN)
|
if (badGuy.getRole() == Role.ADMIN)
|
||||||
badGuy.getFaction().promoteNewLeader();
|
badGuy.getFaction().promoteNewLeader();
|
||||||
|
|
||||||
|
@ -1,41 +1,35 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsServerListener implements Listener
|
public class FactionsServerListener implements Listener {
|
||||||
{
|
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsServerListener(P p)
|
|
||||||
{
|
public FactionsServerListener(P p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPluginDisable(PluginDisableEvent event)
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
{
|
|
||||||
String name = event.getPlugin().getDescription().getName();
|
String name = event.getPlugin().getDescription().getName();
|
||||||
if (name.equals("Spout"))
|
if (name.equals("Spout")) {
|
||||||
{
|
|
||||||
SpoutFeatures.setAvailable(false, "");
|
SpoutFeatures.setAvailable(false, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPluginEnable(PluginEnableEvent event)
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
{
|
|
||||||
Plugin plug = event.getPlugin();
|
Plugin plug = event.getPlugin();
|
||||||
String name = plug.getDescription().getName();
|
String name = plug.getDescription().getName();
|
||||||
if (name.equals("Spout"))
|
if (name.equals("Spout")) {
|
||||||
{
|
|
||||||
SpoutFeatures.setAvailable(true, plug.getDescription().getFullName());
|
SpoutFeatures.setAvailable(true, plug.getDescription().getFullName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.massivecraft.factions.struct;
|
package com.massivecraft.factions.struct;
|
||||||
|
|
||||||
public enum ChatMode
|
public enum ChatMode {
|
||||||
{
|
|
||||||
FACTION(2, "faction chat"),
|
FACTION(2, "faction chat"),
|
||||||
ALLIANCE(1, "alliance chat"),
|
ALLIANCE(1, "alliance chat"),
|
||||||
PUBLIC(0, "public chat");
|
PUBLIC(0, "public chat");
|
||||||
@ -9,30 +8,25 @@ public enum ChatMode
|
|||||||
public final int value;
|
public final int value;
|
||||||
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) {
|
||||||
{
|
|
||||||
return this.value >= role.value;
|
return this.value >= role.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtMost(ChatMode role)
|
public boolean isAtMost(ChatMode role) {
|
||||||
{
|
|
||||||
return this.value <= role.value;
|
return this.value <= role.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return this.nicename;
|
return this.nicename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatMode getNext()
|
public ChatMode getNext() {
|
||||||
{
|
|
||||||
if (this == PUBLIC) return ALLIANCE;
|
if (this == PUBLIC) return ALLIANCE;
|
||||||
if (this == ALLIANCE) return FACTION;
|
if (this == ALLIANCE) return FACTION;
|
||||||
return PUBLIC;
|
return PUBLIC;
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package com.massivecraft.factions.struct;
|
package com.massivecraft.factions.struct;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.massivecraft.factions.P;
|
public enum Permission {
|
||||||
|
|
||||||
public enum Permission
|
|
||||||
{
|
|
||||||
MANAGE_SAFE_ZONE("managesafezone"),
|
MANAGE_SAFE_ZONE("managesafezone"),
|
||||||
MANAGE_WAR_ZONE("managewarzone"),
|
MANAGE_WAR_ZONE("managewarzone"),
|
||||||
OWNERSHIP_BYPASS("ownershipbypass"),
|
OWNERSHIP_BYPASS("ownershipbypass"),
|
||||||
@ -65,23 +63,19 @@ public enum Permission
|
|||||||
TITLE("title"),
|
TITLE("title"),
|
||||||
UNCLAIM("unclaim"),
|
UNCLAIM("unclaim"),
|
||||||
UNCLAIM_ALL("unclaimall"),
|
UNCLAIM_ALL("unclaimall"),
|
||||||
VERSION("version"),
|
VERSION("version"),;
|
||||||
;
|
|
||||||
|
|
||||||
public final String node;
|
public final String node;
|
||||||
|
|
||||||
Permission(final String node)
|
Permission(final String node) {
|
||||||
{
|
|
||||||
this.node = "factions." + node;
|
this.node = "factions." + node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(CommandSender sender, boolean informSenderIfNot)
|
public boolean has(CommandSender sender, boolean informSenderIfNot) {
|
||||||
{
|
|
||||||
return P.p.perm.has(sender, this.node, informSenderIfNot);
|
return P.p.perm.has(sender, this.node, informSenderIfNot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(CommandSender sender)
|
public boolean has(CommandSender sender) {
|
||||||
{
|
|
||||||
return has(sender, false);
|
return has(sender, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package com.massivecraft.factions.struct;
|
package com.massivecraft.factions.struct;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Conf;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
|
|
||||||
|
public enum Relation {
|
||||||
public enum Relation
|
|
||||||
{
|
|
||||||
MEMBER(3, "member"),
|
MEMBER(3, "member"),
|
||||||
ALLY(2, "ally"),
|
ALLY(2, "ally"),
|
||||||
NEUTRAL(1, "neutral"),
|
NEUTRAL(1, "neutral"),
|
||||||
@ -15,50 +13,41 @@ public enum Relation
|
|||||||
public final int value;
|
public final int value;
|
||||||
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
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return this.nicename;
|
return this.nicename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMember()
|
public boolean isMember() {
|
||||||
{
|
|
||||||
return this == MEMBER;
|
return this == MEMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlly()
|
public boolean isAlly() {
|
||||||
{
|
|
||||||
return this == ALLY;
|
return this == ALLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNeutral()
|
public boolean isNeutral() {
|
||||||
{
|
|
||||||
return this == NEUTRAL;
|
return this == NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnemy()
|
public boolean isEnemy() {
|
||||||
{
|
|
||||||
return this == ENEMY;
|
return this == ENEMY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(Relation relation)
|
public boolean isAtLeast(Relation relation) {
|
||||||
{
|
|
||||||
return this.value >= relation.value;
|
return this.value >= relation.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtMost(Relation relation)
|
public boolean isAtMost(Relation relation) {
|
||||||
{
|
|
||||||
return this.value <= relation.value;
|
return this.value <= relation.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor()
|
public ChatColor getColor() {
|
||||||
{
|
|
||||||
if (this == MEMBER)
|
if (this == MEMBER)
|
||||||
return Conf.colorMember;
|
return Conf.colorMember;
|
||||||
else if (this == ALLY)
|
else if (this == ALLY)
|
||||||
@ -70,22 +59,18 @@ public enum Relation
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
public boolean confDenyBuild(boolean online)
|
public boolean confDenyBuild(boolean online) {
|
||||||
{
|
|
||||||
if (isMember())
|
if (isMember())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (online)
|
if (online) {
|
||||||
{
|
|
||||||
if (isEnemy())
|
if (isEnemy())
|
||||||
return Conf.territoryEnemyDenyBuild;
|
return Conf.territoryEnemyDenyBuild;
|
||||||
else if (isAlly())
|
else if (isAlly())
|
||||||
return Conf.territoryAllyDenyBuild;
|
return Conf.territoryAllyDenyBuild;
|
||||||
else
|
else
|
||||||
return Conf.territoryDenyBuild;
|
return Conf.territoryDenyBuild;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isEnemy())
|
if (isEnemy())
|
||||||
return Conf.territoryEnemyDenyBuildWhenOffline;
|
return Conf.territoryEnemyDenyBuildWhenOffline;
|
||||||
else if (isAlly())
|
else if (isAlly())
|
||||||
@ -96,22 +81,18 @@ public enum Relation
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
||||||
public boolean confPainBuild(boolean online)
|
public boolean confPainBuild(boolean online) {
|
||||||
{
|
|
||||||
if (isMember())
|
if (isMember())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (online)
|
if (online) {
|
||||||
{
|
|
||||||
if (isEnemy())
|
if (isEnemy())
|
||||||
return Conf.territoryEnemyPainBuild;
|
return Conf.territoryEnemyPainBuild;
|
||||||
else if (isAlly())
|
else if (isAlly())
|
||||||
return Conf.territoryAllyPainBuild;
|
return Conf.territoryAllyPainBuild;
|
||||||
else
|
else
|
||||||
return Conf.territoryPainBuild;
|
return Conf.territoryPainBuild;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isEnemy())
|
if (isEnemy())
|
||||||
return Conf.territoryEnemyPainBuildWhenOffline;
|
return Conf.territoryEnemyPainBuildWhenOffline;
|
||||||
else if (isAlly())
|
else if (isAlly())
|
||||||
@ -122,8 +103,7 @@ public enum Relation
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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())
|
if (isMember())
|
||||||
return false;
|
return false;
|
||||||
else if (isEnemy())
|
else if (isEnemy())
|
||||||
@ -134,8 +114,7 @@ public enum Relation
|
|||||||
return Conf.territoryDenyUseage;
|
return Conf.territoryDenyUseage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRelationCost()
|
public double getRelationCost() {
|
||||||
{
|
|
||||||
if (isEnemy())
|
if (isEnemy())
|
||||||
return Conf.econCostEnemy;
|
return Conf.econCostEnemy;
|
||||||
else if (isAlly())
|
else if (isAlly())
|
||||||
|
@ -2,8 +2,7 @@ package com.massivecraft.factions.struct;
|
|||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
|
|
||||||
public enum Role
|
public enum Role {
|
||||||
{
|
|
||||||
ADMIN(2, "admin"),
|
ADMIN(2, "admin"),
|
||||||
MODERATOR(1, "moderator"),
|
MODERATOR(1, "moderator"),
|
||||||
NORMAL(0, "normal member");
|
NORMAL(0, "normal member");
|
||||||
@ -11,37 +10,30 @@ public enum Role
|
|||||||
public final int value;
|
public final int value;
|
||||||
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) {
|
||||||
{
|
|
||||||
return this.value >= role.value;
|
return this.value >= role.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtMost(Role role)
|
public boolean isAtMost(Role role) {
|
||||||
{
|
|
||||||
return this.value <= role.value;
|
return this.value <= role.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return this.nicename;
|
return this.nicename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix()
|
public String getPrefix() {
|
||||||
{
|
if (this == Role.ADMIN) {
|
||||||
if (this == Role.ADMIN)
|
|
||||||
{
|
|
||||||
return Conf.prefixAdmin;
|
return Conf.prefixAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this == Role.MODERATOR)
|
if (this == Role.MODERATOR) {
|
||||||
{
|
|
||||||
return Conf.prefixMod;
|
return Conf.prefixMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.massivecraft.factions.util;
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class AsciiCompass
|
import java.util.ArrayList;
|
||||||
{
|
|
||||||
public enum Point
|
public class AsciiCompass {
|
||||||
{
|
public enum Point {
|
||||||
N('N'),
|
N('N'),
|
||||||
NE('/'),
|
NE('/'),
|
||||||
E('E'),
|
E('E'),
|
||||||
@ -19,25 +17,21 @@ public class AsciiCompass
|
|||||||
|
|
||||||
public final char asciiChar;
|
public final char asciiChar;
|
||||||
|
|
||||||
private Point(final char asciiChar)
|
private Point(final char asciiChar) {
|
||||||
{
|
|
||||||
this.asciiChar = asciiChar;
|
this.asciiChar = asciiChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return String.valueOf(this.asciiChar);
|
return String.valueOf(this.asciiChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(boolean isActive, ChatColor colorActive, String colorDefault)
|
public String toString(boolean isActive, ChatColor colorActive, String colorDefault) {
|
||||||
{
|
|
||||||
return (isActive ? colorActive : colorDefault) + String.valueOf(this.asciiChar);
|
return (isActive ? colorActive : colorDefault) + String.valueOf(this.asciiChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (degrees < 0)
|
||||||
degrees += 360;
|
degrees += 360;
|
||||||
@ -64,8 +58,7 @@ public class AsciiCompass
|
|||||||
return null;
|
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;
|
||||||
|
|
||||||
@ -90,8 +83,7 @@ public class AsciiCompass
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> getAsciiCompass(double inDegrees, ChatColor colorActive, String colorDefault)
|
public static ArrayList<String> getAsciiCompass(double inDegrees, ChatColor colorActive, String colorDefault) {
|
||||||
{
|
|
||||||
return getAsciiCompass(getCompassPointForDirection(inDegrees), colorActive, colorDefault);
|
return getAsciiCompass(getCompassPointForDirection(inDegrees), colorActive, colorDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,20 @@
|
|||||||
package com.massivecraft.factions.util;
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.*;
|
||||||
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
public class AutoLeaveProcessTask extends BukkitRunnable {
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
|
|
||||||
public class AutoLeaveProcessTask extends BukkitRunnable
|
|
||||||
{
|
|
||||||
private transient boolean readyToGo = false;
|
private transient boolean readyToGo = false;
|
||||||
private transient boolean finished = false;
|
private transient boolean finished = false;
|
||||||
private transient ArrayList<FPlayer> fplayers;
|
private transient ArrayList<FPlayer> fplayers;
|
||||||
private transient ListIterator<FPlayer> iterator;
|
private transient ListIterator<FPlayer> iterator;
|
||||||
private transient double toleranceMillis;
|
private transient double toleranceMillis;
|
||||||
|
|
||||||
public AutoLeaveProcessTask()
|
public AutoLeaveProcessTask() {
|
||||||
{
|
|
||||||
fplayers = new ArrayList<FPlayer>(FPlayers.i.get());
|
fplayers = new ArrayList<FPlayer>(FPlayers.i.get());
|
||||||
this.iterator = fplayers.listIterator();
|
this.iterator = fplayers.listIterator();
|
||||||
this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000;
|
this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000;
|
||||||
@ -29,10 +22,8 @@ public class AutoLeaveProcessTask extends BukkitRunnable
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@ -43,26 +34,22 @@ public class AutoLeaveProcessTask extends BukkitRunnable
|
|||||||
// and this is tracked to keep one iteration from dragging on too long and possibly choking the system if there are a very large number of players to go through
|
// and this is tracked to keep one iteration from dragging on too long and possibly choking the system if there are a very large number of players to go through
|
||||||
long loopStartTime = System.currentTimeMillis();
|
long loopStartTime = System.currentTimeMillis();
|
||||||
|
|
||||||
while(iterator.hasNext())
|
while (iterator.hasNext()) {
|
||||||
{
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
// 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();
|
||||||
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis)
|
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) {
|
||||||
{
|
|
||||||
if (Conf.logFactionLeave || Conf.logFactionKick)
|
if (Conf.logFactionLeave || Conf.logFactionKick)
|
||||||
P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");
|
P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");
|
||||||
|
|
||||||
// if player is faction admin, sort out the faction since he's going away
|
// if player is faction admin, sort out the faction since he's going away
|
||||||
if (fplayer.getRole() == Role.ADMIN)
|
if (fplayer.getRole() == Role.ADMIN) {
|
||||||
{
|
|
||||||
Faction faction = fplayer.getFaction();
|
Faction faction = fplayer.getFaction();
|
||||||
if (faction != null)
|
if (faction != null)
|
||||||
fplayer.getFaction().promoteNewLeader();
|
fplayer.getFaction().promoteNewLeader();
|
||||||
@ -79,16 +66,14 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFinished()
|
public boolean isFinished() {
|
||||||
{
|
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,15 @@ package com.massivecraft.factions.util;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
|
||||||
public class AutoLeaveTask implements Runnable
|
public class AutoLeaveTask implements Runnable {
|
||||||
{
|
|
||||||
private static AutoLeaveProcessTask task;
|
private static AutoLeaveProcessTask task;
|
||||||
double rate;
|
double rate;
|
||||||
|
|
||||||
public AutoLeaveTask()
|
public AutoLeaveTask() {
|
||||||
{
|
|
||||||
this.rate = Conf.autoLeaveRoutineRunsEveryXMinutes;
|
this.rate = Conf.autoLeaveRoutineRunsEveryXMinutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void run()
|
public synchronized void run() {
|
||||||
{
|
|
||||||
if (task != null && !task.isFinished())
|
if (task != null && !task.isFinished())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ import org.bukkit.World;
|
|||||||
* yet when an object of this class is created, only when the Location is first accessed.
|
* yet when an object of this class is created, only when the Location is first accessed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LazyLocation
|
public class LazyLocation {
|
||||||
{
|
|
||||||
private Location location = null;
|
private Location location = null;
|
||||||
private String worldName;
|
private String worldName;
|
||||||
private double x;
|
private double x;
|
||||||
@ -19,18 +18,15 @@ public class LazyLocation
|
|||||||
private float pitch;
|
private float pitch;
|
||||||
private float yaw;
|
private float yaw;
|
||||||
|
|
||||||
public LazyLocation(Location loc)
|
public LazyLocation(Location loc) {
|
||||||
{
|
|
||||||
setLocation(loc);
|
setLocation(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LazyLocation(final String worldName, final double x, final double y, final double z)
|
public LazyLocation(final String worldName, final double x, final double y, final double z) {
|
||||||
{
|
|
||||||
this(worldName, x, y, z, 0, 0);
|
this(worldName, x, y, z, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@ -40,16 +36,14 @@ public class LazyLocation
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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.worldName = loc.getWorld().getName();
|
||||||
this.x = loc.getX();
|
this.x = loc.getX();
|
||||||
@ -61,8 +55,7 @@ public class LazyLocation
|
|||||||
|
|
||||||
|
|
||||||
// This initializes the Location
|
// This initializes the Location
|
||||||
private void initLocation()
|
private void initLocation() {
|
||||||
{
|
|
||||||
// if location is already initialized, simply return
|
// if location is already initialized, simply return
|
||||||
if (location != null) return;
|
if (location != null) return;
|
||||||
|
|
||||||
@ -75,33 +68,27 @@ public class LazyLocation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final String getWorldName()
|
public final String getWorldName() {
|
||||||
{
|
|
||||||
return worldName;
|
return worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getX()
|
public final double getX() {
|
||||||
{
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getY()
|
public final double getY() {
|
||||||
{
|
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getZ()
|
public final double getZ() {
|
||||||
{
|
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getPitch()
|
public final double getPitch() {
|
||||||
{
|
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getYaw()
|
public final double getYaw() {
|
||||||
{
|
|
||||||
return yaw;
|
return yaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,26 @@
|
|||||||
package com.massivecraft.factions.util;
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
|
import org.bukkit.craftbukkit.libs.com.google.gson.*;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonArray;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonDeserializationContext;
|
import java.util.logging.Level;
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonDeserializer;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonElement;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonObject;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonParseException;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonPrimitive;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonSerializationContext;
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.JsonSerializer;
|
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
|
|
||||||
public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLocation, Set<String>>>, JsonSerializer<Map<FLocation, Set<String>>>
|
public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLocation, Set<String>>>, JsonSerializer<Map<FLocation, Set<String>>> {
|
||||||
{
|
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,19 +31,16 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
String[] coords;
|
String[] coords;
|
||||||
int x, z;
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +50,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
|
|
||||||
return locationMap;
|
return locationMap;
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets.");
|
P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets.");
|
||||||
return null;
|
return null;
|
||||||
@ -74,13 +58,11 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(Map<FLocation, Set<String>> src, Type typeOfSrc, JsonSerializationContext context)
|
public JsonElement serialize(Map<FLocation, Set<String>> src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
{
|
|
||||||
JsonObject obj = new JsonObject();
|
JsonObject obj = new JsonObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (src != null)
|
if (src != null) {
|
||||||
{
|
|
||||||
FLocation loc;
|
FLocation loc;
|
||||||
String locWorld;
|
String locWorld;
|
||||||
Set<String> nameSet;
|
Set<String> nameSet;
|
||||||
@ -88,27 +70,23 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
JsonArray nameArray;
|
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();
|
locWorld = loc.getWorldName();
|
||||||
nameSet = entry.getValue();
|
nameSet = entry.getValue();
|
||||||
|
|
||||||
if (nameSet == null || nameSet.isEmpty())
|
if (nameSet == null || nameSet.isEmpty()) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nameArray = new JsonArray();
|
nameArray = new JsonArray();
|
||||||
iter = nameSet.iterator();
|
iter = nameSet.iterator();
|
||||||
while (iter.hasNext())
|
while (iter.hasNext()) {
|
||||||
{
|
|
||||||
nameElement = new JsonPrimitive(iter.next());
|
nameElement = new JsonPrimitive(iter.next());
|
||||||
nameArray.add(nameElement);
|
nameArray.add(nameElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! obj.has(locWorld))
|
if (!obj.has(locWorld)) {
|
||||||
{
|
|
||||||
obj.add(locWorld, new JsonObject());
|
obj.add(locWorld, new JsonObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,9 +95,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets.");
|
P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets.");
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package com.massivecraft.factions.util;
|
package com.massivecraft.factions.util;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
public class MiscUtil {
|
||||||
import org.bukkit.entity.Creature;
|
public static EntityType creatureTypeFromEntity(Entity entity) {
|
||||||
import org.bukkit.entity.EntityType;
|
if (!(entity instanceof Creature)) {
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
public class MiscUtil
|
|
||||||
{
|
|
||||||
public static EntityType creatureTypeFromEntity(Entity entity)
|
|
||||||
{
|
|
||||||
if ( ! (entity instanceof Creature))
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,17 +45,14 @@ public class MiscUtil
|
|||||||
"s", "t", "u", "v", "w", "x", "y", "z"
|
"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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user