Reformat before I go crazy.
This commit is contained in:
parent
0c3ea377dd
commit
814e439705
@ -1,383 +1,320 @@
|
|||||||
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()) {
|
||||||
{
|
LWCFeatures.clearAllChests(entry.getKey());
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
}
|
||||||
{
|
iter.remove();
|
||||||
LWCFeatures.clearAllChests(entry.getKey());
|
}
|
||||||
}
|
}
|
||||||
iter.remove();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
FLocation c = flocation.getRelative(0, 1);
|
||||||
FLocation c = flocation.getRelative(0, 1);
|
FLocation d = flocation.getRelative(0, -1);
|
||||||
FLocation d = flocation.getRelative(0, -1);
|
return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d);
|
||||||
return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Is this coord connected to any coord claimed by the specified faction?
|
// Is this coord connected to any coord claimed by the specified faction?
|
||||||
public static boolean isConnectedLocation(FLocation flocation, Faction faction)
|
public static boolean isConnectedLocation(FLocation flocation, Faction faction) {
|
||||||
{
|
FLocation a = flocation.getRelative(1, 0);
|
||||||
FLocation a = flocation.getRelative(1, 0);
|
FLocation b = flocation.getRelative(-1, 0);
|
||||||
FLocation b = flocation.getRelative(-1, 0);
|
FLocation c = flocation.getRelative(0, 1);
|
||||||
FLocation c = flocation.getRelative(0, 1);
|
FLocation d = flocation.getRelative(0, -1);
|
||||||
FLocation d = flocation.getRelative(0, -1);
|
return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d);
|
||||||
return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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()) {
|
||||||
{
|
LWCFeatures.clearAllChests(entry.getKey());
|
||||||
if(Conf.onUnclaimResetLwcLocks && LWCFeatures.getEnabled())
|
}
|
||||||
{
|
P.p.log("Board cleaner removed " + entry.getValue() + " from " + entry.getKey());
|
||||||
LWCFeatures.clearAllChests(entry.getKey());
|
iter.remove();
|
||||||
}
|
}
|
||||||
P.p.log("Board cleaner removed "+entry.getValue()+" from "+entry.getKey());
|
}
|
||||||
iter.remove();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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)) {
|
||||||
{
|
ret += 1;
|
||||||
if(thatFactionId.equals(factionId))
|
}
|
||||||
{
|
}
|
||||||
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;
|
}
|
||||||
}
|
return ret;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Map generation
|
// Map generation
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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>();
|
||||||
{
|
Faction factionLoc = getFactionAt(flocation);
|
||||||
ArrayList<String> ret = new ArrayList<String>();
|
ret.add(P.p.txt.titleize("(" + flocation.getCoordString() + ") " + factionLoc.getTag(faction)));
|
||||||
Faction factionLoc = getFactionAt(flocation);
|
|
||||||
ret.add(P.p.txt.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(faction)));
|
|
||||||
|
|
||||||
int halfWidth = Conf.mapWidth / 2;
|
int halfWidth = Conf.mapWidth / 2;
|
||||||
int halfHeight = Conf.mapHeight / 2;
|
int halfHeight = Conf.mapHeight / 2;
|
||||||
FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight);
|
FLocation topLeft = flocation.getRelative(-halfWidth, -halfHeight);
|
||||||
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--;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Character> fList = new HashMap<String, Character>();
|
Map<String, Character> fList = new HashMap<String, Character>();
|
||||||
int chrIdx = 0;
|
int chrIdx = 0;
|
||||||
|
|
||||||
// For each row
|
// For each row
|
||||||
for (int dz = 0; dz < height; dz++)
|
for (int dz = 0; dz < height; dz++) {
|
||||||
{
|
// Draw and add that row
|
||||||
// Draw and add that row
|
String row = "";
|
||||||
String row = "";
|
for (int dx = 0; dx < width; dx++) {
|
||||||
for (int dx = 0; dx < width; dx++)
|
if (dx == halfWidth && dz == halfHeight) {
|
||||||
{
|
row += ChatColor.AQUA + "+";
|
||||||
if(dx == halfWidth && dz == halfHeight)
|
} else {
|
||||||
{
|
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
||||||
row += ChatColor.AQUA+"+";
|
Faction factionHere = getFactionAt(flocationHere);
|
||||||
}
|
Relation relation = faction.getRelationTo(factionHere);
|
||||||
else
|
if (factionHere.isNone()) {
|
||||||
{
|
row += ChatColor.GRAY + "-";
|
||||||
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
} else if (factionHere.isSafeZone()) {
|
||||||
Faction factionHere = getFactionAt(flocationHere);
|
row += Conf.colorPeaceful + "+";
|
||||||
Relation relation = faction.getRelationTo(factionHere);
|
} else if (factionHere.isWarZone()) {
|
||||||
if (factionHere.isNone())
|
row += ChatColor.DARK_RED + "+";
|
||||||
{
|
} else if
|
||||||
row += ChatColor.GRAY+"-";
|
(
|
||||||
}
|
factionHere == faction
|
||||||
else if (factionHere.isSafeZone())
|
||
|
||||||
{
|
factionHere == factionLoc
|
||||||
row += Conf.colorPeaceful+"+";
|
||
|
||||||
}
|
relation.isAtLeast(Relation.ALLY)
|
||||||
else if (factionHere.isWarZone())
|
||
|
||||||
{
|
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
||||||
row += ChatColor.DARK_RED+"+";
|
||
|
||||||
}
|
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
|
||||||
else if
|
) {
|
||||||
(
|
if (!fList.containsKey(factionHere.getTag()))
|
||||||
factionHere == faction
|
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
|
||||||
||
|
char tag = fList.get(factionHere.getTag());
|
||||||
factionHere == factionLoc
|
row += factionHere.getColorTo(faction) + "" + tag;
|
||||||
||
|
} else {
|
||||||
relation.isAtLeast(Relation.ALLY)
|
row += ChatColor.GRAY + "-";
|
||||||
||
|
}
|
||||||
(Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL))
|
}
|
||||||
||
|
}
|
||||||
(Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY))
|
ret.add(row);
|
||||||
)
|
}
|
||||||
{
|
|
||||||
if (!fList.containsKey(factionHere.getTag()))
|
|
||||||
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
|
|
||||||
char tag = fList.get(factionHere.getTag());
|
|
||||||
row += factionHere.getColorTo(faction) + "" + tag;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
row += ChatColor.GRAY+"-";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret.add(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the compass
|
// Get the compass
|
||||||
ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, P.p.txt.parse("<a>"));
|
ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, P.p.txt.parse("<a>"));
|
||||||
|
|
||||||
// Add the compass
|
// Add the compass
|
||||||
ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3));
|
ret.set(1, asciiCompass.get(0) + ret.get(1).substring(3 * 3));
|
||||||
ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3));
|
ret.set(2, asciiCompass.get(1) + ret.get(2).substring(3 * 3));
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// 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>());
|
|
||||||
}
|
|
||||||
|
|
||||||
worldCoordIds.get(worldName).put(coords, id);
|
worldCoordIds.get(worldName).put(coords, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
String[] coords;
|
String[] coords;
|
||||||
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]+");
|
||||||
{
|
x = Integer.parseInt(coords[0]);
|
||||||
coords = entry2.getKey().trim().split("[,\\s]+");
|
z = Integer.parseInt(coords[1]);
|
||||||
x = Integer.parseInt(coords[0]);
|
factionId = entry2.getValue();
|
||||||
z = Integer.parseInt(coords[1]);
|
flocationIds.put(new FLocation(worldName, x, z), factionId);
|
||||||
factionId = entry2.getValue();
|
}
|
||||||
flocationIds.put(new FLocation(worldName, x, z), factionId);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
}
|
e.printStackTrace();
|
||||||
catch (Exception e)
|
P.p.log("Failed to save the board to disk.");
|
||||||
{
|
return false;
|
||||||
e.printStackTrace();
|
}
|
||||||
P.p.log("Failed to save the board to disk.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
||||||
{
|
P.p.log("Failed to load the board from disk.");
|
||||||
e.printStackTrace();
|
return false;
|
||||||
P.p.log("Failed to load the board from disk.");
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,385 +1,383 @@
|
|||||||
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 static List<String> baseCommandAliases = new ArrayList<String>();
|
|
||||||
public static boolean allowNoSlashCommand = true;
|
|
||||||
|
|
||||||
// Colors
|
public class Conf {
|
||||||
public static ChatColor colorMember = ChatColor.GREEN;
|
public static List<String> baseCommandAliases = new ArrayList<String>();
|
||||||
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
|
public static boolean allowNoSlashCommand = true;
|
||||||
public static ChatColor colorNeutral = ChatColor.WHITE;
|
|
||||||
public static ChatColor colorEnemy = ChatColor.RED;
|
|
||||||
|
|
||||||
public static ChatColor colorPeaceful = ChatColor.GOLD;
|
// Colors
|
||||||
public static ChatColor colorWar = ChatColor.DARK_RED;
|
public static ChatColor colorMember = ChatColor.GREEN;
|
||||||
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
|
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
|
||||||
|
public static ChatColor colorNeutral = ChatColor.WHITE;
|
||||||
|
public static ChatColor colorEnemy = ChatColor.RED;
|
||||||
|
|
||||||
// Power
|
public static ChatColor colorPeaceful = ChatColor.GOLD;
|
||||||
public static double powerPlayerMax = 10.0;
|
public static ChatColor colorWar = ChatColor.DARK_RED;
|
||||||
public static double powerPlayerMin = -10.0;
|
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
|
||||||
public static double powerPlayerStarting = 0.0;
|
|
||||||
public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
|
|
||||||
public static double powerPerDeath = 4.0; // A death makes you lose 4 power
|
|
||||||
public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline?
|
|
||||||
public static double powerOfflineLossPerDay = 0.0; // players will lose this much power per day offline
|
|
||||||
public static double powerOfflineLossLimit = 0.0; // players will no longer lose power from being offline once their power drops to this amount or less
|
|
||||||
public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
|
||||||
|
|
||||||
public static String prefixAdmin = "**";
|
// Power
|
||||||
public static String prefixMod = "*";
|
public static double powerPlayerMax = 10.0;
|
||||||
|
public static double powerPlayerMin = -10.0;
|
||||||
|
public static double powerPlayerStarting = 0.0;
|
||||||
|
public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
|
||||||
|
public static double powerPerDeath = 4.0; // A death makes you lose 4 power
|
||||||
|
public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline?
|
||||||
|
public static double powerOfflineLossPerDay = 0.0; // players will lose this much power per day offline
|
||||||
|
public static double powerOfflineLossLimit = 0.0; // players will no longer lose power from being offline once their power drops to this amount or less
|
||||||
|
public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
||||||
|
|
||||||
public static int factionTagLengthMin = 3;
|
public static String prefixAdmin = "**";
|
||||||
public static int factionTagLengthMax = 10;
|
public static String prefixMod = "*";
|
||||||
public static boolean factionTagForceUpperCase = false;
|
|
||||||
|
|
||||||
public static boolean newFactionsDefaultOpen = false;
|
public static int factionTagLengthMin = 3;
|
||||||
|
public static int factionTagLengthMax = 10;
|
||||||
|
public static boolean factionTagForceUpperCase = false;
|
||||||
|
|
||||||
// when faction membership hits this limit, players will no longer be able to join using /f join; default is 0, no limit
|
public static boolean newFactionsDefaultOpen = false;
|
||||||
public static int factionMemberLimit = 0;
|
|
||||||
|
|
||||||
// what faction ID to start new players in when they first join the server; default is 0, "no faction"
|
// when faction membership hits this limit, players will no longer be able to join using /f join; default is 0, no limit
|
||||||
public static String newPlayerStartingFactionID = "0";
|
public static int factionMemberLimit = 0;
|
||||||
|
|
||||||
public static boolean showMapFactionKey = true;
|
// what faction ID to start new players in when they first join the server; default is 0, "no faction"
|
||||||
public static boolean showNeutralFactionsOnMap = true;
|
public static String newPlayerStartingFactionID = "0";
|
||||||
public static boolean showEnemyFactionsOnMap = true;
|
|
||||||
|
|
||||||
// Disallow joining/leaving/kicking while power is negative
|
public static boolean showMapFactionKey = true;
|
||||||
public static boolean canLeaveWithNegativePower = true;
|
public static boolean showNeutralFactionsOnMap = true;
|
||||||
|
public static boolean showEnemyFactionsOnMap = true;
|
||||||
|
|
||||||
// Configuration for faction-only chat
|
// Disallow joining/leaving/kicking while power is negative
|
||||||
public static boolean factionOnlyChat = true;
|
public static boolean canLeaveWithNegativePower = true;
|
||||||
// Configuration on the Faction tag in chat messages.
|
|
||||||
public static boolean chatTagEnabled = true;
|
|
||||||
public static transient boolean chatTagHandledByAnotherPlugin = false;
|
|
||||||
public static boolean chatTagRelationColored = true;
|
|
||||||
public static String chatTagReplaceString = "[FACTION]";
|
|
||||||
public static String chatTagInsertAfterString = "";
|
|
||||||
public static String chatTagInsertBeforeString = "";
|
|
||||||
public static int chatTagInsertIndex = 1;
|
|
||||||
public static boolean chatTagPadBefore = false;
|
|
||||||
public static boolean chatTagPadAfter = true;
|
|
||||||
public static String chatTagFormat = "%s"+ChatColor.WHITE;
|
|
||||||
public static String factionChatFormat = "%s:"+ChatColor.WHITE+" %s";
|
|
||||||
public static String allianceChatFormat = ChatColor.LIGHT_PURPLE+"%s:"+ChatColor.WHITE+" %s";
|
|
||||||
|
|
||||||
public static boolean broadcastDescriptionChanges = false;
|
// Configuration for faction-only chat
|
||||||
|
public static boolean factionOnlyChat = true;
|
||||||
|
// Configuration on the Faction tag in chat messages.
|
||||||
|
public static boolean chatTagEnabled = true;
|
||||||
|
public static transient boolean chatTagHandledByAnotherPlugin = false;
|
||||||
|
public static boolean chatTagRelationColored = true;
|
||||||
|
public static String chatTagReplaceString = "[FACTION]";
|
||||||
|
public static String chatTagInsertAfterString = "";
|
||||||
|
public static String chatTagInsertBeforeString = "";
|
||||||
|
public static int chatTagInsertIndex = 1;
|
||||||
|
public static boolean chatTagPadBefore = false;
|
||||||
|
public static boolean chatTagPadAfter = true;
|
||||||
|
public static String chatTagFormat = "%s" + ChatColor.WHITE;
|
||||||
|
public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s";
|
||||||
|
public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s";
|
||||||
|
|
||||||
public static double saveToFileEveryXMinutes = 30.0;
|
public static boolean broadcastDescriptionChanges = false;
|
||||||
|
|
||||||
public static double autoLeaveAfterDaysOfInactivity = 10.0;
|
public static double saveToFileEveryXMinutes = 30.0;
|
||||||
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
|
|
||||||
public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick
|
|
||||||
public static boolean removePlayerDataWhenBanned = true;
|
|
||||||
|
|
||||||
public static boolean worldGuardChecking = false;
|
public static double autoLeaveAfterDaysOfInactivity = 10.0;
|
||||||
public static boolean worldGuardBuildPriority = false;
|
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
|
||||||
|
public static int autoLeaveRoutineMaxMillisecondsPerTick = 5; // 1 server tick is roughly 50ms, so default max 10% of a tick
|
||||||
|
public static boolean removePlayerDataWhenBanned = true;
|
||||||
|
|
||||||
//LWC
|
public static boolean worldGuardChecking = false;
|
||||||
public static boolean lwcIntegration = false;
|
public static boolean worldGuardBuildPriority = false;
|
||||||
public static boolean onUnclaimResetLwcLocks = false;
|
|
||||||
public static boolean onCaptureResetLwcLocks = false;
|
|
||||||
|
|
||||||
// server logging options
|
//LWC
|
||||||
public static boolean logFactionCreate = true;
|
public static boolean lwcIntegration = false;
|
||||||
public static boolean logFactionDisband = true;
|
public static boolean onUnclaimResetLwcLocks = false;
|
||||||
public static boolean logFactionJoin = true;
|
public static boolean onCaptureResetLwcLocks = false;
|
||||||
public static boolean logFactionKick = true;
|
|
||||||
public static boolean logFactionLeave = true;
|
|
||||||
public static boolean logLandClaims = true;
|
|
||||||
public static boolean logLandUnclaims = true;
|
|
||||||
public static boolean logMoneyTransactions = true;
|
|
||||||
public static boolean logPlayerCommands = true;
|
|
||||||
|
|
||||||
// prevent some potential exploits
|
// server logging options
|
||||||
public static boolean handleExploitObsidianGenerators = true;
|
public static boolean logFactionCreate = true;
|
||||||
public static boolean handleExploitEnderPearlClipping = true;
|
public static boolean logFactionDisband = true;
|
||||||
public static boolean handleExploitInteractionSpam = true;
|
public static boolean logFactionJoin = true;
|
||||||
public static boolean handleExploitTNTWaterlog = false;
|
public static boolean logFactionKick = true;
|
||||||
|
public static boolean logFactionLeave = true;
|
||||||
|
public static boolean logLandClaims = true;
|
||||||
|
public static boolean logLandUnclaims = true;
|
||||||
|
public static boolean logMoneyTransactions = true;
|
||||||
|
public static boolean logPlayerCommands = true;
|
||||||
|
|
||||||
public static boolean homesEnabled = true;
|
// prevent some potential exploits
|
||||||
public static boolean homesMustBeInClaimedTerritory = true;
|
public static boolean handleExploitObsidianGenerators = true;
|
||||||
public static boolean homesTeleportToOnDeath = true;
|
public static boolean handleExploitEnderPearlClipping = true;
|
||||||
public static boolean homesRespawnFromNoPowerLossWorlds = true;
|
public static boolean handleExploitInteractionSpam = true;
|
||||||
public static boolean homesTeleportCommandEnabled = true;
|
public static boolean handleExploitTNTWaterlog = false;
|
||||||
public static boolean homesTeleportCommandEssentialsIntegration = true;
|
|
||||||
public static boolean homesTeleportCommandSmokeEffectEnabled = true;
|
|
||||||
public static float homesTeleportCommandSmokeEffectThickness = 3f;
|
|
||||||
public static boolean homesTeleportAllowedFromEnemyTerritory = true;
|
|
||||||
public static boolean homesTeleportAllowedFromDifferentWorld = true;
|
|
||||||
public static double homesTeleportAllowedEnemyDistance = 32.0;
|
|
||||||
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
|
|
||||||
|
|
||||||
public static boolean disablePVPBetweenNeutralFactions = false;
|
public static boolean homesEnabled = true;
|
||||||
public static boolean disablePVPForFactionlessPlayers = false;
|
public static boolean homesMustBeInClaimedTerritory = true;
|
||||||
public static boolean enablePVPAgainstFactionlessInAttackersLand = false;
|
public static boolean homesTeleportToOnDeath = true;
|
||||||
|
public static boolean homesRespawnFromNoPowerLossWorlds = true;
|
||||||
|
public static boolean homesTeleportCommandEnabled = true;
|
||||||
|
public static boolean homesTeleportCommandEssentialsIntegration = true;
|
||||||
|
public static boolean homesTeleportCommandSmokeEffectEnabled = true;
|
||||||
|
public static float homesTeleportCommandSmokeEffectThickness = 3f;
|
||||||
|
public static boolean homesTeleportAllowedFromEnemyTerritory = true;
|
||||||
|
public static boolean homesTeleportAllowedFromDifferentWorld = true;
|
||||||
|
public static double homesTeleportAllowedEnemyDistance = 32.0;
|
||||||
|
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
|
||||||
|
|
||||||
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
|
public static boolean disablePVPBetweenNeutralFactions = false;
|
||||||
|
public static boolean disablePVPForFactionlessPlayers = false;
|
||||||
|
public static boolean enablePVPAgainstFactionlessInAttackersLand = false;
|
||||||
|
|
||||||
public static boolean peacefulTerritoryDisablePVP = true;
|
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
|
||||||
public static boolean peacefulTerritoryDisableMonsters = false;
|
|
||||||
public static boolean peacefulMembersDisablePowerLoss = true;
|
|
||||||
|
|
||||||
public static boolean permanentFactionsDisableLeaderPromotion = false;
|
public static boolean peacefulTerritoryDisablePVP = true;
|
||||||
|
public static boolean peacefulTerritoryDisableMonsters = false;
|
||||||
|
public static boolean peacefulMembersDisablePowerLoss = true;
|
||||||
|
|
||||||
public static boolean claimsMustBeConnected = false;
|
public static boolean permanentFactionsDisableLeaderPromotion = false;
|
||||||
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
|
|
||||||
public static int claimsRequireMinFactionMembers = 1;
|
|
||||||
public static int claimedLandsMax = 0;
|
|
||||||
|
|
||||||
// if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit
|
public static boolean claimsMustBeConnected = false;
|
||||||
public static int radiusClaimFailureLimit = 9;
|
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
|
||||||
|
public static int claimsRequireMinFactionMembers = 1;
|
||||||
|
public static int claimedLandsMax = 0;
|
||||||
|
|
||||||
public static double considerFactionsReallyOfflineAfterXMinutes = 0.0;
|
// if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit
|
||||||
|
public static int radiusClaimFailureLimit = 9;
|
||||||
|
|
||||||
public static int actionDeniedPainAmount = 1;
|
public static double considerFactionsReallyOfflineAfterXMinutes = 0.0;
|
||||||
|
|
||||||
// commands which will be prevented if the player is a member of a permanent faction
|
public static int actionDeniedPainAmount = 1;
|
||||||
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<String>();
|
|
||||||
|
|
||||||
// commands which will be prevented when in claimed territory of another faction
|
// commands which will be prevented if the player is a member of a permanent faction
|
||||||
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<String>();
|
public static Set<String> permanentFactionMemberDenyCommands = new LinkedHashSet<String>();
|
||||||
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<String>();
|
|
||||||
|
|
||||||
public static double territoryShieldFactor = 0.3;
|
// commands which will be prevented when in claimed territory of another faction
|
||||||
public static boolean territoryDenyBuild = true;
|
public static Set<String> territoryNeutralDenyCommands = new LinkedHashSet<String>();
|
||||||
public static boolean territoryDenyBuildWhenOffline = true;
|
public static Set<String> territoryEnemyDenyCommands = new LinkedHashSet<String>();
|
||||||
public static boolean territoryPainBuild = false;
|
|
||||||
public static boolean territoryPainBuildWhenOffline = false;
|
|
||||||
public static boolean territoryDenyUseage = true;
|
|
||||||
public static boolean territoryEnemyDenyBuild = true;
|
|
||||||
public static boolean territoryEnemyDenyBuildWhenOffline = true;
|
|
||||||
public static boolean territoryEnemyPainBuild = false;
|
|
||||||
public static boolean territoryEnemyPainBuildWhenOffline = false;
|
|
||||||
public static boolean territoryEnemyDenyUseage = true;
|
|
||||||
public static boolean territoryEnemyProtectMaterials = true;
|
|
||||||
public static boolean territoryAllyDenyBuild = true;
|
|
||||||
public static boolean territoryAllyDenyBuildWhenOffline = true;
|
|
||||||
public static boolean territoryAllyPainBuild = false;
|
|
||||||
public static boolean territoryAllyPainBuildWhenOffline = false;
|
|
||||||
public static boolean territoryAllyDenyUseage = true;
|
|
||||||
public static boolean territoryAllyProtectMaterials = true;
|
|
||||||
public static boolean territoryBlockCreepers = false;
|
|
||||||
public static boolean territoryBlockCreepersWhenOffline = false;
|
|
||||||
public static boolean territoryBlockFireballs = false;
|
|
||||||
public static boolean territoryBlockFireballsWhenOffline = false;
|
|
||||||
public static boolean territoryBlockTNT = false;
|
|
||||||
public static boolean territoryBlockTNTWhenOffline = false;
|
|
||||||
public static boolean territoryDenyEndermanBlocks = true;
|
|
||||||
public static boolean territoryDenyEndermanBlocksWhenOffline = true;
|
|
||||||
|
|
||||||
public static boolean safeZoneDenyBuild = true;
|
public static double territoryShieldFactor = 0.3;
|
||||||
public static boolean safeZoneDenyUseage = true;
|
public static boolean territoryDenyBuild = true;
|
||||||
public static boolean safeZoneBlockTNT = true;
|
public static boolean territoryDenyBuildWhenOffline = true;
|
||||||
public static boolean safeZonePreventAllDamageToPlayers = false;
|
public static boolean territoryPainBuild = false;
|
||||||
public static boolean safeZoneDenyEndermanBlocks = true;
|
public static boolean territoryPainBuildWhenOffline = false;
|
||||||
|
public static boolean territoryDenyUseage = true;
|
||||||
|
public static boolean territoryEnemyDenyBuild = true;
|
||||||
|
public static boolean territoryEnemyDenyBuildWhenOffline = true;
|
||||||
|
public static boolean territoryEnemyPainBuild = false;
|
||||||
|
public static boolean territoryEnemyPainBuildWhenOffline = false;
|
||||||
|
public static boolean territoryEnemyDenyUseage = true;
|
||||||
|
public static boolean territoryEnemyProtectMaterials = true;
|
||||||
|
public static boolean territoryAllyDenyBuild = true;
|
||||||
|
public static boolean territoryAllyDenyBuildWhenOffline = true;
|
||||||
|
public static boolean territoryAllyPainBuild = false;
|
||||||
|
public static boolean territoryAllyPainBuildWhenOffline = false;
|
||||||
|
public static boolean territoryAllyDenyUseage = true;
|
||||||
|
public static boolean territoryAllyProtectMaterials = true;
|
||||||
|
public static boolean territoryBlockCreepers = false;
|
||||||
|
public static boolean territoryBlockCreepersWhenOffline = false;
|
||||||
|
public static boolean territoryBlockFireballs = false;
|
||||||
|
public static boolean territoryBlockFireballsWhenOffline = false;
|
||||||
|
public static boolean territoryBlockTNT = false;
|
||||||
|
public static boolean territoryBlockTNTWhenOffline = false;
|
||||||
|
public static boolean territoryDenyEndermanBlocks = true;
|
||||||
|
public static boolean territoryDenyEndermanBlocksWhenOffline = true;
|
||||||
|
|
||||||
public static boolean warZoneDenyBuild = true;
|
public static boolean safeZoneDenyBuild = true;
|
||||||
public static boolean warZoneDenyUseage = true;
|
public static boolean safeZoneDenyUseage = true;
|
||||||
public static boolean warZoneBlockCreepers = false;
|
public static boolean safeZoneBlockTNT = true;
|
||||||
public static boolean warZoneBlockFireballs = false;
|
public static boolean safeZonePreventAllDamageToPlayers = false;
|
||||||
public static boolean warZoneBlockTNT = true;
|
public static boolean safeZoneDenyEndermanBlocks = true;
|
||||||
public static boolean warZonePowerLoss = true;
|
|
||||||
public static boolean warZoneFriendlyFire = false;
|
|
||||||
public static boolean warZoneDenyEndermanBlocks = true;
|
|
||||||
|
|
||||||
public static boolean wildernessDenyBuild = false;
|
public static boolean warZoneDenyBuild = true;
|
||||||
public static boolean wildernessDenyUseage = false;
|
public static boolean warZoneDenyUseage = true;
|
||||||
public static boolean wildernessBlockCreepers = false;
|
public static boolean warZoneBlockCreepers = false;
|
||||||
public static boolean wildernessBlockFireballs = false;
|
public static boolean warZoneBlockFireballs = false;
|
||||||
public static boolean wildernessBlockTNT = false;
|
public static boolean warZoneBlockTNT = true;
|
||||||
public static boolean wildernessPowerLoss = true;
|
public static boolean warZonePowerLoss = true;
|
||||||
public static boolean wildernessDenyEndermanBlocks = false;
|
public static boolean warZoneFriendlyFire = false;
|
||||||
|
public static boolean warZoneDenyEndermanBlocks = true;
|
||||||
|
|
||||||
// for claimed areas where further faction-member ownership can be defined
|
public static boolean wildernessDenyBuild = false;
|
||||||
public static boolean ownedAreasEnabled = true;
|
public static boolean wildernessDenyUseage = false;
|
||||||
public static int ownedAreasLimitPerFaction = 0;
|
public static boolean wildernessBlockCreepers = false;
|
||||||
public static boolean ownedAreasModeratorsCanSet = false;
|
public static boolean wildernessBlockFireballs = false;
|
||||||
public static boolean ownedAreaModeratorsBypass = true;
|
public static boolean wildernessBlockTNT = false;
|
||||||
public static boolean ownedAreaDenyBuild = true;
|
public static boolean wildernessPowerLoss = true;
|
||||||
public static boolean ownedAreaPainBuild = false;
|
public static boolean wildernessDenyEndermanBlocks = false;
|
||||||
public static boolean ownedAreaProtectMaterials = true;
|
|
||||||
public static boolean ownedAreaDenyUseage = true;
|
|
||||||
|
|
||||||
public static String ownedLandMessage = "Owner(s): ";
|
// for claimed areas where further faction-member ownership can be defined
|
||||||
public static String publicLandMessage = "Public faction land.";
|
public static boolean ownedAreasEnabled = true;
|
||||||
public static boolean ownedMessageOnBorder = true;
|
public static int ownedAreasLimitPerFaction = 0;
|
||||||
public static boolean ownedMessageInsideTerritory = true;
|
public static boolean ownedAreasModeratorsCanSet = false;
|
||||||
public static boolean ownedMessageByChunk = false;
|
public static boolean ownedAreaModeratorsBypass = true;
|
||||||
|
public static boolean ownedAreaDenyBuild = true;
|
||||||
|
public static boolean ownedAreaPainBuild = false;
|
||||||
|
public static boolean ownedAreaProtectMaterials = true;
|
||||||
|
public static boolean ownedAreaDenyUseage = true;
|
||||||
|
|
||||||
public static boolean pistonProtectionThroughDenyBuild = true;
|
public static String ownedLandMessage = "Owner(s): ";
|
||||||
|
public static String publicLandMessage = "Public faction land.";
|
||||||
|
public static boolean ownedMessageOnBorder = true;
|
||||||
|
public static boolean ownedMessageInsideTerritory = true;
|
||||||
|
public static boolean ownedMessageByChunk = false;
|
||||||
|
|
||||||
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
|
public static boolean pistonProtectionThroughDenyBuild = true;
|
||||||
public static Set<Material> territoryDenyUseageMaterials = EnumSet.noneOf(Material.class);
|
|
||||||
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
|
||||||
public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
|
||||||
|
|
||||||
public static transient Set<EntityType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(EntityType.class);
|
public static Set<Material> territoryProtectedMaterials = EnumSet.noneOf(Material.class);
|
||||||
|
public static Set<Material> territoryDenyUseageMaterials = EnumSet.noneOf(Material.class);
|
||||||
|
public static Set<Material> territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||||
|
public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||||
|
|
||||||
// Spout features
|
public static transient Set<EntityType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(EntityType.class);
|
||||||
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
|
|
||||||
public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that
|
|
||||||
public static boolean spoutFactionAdminCapes = true; // Show capes on faction admins, colored based on the viewer's relation to the target player
|
|
||||||
public static boolean spoutFactionModeratorCapes = true; // same, but for faction moderators
|
|
||||||
public static int spoutTerritoryDisplayPosition = 1; // permanent territory display, instead of by chat; 0 = disabled, 1 = top left, 2 = top center, 3+ = top right
|
|
||||||
public static float spoutTerritoryDisplaySize = 1.0f; // text scale (size) for territory display
|
|
||||||
public static boolean spoutTerritoryDisplayShowDescription = true; // whether to show the faction description, not just the faction tag
|
|
||||||
public static boolean spoutTerritoryOwnersShow = true; // show territory owner list as well
|
|
||||||
public static boolean spoutTerritoryNoticeShow = true; // show additional brief territory notice near center of screen, to be sure player notices transition
|
|
||||||
public static int spoutTerritoryNoticeTop = 40; // how far down the screen to place the additional notice
|
|
||||||
public static boolean spoutTerritoryNoticeShowDescription = false; // whether to show the faction description in the notice, not just the faction tag
|
|
||||||
public static float spoutTerritoryNoticeSize = 1.5f; // text scale (size) for notice
|
|
||||||
public static float spoutTerritoryNoticeLeaveAfterSeconds = 2.00f; // how many seconds before the notice goes away
|
|
||||||
public static String capeAlly = "https://github.com/MassiveCraft/Factions/raw/master/capes/ally.png";
|
|
||||||
public static String capeEnemy = "https://github.com/MassiveCraft/Factions/raw/master/capes/enemy.png";
|
|
||||||
public static String capeMember = "https://github.com/MassiveCraft/Factions/raw/master/capes/member.png";
|
|
||||||
public static String capeNeutral = "https://github.com/MassiveCraft/Factions/raw/master/capes/neutral.png";
|
|
||||||
public static String capePeaceful = "https://github.com/MassiveCraft/Factions/raw/master/capes/peaceful.png";
|
|
||||||
|
|
||||||
// Economy settings
|
// Spout features
|
||||||
public static boolean econEnabled = false;
|
public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads
|
||||||
public static String econUniverseAccount = "";
|
public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that
|
||||||
public static double econCostClaimWilderness = 30.0;
|
public static boolean spoutFactionAdminCapes = true; // Show capes on faction admins, colored based on the viewer's relation to the target player
|
||||||
public static double econCostClaimFromFactionBonus = 30.0;
|
public static boolean spoutFactionModeratorCapes = true; // same, but for faction moderators
|
||||||
public static double econClaimAdditionalMultiplier = 0.5;
|
public static int spoutTerritoryDisplayPosition = 1; // permanent territory display, instead of by chat; 0 = disabled, 1 = top left, 2 = top center, 3+ = top right
|
||||||
public static double econClaimRefundMultiplier = 0.7;
|
public static float spoutTerritoryDisplaySize = 1.0f; // text scale (size) for territory display
|
||||||
public static double econClaimUnconnectedFee = 0.0;
|
public static boolean spoutTerritoryDisplayShowDescription = true; // whether to show the faction description, not just the faction tag
|
||||||
public static double econCostCreate = 100.0;
|
public static boolean spoutTerritoryOwnersShow = true; // show territory owner list as well
|
||||||
public static double econCostOwner = 15.0;
|
public static boolean spoutTerritoryNoticeShow = true; // show additional brief territory notice near center of screen, to be sure player notices transition
|
||||||
public static double econCostSethome = 30.0;
|
public static int spoutTerritoryNoticeTop = 40; // how far down the screen to place the additional notice
|
||||||
public static double econCostJoin = 0.0;
|
public static boolean spoutTerritoryNoticeShowDescription = false; // whether to show the faction description in the notice, not just the faction tag
|
||||||
public static double econCostLeave = 0.0;
|
public static float spoutTerritoryNoticeSize = 1.5f; // text scale (size) for notice
|
||||||
public static double econCostKick = 0.0;
|
public static float spoutTerritoryNoticeLeaveAfterSeconds = 2.00f; // how many seconds before the notice goes away
|
||||||
public static double econCostInvite = 0.0;
|
public static String capeAlly = "https://github.com/MassiveCraft/Factions/raw/master/capes/ally.png";
|
||||||
public static double econCostHome = 0.0;
|
public static String capeEnemy = "https://github.com/MassiveCraft/Factions/raw/master/capes/enemy.png";
|
||||||
public static double econCostTag = 0.0;
|
public static String capeMember = "https://github.com/MassiveCraft/Factions/raw/master/capes/member.png";
|
||||||
public static double econCostDesc = 0.0;
|
public static String capeNeutral = "https://github.com/MassiveCraft/Factions/raw/master/capes/neutral.png";
|
||||||
public static double econCostTitle = 0.0;
|
public static String capePeaceful = "https://github.com/MassiveCraft/Factions/raw/master/capes/peaceful.png";
|
||||||
public static double econCostList = 0.0;
|
|
||||||
public static double econCostMap = 0.0;
|
|
||||||
public static double econCostPower = 0.0;
|
|
||||||
public static double econCostShow = 0.0;
|
|
||||||
public static double econCostOpen = 0.0;
|
|
||||||
public static double econCostAlly = 0.0;
|
|
||||||
public static double econCostEnemy = 0.0;
|
|
||||||
public static double econCostNeutral = 0.0;
|
|
||||||
public static double econCostNoBoom = 0.0;
|
|
||||||
|
|
||||||
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
|
// Economy settings
|
||||||
public static boolean bankEnabled = true;
|
public static boolean econEnabled = false;
|
||||||
public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
public static String econUniverseAccount = "";
|
||||||
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
|
public static double econCostClaimWilderness = 30.0;
|
||||||
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
public static double econCostClaimFromFactionBonus = 30.0;
|
||||||
|
public static double econClaimAdditionalMultiplier = 0.5;
|
||||||
|
public static double econClaimRefundMultiplier = 0.7;
|
||||||
|
public static double econClaimUnconnectedFee = 0.0;
|
||||||
|
public static double econCostCreate = 100.0;
|
||||||
|
public static double econCostOwner = 15.0;
|
||||||
|
public static double econCostSethome = 30.0;
|
||||||
|
public static double econCostJoin = 0.0;
|
||||||
|
public static double econCostLeave = 0.0;
|
||||||
|
public static double econCostKick = 0.0;
|
||||||
|
public static double econCostInvite = 0.0;
|
||||||
|
public static double econCostHome = 0.0;
|
||||||
|
public static double econCostTag = 0.0;
|
||||||
|
public static double econCostDesc = 0.0;
|
||||||
|
public static double econCostTitle = 0.0;
|
||||||
|
public static double econCostList = 0.0;
|
||||||
|
public static double econCostMap = 0.0;
|
||||||
|
public static double econCostPower = 0.0;
|
||||||
|
public static double econCostShow = 0.0;
|
||||||
|
public static double econCostOpen = 0.0;
|
||||||
|
public static double econCostAlly = 0.0;
|
||||||
|
public static double econCostEnemy = 0.0;
|
||||||
|
public static double econCostNeutral = 0.0;
|
||||||
|
public static double econCostNoBoom = 0.0;
|
||||||
|
|
||||||
// mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
|
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
|
||||||
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
|
public static boolean bankEnabled = true;
|
||||||
|
public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
|
||||||
|
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
|
||||||
|
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
|
||||||
|
|
||||||
public static Set<String> worldsNoClaiming = new LinkedHashSet<String>();
|
// mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
|
||||||
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
|
public static Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
|
||||||
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
|
|
||||||
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
|
|
||||||
|
|
||||||
public static transient int mapHeight = 8;
|
public static Set<String> worldsNoClaiming = new LinkedHashSet<String>();
|
||||||
public static transient int mapWidth = 39;
|
public static Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
|
||||||
public static transient char[] mapKeyChrs = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
|
public static Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
|
||||||
|
public static Set<String> worldsNoWildernessProtection = new LinkedHashSet<String>();
|
||||||
|
|
||||||
static
|
public static transient int mapHeight = 8;
|
||||||
{
|
public static transient int mapWidth = 39;
|
||||||
baseCommandAliases.add("f");
|
public static transient char[] mapKeyChrs = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
|
||||||
|
|
||||||
territoryEnemyDenyCommands.add("home");
|
static {
|
||||||
territoryEnemyDenyCommands.add("sethome");
|
baseCommandAliases.add("f");
|
||||||
territoryEnemyDenyCommands.add("spawn");
|
|
||||||
territoryEnemyDenyCommands.add("tpahere");
|
|
||||||
territoryEnemyDenyCommands.add("tpaccept");
|
|
||||||
territoryEnemyDenyCommands.add("tpa");
|
|
||||||
|
|
||||||
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
|
territoryEnemyDenyCommands.add("home");
|
||||||
territoryProtectedMaterials.add(Material.TRAP_DOOR);
|
territoryEnemyDenyCommands.add("sethome");
|
||||||
territoryProtectedMaterials.add(Material.FENCE_GATE);
|
territoryEnemyDenyCommands.add("spawn");
|
||||||
territoryProtectedMaterials.add(Material.DISPENSER);
|
territoryEnemyDenyCommands.add("tpahere");
|
||||||
territoryProtectedMaterials.add(Material.CHEST);
|
territoryEnemyDenyCommands.add("tpaccept");
|
||||||
territoryProtectedMaterials.add(Material.FURNACE);
|
territoryEnemyDenyCommands.add("tpa");
|
||||||
territoryProtectedMaterials.add(Material.BURNING_FURNACE);
|
|
||||||
territoryProtectedMaterials.add(Material.DIODE_BLOCK_OFF);
|
|
||||||
territoryProtectedMaterials.add(Material.DIODE_BLOCK_ON);
|
|
||||||
territoryProtectedMaterials.add(Material.JUKEBOX);
|
|
||||||
territoryProtectedMaterials.add(Material.BREWING_STAND);
|
|
||||||
territoryProtectedMaterials.add(Material.ENCHANTMENT_TABLE);
|
|
||||||
territoryProtectedMaterials.add(Material.CAULDRON);
|
|
||||||
territoryProtectedMaterials.add(Material.SOIL);
|
|
||||||
territoryProtectedMaterials.add(Material.BEACON);
|
|
||||||
territoryProtectedMaterials.add(Material.ANVIL);
|
|
||||||
territoryProtectedMaterials.add(Material.TRAPPED_CHEST);
|
|
||||||
territoryProtectedMaterials.add(Material.DROPPER);
|
|
||||||
territoryProtectedMaterials.add(Material.HOPPER);
|
|
||||||
|
|
||||||
territoryDenyUseageMaterials.add(Material.FIREBALL);
|
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
|
||||||
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
|
territoryProtectedMaterials.add(Material.TRAP_DOOR);
|
||||||
territoryDenyUseageMaterials.add(Material.BUCKET);
|
territoryProtectedMaterials.add(Material.FENCE_GATE);
|
||||||
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
|
territoryProtectedMaterials.add(Material.DISPENSER);
|
||||||
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
|
territoryProtectedMaterials.add(Material.CHEST);
|
||||||
|
territoryProtectedMaterials.add(Material.FURNACE);
|
||||||
|
territoryProtectedMaterials.add(Material.BURNING_FURNACE);
|
||||||
|
territoryProtectedMaterials.add(Material.DIODE_BLOCK_OFF);
|
||||||
|
territoryProtectedMaterials.add(Material.DIODE_BLOCK_ON);
|
||||||
|
territoryProtectedMaterials.add(Material.JUKEBOX);
|
||||||
|
territoryProtectedMaterials.add(Material.BREWING_STAND);
|
||||||
|
territoryProtectedMaterials.add(Material.ENCHANTMENT_TABLE);
|
||||||
|
territoryProtectedMaterials.add(Material.CAULDRON);
|
||||||
|
territoryProtectedMaterials.add(Material.SOIL);
|
||||||
|
territoryProtectedMaterials.add(Material.BEACON);
|
||||||
|
territoryProtectedMaterials.add(Material.ANVIL);
|
||||||
|
territoryProtectedMaterials.add(Material.TRAPPED_CHEST);
|
||||||
|
territoryProtectedMaterials.add(Material.DROPPER);
|
||||||
|
territoryProtectedMaterials.add(Material.HOPPER);
|
||||||
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR);
|
territoryDenyUseageMaterials.add(Material.FIREBALL);
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.TRAP_DOOR);
|
territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL);
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.FENCE_GATE);
|
territoryDenyUseageMaterials.add(Material.BUCKET);
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER);
|
territoryDenyUseageMaterials.add(Material.WATER_BUCKET);
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.CHEST);
|
territoryDenyUseageMaterials.add(Material.LAVA_BUCKET);
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.FURNACE);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.BURNING_FURNACE);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.DIODE_BLOCK_OFF);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.DIODE_BLOCK_ON);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.JUKEBOX);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.BREWING_STAND);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.ENCHANTMENT_TABLE);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.SOIL);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.ANVIL);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.TRAPPED_CHEST);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.DROPPER);
|
|
||||||
territoryProtectedMaterialsWhenOffline.add(Material.HOPPER);
|
|
||||||
|
|
||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.FIREBALL);
|
territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR);
|
||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);
|
territoryProtectedMaterialsWhenOffline.add(Material.TRAP_DOOR);
|
||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
|
territoryProtectedMaterialsWhenOffline.add(Material.FENCE_GATE);
|
||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
|
territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER);
|
||||||
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
|
territoryProtectedMaterialsWhenOffline.add(Material.CHEST);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.FURNACE);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.BURNING_FURNACE);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.DIODE_BLOCK_OFF);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.DIODE_BLOCK_ON);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.JUKEBOX);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.BREWING_STAND);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.ENCHANTMENT_TABLE);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.SOIL);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.BEACON);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.ANVIL);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.TRAPPED_CHEST);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.DROPPER);
|
||||||
|
territoryProtectedMaterialsWhenOffline.add(Material.HOPPER);
|
||||||
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.FIREBALL);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
|
territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET);
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.WITCH);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
|
|
||||||
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
safeZoneNerfedCreatureTypes.add(EntityType.BLAZE);
|
||||||
// Persistance
|
safeZoneNerfedCreatureTypes.add(EntityType.CAVE_SPIDER);
|
||||||
// -------------------------------------------- //
|
safeZoneNerfedCreatureTypes.add(EntityType.CREEPER);
|
||||||
private static transient Conf i = new Conf();
|
safeZoneNerfedCreatureTypes.add(EntityType.ENDER_DRAGON);
|
||||||
public static void load()
|
safeZoneNerfedCreatureTypes.add(EntityType.ENDERMAN);
|
||||||
{
|
safeZoneNerfedCreatureTypes.add(EntityType.GHAST);
|
||||||
P.p.persist.loadOrSaveDefault(i, Conf.class, "conf");
|
safeZoneNerfedCreatureTypes.add(EntityType.MAGMA_CUBE);
|
||||||
}
|
safeZoneNerfedCreatureTypes.add(EntityType.PIG_ZOMBIE);
|
||||||
public static void save()
|
safeZoneNerfedCreatureTypes.add(EntityType.SILVERFISH);
|
||||||
{
|
safeZoneNerfedCreatureTypes.add(EntityType.SKELETON);
|
||||||
P.p.persist.save(i);
|
safeZoneNerfedCreatureTypes.add(EntityType.SPIDER);
|
||||||
}
|
safeZoneNerfedCreatureTypes.add(EntityType.SLIME);
|
||||||
|
safeZoneNerfedCreatureTypes.add(EntityType.WITCH);
|
||||||
|
safeZoneNerfedCreatureTypes.add(EntityType.WITHER);
|
||||||
|
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// Persistance
|
||||||
|
// -------------------------------------------- //
|
||||||
|
private static transient Conf i = new Conf();
|
||||||
|
|
||||||
|
public static void load() {
|
||||||
|
P.p.persist.loadOrSaveDefault(i, Conf.class, "conf");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save() {
|
||||||
|
P.p.persist.save(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,221 +1,189 @@
|
|||||||
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;
|
||||||
private int z = 0;
|
private int z = 0;
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "["+this.getWorldName()+","+this.getCoordString()+"]";
|
return "[" + this.getWorldName() + "," + this.getCoordString() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Block/Chunk/Region Value Transformation
|
// Block/Chunk/Region Value Transformation
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
// 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"
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Some Geometry
|
// Some Geometry
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
public Set<FLocation> getCircle(double radius)
|
public Set<FLocation> getCircle(double radius) {
|
||||||
{
|
Set<FLocation> ret = new LinkedHashSet<FLocation>();
|
||||||
Set<FLocation> ret = new LinkedHashSet<FLocation>();
|
if (radius <= 0) return ret;
|
||||||
if (radius <= 0) return ret;
|
|
||||||
|
|
||||||
int xfrom = (int) Math.floor(this.x - radius);
|
int xfrom = (int) Math.floor(this.x - radius);
|
||||||
int xto = (int) Math.ceil(this.x + radius);
|
int xto = (int) Math.ceil(this.x + radius);
|
||||||
int zfrom = (int) Math.floor(this.z - radius);
|
int 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);
|
||||||
{
|
if (this.getDistanceTo(potential) <= radius)
|
||||||
FLocation potential = new FLocation(this.worldName, x, z);
|
ret.add(potential);
|
||||||
if (this.getDistanceTo(potential) <= radius)
|
}
|
||||||
ret.add(potential);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// Comparison
|
// Comparison
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
@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))
|
return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
FLocation that = (FLocation) obj;
|
FLocation that = (FLocation) obj;
|
||||||
return this.x == that.x && this.z == that.z && ( this.worldName==null ? that.worldName==null : this.worldName.equals(that.worldName) );
|
return this.x == that.x && this.z == that.z && (this.worldName == null ? that.worldName == null : this.worldName.equals(that.worldName));
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,50 +1,44 @@
|
|||||||
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;
|
public static FPlayers i = new FPlayers();
|
||||||
import com.massivecraft.factions.zcore.persist.PlayerEntityCollection;
|
|
||||||
|
|
||||||
public class FPlayers extends PlayerEntityCollection<FPlayer>
|
P p = P.p;
|
||||||
{
|
|
||||||
public static FPlayers i = new FPlayers();
|
|
||||||
|
|
||||||
P p = P.p;
|
private FPlayers() {
|
||||||
|
super
|
||||||
|
(
|
||||||
|
FPlayer.class,
|
||||||
|
new CopyOnWriteArrayList<FPlayer>(),
|
||||||
|
new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER),
|
||||||
|
new File(P.p.getDataFolder(), "players.json"),
|
||||||
|
P.p.gson
|
||||||
|
);
|
||||||
|
|
||||||
private FPlayers()
|
this.setCreative(true);
|
||||||
{
|
}
|
||||||
super
|
|
||||||
(
|
|
||||||
FPlayer.class,
|
|
||||||
new CopyOnWriteArrayList<FPlayer>(),
|
|
||||||
new ConcurrentSkipListMap<String, FPlayer>(String.CASE_INSENSITIVE_ORDER),
|
|
||||||
new File(P.p.getDataFolder(), "players.json"),
|
|
||||||
P.p.gson
|
|
||||||
);
|
|
||||||
|
|
||||||
this.setCreative(true);
|
@Override
|
||||||
}
|
public Type getMapType() {
|
||||||
|
return new TypeToken<Map<String, FPlayer>>() {
|
||||||
|
}.getType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void clean() {
|
||||||
public Type getMapType()
|
for (FPlayer fplayer : this.get()) {
|
||||||
{
|
if (!Factions.i.exists(fplayer.getFactionId())) {
|
||||||
return new TypeToken<Map<String, FPlayer>>(){}.getType();
|
p.log("Reset faction data (invalid faction) for player " + fplayer.getName());
|
||||||
}
|
fplayer.resetFactionData(false);
|
||||||
|
}
|
||||||
public void clean()
|
}
|
||||||
{
|
}
|
||||||
for (FPlayer fplayer : this.get())
|
|
||||||
{
|
|
||||||
if ( ! Factions.i.exists(fplayer.getFactionId()))
|
|
||||||
{
|
|
||||||
p.log("Reset faction data (invalid faction) for player "+fplayer.getName());
|
|
||||||
fplayer.resetFactionData(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,189 +1,163 @@
|
|||||||
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> {
|
||||||
|
public static Factions i = new Factions();
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
P p = P.p;
|
||||||
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>
|
private Factions() {
|
||||||
{
|
super
|
||||||
public static Factions i = new Factions();
|
(
|
||||||
|
Faction.class,
|
||||||
|
new CopyOnWriteArrayList<Faction>(),
|
||||||
|
new ConcurrentHashMap<String, Faction>(),
|
||||||
|
new File(P.p.getDataFolder(), "factions.json"),
|
||||||
|
P.p.gson
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
P p = P.p;
|
@Override
|
||||||
|
public Type getMapType() {
|
||||||
|
return new TypeToken<Map<String, Faction>>() {
|
||||||
|
}.getType();
|
||||||
|
}
|
||||||
|
|
||||||
private Factions()
|
@Override
|
||||||
{
|
public boolean loadFromDisc() {
|
||||||
super
|
if (!super.loadFromDisc()) return false;
|
||||||
(
|
|
||||||
Faction.class,
|
|
||||||
new CopyOnWriteArrayList<Faction>(),
|
|
||||||
new ConcurrentHashMap<String, Faction>(),
|
|
||||||
new File(P.p.getDataFolder(), "factions.json"),
|
|
||||||
P.p.gson
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// Make sure the default neutral faction exists
|
||||||
public Type getMapType()
|
if (!this.exists("0")) {
|
||||||
{
|
Faction faction = this.create("0");
|
||||||
return new TypeToken<Map<String, Faction>>(){}.getType();
|
faction.setTag(ChatColor.DARK_GREEN + "Wilderness");
|
||||||
}
|
faction.setDescription("");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
// Make sure the safe zone faction exists
|
||||||
public boolean loadFromDisc()
|
if (!this.exists("-1")) {
|
||||||
{
|
Faction faction = this.create("-1");
|
||||||
if ( ! super.loadFromDisc()) return false;
|
faction.setTag("SafeZone");
|
||||||
|
faction.setDescription("Free from PVP and monsters");
|
||||||
|
} else {
|
||||||
|
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||||
|
Faction faction = this.getSafeZone();
|
||||||
|
if (faction.getTag().contains(" "))
|
||||||
|
faction.setTag("SafeZone");
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the default neutral faction exists
|
// Make sure the war zone faction exists
|
||||||
if ( ! this.exists("0"))
|
if (!this.exists("-2")) {
|
||||||
{
|
Faction faction = this.create("-2");
|
||||||
Faction faction = this.create("0");
|
faction.setTag("WarZone");
|
||||||
faction.setTag(ChatColor.DARK_GREEN+"Wilderness");
|
faction.setDescription("Not the safest place to be");
|
||||||
faction.setDescription("");
|
} else {
|
||||||
}
|
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||||
|
Faction faction = this.getWarZone();
|
||||||
|
if (faction.getTag().contains(" "))
|
||||||
|
faction.setTag("WarZone");
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the safe zone faction exists
|
// populate all faction player lists
|
||||||
if ( ! this.exists("-1"))
|
for (Faction faction : i.get()) {
|
||||||
{
|
faction.refreshFPlayers();
|
||||||
Faction faction = this.create("-1");
|
}
|
||||||
faction.setTag("SafeZone");
|
|
||||||
faction.setDescription("Free from PVP and monsters");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
|
||||||
Faction faction = this.getSafeZone();
|
|
||||||
if (faction.getTag().contains(" "))
|
|
||||||
faction.setTag("SafeZone");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the war zone faction exists
|
return true;
|
||||||
if ( ! this.exists("-2"))
|
}
|
||||||
{
|
|
||||||
Faction faction = this.create("-2");
|
|
||||||
faction.setTag("WarZone");
|
|
||||||
faction.setDescription("Not the safest place to be");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
|
||||||
Faction faction = this.getWarZone();
|
|
||||||
if (faction.getTag().contains(" "))
|
|
||||||
faction.setTag("WarZone");
|
|
||||||
}
|
|
||||||
|
|
||||||
// populate all faction player lists
|
|
||||||
for (Faction faction : i.get())
|
|
||||||
{
|
|
||||||
faction.refreshFPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// GET
|
// GET
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
|
|
||||||
@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!");
|
||||||
{
|
Board.clean();
|
||||||
p.log(Level.WARNING, "Non existing factionId "+id+" requested! Issuing cleaning!");
|
FPlayers.i.clean();
|
||||||
Board.clean();
|
}
|
||||||
FPlayers.i.clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
// 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));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)) {
|
||||||
{
|
return faction;
|
||||||
if (faction.getComparisonTag().equals(compStr))
|
}
|
||||||
{
|
}
|
||||||
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);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String tag = TextUtil.getBestStartWithCI(tag2faction.keySet(), searchFor);
|
String tag = TextUtil.getBestStartWithCI(tag2faction.keySet(), searchFor);
|
||||||
if (tag == null) return null;
|
if (tag == null) return null;
|
||||||
return tag2faction.get(tag);
|
return tag2faction.get(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,334 +12,319 @@ 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;
|
|
||||||
|
|
||||||
// Listeners
|
// Listeners
|
||||||
public final FactionsPlayerListener playerListener;
|
public final FactionsPlayerListener playerListener;
|
||||||
public final FactionsChatListener chatListener;
|
public final FactionsChatListener chatListener;
|
||||||
public final FactionsEntityListener entityListener;
|
public final FactionsEntityListener entityListener;
|
||||||
public final FactionsExploitListener exploitListener;
|
public final FactionsExploitListener exploitListener;
|
||||||
public final FactionsBlockListener blockListener;
|
public final FactionsBlockListener blockListener;
|
||||||
public final FactionsServerListener serverListener;
|
public final FactionsServerListener serverListener;
|
||||||
|
|
||||||
// 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);}
|
|
||||||
private Integer AutoLeaveTask = null;
|
|
||||||
|
|
||||||
// Commands
|
public boolean getLocked() {
|
||||||
public FCmdRoot cmdBase;
|
return this.locked;
|
||||||
public CmdAutoHelp cmdAutoHelp;
|
}
|
||||||
|
|
||||||
public P()
|
public void setLocked(boolean val) {
|
||||||
{
|
this.locked = val;
|
||||||
p = this;
|
this.setAutoSave(val);
|
||||||
this.playerListener = new FactionsPlayerListener(this);
|
}
|
||||||
this.chatListener = new FactionsChatListener(this);
|
|
||||||
this.entityListener = new FactionsEntityListener(this);
|
private Integer AutoLeaveTask = null;
|
||||||
this.exploitListener = new FactionsExploitListener();
|
|
||||||
this.blockListener = new FactionsBlockListener(this);
|
// Commands
|
||||||
this.serverListener = new FactionsServerListener(this);
|
public FCmdRoot cmdBase;
|
||||||
}
|
public CmdAutoHelp cmdAutoHelp;
|
||||||
|
|
||||||
|
public P() {
|
||||||
|
p = this;
|
||||||
|
this.playerListener = new FactionsPlayerListener(this);
|
||||||
|
this.chatListener = new FactionsChatListener(this);
|
||||||
|
this.entityListener = new FactionsEntityListener(this);
|
||||||
|
this.exploitListener = new FactionsExploitListener();
|
||||||
|
this.blockListener = new FactionsBlockListener(this);
|
||||||
|
this.serverListener = new FactionsServerListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@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");
|
||||||
{
|
} catch (ClassNotFoundException ex) {
|
||||||
Class.forName("org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken");
|
this.log(Level.SEVERE, "GSON lib not found. Your CraftBukkit build is too old (< 1.3.2) or otherwise not compatible.");
|
||||||
}
|
this.suicide();
|
||||||
catch (ClassNotFoundException ex)
|
return;
|
||||||
{
|
}
|
||||||
this.log(Level.SEVERE, "GSON lib not found. Your CraftBukkit build is too old (< 1.3.2) or otherwise not compatible.");
|
|
||||||
this.suicide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! preEnable()) return;
|
if (!preEnable()) return;
|
||||||
this.loadSuccessful = false;
|
this.loadSuccessful = false;
|
||||||
|
|
||||||
// Load Conf from disk
|
// Load Conf from disk
|
||||||
Conf.load();
|
Conf.load();
|
||||||
FPlayers.i.loadFromDisc();
|
FPlayers.i.loadFromDisc();
|
||||||
Factions.i.loadFromDisc();
|
Factions.i.loadFromDisc();
|
||||||
Board.load();
|
Board.load();
|
||||||
|
|
||||||
// Add Base Commands
|
// Add Base Commands
|
||||||
this.cmdBase = new FCmdRoot();
|
this.cmdBase = new FCmdRoot();
|
||||||
this.cmdAutoHelp = new CmdAutoHelp();
|
this.cmdAutoHelp = new CmdAutoHelp();
|
||||||
this.getBaseCommands().add(cmdBase);
|
this.getBaseCommands().add(cmdBase);
|
||||||
|
|
||||||
EssentialsFeatures.setup();
|
EssentialsFeatures.setup();
|
||||||
SpoutFeatures.setup();
|
SpoutFeatures.setup();
|
||||||
Econ.setup();
|
Econ.setup();
|
||||||
CapiFeatures.setup();
|
CapiFeatures.setup();
|
||||||
LWCFeatures.setup();
|
LWCFeatures.setup();
|
||||||
|
|
||||||
if(Conf.worldGuardChecking || Conf.worldGuardBuildPriority)
|
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) {
|
||||||
{
|
Worldguard.init(this);
|
||||||
Worldguard.init(this);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// start up task which runs the autoLeaveAfterDaysOfInactivity routine
|
// start up task which runs the autoLeaveAfterDaysOfInactivity routine
|
||||||
startAutoLeaveTask(false);
|
startAutoLeaveTask(false);
|
||||||
|
|
||||||
// Register Event Handlers
|
// Register Event Handlers
|
||||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||||
getServer().getPluginManager().registerEvents(chatListener, this);
|
getServer().getPluginManager().registerEvents(chatListener, this);
|
||||||
getServer().getPluginManager().registerEvents(entityListener, this);
|
getServer().getPluginManager().registerEvents(entityListener, this);
|
||||||
getServer().getPluginManager().registerEvents(exploitListener, this);
|
getServer().getPluginManager().registerEvents(exploitListener, this);
|
||||||
getServer().getPluginManager().registerEvents(blockListener, this);
|
getServer().getPluginManager().registerEvents(blockListener, this);
|
||||||
getServer().getPluginManager().registerEvents(serverListener, this);
|
getServer().getPluginManager().registerEvents(serverListener, this);
|
||||||
|
|
||||||
// since some other plugins execute commands directly through this command interface, provide it
|
// since some other plugins execute commands directly through this command interface, provide it
|
||||||
this.getCommand(this.refCommand).setExecutor(this);
|
this.getCommand(this.refCommand).setExecutor(this);
|
||||||
|
|
||||||
postEnable();
|
postEnable();
|
||||||
this.loadSuccessful = true;
|
this.loadSuccessful = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GsonBuilder getGsonBuilder()
|
public GsonBuilder getGsonBuilder() {
|
||||||
{
|
Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>() {
|
||||||
Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>(){}.getType();
|
}.getType();
|
||||||
|
|
||||||
return new GsonBuilder()
|
return new GsonBuilder()
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.disableHtmlEscaping()
|
.disableHtmlEscaping()
|
||||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
||||||
.registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter())
|
.registerTypeAdapter(LazyLocation.class, new MyLocationTypeAdapter())
|
||||||
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter());
|
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable() {
|
||||||
{
|
// only save data if plugin actually completely loaded successfully
|
||||||
// only save data if plugin actually completely loaded successfully
|
if (this.loadSuccessful) {
|
||||||
if (this.loadSuccessful)
|
Board.save();
|
||||||
{
|
Conf.save();
|
||||||
Board.save();
|
}
|
||||||
Conf.save();
|
EssentialsFeatures.unhookChat();
|
||||||
}
|
if (AutoLeaveTask != null) {
|
||||||
EssentialsFeatures.unhookChat();
|
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||||
if (AutoLeaveTask != null)
|
AutoLeaveTask = null;
|
||||||
{
|
}
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
super.onDisable();
|
||||||
AutoLeaveTask = null;
|
}
|
||||||
}
|
|
||||||
super.onDisable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startAutoLeaveTask(boolean restartIfRunning)
|
public void startAutoLeaveTask(boolean restartIfRunning) {
|
||||||
{
|
if (AutoLeaveTask != null) {
|
||||||
if (AutoLeaveTask != null)
|
if (!restartIfRunning) return;
|
||||||
{
|
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
||||||
if ( ! restartIfRunning) return;
|
}
|
||||||
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;
|
|
||||||
|
|
||||||
// otherwise, needs to be handled; presumably another plugin directly ran the command
|
// otherwise, needs to be handled; presumably another plugin directly ran the command
|
||||||
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
String cmd = Conf.baseCommandAliases.isEmpty() ? "/f" : "/" + Conf.baseCommandAliases.get(0);
|
||||||
return handleCommand(sender, cmd + " " + TextUtil.implode(Arrays.asList(split), " "), false);
|
return handleCommand(sender, cmd + " " + TextUtil.implode(Arrays.asList(split), " "), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// Functions for other plugins to hook into
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// This value will be updated whenever new hooks are added
|
||||||
// Functions for other plugins to hook into
|
public int hookSupportVersion() {
|
||||||
// -------------------------------------------- //
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
// This value will be updated whenever new hooks are added
|
// If another plugin is handling insertion of chat tags, this should be used to notify Factions
|
||||||
public int hookSupportVersion()
|
public void handleFactionTagExternally(boolean notByFactions) {
|
||||||
{
|
Conf.chatTagHandledByAnotherPlugin = notByFactions;
|
||||||
return 3;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If another plugin is handling insertion of chat tags, this should be used to notify Factions
|
// Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat
|
||||||
public void handleFactionTagExternally(boolean notByFactions)
|
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
|
||||||
{
|
|
||||||
Conf.chatTagHandledByAnotherPlugin = notByFactions;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat
|
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event) {
|
||||||
// enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand()
|
if (event == null) return false;
|
||||||
|
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean shouldLetFactionsHandleThisChat(AsyncPlayerChatEvent event)
|
// 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
|
||||||
if (event == null) return false;
|
public boolean isPlayerFactionChatting(Player player) {
|
||||||
return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage()));
|
if (player == null) return false;
|
||||||
}
|
FPlayer me = FPlayers.i.get(player);
|
||||||
|
|
||||||
// Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels,
|
if (me == null) return false;
|
||||||
// local chat, or anything else which targets individual recipients, so Faction Chat can be done
|
return me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
||||||
public boolean isPlayerFactionChatting(Player player)
|
}
|
||||||
{
|
|
||||||
if (player == null) return false;
|
|
||||||
FPlayer me = FPlayers.i.get(player);
|
|
||||||
|
|
||||||
if (me == null)return false;
|
// Is this chat message actually a Factions command, and thus should be left alone by other plugins?
|
||||||
return me.getChatMode().isAtLeast(ChatMode.ALLIANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is this chat message actually a Factions command, and thus should be left alone by other plugins?
|
// TODO: GET THIS BACK AND WORKING
|
||||||
|
|
||||||
// TODO: GET THIS BACK AND WORKING
|
public boolean isFactionsCommand(String check) {
|
||||||
|
if (check == null || check.isEmpty()) return false;
|
||||||
|
return this.handleCommand(null, check, true);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFactionsCommand(String check)
|
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
|
||||||
{
|
public String getPlayerFactionTag(Player player) {
|
||||||
if (check == null || check.isEmpty()) return false;
|
return getPlayerFactionTagRelation(player, null);
|
||||||
return this.handleCommand(null, check, true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat
|
// Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag
|
||||||
public String getPlayerFactionTag(Player player)
|
public String getPlayerFactionTagRelation(Player speaker, Player listener) {
|
||||||
{
|
String tag = "~";
|
||||||
return getPlayerFactionTagRelation(player, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag
|
if (speaker == null)
|
||||||
public String getPlayerFactionTagRelation(Player speaker, Player listener)
|
return tag;
|
||||||
{
|
|
||||||
String tag = "~";
|
|
||||||
|
|
||||||
if (speaker == null)
|
FPlayer me = FPlayers.i.get(speaker);
|
||||||
return tag;
|
if (me == null)
|
||||||
|
return tag;
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(speaker);
|
// if listener isn't set, or config option is disabled, give back uncolored tag
|
||||||
if (me == null)
|
if (listener == null || !Conf.chatTagRelationColored) {
|
||||||
return tag;
|
tag = me.getChatTag().trim();
|
||||||
|
} else {
|
||||||
|
FPlayer you = FPlayers.i.get(listener);
|
||||||
|
if (you == null)
|
||||||
|
tag = me.getChatTag().trim();
|
||||||
|
else // everything checks out, give the colored tag
|
||||||
|
tag = me.getChatTag(you).trim();
|
||||||
|
}
|
||||||
|
if (tag.isEmpty())
|
||||||
|
tag = "~";
|
||||||
|
|
||||||
// if listener isn't set, or config option is disabled, give back uncolored tag
|
return tag;
|
||||||
if (listener == null || !Conf.chatTagRelationColored) {
|
}
|
||||||
tag = me.getChatTag().trim();
|
|
||||||
} else {
|
|
||||||
FPlayer you = FPlayers.i.get(listener);
|
|
||||||
if (you == null)
|
|
||||||
tag = me.getChatTag().trim();
|
|
||||||
else // everything checks out, give the colored tag
|
|
||||||
tag = me.getChatTag(you).trim();
|
|
||||||
}
|
|
||||||
if (tag.isEmpty())
|
|
||||||
tag = "~";
|
|
||||||
|
|
||||||
return tag;
|
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
||||||
}
|
public String getPlayerTitle(Player player) {
|
||||||
|
if (player == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
// Get a player's title within their faction, mainly for usage by chat plugins for local/channel chat
|
FPlayer me = FPlayers.i.get(player);
|
||||||
public String getPlayerTitle(Player player)
|
if (me == null)
|
||||||
{
|
return "";
|
||||||
if (player == null)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(player);
|
return me.getTitle().trim();
|
||||||
if (me == null)
|
}
|
||||||
return "";
|
|
||||||
|
|
||||||
return me.getTitle().trim();
|
// Get a list of all faction tags (names)
|
||||||
}
|
public Set<String> getFactionTags() {
|
||||||
|
Set<String> tags = new HashSet<String>();
|
||||||
|
for (Faction faction : Factions.i.get()) {
|
||||||
|
tags.add(faction.getTag());
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
// Get a list of all faction tags (names)
|
// Get a list of all players in the specified faction
|
||||||
public Set<String> getFactionTags()
|
public Set<String> getPlayersInFaction(String factionTag) {
|
||||||
{
|
Set<String> players = new HashSet<String>();
|
||||||
Set<String> tags = new HashSet<String>();
|
Faction faction = Factions.i.getByTag(factionTag);
|
||||||
for (Faction faction : Factions.i.get())
|
if (faction != null) {
|
||||||
{
|
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||||
tags.add(faction.getTag());
|
players.add(fplayer.getName());
|
||||||
}
|
}
|
||||||
return tags;
|
}
|
||||||
}
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
// Get a list of all players in the specified faction
|
// Get a list of all online players in the specified faction
|
||||||
public Set<String> getPlayersInFaction(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)) {
|
||||||
{
|
players.add(fplayer.getName());
|
||||||
for (FPlayer fplayer : faction.getFPlayers())
|
}
|
||||||
{
|
}
|
||||||
players.add(fplayer.getName());
|
return players;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a list of all online players in the specified faction
|
// check if player is allowed to build/destroy in a particular location
|
||||||
public Set<String> getOnlinePlayersInFaction(String factionTag)
|
public boolean isPlayerAllowedToBuildHere(Player player, Location location) {
|
||||||
{
|
return FactionsBlockListener.playerCanBuildDestroyBlock(player, location, "", true);
|
||||||
Set<String> players = new HashSet<String>();
|
}
|
||||||
Faction faction = Factions.i.getByTag(factionTag);
|
|
||||||
if (faction != null)
|
|
||||||
{
|
|
||||||
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
players.add(fplayer.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if player is allowed to build/destroy in a particular location
|
// check if player is allowed to interact with the specified block (doors/chests/whatever)
|
||||||
public boolean isPlayerAllowedToBuildHere(Player player, Location location)
|
public boolean isPlayerAllowedToInteractWith(Player player, Block block) {
|
||||||
{
|
return FactionsPlayerListener.canPlayerUseBlock(player, block, 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 use a specified item (flint&steel, buckets, etc) in a particular location
|
||||||
public boolean isPlayerAllowedToInteractWith(Player player, Block block)
|
public boolean isPlayerAllowedToUseThisHere(Player player, Location location, Material material) {
|
||||||
{
|
return FactionsPlayerListener.playerCanUseItemHere(player, location, material, 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
|
|
||||||
public boolean isPlayerAllowedToUseThisHere(Player player, Location location, Material material)
|
|
||||||
{
|
|
||||||
return FactionsPlayerListener.playerCanUseItemHere(player, location, material, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,90 +1,80 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("admin");
|
||||||
super();
|
|
||||||
this.aliases.add("admin");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.ADMIN.node;
|
this.permission = Permission.ADMIN.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
||||||
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
if (fyou == null) return;
|
||||||
if (fyou == null) return;
|
|
||||||
|
|
||||||
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
boolean permAny = Permission.ADMIN_ANY.has(sender, false);
|
||||||
Faction targetFaction = fyou.getFaction();
|
Faction targetFaction = fyou.getFaction();
|
||||||
|
|
||||||
if (targetFaction != myFaction && !permAny)
|
if (targetFaction != myFaction && !permAny) {
|
||||||
{
|
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
|
||||||
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny)
|
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||||
{
|
msg("<b>You are not the faction admin.");
|
||||||
msg("<b>You are not the faction admin.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fyou == fme && !permAny)
|
if (fyou == fme && !permAny) {
|
||||||
{
|
msg("<b>The target player musn't be yourself.");
|
||||||
msg("<b>The target player musn't be yourself.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
// only perform a FPlayerJoinEvent when newLeader isn't actually in the faction
|
||||||
if (fyou.getFaction() != targetFaction)
|
if (fyou.getFaction() != targetFaction) {
|
||||||
{
|
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.i.get(me), targetFaction, FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
||||||
FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayers.i.get(me),targetFaction,FPlayerJoinEvent.PlayerJoinReason.LEADER);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
if (event.isCancelled()) return;
|
||||||
if (event.isCancelled()) return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer admin = targetFaction.getFPlayerAdmin();
|
FPlayer admin = targetFaction.getFPlayerAdmin();
|
||||||
|
|
||||||
// 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));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// promote target player, and demote existing admin if one exists
|
// promote target player, and demote existing admin if one exists
|
||||||
if (admin != null)
|
if (admin != null)
|
||||||
admin.setRole(Role.MODERATOR);
|
admin.setRole(Role.MODERATOR);
|
||||||
fyou.setRole(Role.ADMIN);
|
fyou.setRole(Role.ADMIN);
|
||||||
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
msg("<i>You have promoted %s<i> to the position of faction admin.", fyou.describeTo(fme, true));
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
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,50 +4,45 @@ 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();
|
||||||
{
|
this.aliases.add("autoclaim");
|
||||||
super();
|
|
||||||
this.aliases.add("autoclaim");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "your");
|
this.optionalArgs.put("faction", "your");
|
||||||
|
|
||||||
this.permission = Permission.AUTOCLAIM.node;
|
this.permission = Permission.AUTOCLAIM.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction forFaction = this.argAsFaction(0, myFaction);
|
||||||
Faction forFaction = this.argAsFaction(0, myFaction);
|
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
|
||||||
if (forFaction == null || forFaction == fme.getAutoClaimFor())
|
fme.setAutoClaimFor(null);
|
||||||
{
|
msg("<i>Auto-claiming of land disabled.");
|
||||||
fme.setAutoClaimFor(null);
|
return;
|
||||||
msg("<i>Auto-claiming of land disabled.");
|
}
|
||||||
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
|
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
|
||||||
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.setAutoClaimFor(forFaction);
|
fme.setAutoClaimFor(forFaction);
|
||||||
|
|
||||||
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
|
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
|
||||||
fme.attemptClaim(forFaction, me.getLocation(), true);
|
fme.attemptClaim(forFaction, me.getLocation(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,48 +1,43 @@
|
|||||||
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()
|
|
||||||
{
|
|
||||||
super(P.p);
|
|
||||||
this.aliases.add("?");
|
|
||||||
this.aliases.add("h");
|
|
||||||
this.aliases.add("help");
|
|
||||||
|
|
||||||
this.setHelpShort("");
|
public class CmdAutoHelp extends MCommand<P> {
|
||||||
|
public CmdAutoHelp() {
|
||||||
|
super(P.p);
|
||||||
|
this.aliases.add("?");
|
||||||
|
this.aliases.add("h");
|
||||||
|
this.aliases.add("help");
|
||||||
|
|
||||||
this.optionalArgs.put("page","1");
|
this.setHelpShort("");
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
this.optionalArgs.put("page", "1");
|
||||||
public void perform()
|
}
|
||||||
{
|
|
||||||
if (this.commandChain.size() == 0) return;
|
|
||||||
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size()-1);
|
|
||||||
|
|
||||||
ArrayList<String> lines = new ArrayList<String>();
|
@Override
|
||||||
|
public void perform() {
|
||||||
|
if (this.commandChain.size() == 0) return;
|
||||||
|
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
||||||
|
|
||||||
lines.addAll(pcmd.helpLong);
|
ArrayList<String> lines = new ArrayList<String>();
|
||||||
|
|
||||||
for(MCommand<?> scmd : pcmd.subCommands)
|
lines.addAll(pcmd.helpLong);
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
scmd.visibility == CommandVisibility.VISIBLE
|
|
||||||
||
|
|
||||||
(scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Help for command \""+pcmd.aliases.get(0)+"\""));
|
for (MCommand<?> scmd : pcmd.subCommands) {
|
||||||
}
|
if
|
||||||
|
(
|
||||||
|
scmd.visibility == CommandVisibility.VISIBLE
|
||||||
|
||
|
||||||
|
(scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))
|
||||||
|
) {
|
||||||
|
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Help for command \"" + pcmd.aliases.get(0) + "\""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,42 +3,38 @@ 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();
|
||||||
{
|
this.aliases.add("noboom");
|
||||||
super();
|
|
||||||
this.aliases.add("noboom");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.NO_BOOM.node;
|
this.permission = Permission.NO_BOOM.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (!myFaction.isPeaceful()) {
|
||||||
if ( ! myFaction.isPeaceful())
|
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful.");
|
||||||
{
|
return;
|
||||||
fme.msg("<b>This command is only usable by factions which are specially designated as peaceful.");
|
}
|
||||||
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.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return;
|
if (!payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return;
|
||||||
|
|
||||||
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled()));
|
myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, !myFaction.getPeacefulExplosionsEnabled()));
|
||||||
|
|
||||||
String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled";
|
String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled";
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> has "+enabled+" explosions in your faction's territory.", fme.describeTo(myFaction));
|
myFaction.msg("%s<i> has " + enabled + " explosions in your faction's territory.", fme.describeTo(myFaction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,40 +3,34 @@ 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();
|
||||||
{
|
this.aliases.add("bypass");
|
||||||
super();
|
|
||||||
this.aliases.add("bypass");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.BYPASS.node;
|
this.permission = Permission.BYPASS.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
}
|
fme.msg("<i>You have disabled admin bypass mode.");
|
||||||
else
|
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
||||||
{
|
}
|
||||||
fme.msg("<i>You have disabled admin bypass mode.");
|
}
|
||||||
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,74 +4,57 @@ 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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("mode", "next");
|
this.optionalArgs.put("mode", "next");
|
||||||
|
|
||||||
this.permission = Permission.CHAT.node;
|
this.permission = Permission.CHAT.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (!Conf.factionOnlyChat) {
|
||||||
if ( ! Conf.factionOnlyChat )
|
msg("<b>The built in chat chat channels are disabled on this server.");
|
||||||
{
|
return;
|
||||||
msg("<b>The built in chat chat channels are disabled on this server.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String modeString = this.argAsString(0);
|
String modeString = this.argAsString(0);
|
||||||
ChatMode modeTarget = fme.getChatMode().getNext();
|
ChatMode modeTarget = fme.getChatMode().getNext();
|
||||||
|
|
||||||
if (modeString != null)
|
if (modeString != null) {
|
||||||
{
|
modeString.toLowerCase();
|
||||||
modeString.toLowerCase();
|
if (modeString.startsWith("p")) {
|
||||||
if(modeString.startsWith("p"))
|
modeTarget = ChatMode.PUBLIC;
|
||||||
{
|
} else if (modeString.startsWith("a")) {
|
||||||
modeTarget = ChatMode.PUBLIC;
|
modeTarget = ChatMode.ALLIANCE;
|
||||||
}
|
} else if (modeString.startsWith("f")) {
|
||||||
else if (modeString.startsWith("a"))
|
modeTarget = ChatMode.FACTION;
|
||||||
{
|
} else {
|
||||||
modeTarget = ChatMode.ALLIANCE;
|
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
|
||||||
}
|
return;
|
||||||
else if(modeString.startsWith("f"))
|
}
|
||||||
{
|
}
|
||||||
modeTarget = ChatMode.FACTION;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
}
|
msg("<i>Alliance only chat mode.");
|
||||||
else if (fme.getChatMode() == ChatMode.ALLIANCE )
|
} else {
|
||||||
{
|
msg("<i>Faction only chat mode.");
|
||||||
msg("<i>Alliance only chat mode.");
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("<i>Faction only chat mode.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,38 +3,32 @@ 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();
|
||||||
{
|
this.aliases.add("chatspy");
|
||||||
super();
|
|
||||||
this.aliases.add("chatspy");
|
|
||||||
|
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.CHATSPY.node;
|
this.permission = Permission.CHATSPY.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
}
|
fme.msg("<i>You have disabled chat spying mode.");
|
||||||
else
|
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
||||||
{
|
}
|
||||||
fme.msg("<i>You have disabled chat spying mode.");
|
}
|
||||||
P.p.log(fme.getName() + " DISABLED chat spying mode.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,81 +1,70 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "your");
|
this.optionalArgs.put("faction", "your");
|
||||||
this.optionalArgs.put("radius", "1");
|
this.optionalArgs.put("radius", "1");
|
||||||
|
|
||||||
this.permission = Permission.CLAIM.node;
|
this.permission = Permission.CLAIM.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
// Read and validate input
|
||||||
// Read and validate input
|
final Faction forFaction = this.argAsFaction(0, myFaction);
|
||||||
final Faction forFaction = this.argAsFaction(0, myFaction);
|
int radius = this.argAsInt(1, 1);
|
||||||
int radius = this.argAsInt(1, 1);
|
|
||||||
|
|
||||||
if (radius < 1)
|
if (radius < 1) {
|
||||||
{
|
msg("<b>If you specify a radius, it must be at least 1.");
|
||||||
msg("<b>If you specify a radius, it must be at least 1.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (radius < 2)
|
if (radius < 2) {
|
||||||
{
|
// single chunk
|
||||||
// single chunk
|
fme.attemptClaim(forFaction, me.getLocation(), true);
|
||||||
fme.attemptClaim(forFaction, me.getLocation(), true);
|
} else {
|
||||||
}
|
// radius claim
|
||||||
else
|
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||||
{
|
msg("<b>You do not have permission to claim in a radius.");
|
||||||
// radius claim
|
return;
|
||||||
if (! Permission.CLAIM_RADIUS.has(sender, false))
|
}
|
||||||
{
|
|
||||||
msg("<b>You do not have permission to claim in a radius.");
|
|
||||||
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();
|
||||||
{
|
return false;
|
||||||
this.stop();
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,302 +1,245 @@
|
|||||||
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;
|
||||||
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public CmdConfig()
|
public class CmdConfig extends FCommand {
|
||||||
{
|
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
|
||||||
super();
|
|
||||||
this.aliases.add("config");
|
|
||||||
|
|
||||||
this.requiredArgs.add("setting");
|
public CmdConfig() {
|
||||||
this.requiredArgs.add("value");
|
super();
|
||||||
this.errorOnToManyArgs = false;
|
this.aliases.add("config");
|
||||||
|
|
||||||
this.permission = Permission.CONFIG.node;
|
this.requiredArgs.add("setting");
|
||||||
this.disableOnLock = true;
|
this.requiredArgs.add("value");
|
||||||
|
this.errorOnToManyArgs = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
this.permission = Permission.CONFIG.node;
|
||||||
senderMustBeMember = false;
|
this.disableOnLock = true;
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
senderMustBePlayer = false;
|
||||||
public void perform()
|
senderMustBeMember = false;
|
||||||
{
|
senderMustBeModerator = false;
|
||||||
// store a lookup map of lowercase field names paired with proper capitalization field names
|
senderMustBeAdmin = false;
|
||||||
// that way, if the person using this command messes up the capitalization, we can fix that
|
}
|
||||||
if (properFieldNames.isEmpty())
|
|
||||||
{
|
|
||||||
Field[] fields = Conf.class.getDeclaredFields();
|
|
||||||
for(int i = 0; i < fields.length; i++)
|
|
||||||
{
|
|
||||||
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String field = this.argAsString(0).toLowerCase();
|
@Override
|
||||||
if (field.startsWith("\"") && field.endsWith("\""))
|
public void perform() {
|
||||||
{
|
// store a lookup map of lowercase field names paired with proper capitalization field names
|
||||||
field = field.substring(1, field.length() - 1);
|
// that way, if the person using this command messes up the capitalization, we can fix that
|
||||||
}
|
if (properFieldNames.isEmpty()) {
|
||||||
String fieldName = properFieldNames.get(field);
|
Field[] fields = Conf.class.getDeclaredFields();
|
||||||
|
for (int i = 0; i < fields.length; i++) {
|
||||||
|
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fieldName == null || fieldName.isEmpty())
|
String field = this.argAsString(0).toLowerCase();
|
||||||
{
|
if (field.startsWith("\"") && field.endsWith("\"")) {
|
||||||
msg("<b>No configuration setting \"<h>%s<b>\" exists.", field);
|
field = field.substring(1, field.length() - 1);
|
||||||
return;
|
}
|
||||||
}
|
String fieldName = properFieldNames.get(field);
|
||||||
|
|
||||||
String success = "";
|
if (fieldName == null || fieldName.isEmpty()) {
|
||||||
|
msg("<b>No configuration setting \"<h>%s<b>\" exists.", field);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String value = args.get(1);
|
String success = "";
|
||||||
for(int i = 2; i < args.size(); i++)
|
|
||||||
{
|
|
||||||
value += ' ' + args.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
String value = args.get(1);
|
||||||
{
|
for (int i = 2; i < args.size(); i++) {
|
||||||
Field target = Conf.class.getField(fieldName);
|
value += ' ' + args.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
// boolean
|
try {
|
||||||
if (target.getType() == boolean.class)
|
Field target = Conf.class.getField(fieldName);
|
||||||
{
|
|
||||||
boolean targetValue = this.strAsBool(value);
|
|
||||||
target.setBoolean(null, targetValue);
|
|
||||||
|
|
||||||
if (targetValue)
|
// boolean
|
||||||
{
|
if (target.getType() == boolean.class) {
|
||||||
success = "\""+fieldName+"\" option set to true (enabled).";
|
boolean targetValue = this.strAsBool(value);
|
||||||
}
|
target.setBoolean(null, targetValue);
|
||||||
else
|
|
||||||
{
|
|
||||||
success = "\""+fieldName+"\" option set to false (disabled).";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// int
|
if (targetValue) {
|
||||||
else if (target.getType() == int.class)
|
success = "\"" + fieldName + "\" option set to true (enabled).";
|
||||||
{
|
} else {
|
||||||
try
|
success = "\"" + fieldName + "\" option set to false (disabled).";
|
||||||
{
|
}
|
||||||
int intVal = Integer.parseInt(value);
|
}
|
||||||
target.setInt(null, intVal);
|
|
||||||
success = "\""+fieldName+"\" option set to "+intVal+".";
|
|
||||||
}
|
|
||||||
catch(NumberFormatException ex)
|
|
||||||
{
|
|
||||||
sendMessage("Cannot set \""+fieldName+"\": integer (whole number) value required.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// long
|
// int
|
||||||
else if (target.getType() == long.class)
|
else if (target.getType() == int.class) {
|
||||||
{
|
try {
|
||||||
try
|
int intVal = Integer.parseInt(value);
|
||||||
{
|
target.setInt(null, intVal);
|
||||||
long longVal = Long.parseLong(value);
|
success = "\"" + fieldName + "\" option set to " + intVal + ".";
|
||||||
target.setLong(null, longVal);
|
} catch (NumberFormatException ex) {
|
||||||
success = "\""+fieldName+"\" option set to "+longVal+".";
|
sendMessage("Cannot set \"" + fieldName + "\": integer (whole number) value required.");
|
||||||
}
|
return;
|
||||||
catch(NumberFormatException ex)
|
}
|
||||||
{
|
}
|
||||||
sendMessage("Cannot set \""+fieldName+"\": long integer (whole number) value required.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// double
|
// long
|
||||||
else if (target.getType() == double.class)
|
else if (target.getType() == long.class) {
|
||||||
{
|
try {
|
||||||
try
|
long longVal = Long.parseLong(value);
|
||||||
{
|
target.setLong(null, longVal);
|
||||||
double doubleVal = Double.parseDouble(value);
|
success = "\"" + fieldName + "\" option set to " + longVal + ".";
|
||||||
target.setDouble(null, doubleVal);
|
} catch (NumberFormatException ex) {
|
||||||
success = "\""+fieldName+"\" option set to "+doubleVal+".";
|
sendMessage("Cannot set \"" + fieldName + "\": long integer (whole number) value required.");
|
||||||
}
|
return;
|
||||||
catch(NumberFormatException ex)
|
}
|
||||||
{
|
}
|
||||||
sendMessage("Cannot set \""+fieldName+"\": double (numeric) value required.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// float
|
// double
|
||||||
else if (target.getType() == float.class)
|
else if (target.getType() == double.class) {
|
||||||
{
|
try {
|
||||||
try
|
double doubleVal = Double.parseDouble(value);
|
||||||
{
|
target.setDouble(null, doubleVal);
|
||||||
float floatVal = Float.parseFloat(value);
|
success = "\"" + fieldName + "\" option set to " + doubleVal + ".";
|
||||||
target.setFloat(null, floatVal);
|
} catch (NumberFormatException ex) {
|
||||||
success = "\""+fieldName+"\" option set to "+floatVal+".";
|
sendMessage("Cannot set \"" + fieldName + "\": double (numeric) value required.");
|
||||||
}
|
return;
|
||||||
catch(NumberFormatException ex)
|
}
|
||||||
{
|
}
|
||||||
sendMessage("Cannot set \""+fieldName+"\": float (numeric) value required.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String
|
// float
|
||||||
else if (target.getType() == String.class)
|
else if (target.getType() == float.class) {
|
||||||
{
|
try {
|
||||||
target.set(null, value);
|
float floatVal = Float.parseFloat(value);
|
||||||
success = "\""+fieldName+"\" option set to \""+value+"\".";
|
target.setFloat(null, floatVal);
|
||||||
}
|
success = "\"" + fieldName + "\" option set to " + floatVal + ".";
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
sendMessage("Cannot set \"" + fieldName + "\": float (numeric) value required.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ChatColor
|
// String
|
||||||
else if (target.getType() == ChatColor.class)
|
else if (target.getType() == String.class) {
|
||||||
{
|
target.set(null, value);
|
||||||
ChatColor newColor = null;
|
success = "\"" + fieldName + "\" option set to \"" + value + "\".";
|
||||||
try
|
}
|
||||||
{
|
|
||||||
newColor = ChatColor.valueOf(value.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
// ChatColor
|
||||||
if (newColor == null)
|
else if (target.getType() == ChatColor.class) {
|
||||||
{
|
ChatColor newColor = null;
|
||||||
sendMessage("Cannot set \""+fieldName+"\": \""+value.toUpperCase()+"\" is not a valid color.");
|
try {
|
||||||
return;
|
newColor = ChatColor.valueOf(value.toUpperCase());
|
||||||
}
|
} catch (IllegalArgumentException ex) {
|
||||||
target.set(null, newColor);
|
|
||||||
success = "\""+fieldName+"\" color option set to \""+value.toUpperCase()+"\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set<?> or other parameterized collection
|
}
|
||||||
else if (target.getGenericType() instanceof ParameterizedType)
|
if (newColor == null) {
|
||||||
{
|
sendMessage("Cannot set \"" + fieldName + "\": \"" + value.toUpperCase() + "\" is not a valid color.");
|
||||||
ParameterizedType targSet = (ParameterizedType)target.getGenericType();
|
return;
|
||||||
Type innerType = targSet.getActualTypeArguments()[0];
|
}
|
||||||
|
target.set(null, newColor);
|
||||||
|
success = "\"" + fieldName + "\" color option set to \"" + value.toUpperCase() + "\".";
|
||||||
|
}
|
||||||
|
|
||||||
// not a Set, somehow, and that should be the only collection we're using in Conf.java
|
// Set<?> or other parameterized collection
|
||||||
if (targSet.getRawType() != Set.class)
|
else if (target.getGenericType() instanceof ParameterizedType) {
|
||||||
{
|
ParameterizedType targSet = (ParameterizedType) target.getGenericType();
|
||||||
sendMessage("\""+fieldName+"\" is not a data collection type which can be modified with this command.");
|
Type innerType = targSet.getActualTypeArguments()[0];
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set<Material>
|
// not a Set, somehow, and that should be the only collection we're using in Conf.java
|
||||||
else if (innerType == Material.class)
|
if (targSet.getRawType() != Set.class) {
|
||||||
{
|
sendMessage("\"" + fieldName + "\" is not a data collection type which can be modified with this command.");
|
||||||
Material newMat = null;
|
return;
|
||||||
try
|
}
|
||||||
{
|
|
||||||
newMat = Material.valueOf(value.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
// Set<Material>
|
||||||
if (newMat == null)
|
else if (innerType == Material.class) {
|
||||||
{
|
Material newMat = null;
|
||||||
sendMessage("Cannot change \""+fieldName+"\" set: \""+value.toUpperCase()+"\" is not a valid material.");
|
try {
|
||||||
return;
|
newMat = Material.valueOf(value.toUpperCase());
|
||||||
}
|
} catch (IllegalArgumentException ex) {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
}
|
||||||
Set<Material> matSet = (Set<Material>)target.get(null);
|
if (newMat == null) {
|
||||||
|
sendMessage("Cannot change \"" + fieldName + "\" set: \"" + value.toUpperCase() + "\" is not a valid material.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Material already present, so remove it
|
@SuppressWarnings("unchecked")
|
||||||
if (matSet.contains(newMat))
|
Set<Material> matSet = (Set<Material>) target.get(null);
|
||||||
{
|
|
||||||
matSet.remove(newMat);
|
|
||||||
target.set(null, matSet);
|
|
||||||
success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" removed.";
|
|
||||||
}
|
|
||||||
// Material not present yet, add it
|
|
||||||
else
|
|
||||||
{
|
|
||||||
matSet.add(newMat);
|
|
||||||
target.set(null, matSet);
|
|
||||||
success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" added.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set<String>
|
// Material already present, so remove it
|
||||||
else if (innerType == String.class)
|
if (matSet.contains(newMat)) {
|
||||||
{
|
matSet.remove(newMat);
|
||||||
@SuppressWarnings("unchecked")
|
target.set(null, matSet);
|
||||||
Set<String> stringSet = (Set<String>)target.get(null);
|
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" removed.";
|
||||||
|
}
|
||||||
|
// Material not present yet, add it
|
||||||
|
else {
|
||||||
|
matSet.add(newMat);
|
||||||
|
target.set(null, matSet);
|
||||||
|
success = "\"" + fieldName + "\" set: Material \"" + value.toUpperCase() + "\" added.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// String already present, so remove it
|
// Set<String>
|
||||||
if (stringSet.contains(value))
|
else if (innerType == String.class) {
|
||||||
{
|
@SuppressWarnings("unchecked")
|
||||||
stringSet.remove(value);
|
Set<String> stringSet = (Set<String>) target.get(null);
|
||||||
target.set(null, stringSet);
|
|
||||||
success = "\""+fieldName+"\" set: \""+value+"\" removed.";
|
|
||||||
}
|
|
||||||
// String not present yet, add it
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stringSet.add(value);
|
|
||||||
target.set(null, stringSet);
|
|
||||||
success = "\""+fieldName+"\" set: \""+value+"\" added.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set of unknown type
|
// String already present, so remove it
|
||||||
else
|
if (stringSet.contains(value)) {
|
||||||
{
|
stringSet.remove(value);
|
||||||
sendMessage("\""+fieldName+"\" is not a data type set which can be modified with this command.");
|
target.set(null, stringSet);
|
||||||
return;
|
success = "\"" + fieldName + "\" set: \"" + value + "\" removed.";
|
||||||
}
|
}
|
||||||
}
|
// String not present yet, add it
|
||||||
|
else {
|
||||||
|
stringSet.add(value);
|
||||||
|
target.set(null, stringSet);
|
||||||
|
success = "\"" + fieldName + "\" set: \"" + value + "\" added.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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 which can be modified with this command.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (NoSuchFieldException ex)
|
|
||||||
{
|
|
||||||
sendMessage("Configuration setting \""+fieldName+"\" couldn't be matched, though it should be... please report this error.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (IllegalAccessException ex)
|
|
||||||
{
|
|
||||||
sendMessage("Error setting configuration setting \""+fieldName+"\" to \""+value+"\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success.isEmpty())
|
// unknown type
|
||||||
{
|
else {
|
||||||
if (sender instanceof Player)
|
sendMessage("\"" + fieldName + "\" is not a data type which can be modified with this command.");
|
||||||
{
|
return;
|
||||||
sendMessage(success);
|
}
|
||||||
P.p.log(success + " Command was run by "+fme.getName()+".");
|
} catch (NoSuchFieldException ex) {
|
||||||
}
|
sendMessage("Configuration setting \"" + fieldName + "\" couldn't be matched, though it should be... please report this error.");
|
||||||
else // using P.p.log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
return;
|
||||||
P.p.log(success);
|
} catch (IllegalAccessException ex) {
|
||||||
}
|
sendMessage("Error setting configuration setting \"" + fieldName + "\" to \"" + value + "\".");
|
||||||
// save change to disk
|
return;
|
||||||
Conf.save();
|
}
|
||||||
|
|
||||||
// in case some Spout related setting was changed
|
if (!success.isEmpty()) {
|
||||||
SpoutFeatures.updateAppearances();
|
if (sender instanceof Player) {
|
||||||
}
|
sendMessage(success);
|
||||||
|
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
|
||||||
|
P.p.log(success);
|
||||||
|
}
|
||||||
|
// save change to disk
|
||||||
|
Conf.save();
|
||||||
|
|
||||||
|
// in case some Spout related setting was changed
|
||||||
|
SpoutFeatures.updateAppearances();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,105 +1,91 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("create");
|
||||||
super();
|
|
||||||
this.aliases.add("create");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.CREATE.node;
|
this.permission = Permission.CREATE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||||
if ( ! canAffordCommand(Conf.econCostCreate, "to create a new faction")) return;
|
if (!canAffordCommand(Conf.econCostCreate, "to create a new faction")) return;
|
||||||
|
|
||||||
// trigger the faction creation event (cancellable)
|
// trigger the faction creation event (cancellable)
|
||||||
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
|
FactionCreateEvent createEvent = new FactionCreateEvent(me, tag);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(createEvent);
|
Bukkit.getServer().getPluginManager().callEvent(createEvent);
|
||||||
if(createEvent.isCancelled()) return;
|
if (createEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if ( ! payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
|
if (!payForCommand(Conf.econCostCreate, "to create a new faction", "for creating a new faction")) return;
|
||||||
|
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// finish setting up the Faction
|
// finish setting up the Faction
|
||||||
faction.setTag(tag);
|
faction.setTag(tag);
|
||||||
|
|
||||||
// trigger the faction join event for the creator
|
// trigger the faction join event for the creator
|
||||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me),faction,FPlayerJoinEvent.PlayerJoinReason.CREATE);
|
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me), faction, FPlayerJoinEvent.PlayerJoinReason.CREATE);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||||
// join event cannot be cancelled or you'll have an empty faction
|
// join event cannot be cancelled or you'll have an empty faction
|
||||||
|
|
||||||
// finish setting up the FPlayer
|
// finish setting up the FPlayer
|
||||||
fme.setRole(Role.ADMIN);
|
fme.setRole(Role.ADMIN);
|
||||||
fme.setFaction(faction);
|
fme.setFaction(faction);
|
||||||
|
|
||||||
for (FPlayer follower : FPlayers.i.getOnline())
|
for (FPlayer follower : FPlayers.i.getOnline()) {
|
||||||
{
|
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
|
||||||
follower.msg("%s<i> created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
msg("<i>You should now: %s", p.cmdBase.cmdDescription.getUseageTemplate());
|
msg("<i>You should now: %s", p.cmdBase.cmdDescription.getUseageTemplate());
|
||||||
|
|
||||||
if (Conf.logFactionCreate)
|
if (Conf.logFactionCreate)
|
||||||
P.p.log(fme.getName()+" created a new faction: "+tag);
|
P.p.log(fme.getName() + " created a new faction: " + tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,45 +3,41 @@ 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");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.DEINVITE.node;
|
this.permission = Permission.DEINVITE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
if (you == null) return;
|
||||||
if (you == null) return;
|
|
||||||
|
|
||||||
if (you.getFaction() == myFaction)
|
if (you.getFaction() == myFaction) {
|
||||||
{
|
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
msg("<i>You might want to: %s", p.cmdBase.cmdKick.getUseageTemplate(false));
|
||||||
msg("<i>You might want to: %s", p.cmdBase.cmdKick.getUseageTemplate(false));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
myFaction.deinvite(you);
|
myFaction.deinvite(you);
|
||||||
|
|
||||||
you.msg("%s<i> revoked your invitation to <h>%s<i>.", fme.describeTo(you), myFaction.describeTo(you));
|
you.msg("%s<i> revoked your invitation to <h>%s<i>.", fme.describeTo(you), myFaction.describeTo(you));
|
||||||
|
|
||||||
myFaction.msg("%s<i> revoked %s's<i> invitation.", fme.describeTo(myFaction), you.describeTo(myFaction));
|
myFaction.msg("%s<i> revoked %s's<i> invitation.", fme.describeTo(myFaction), you.describeTo(myFaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,47 +6,43 @@ 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();
|
||||||
{
|
this.aliases.add("desc");
|
||||||
super();
|
|
||||||
this.aliases.add("desc");
|
|
||||||
|
|
||||||
this.requiredArgs.add("desc");
|
this.requiredArgs.add("desc");
|
||||||
this.errorOnToManyArgs = false;
|
this.errorOnToManyArgs = false;
|
||||||
//this.optionalArgs
|
//this.optionalArgs
|
||||||
|
|
||||||
this.permission = Permission.DESCRIPTION.node;
|
this.permission = Permission.DESCRIPTION.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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"))
|
||||||
if ( ! payForCommand(Conf.econCostDesc, "to change faction description", "for changing faction description")) return;
|
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,113 +1,92 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("disband");
|
||||||
super();
|
|
||||||
this.aliases.add("disband");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction tag", "yours");
|
this.optionalArgs.put("faction tag", "yours");
|
||||||
|
|
||||||
this.permission = Permission.DISBAND.node;
|
this.permission = Permission.DISBAND.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
// The faction, default to your own.. but null if console sender.
|
||||||
// The faction, default to your own.. but null if console sender.
|
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
||||||
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
if (faction == null) return;
|
||||||
if (faction == null) return;
|
|
||||||
|
|
||||||
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
||||||
|
|
||||||
if (isMyFaction)
|
if (isMyFaction) {
|
||||||
{
|
if (!assertMinRole(Role.ADMIN)) return;
|
||||||
if ( ! assertMinRole(Role.ADMIN)) return;
|
} else {
|
||||||
}
|
if (!Permission.DISBAND_ANY.has(sender, true)) {
|
||||||
else
|
return;
|
||||||
{
|
}
|
||||||
if ( ! Permission.DISBAND_ANY.has(sender, true))
|
}
|
||||||
{
|
|
||||||
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.");
|
||||||
{
|
return;
|
||||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
|
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
|
||||||
if(disbandEvent.isCancelled()) return;
|
if (disbandEvent.isCancelled()) return;
|
||||||
|
|
||||||
// Send FPlayerLeaveEvent for each player in the faction
|
// Send FPlayerLeaveEvent for each player in the faction
|
||||||
for ( FPlayer fplayer : faction.getFPlayers() )
|
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||||
{
|
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);
|
||||||
{
|
} else {
|
||||||
fplayer.msg("<h>%s<i> disbanded your faction.", who);
|
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
if (Conf.logFactionDisband)
|
||||||
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
P.p.log("The faction " + faction.getTag() + " (" + faction.getId() + ") was disbanded by " + (senderIsConsole ? "console command" : fme.getName()) + ".");
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Conf.logFactionDisband)
|
|
||||||
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()+".");
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
faction.detach();
|
faction.detach();
|
||||||
|
|
||||||
SpoutFeatures.updateAppearances();
|
SpoutFeatures.updateAppearances();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,190 +1,184 @@
|
|||||||
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 {
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.aliases.add("help");
|
|
||||||
this.aliases.add("h");
|
|
||||||
this.aliases.add("?");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
public CmdHelp() {
|
||||||
this.optionalArgs.put("page", "1");
|
super();
|
||||||
|
this.aliases.add("help");
|
||||||
|
this.aliases.add("h");
|
||||||
|
this.aliases.add("?");
|
||||||
|
|
||||||
this.permission = Permission.HELP.node;
|
//this.requiredArgs.add("");
|
||||||
this.disableOnLock = false;
|
this.optionalArgs.put("page", "1");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
this.permission = Permission.HELP.node;
|
||||||
senderMustBeMember = false;
|
this.disableOnLock = false;
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
senderMustBePlayer = false;
|
||||||
public void perform()
|
senderMustBeMember = false;
|
||||||
{
|
senderMustBeModerator = false;
|
||||||
if (helpPages == null) updateHelp();
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
|
|
||||||
int page = this.argAsInt(0, 1);
|
@Override
|
||||||
|
public void perform() {
|
||||||
|
if (helpPages == null) updateHelp();
|
||||||
|
|
||||||
sendMessage(p.txt.titleize("Factions Help ("+page+"/"+helpPages.size()+")"));
|
int page = this.argAsInt(0, 1);
|
||||||
|
|
||||||
page -= 1;
|
sendMessage(p.txt.titleize("Factions Help (" + page + "/" + helpPages.size() + ")"));
|
||||||
|
|
||||||
if (page < 0 || page >= helpPages.size())
|
page -= 1;
|
||||||
{
|
|
||||||
msg("<b>This page does not exist");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendMessage(helpPages.get(page));
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------//
|
if (page < 0 || page >= helpPages.size()) {
|
||||||
// Build the help pages
|
msg("<b>This page does not exist");
|
||||||
//----------------------------------------------//
|
return;
|
||||||
|
}
|
||||||
|
sendMessage(helpPages.get(page));
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<ArrayList<String>> helpPages;
|
//----------------------------------------------//
|
||||||
|
// Build the help pages
|
||||||
|
//----------------------------------------------//
|
||||||
|
|
||||||
public void updateHelp()
|
public ArrayList<ArrayList<String>> helpPages;
|
||||||
{
|
|
||||||
helpPages = new ArrayList<ArrayList<String>>();
|
|
||||||
ArrayList<String> pageLines;
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
public void updateHelp() {
|
||||||
pageLines.add( p.cmdBase.cmdHelp.getUseageTemplate(true) );
|
helpPages = new ArrayList<ArrayList<String>>();
|
||||||
pageLines.add( p.cmdBase.cmdList.getUseageTemplate(true) );
|
ArrayList<String> pageLines;
|
||||||
pageLines.add( p.cmdBase.cmdShow.getUseageTemplate(true) );
|
|
||||||
pageLines.add( p.cmdBase.cmdPower.getUseageTemplate(true) );
|
|
||||||
pageLines.add( p.cmdBase.cmdJoin.getUseageTemplate(true) );
|
|
||||||
pageLines.add( p.cmdBase.cmdLeave.getUseageTemplate(true) );
|
|
||||||
pageLines.add( p.cmdBase.cmdChat.getUseageTemplate(true) );
|
|
||||||
pageLines.add( p.cmdBase.cmdHome.getUseageTemplate(true) );
|
|
||||||
pageLines.add( p.txt.parse("<i>Learn how to create a faction on the next page.") );
|
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add( p.cmdBase.cmdCreate.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdHelp.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdDescription.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdList.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdTag.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdShow.getUseageTemplate(true));
|
||||||
pageLines.add( p.txt.parse("<i>You might want to close it and use invitations:" ));
|
pageLines.add(p.cmdBase.cmdPower.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdOpen.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdInvite.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdDeinvite.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true));
|
||||||
pageLines.add( p.txt.parse("<i>And don't forget to set your home:" ));
|
pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdSethome.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>Learn how to create a faction on the next page."));
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled)
|
pageLines = new ArrayList<String>();
|
||||||
{
|
pageLines.add(p.cmdBase.cmdCreate.getUseageTemplate(true));
|
||||||
pageLines = new ArrayList<String>();
|
pageLines.add(p.cmdBase.cmdDescription.getUseageTemplate(true));
|
||||||
pageLines.add( "" );
|
pageLines.add(p.cmdBase.cmdTag.getUseageTemplate(true));
|
||||||
pageLines.add( p.txt.parse("<i>Your faction has a bank which is used to pay for certain" ));
|
pageLines.add(p.txt.parse("<i>You might want to close it and use invitations:"));
|
||||||
pageLines.add( p.txt.parse("<i>things, so it will need to have money deposited into it." ));
|
pageLines.add(p.cmdBase.cmdOpen.getUseageTemplate(true));
|
||||||
pageLines.add( p.txt.parse("<i>To learn more, use the money command." ));
|
pageLines.add(p.cmdBase.cmdInvite.getUseageTemplate(true));
|
||||||
pageLines.add( "" );
|
pageLines.add(p.cmdBase.cmdDeinvite.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdMoney.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>And don't forget to set your home:"));
|
||||||
pageLines.add( "" );
|
pageLines.add(p.cmdBase.cmdSethome.getUseageTemplate(true));
|
||||||
pageLines.add( "" );
|
helpPages.add(pageLines);
|
||||||
pageLines.add( "" );
|
|
||||||
helpPages.add(pageLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
if (Econ.isSetup() && Conf.econEnabled && Conf.bankEnabled) {
|
||||||
pageLines.add( p.cmdBase.cmdClaim.getUseageTemplate(true) );
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add( p.cmdBase.cmdAutoClaim.getUseageTemplate(true) );
|
pageLines.add("");
|
||||||
pageLines.add( p.cmdBase.cmdUnclaim.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>Your faction has a bank which is used to pay for certain"));
|
||||||
pageLines.add( p.cmdBase.cmdUnclaimall.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>things, so it will need to have money deposited into it."));
|
||||||
pageLines.add( p.cmdBase.cmdKick.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>To learn more, use the money command."));
|
||||||
pageLines.add( p.cmdBase.cmdMod.getUseageTemplate(true) );
|
pageLines.add("");
|
||||||
pageLines.add( p.cmdBase.cmdAdmin.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdMoney.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdTitle.getUseageTemplate(true) );
|
pageLines.add("");
|
||||||
pageLines.add( p.txt.parse("<i>Player titles are just for fun. No rules connected to them." ));
|
pageLines.add("");
|
||||||
helpPages.add(pageLines);
|
pageLines.add("");
|
||||||
|
helpPages.add(pageLines);
|
||||||
|
}
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdClaim.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdBoom.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdAutoClaim.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdUnclaim.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdUnclaimall.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so"));
|
pageLines.add(p.cmdBase.cmdKick.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>that only the owner(s), faction admin, and possibly the"));
|
pageLines.add(p.cmdBase.cmdMod.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>faction moderators have full access."));
|
pageLines.add(p.cmdBase.cmdAdmin.getUseageTemplate(true));
|
||||||
helpPages.add(pageLines);
|
pageLines.add(p.cmdBase.cmdTitle.getUseageTemplate(true));
|
||||||
|
pageLines.add(p.txt.parse("<i>Player titles are just for fun. No rules connected to them."));
|
||||||
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdMap.getUseageTemplate(true));
|
||||||
pageLines.add("");
|
pageLines.add(p.cmdBase.cmdBoom.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdOwner.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdOwnerList.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>Claimed land with ownership set is further protected so"));
|
||||||
pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction."));
|
pageLines.add(p.txt.parse("<i>that only the owner(s), faction admin, and possibly the"));
|
||||||
pageLines.add(p.txt.parse("<i>Your default relation with other factions will be neutral."));
|
pageLines.add(p.txt.parse("<i>faction moderators have full access."));
|
||||||
pageLines.add(p.txt.parse("<i>If BOTH factions choose \"ally\" you will be allies."));
|
helpPages.add(pageLines);
|
||||||
pageLines.add(p.txt.parse("<i>If ONE faction chooses \"enemy\" you will be enemies."));
|
|
||||||
helpPages.add(pageLines);
|
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add(p.txt.parse("<i>You can never hurt members or allies."));
|
pageLines.add(p.cmdBase.cmdDisband.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>You can not hurt neutrals in their own territory."));
|
pageLines.add("");
|
||||||
pageLines.add(p.txt.parse("<i>You can always hurt enemies and players without faction."));
|
pageLines.add(p.cmdBase.cmdRelationAlly.getUseageTemplate(true));
|
||||||
pageLines.add("");
|
pageLines.add(p.cmdBase.cmdRelationNeutral.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>Damage from enemies is reduced in your own territory."));
|
pageLines.add(p.cmdBase.cmdRelationEnemy.getUseageTemplate(true));
|
||||||
pageLines.add(p.txt.parse("<i>When you die you lose power. It is restored over time."));
|
pageLines.add(p.txt.parse("<i>Set the relation you WISH to have with another faction."));
|
||||||
pageLines.add(p.txt.parse("<i>The power of a faction is the sum of all member power."));
|
pageLines.add(p.txt.parse("<i>Your default relation with other factions will be neutral."));
|
||||||
pageLines.add(p.txt.parse("<i>The power of a faction determines how much land it can hold."));
|
pageLines.add(p.txt.parse("<i>If BOTH factions choose \"ally\" you will be allies."));
|
||||||
pageLines.add(p.txt.parse("<i>You can claim land from factions with too little power."));
|
pageLines.add(p.txt.parse("<i>If ONE faction chooses \"enemy\" you will be enemies."));
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add(p.txt.parse("<i>Only faction members can build and destroy in their own"));
|
pageLines.add(p.txt.parse("<i>You can never hurt members or allies."));
|
||||||
pageLines.add(p.txt.parse("<i>territory. Usage of the following items is also restricted:"));
|
pageLines.add(p.txt.parse("<i>You can not hurt neutrals in their own territory."));
|
||||||
pageLines.add(p.txt.parse("<i>Door, Chest, Furnace, Dispenser, Diode."));
|
pageLines.add(p.txt.parse("<i>You can always hurt enemies and players without faction."));
|
||||||
pageLines.add("");
|
pageLines.add("");
|
||||||
pageLines.add(p.txt.parse("<i>Make sure to put pressure plates in front of doors for your"));
|
pageLines.add(p.txt.parse("<i>Damage from enemies is reduced in your own territory."));
|
||||||
pageLines.add(p.txt.parse("<i>guest visitors. Otherwise they can't get through. You can"));
|
pageLines.add(p.txt.parse("<i>When you die you lose power. It is restored over time."));
|
||||||
pageLines.add(p.txt.parse("<i>also use this to create member only areas."));
|
pageLines.add(p.txt.parse("<i>The power of a faction is the sum of all member power."));
|
||||||
pageLines.add(p.txt.parse("<i>As dispensers are protected, you can create traps without"));
|
pageLines.add(p.txt.parse("<i>The power of a faction determines how much land it can hold."));
|
||||||
pageLines.add(p.txt.parse("<i>worrying about those arrows getting stolen."));
|
pageLines.add(p.txt.parse("<i>You can claim land from factions with too little power."));
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add("Finally some commands for the server admins:");
|
pageLines.add(p.txt.parse("<i>Only faction members can build and destroy in their own"));
|
||||||
pageLines.add( p.cmdBase.cmdBypass.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>territory. Usage of the following items is also restricted:"));
|
||||||
pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone"));
|
pageLines.add(p.txt.parse("<i>Door, Chest, Furnace, Dispenser, Diode."));
|
||||||
pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone"));
|
pageLines.add("");
|
||||||
pageLines.add(p.txt.parse("<c>/f autoclaim [safezone|warzone] <i>take a guess"));
|
pageLines.add(p.txt.parse("<i>Make sure to put pressure plates in front of doors for your"));
|
||||||
pageLines.add( p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>guest visitors. Otherwise they can't get through. You can"));
|
||||||
pageLines.add( p.cmdBase.cmdWarunclaimall.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>also use this to create member only areas."));
|
||||||
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well."));
|
pageLines.add(p.txt.parse("<i>As dispensers are protected, you can create traps without"));
|
||||||
pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<i>worrying about those arrows getting stolen."));
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
pageLines.add("Finally some commands for the server admins:");
|
||||||
pageLines.add( p.cmdBase.cmdChatSpy.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdBypass.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<c>/f claim safezone <i>claim land for the Safe Zone"));
|
||||||
pageLines.add( p.cmdBase.cmdPermanentPower.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<c>/f claim warzone <i>claim land for the War Zone"));
|
||||||
pageLines.add( p.cmdBase.cmdPowerBoost.getUseageTemplate(true) );
|
pageLines.add(p.txt.parse("<c>/f autoclaim [safezone|warzone] <i>take a guess"));
|
||||||
pageLines.add( p.cmdBase.cmdConfig.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true));
|
||||||
helpPages.add(pageLines);
|
pageLines.add(p.cmdBase.cmdWarunclaimall.getUseageTemplate(true));
|
||||||
|
pageLines.add(p.txt.parse("<i>Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well."));
|
||||||
|
pageLines.add(p.cmdBase.cmdPeaceful.getUseageTemplate(true));
|
||||||
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
pageLines = new ArrayList<String>();
|
pageLines = new ArrayList<String>();
|
||||||
pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
||||||
pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdChatSpy.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdPermanent.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdSaveAll.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdPermanentPower.getUseageTemplate(true));
|
||||||
pageLines.add( p.cmdBase.cmdVersion.getUseageTemplate(true) );
|
pageLines.add(p.cmdBase.cmdPowerBoost.getUseageTemplate(true));
|
||||||
helpPages.add(pageLines);
|
pageLines.add(p.cmdBase.cmdConfig.getUseageTemplate(true));
|
||||||
}
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
|
pageLines = new ArrayList<String>();
|
||||||
|
pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
||||||
|
pageLines.add(p.cmdBase.cmdLock.getUseageTemplate(true));
|
||||||
|
pageLines.add(p.cmdBase.cmdReload.getUseageTemplate(true));
|
||||||
|
pageLines.add(p.cmdBase.cmdSaveAll.getUseageTemplate(true));
|
||||||
|
pageLines.add(p.cmdBase.cmdVersion.getUseageTemplate(true));
|
||||||
|
helpPages.add(pageLines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,148 +1,132 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.HOME.node;
|
this.permission = Permission.HOME.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
// TODO: Hide this command on help also.
|
||||||
// TODO: Hide this command on help also.
|
if (!Conf.homesEnabled) {
|
||||||
if ( ! Conf.homesEnabled)
|
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
||||||
{
|
return;
|
||||||
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! Conf.homesTeleportCommandEnabled)
|
if (!Conf.homesTeleportCommandEnabled) {
|
||||||
{
|
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
|
||||||
fme.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! myFaction.hasHome())
|
if (!myFaction.hasHome()) {
|
||||||
{
|
fme.msg("<b>Your faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? "<i> Ask your leader to:" : "<i>You should:"));
|
||||||
fme.msg("<b>Your faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? "<i> Ask your leader to:" : "<i>You should:"));
|
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
||||||
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory())
|
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
|
||||||
{
|
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
|
||||||
fme.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID())
|
if (!Conf.homesTeleportAllowedFromDifferentWorld && me.getWorld().getUID() != myFaction.getHome().getWorld().getUID()) {
|
||||||
{
|
fme.msg("<b>You cannot teleport to your faction home while in a different world.");
|
||||||
fme.msg("<b>You cannot teleport to your faction home while in a different world.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Faction faction = Board.getFactionAt(new FLocation(me.getLocation()));
|
Faction faction = Board.getFactionAt(new FLocation(me.getLocation()));
|
||||||
Location loc = me.getLocation().clone();
|
Location loc = me.getLocation().clone();
|
||||||
|
|
||||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
Conf.homesTeleportAllowedEnemyDistance > 0
|
Conf.homesTeleportAllowedEnemyDistance > 0
|
||||||
&&
|
&&
|
||||||
! faction.isSafeZone()
|
!faction.isSafeZone()
|
||||||
&&
|
&&
|
||||||
(
|
(
|
||||||
! fme.isInOwnTerritory()
|
!fme.isInOwnTerritory()
|
||||||
||
|
||
|
||||||
(
|
(
|
||||||
fme.isInOwnTerritory()
|
fme.isInOwnTerritory()
|
||||||
&&
|
&&
|
||||||
! 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;
|
|
||||||
|
|
||||||
FPlayer fp = FPlayers.i.get(p);
|
FPlayer fp = FPlayers.i.get(p);
|
||||||
if (fme.getRelationTo(fp) != Relation.ENEMY)
|
if (fme.getRelationTo(fp) != Relation.ENEMY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Location l = p.getLocation();
|
Location l = p.getLocation();
|
||||||
double dx = Math.abs(x - l.getX());
|
double dx = Math.abs(x - l.getX());
|
||||||
double dy = Math.abs(y - l.getY());
|
double dy = Math.abs(y - l.getY());
|
||||||
double dz = Math.abs(z - l.getZ());
|
double dz = Math.abs(z - l.getZ());
|
||||||
double max = Conf.homesTeleportAllowedEnemyDistance;
|
double max = Conf.homesTeleportAllowedEnemyDistance;
|
||||||
|
|
||||||
// box-shaped distance check
|
// box-shaped distance check
|
||||||
if (dx > max || dy > max || dz > max)
|
if (dx > max || dy > max || dz > max)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fme.msg("<b>You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");
|
fme.msg("<b>You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
|
// if Essentials teleport handling is enabled and available, pass the teleport off to it (for delay and cooldown)
|
||||||
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));
|
smokeLocations.add(myFaction.getHome());
|
||||||
smokeLocations.add(myFaction.getHome());
|
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
||||||
smokeLocations.add(myFaction.getHome().clone().add(0, 1, 0));
|
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
me.teleport(myFaction.getHome());
|
me.teleport(myFaction.getHome());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,46 +4,42 @@ 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();
|
||||||
{
|
this.aliases.add("invite");
|
||||||
super();
|
this.aliases.add("inv");
|
||||||
this.aliases.add("invite");
|
|
||||||
this.aliases.add("inv");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.INVITE.node;
|
this.permission = Permission.INVITE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
if (you == null) return;
|
||||||
if (you == null) return;
|
|
||||||
|
|
||||||
if (you.getFaction() == myFaction)
|
if (you.getFaction() == myFaction) {
|
||||||
{
|
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
||||||
msg("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
|
msg("<i>You might want to: " + p.cmdBase.cmdKick.getUseageTemplate(false));
|
||||||
msg("<i>You might want to: " + p.cmdBase.cmdKick.getUseageTemplate(false));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return;
|
if (!payForCommand(Conf.econCostInvite, "to invite someone", "for inviting someone")) return;
|
||||||
|
|
||||||
myFaction.invite(you);
|
myFaction.invite(you);
|
||||||
|
|
||||||
you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
|
you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
|
||||||
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), you.describeTo(myFaction));
|
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), you.describeTo(myFaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,114 +1,98 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("join");
|
||||||
super();
|
|
||||||
this.aliases.add("join");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction name");
|
this.requiredArgs.add("faction name");
|
||||||
this.optionalArgs.put("player", "you");
|
this.optionalArgs.put("player", "you");
|
||||||
|
|
||||||
this.permission = Permission.JOIN.node;
|
this.permission = Permission.JOIN.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction faction = this.argAsFaction(0);
|
||||||
Faction faction = this.argAsFaction(0);
|
if (faction == null) return;
|
||||||
if (faction == null) return;
|
|
||||||
|
|
||||||
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));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||||
if (samePlayer && ! canAffordCommand(Conf.econCostJoin, "to join a faction")) return;
|
if (samePlayer && !canAffordCommand(Conf.econCostJoin, "to join a faction")) return;
|
||||||
|
|
||||||
// trigger the join event (cancellable)
|
// trigger the join event (cancellable)
|
||||||
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.i.get(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
Bukkit.getServer().getPluginManager().callEvent(joinEvent);
|
||||||
if (joinEvent.isCancelled()) return;
|
if (joinEvent.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if (samePlayer && ! payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return;
|
if (samePlayer && !payForCommand(Conf.econCostJoin, "to join a faction", "for joining a faction")) return;
|
||||||
|
|
||||||
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
|
fme.msg("<i>%s successfully joined %s.", fplayer.describeTo(fme, true), faction.getTag(fme));
|
||||||
|
|
||||||
if (!samePlayer)
|
if (!samePlayer)
|
||||||
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
fplayer.msg("<i>%s moved you into the faction %s.", fme.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||||
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
faction.msg("<i>%s joined your faction.", fplayer.describeTo(faction, true));
|
||||||
|
|
||||||
fplayer.resetFactionData();
|
fplayer.resetFactionData();
|
||||||
fplayer.setFaction(faction);
|
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
|
P.p.log("%s moved the player %s into the faction %s.", fme.getName(), fplayer.getName(), faction.getTag());
|
||||||
P.p.log("%s moved the player %s into the faction %s.", fme.getName(), fplayer.getName(), faction.getTag());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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,91 +7,84 @@ 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");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.KICK.node;
|
this.permission = Permission.KICK.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
if (you == null) return;
|
||||||
if (you == null) return;
|
|
||||||
|
|
||||||
if (fme == you)
|
if (fme == you) {
|
||||||
{
|
msg("<b>You cannot kick yourself.");
|
||||||
msg("<b>You cannot kick yourself.");
|
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
|
||||||
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Faction yourFaction = you.getFaction();
|
Faction yourFaction = you.getFaction();
|
||||||
|
|
||||||
// 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));
|
||||||
{
|
return;
|
||||||
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme));
|
}
|
||||||
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;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||||
if ( ! canAffordCommand(Conf.econCostKick, "to kick someone from the faction")) return;
|
if (!canAffordCommand(Conf.econCostKick, "to kick someone from the faction")) return;
|
||||||
|
|
||||||
// trigger the leave event (cancellable) [reason:kicked]
|
// trigger the leave event (cancellable) [reason:kicked]
|
||||||
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
FPlayerLeaveEvent event = new FPlayerLeaveEvent(you, you.getFaction(), FPlayerLeaveEvent.PlayerLeaveReason.KICKED);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// then make 'em pay (if applicable)
|
||||||
if ( ! payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) 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));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Conf.logFactionKick)
|
if (Conf.logFactionKick)
|
||||||
P.p.log((senderIsConsole ? "A console command" : fme.getName())+" kicked "+you.getName()+" from the faction: "+yourFaction.getTag());
|
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + you.getName() + " from the faction: " + yourFaction.getTag());
|
||||||
|
|
||||||
if (you.getRole() == Role.ADMIN)
|
if (you.getRole() == Role.ADMIN)
|
||||||
yourFaction.promoteNewLeader();
|
yourFaction.promoteNewLeader();
|
||||||
|
|
||||||
yourFaction.deinvite(you);
|
yourFaction.deinvite(you);
|
||||||
you.resetFactionData();
|
you.resetFactionData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,25 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdLeave extends FCommand {
|
public class CmdLeave extends FCommand {
|
||||||
|
|
||||||
public CmdLeave()
|
public CmdLeave() {
|
||||||
{
|
super();
|
||||||
super();
|
this.aliases.add("leave");
|
||||||
this.aliases.add("leave");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.LEAVE.node;
|
this.permission = Permission.LEAVE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = true;
|
senderMustBeMember = true;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
fme.leave(true);
|
||||||
fme.leave(true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,79 +1,76 @@
|
|||||||
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 {
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.aliases.add("list");
|
|
||||||
this.aliases.add("ls");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
public CmdList() {
|
||||||
this.optionalArgs.put("page", "1");
|
super();
|
||||||
|
this.aliases.add("list");
|
||||||
|
this.aliases.add("ls");
|
||||||
|
|
||||||
this.permission = Permission.LIST.node;
|
//this.requiredArgs.add("");
|
||||||
this.disableOnLock = false;
|
this.optionalArgs.put("page", "1");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
this.permission = Permission.LIST.node;
|
||||||
senderMustBeMember = false;
|
this.disableOnLock = false;
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
senderMustBePlayer = false;
|
||||||
public void perform()
|
senderMustBeMember = false;
|
||||||
{
|
senderMustBeModerator = false;
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
senderMustBeAdmin = false;
|
||||||
if ( ! payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return;
|
}
|
||||||
|
|
||||||
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
@Override
|
||||||
factionList.remove(Factions.i.getNone());
|
public void perform() {
|
||||||
factionList.remove(Factions.i.getSafeZone());
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
factionList.remove(Factions.i.getWarZone());
|
if (!payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return;
|
||||||
|
|
||||||
// Sort by total followers first
|
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
||||||
Collections.sort(factionList, new Comparator<Faction>(){
|
factionList.remove(Factions.i.getNone());
|
||||||
@Override
|
factionList.remove(Factions.i.getSafeZone());
|
||||||
public int compare(Faction f1, Faction f2) {
|
factionList.remove(Factions.i.getWarZone());
|
||||||
int f1Size = f1.getFPlayers().size();
|
|
||||||
int f2Size = f2.getFPlayers().size();
|
|
||||||
if (f1Size < f2Size)
|
|
||||||
return 1;
|
|
||||||
else if (f1Size > f2Size)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Then sort by how many members are online now
|
// Sort by total followers first
|
||||||
Collections.sort(factionList, new Comparator<Faction>(){
|
Collections.sort(factionList, new Comparator<Faction>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Faction f1, Faction f2) {
|
public int compare(Faction f1, Faction f2) {
|
||||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
int f1Size = f1.getFPlayers().size();
|
||||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
int f2Size = f2.getFPlayers().size();
|
||||||
if (f1Size < f2Size)
|
if (f1Size < f2Size)
|
||||||
return 1;
|
return 1;
|
||||||
else if (f1Size > f2Size)
|
else if (f1Size > f2Size)
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ArrayList<String> lines = new ArrayList<String>();
|
// Then sort by how many members are online now
|
||||||
|
Collections.sort(factionList, new Comparator<Faction>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Faction f1, Faction f2) {
|
||||||
|
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||||
|
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||||
|
if (f1Size < f2Size)
|
||||||
|
return 1;
|
||||||
|
else if (f1Size > f2Size)
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ArrayList<String> lines = new ArrayList<String>();
|
||||||
|
|
||||||
/* // this code was really slow on large servers, getting full info for every faction and then only showing 9 of them; rewritten below
|
/* // this code was really slow on large servers, getting full info for every faction and then only showing 9 of them; rewritten below
|
||||||
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()));
|
||||||
for (Faction faction : factionList)
|
for (Faction faction : factionList)
|
||||||
{
|
{
|
||||||
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
||||||
@ -89,39 +86,37 @@ public class CmdList extends FCommand
|
|||||||
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Faction List"));
|
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Faction List"));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
factionList.add(0, Factions.i.getNone());
|
factionList.add(0, Factions.i.getNone());
|
||||||
|
|
||||||
final int pageheight = 9;
|
final int pageheight = 9;
|
||||||
int pagenumber = this.argAsInt(0, 1);
|
int pagenumber = this.argAsInt(0, 1);
|
||||||
int pagecount = (factionList.size() / pageheight) + 1;
|
int pagecount = (factionList.size() / pageheight) + 1;
|
||||||
if (pagenumber > pagecount)
|
if (pagenumber > pagecount)
|
||||||
pagenumber = pagecount;
|
pagenumber = pagecount;
|
||||||
else if (pagenumber < 1)
|
else if (pagenumber < 1)
|
||||||
pagenumber = 1;
|
pagenumber = 1;
|
||||||
int start = (pagenumber - 1) * pageheight;
|
int start = (pagenumber - 1) * pageheight;
|
||||||
int end = start + pageheight;
|
int end = start + pageheight;
|
||||||
if (end > factionList.size())
|
if (end > factionList.size())
|
||||||
end = factionList.size();
|
end = factionList.size();
|
||||||
|
|
||||||
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()));
|
||||||
{
|
continue;
|
||||||
lines.add(p.txt.parse("<i>Factionless<i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
|
}
|
||||||
continue;
|
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
||||||
}
|
faction.getTag(fme),
|
||||||
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
faction.getFPlayersWhereOnline(true).size(),
|
||||||
faction.getTag(fme),
|
faction.getFPlayers().size(),
|
||||||
faction.getFPlayersWhereOnline(true).size(),
|
faction.getLandRounded(),
|
||||||
faction.getFPlayers().size(),
|
faction.getPowerRounded(),
|
||||||
faction.getLandRounded(),
|
faction.getPowerMaxRounded())
|
||||||
faction.getPowerRounded(),
|
);
|
||||||
faction.getPowerMaxRounded())
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage(lines);
|
sendMessage(lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,43 +4,38 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
|
|
||||||
public class CmdLock extends FCommand {
|
public class CmdLock extends FCommand {
|
||||||
|
|
||||||
// TODO: This solution needs refactoring.
|
// TODO: This solution needs refactoring.
|
||||||
/*
|
/*
|
||||||
factions.lock:
|
factions.lock:
|
||||||
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
||||||
default: op
|
default: op
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CmdLock()
|
public CmdLock() {
|
||||||
{
|
super();
|
||||||
super();
|
this.aliases.add("lock");
|
||||||
this.aliases.add("lock");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "flip");
|
this.optionalArgs.put("on/off", "flip");
|
||||||
|
|
||||||
this.permission = Permission.LOCK.node;
|
this.permission = Permission.LOCK.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
}
|
msg("<i>Factions in now unlocked");
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
msg("<i>Factions in now unlocked");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,62 +6,52 @@ 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();
|
||||||
{
|
this.aliases.add("map");
|
||||||
super();
|
|
||||||
this.aliases.add("map");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("on/off", "once");
|
this.optionalArgs.put("on/off", "once");
|
||||||
|
|
||||||
this.permission = Permission.MAP.node;
|
this.permission = Permission.MAP.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (this.argIsSet(0)) {
|
||||||
if (this.argIsSet(0))
|
if (this.argAsBool(0, !fme.isMapAutoUpdating())) {
|
||||||
{
|
// Turn on
|
||||||
if (this.argAsBool(0, ! fme.isMapAutoUpdating()))
|
|
||||||
{
|
|
||||||
// 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
|
||||||
if ( ! payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return;
|
if (!payForCommand(Conf.econCostMap, "to show the map", "for showing the map")) return;
|
||||||
|
|
||||||
fme.setMapAutoUpdating(true);
|
fme.setMapAutoUpdating(true);
|
||||||
msg("<i>Map auto update <green>ENABLED.");
|
msg("<i>Map auto update <green>ENABLED.");
|
||||||
|
|
||||||
// And show the map once
|
// And show the map once
|
||||||
showMap();
|
showMap();
|
||||||
}
|
} else {
|
||||||
else
|
// Turn off
|
||||||
{
|
fme.setMapAutoUpdating(false);
|
||||||
// Turn off
|
msg("<i>Map auto update <red>DISABLED.");
|
||||||
fme.setMapAutoUpdating(false);
|
}
|
||||||
msg("<i>Map auto update <red>DISABLED.");
|
} else {
|
||||||
}
|
// 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;
|
||||||
else
|
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
showMap();
|
showMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,77 +1,67 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
this.requiredArgs.add("player name");
|
this.requiredArgs.add("player name");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MOD.node;
|
this.permission = Permission.MOD.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
if (you == null) return;
|
||||||
if (you == null) return;
|
|
||||||
|
|
||||||
boolean permAny = Permission.MOD_ANY.has(sender, false);
|
boolean permAny = Permission.MOD_ANY.has(sender, false);
|
||||||
Faction targetFaction = you.getFaction();
|
Faction targetFaction = you.getFaction();
|
||||||
|
|
||||||
if (targetFaction != myFaction && !permAny)
|
if (targetFaction != myFaction && !permAny) {
|
||||||
{
|
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
|
||||||
msg("%s<b> is not a member in your faction.", you.describeTo(fme, true));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fme != null && fme.getRole() != Role.ADMIN && !permAny)
|
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
||||||
{
|
msg("<b>You are not the faction admin.");
|
||||||
msg("<b>You are not the faction admin.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (you == fme && !permAny)
|
if (you == fme && !permAny) {
|
||||||
{
|
msg("<b>The target player musn't be yourself.");
|
||||||
msg("<b>The target player musn't be yourself.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (you.getRole() == Role.ADMIN)
|
if (you.getRole() == Role.ADMIN) {
|
||||||
{
|
msg("<b>The target player is a faction admin. Demote them first.");
|
||||||
msg("<b>The target player is a faction admin. Demote them first.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (you.getRole() == Role.MODERATOR)
|
if (you.getRole() == Role.MODERATOR) {
|
||||||
{
|
// 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 {
|
||||||
}
|
// Give
|
||||||
else
|
you.setRole(Role.MODERATOR);
|
||||||
{
|
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
|
||||||
// Give
|
msg("<i>You have promoted %s<i> to moderator.", you.describeTo(fme, true));
|
||||||
you.setRole(Role.MODERATOR);
|
}
|
||||||
targetFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(targetFaction, true));
|
}
|
||||||
msg("<i>You have promoted %s<i> to moderator.", you.describeTo(fme, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,46 +2,43 @@ 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();
|
public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf();
|
||||||
public CmdMoneyTransferFf cmdMoneyTransferFf = new CmdMoneyTransferFf();
|
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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("","")
|
//this.optionalArgs.put("","")
|
||||||
|
|
||||||
this.isMoneyCommand = true;
|
this.isMoneyCommand = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("faction money commands");
|
this.setHelpShort("faction money commands");
|
||||||
this.helpLong.add(p.txt.parseTags("<i>The faction money commands."));
|
this.helpLong.add(p.txt.parseTags("<i>The faction money commands."));
|
||||||
|
|
||||||
this.addSubCommand(this.cmdMoneyBalance);
|
this.addSubCommand(this.cmdMoneyBalance);
|
||||||
this.addSubCommand(this.cmdMoneyDeposit);
|
this.addSubCommand(this.cmdMoneyDeposit);
|
||||||
this.addSubCommand(this.cmdMoneyWithdraw);
|
this.addSubCommand(this.cmdMoneyWithdraw);
|
||||||
this.addSubCommand(this.cmdMoneyTransferFf);
|
this.addSubCommand(this.cmdMoneyTransferFf);
|
||||||
this.addSubCommand(this.cmdMoneyTransferFp);
|
this.addSubCommand(this.cmdMoneyTransferFp);
|
||||||
this.addSubCommand(this.cmdMoneyTransferPf);
|
this.addSubCommand(this.cmdMoneyTransferPf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
this.commandChain.add(this);
|
||||||
this.commandChain.add(this);
|
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
||||||
P.p.cmdAutoHelp.execute(this.sender, this.args, this.commandChain);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,38 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("b");
|
||||||
super();
|
this.aliases.add("balance");
|
||||||
this.aliases.add("b");
|
|
||||||
this.aliases.add("balance");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction", "yours");
|
this.optionalArgs.put("faction", "yours");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_BALANCE.node;
|
this.permission = Permission.MONEY_BALANCE.node;
|
||||||
this.setHelpShort("show faction balance");
|
this.setHelpShort("show faction balance");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction faction = myFaction;
|
||||||
Faction faction = myFaction;
|
if (this.argIsSet(0)) {
|
||||||
if (this.argIsSet(0))
|
faction = this.argAsFaction(0);
|
||||||
{
|
}
|
||||||
faction = this.argAsFaction(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
if (faction != myFaction && ! Permission.MONEY_BALANCE_ANY.has(sender, true)) return;
|
if (faction != myFaction && !Permission.MONEY_BALANCE_ANY.has(sender, true)) return;
|
||||||
|
|
||||||
Econ.sendBalanceInfo(fme, faction);
|
Econ.sendBalanceInfo(fme, faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,41 +5,37 @@ 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");
|
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount");
|
||||||
this.optionalArgs.put("faction", "yours");
|
this.optionalArgs.put("faction", "yours");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_DEPOSIT.node;
|
this.permission = Permission.MONEY_DEPOSIT.node;
|
||||||
this.setHelpShort("deposit money");
|
this.setHelpShort("deposit money");
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
double amount = this.argAsDouble(0, 0d);
|
||||||
double amount = this.argAsDouble(0, 0d);
|
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
if (faction == null) return;
|
||||||
if (faction == null) return;
|
boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
||||||
boolean success = Econ.transferMoney(fme, fme, faction, amount);
|
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions)
|
if (success && Conf.logMoneyTransactions)
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s deposited %s in the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,43 @@
|
|||||||
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");
|
||||||
this.requiredArgs.add("faction");
|
this.requiredArgs.add("faction");
|
||||||
this.requiredArgs.add("faction");
|
this.requiredArgs.add("faction");
|
||||||
|
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_F2F.node;
|
this.permission = Permission.MONEY_F2F.node;
|
||||||
this.setHelpShort("transfer f -> f");
|
this.setHelpShort("transfer f -> f");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
double amount = this.argAsDouble(0, 0d);
|
||||||
double amount = this.argAsDouble(0, 0d);
|
EconomyParticipator from = this.argAsFaction(1);
|
||||||
EconomyParticipator from = this.argAsFaction(1);
|
if (from == null) return;
|
||||||
if (from == null) return;
|
EconomyParticipator to = this.argAsFaction(2);
|
||||||
EconomyParticipator to = this.argAsFaction(2);
|
if (to == null) return;
|
||||||
if (to == null) return;
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions)
|
if (success && Conf.logMoneyTransactions)
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,43 @@
|
|||||||
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");
|
||||||
this.requiredArgs.add("faction");
|
this.requiredArgs.add("faction");
|
||||||
this.requiredArgs.add("player");
|
this.requiredArgs.add("player");
|
||||||
|
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_F2P.node;
|
this.permission = Permission.MONEY_F2P.node;
|
||||||
this.setHelpShort("transfer f -> p");
|
this.setHelpShort("transfer f -> p");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
double amount = this.argAsDouble(0, 0d);
|
||||||
double amount = this.argAsDouble(0, 0d);
|
EconomyParticipator from = this.argAsFaction(1);
|
||||||
EconomyParticipator from = this.argAsFaction(1);
|
if (from == null) return;
|
||||||
if (from == null) return;
|
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
||||||
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
|
if (to == null) return;
|
||||||
if (to == null) return;
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions)
|
if (success && Conf.logMoneyTransactions)
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,43 @@
|
|||||||
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");
|
||||||
this.requiredArgs.add("player");
|
this.requiredArgs.add("player");
|
||||||
this.requiredArgs.add("faction");
|
this.requiredArgs.add("faction");
|
||||||
|
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_P2F.node;
|
this.permission = Permission.MONEY_P2F.node;
|
||||||
this.setHelpShort("transfer p -> f");
|
this.setHelpShort("transfer p -> f");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
double amount = this.argAsDouble(0, 0d);
|
||||||
double amount = this.argAsDouble(0, 0d);
|
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
||||||
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
|
if (from == null) return;
|
||||||
if (from == null) return;
|
EconomyParticipator to = this.argAsFaction(2);
|
||||||
EconomyParticipator to = this.argAsFaction(2);
|
if (to == null) return;
|
||||||
if (to == null) return;
|
|
||||||
|
|
||||||
boolean success = Econ.transferMoney(fme, from, to, amount);
|
boolean success = Econ.transferMoney(fme, from, to, amount);
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions)
|
if (success && Conf.logMoneyTransactions)
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", fme.getName(), Econ.moneyString(amount), from.describeTo(null), to.describeTo(null))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,38 @@
|
|||||||
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("withdraw");
|
||||||
this.aliases.add("w");
|
|
||||||
this.aliases.add("withdraw");
|
|
||||||
|
|
||||||
this.requiredArgs.add("amount");
|
this.requiredArgs.add("amount");
|
||||||
this.optionalArgs.put("faction", "yours");
|
this.optionalArgs.put("faction", "yours");
|
||||||
|
|
||||||
this.permission = Permission.MONEY_WITHDRAW.node;
|
this.permission = Permission.MONEY_WITHDRAW.node;
|
||||||
this.setHelpShort("withdraw money");
|
this.setHelpShort("withdraw money");
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
double amount = this.argAsDouble(0, 0d);
|
||||||
double amount = this.argAsDouble(0, 0d);
|
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
||||||
EconomyParticipator faction = this.argAsFaction(1, myFaction);
|
if (faction == null) return;
|
||||||
if (faction == null) return;
|
boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
||||||
boolean success = Econ.transferMoney(fme, faction, fme, amount);
|
|
||||||
|
|
||||||
if (success && Conf.logMoneyTransactions)
|
if (success && Conf.logMoneyTransactions)
|
||||||
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
P.p.log(ChatColor.stripColor(P.p.txt.parse("%s withdrew %s from the faction bank: %s", fme.getName(), Econ.moneyString(amount), faction.describeTo(null))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,45 +5,41 @@ 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();
|
||||||
{
|
this.aliases.add("open");
|
||||||
super();
|
|
||||||
this.aliases.add("open");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("yes/no", "flip");
|
this.optionalArgs.put("yes/no", "flip");
|
||||||
|
|
||||||
this.permission = Permission.OPEN.node;
|
this.permission = Permission.OPEN.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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"))
|
||||||
if ( ! payForCommand(Conf.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return;
|
return;
|
||||||
|
|
||||||
myFaction.setOpen(this.argAsBool(0, ! myFaction.getOpen()));
|
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
||||||
|
|
||||||
String open = myFaction.getOpen() ? "open" : "closed";
|
String open = myFaction.getOpen() ? "open" : "closed";
|
||||||
|
|
||||||
// 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,115 +1,100 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("player name", "you");
|
this.optionalArgs.put("player name", "you");
|
||||||
|
|
||||||
this.permission = Permission.OWNER.node;
|
this.permission = Permission.OWNER.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.");
|
||||||
{
|
return;
|
||||||
fme.msg("<b>This land is not claimed by your faction, so you can't set ownership of it.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! factionHere.isNormal())
|
if (!factionHere.isNormal()) {
|
||||||
{
|
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible.");
|
||||||
fme.msg("<b>This land is not claimed by a faction. Ownership is not possible.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||||
if (target == null) return;
|
if (target == null) return;
|
||||||
|
|
||||||
String playerName = target.getName();
|
String playerName = target.getName();
|
||||||
|
|
||||||
if (target.getFaction() != myFaction)
|
if (target.getFaction() != myFaction) {
|
||||||
{
|
fme.msg("%s<i> is not a member of this faction.", playerName);
|
||||||
fme.msg("%s<i> is not a member of this faction.", playerName);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if no player name was passed, and this claim does already have owners set, clear them
|
// if no player name was passed, and this claim does already have owners set, clear them
|
||||||
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation))
|
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
|
||||||
{
|
myFaction.clearClaimOwnership(flocation);
|
||||||
myFaction.clearClaimOwnership(flocation);
|
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);
|
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(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);
|
||||||
|
|
||||||
fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName);
|
fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,68 +6,59 @@ 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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.OWNERLIST.node;
|
this.permission = Permission.OWNERLIST.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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.");
|
||||||
{
|
return;
|
||||||
fme.msg("<b>This land is not claimed by your faction.");
|
}
|
||||||
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;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String owners = myFaction.getOwnerListString(flocation);
|
String owners = myFaction.getOwnerListString(flocation);
|
||||||
|
|
||||||
if (owners == null || owners.isEmpty())
|
if (owners == null || owners.isEmpty()) {
|
||||||
{
|
fme.msg("<i>No owners are set here; everyone in the faction has access.");
|
||||||
fme.msg("<i>No owners are set here; everyone in the faction has access.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fme.msg("<i>Current owner(s) of this land: %s", owners);
|
fme.msg("<i>Current owner(s) of this land: %s", owners);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,53 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SET_PEACEFUL.node;
|
this.permission = Permission.SET_PEACEFUL.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction faction = this.argAsFaction(0);
|
||||||
Faction faction = this.argAsFaction(0);
|
if (faction == null) return;
|
||||||
if (faction == null) return;
|
|
||||||
|
|
||||||
String change;
|
String change;
|
||||||
if (faction.isPeaceful())
|
if (faction.isPeaceful()) {
|
||||||
{
|
change = "removed peaceful status from";
|
||||||
change = "removed peaceful status from";
|
faction.setPeaceful(false);
|
||||||
faction.setPeaceful(false);
|
} else {
|
||||||
}
|
change = "granted peaceful status to";
|
||||||
else
|
faction.setPeaceful(true);
|
||||||
{
|
}
|
||||||
change = "granted peaceful status to";
|
|
||||||
faction.setPeaceful(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
if (fplayer.getFaction() == faction) {
|
||||||
if (fplayer.getFaction() == faction)
|
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true)) + "<i> has " + change + " your faction.");
|
||||||
{
|
} else {
|
||||||
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 + " the faction \"" + faction.getTag(fplayer) + "<i>\".");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "<i>\".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SpoutFeatures.updateAppearances(faction);
|
SpoutFeatures.updateAppearances(faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,62 +1,52 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("permanent");
|
||||||
super();
|
|
||||||
this.aliases.add("permanent");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
this.requiredArgs.add("faction tag");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SET_PERMANENT.node;
|
this.permission = Permission.SET_PERMANENT.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction faction = this.argAsFaction(0);
|
||||||
Faction faction = this.argAsFaction(0);
|
if (faction == null) return;
|
||||||
if (faction == null) return;
|
|
||||||
|
|
||||||
String change;
|
String change;
|
||||||
if(faction.isPermanent())
|
if (faction.isPermanent()) {
|
||||||
{
|
change = "removed permanent status from";
|
||||||
change = "removed permanent status from";
|
faction.setPermanent(false);
|
||||||
faction.setPermanent(false);
|
} else {
|
||||||
}
|
change = "added permanent status to";
|
||||||
else
|
faction.setPermanent(true);
|
||||||
{
|
}
|
||||||
change = "added permanent status to";
|
|
||||||
faction.setPermanent(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
P.p.log((fme == null ? "A server admin" : fme.getName())+" "+change+" the faction \"" + faction.getTag() + "\".");
|
P.p.log((fme == null ? "A server admin" : fme.getName()) + " " + change + " the faction \"" + faction.getTag() + "\".");
|
||||||
|
|
||||||
// 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.");
|
||||||
{
|
} else {
|
||||||
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 + " the faction \"" + faction.getTag(fplayer) + "\".");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,45 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("permanentpower");
|
||||||
super();
|
|
||||||
this.aliases.add("permanentpower");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction");
|
this.requiredArgs.add("faction");
|
||||||
this.optionalArgs.put("power", "reset");
|
this.optionalArgs.put("power", "reset");
|
||||||
|
|
||||||
this.permission = Permission.SET_PERMANENTPOWER.node;
|
this.permission = Permission.SET_PERMANENTPOWER.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction targetFaction = this.argAsFaction(0);
|
||||||
Faction targetFaction = this.argAsFaction(0);
|
if (targetFaction == null) return;
|
||||||
if (targetFaction == null) return;
|
|
||||||
|
|
||||||
Integer targetPower = this.argAsInt(1);
|
Integer targetPower = this.argAsInt(1);
|
||||||
|
|
||||||
targetFaction.setPermanentPower(targetPower);
|
targetFaction.setPermanentPower(targetPower);
|
||||||
|
|
||||||
String change = "removed permanentpower status from";
|
String change = "removed permanentpower status from";
|
||||||
if(targetFaction.hasPermanentPower())
|
if (targetFaction.hasPermanentPower()) {
|
||||||
{
|
change = "added permanentpower status to";
|
||||||
change = "added permanentpower status to";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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,41 +4,38 @@ 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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("faction tag");
|
//this.requiredArgs.add("faction tag");
|
||||||
this.optionalArgs.put("player name", "you");
|
this.optionalArgs.put("player name", "you");
|
||||||
|
|
||||||
this.permission = Permission.POWER.node;
|
this.permission = Permission.POWER.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
||||||
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
|
if (target == null) return;
|
||||||
if (target == null) return;
|
|
||||||
|
|
||||||
if (target != fme && ! Permission.POWER_ANY.has(sender, true)) return;
|
if (target != fme && !Permission.POWER_ANY.has(sender, true)) return;
|
||||||
|
|
||||||
// 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.econCostPower, "to show player power info", "for showing player power info")) return;
|
if (!payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) return;
|
||||||
|
|
||||||
double powerBoost = target.getPowerBoost();
|
double powerBoost = target.getPowerBoost();
|
||||||
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||||
msg("%s<a> - Power / Maxpower: <i>%d / %d %s", target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost);
|
msg("%s<a> - Power / Maxpower: <i>%d / %d %s", target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,72 +1,62 @@
|
|||||||
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();
|
||||||
{
|
this.aliases.add("powerboost");
|
||||||
super();
|
|
||||||
this.aliases.add("powerboost");
|
|
||||||
|
|
||||||
this.requiredArgs.add("p|f|player|faction");
|
this.requiredArgs.add("p|f|player|faction");
|
||||||
this.requiredArgs.add("name");
|
this.requiredArgs.add("name");
|
||||||
this.requiredArgs.add("#");
|
this.requiredArgs.add("#");
|
||||||
|
|
||||||
this.permission = Permission.POWERBOOST.node;
|
this.permission = Permission.POWERBOOST.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
String type = this.argAsString(0).toLowerCase();
|
||||||
String type = this.argAsString(0).toLowerCase();
|
boolean doPlayer = true;
|
||||||
boolean doPlayer = true;
|
if (type.equals("f") || type.equals("faction")) {
|
||||||
if (type.equals("f") || type.equals("faction"))
|
doPlayer = false;
|
||||||
{
|
} else if (!type.equals("p") && !type.equals("player")) {
|
||||||
doPlayer = false;
|
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");
|
||||||
else if (!type.equals("p") && !type.equals("player"))
|
return;
|
||||||
{
|
}
|
||||||
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");
|
|
||||||
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 {
|
||||||
}
|
Faction targetFaction = this.argAsFaction(1);
|
||||||
else
|
if (targetFaction == null) return;
|
||||||
{
|
targetFaction.setPowerBoost(targetPower);
|
||||||
Faction targetFaction = this.argAsFaction(1);
|
target = "Faction \"" + targetFaction.getTag() + "\"";
|
||||||
if (targetFaction == null) return;
|
}
|
||||||
targetFaction.setPowerBoost(targetPower);
|
|
||||||
target = "Faction \""+targetFaction.getTag()+"\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
|
msg("<i>" + target + " now has a power bonus/penalty of " + targetPower + " to min and max power levels.");
|
||||||
if (!senderIsConsole)
|
if (!senderIsConsole)
|
||||||
P.p.log(fme.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
|
P.p.log(fme.getName() + " has set the power bonus/penalty for " + target + " to " + targetPower + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,9 @@ 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");
|
||||||
{
|
targetRelation = Relation.ALLY;
|
||||||
aliases.add("ally");
|
}
|
||||||
targetRelation = Relation.ALLY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,9 @@ 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");
|
||||||
{
|
targetRelation = Relation.ENEMY;
|
||||||
aliases.add("enemy");
|
}
|
||||||
targetRelation = Relation.ENEMY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,9 @@ 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");
|
||||||
{
|
targetRelation = Relation.NEUTRAL;
|
||||||
aliases.add("neutral");
|
}
|
||||||
targetRelation = Relation.NEUTRAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,60 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
this.optionalArgs.put("file", "all");
|
this.optionalArgs.put("file", "all");
|
||||||
|
|
||||||
this.permission = Permission.RELOAD.node;
|
this.permission = Permission.RELOAD.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
long timeInitStart = System.currentTimeMillis();
|
||||||
long timeInitStart = System.currentTimeMillis();
|
String file = this.argAsString(0, "all").toLowerCase();
|
||||||
String file = this.argAsString(0, "all").toLowerCase();
|
|
||||||
|
|
||||||
String fileName;
|
String fileName;
|
||||||
|
|
||||||
if (file.startsWith("c"))
|
if (file.startsWith("c")) {
|
||||||
{
|
Conf.load();
|
||||||
Conf.load();
|
fileName = "conf.json";
|
||||||
fileName = "conf.json";
|
} else if (file.startsWith("b")) {
|
||||||
}
|
Board.load();
|
||||||
else if (file.startsWith("b"))
|
fileName = "board.json";
|
||||||
{
|
} else if (file.startsWith("f")) {
|
||||||
Board.load();
|
Factions.i.loadFromDisc();
|
||||||
fileName = "board.json";
|
fileName = "factions.json";
|
||||||
}
|
} else if (file.startsWith("p")) {
|
||||||
else if (file.startsWith("f"))
|
FPlayers.i.loadFromDisc();
|
||||||
{
|
fileName = "players.json";
|
||||||
Factions.i.loadFromDisc();
|
} else if (file.startsWith("a")) {
|
||||||
fileName = "factions.json";
|
fileName = "all";
|
||||||
}
|
Conf.load();
|
||||||
else if (file.startsWith("p"))
|
FPlayers.i.loadFromDisc();
|
||||||
{
|
Factions.i.loadFromDisc();
|
||||||
FPlayers.i.loadFromDisc();
|
Board.load();
|
||||||
fileName = "players.json";
|
} else {
|
||||||
}
|
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
||||||
else if (file.startsWith("a"))
|
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
|
||||||
{
|
return;
|
||||||
fileName = "all";
|
}
|
||||||
Conf.load();
|
|
||||||
FPlayers.i.loadFromDisc();
|
|
||||||
Factions.i.loadFromDisc();
|
|
||||||
Board.load();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
P.p.log("RELOAD CANCELLED - SPECIFIED FILE INVALID");
|
|
||||||
msg("<b>Invalid file specified. <i>Valid files: all, conf, board, factions, players");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long timeReload = (System.currentTimeMillis()-timeInitStart);
|
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
||||||
|
|
||||||
msg("<i>Reloaded <h>%s <i>from disk, took <h>%dms<i>.", fileName, timeReload);
|
msg("<i>Reloaded <h>%s <i>from disk, took <h>%dms<i>.", fileName, timeReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,36 +6,33 @@ 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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("radius", "0");
|
//this.optionalArgs.put("radius", "0");
|
||||||
|
|
||||||
this.permission = Permission.MANAGE_SAFE_ZONE.node;
|
this.permission = Permission.MANAGE_SAFE_ZONE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("Unclaim all safezone land");
|
this.setHelpShort("Unclaim all safezone land");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Board.unclaimAll(Factions.i.getSafeZone().getId());
|
||||||
Board.unclaimAll(Factions.i.getSafeZone().getId());
|
msg("<i>You unclaimed ALL safe zone land.");
|
||||||
msg("<i>You unclaimed ALL safe zone land.");
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims)
|
if (Conf.logLandUnclaims)
|
||||||
P.p.log(fme.getName()+" unclaimed all safe zones.");
|
P.p.log(fme.getName() + " unclaimed all safe zones.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,35 +6,32 @@ 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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.SAVE.node;
|
this.permission = Permission.SAVE.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayers.i.saveToDisc();
|
||||||
FPlayers.i.saveToDisc();
|
Factions.i.saveToDisc();
|
||||||
Factions.i.saveToDisc();
|
Board.save();
|
||||||
Board.save();
|
Conf.save();
|
||||||
Conf.save();
|
msg("<i>Factions saved to disk!");
|
||||||
msg("<i>Factions saved to disk!");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,71 +7,62 @@ 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("");
|
||||||
this.optionalArgs.put("faction tag", "mine");
|
this.optionalArgs.put("faction tag", "mine");
|
||||||
|
|
||||||
this.permission = Permission.SETHOME.node;
|
this.permission = Permission.SETHOME.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (!Conf.homesEnabled) {
|
||||||
if ( ! Conf.homesEnabled)
|
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
||||||
{
|
return;
|
||||||
fme.msg("<b>Sorry, Faction homes are disabled on this server.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Faction faction = this.argAsFaction(0, myFaction);
|
Faction faction = this.argAsFaction(0, myFaction);
|
||||||
if (faction == null) return;
|
if (faction == null) return;
|
||||||
|
|
||||||
// Can the player set the home for this faction?
|
// Can the player set the home for this faction?
|
||||||
if (faction == myFaction)
|
if (faction == myFaction) {
|
||||||
{
|
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) return;
|
||||||
if ( ! Permission.SETHOME_ANY.has(sender) && ! assertMinRole(Role.MODERATOR)) return;
|
} else {
|
||||||
}
|
if (!Permission.SETHOME_ANY.has(sender, true)) return;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
if ( ! Permission.SETHOME_ANY.has(sender, true)) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can the player set the faction home HERE?
|
// Can the player set the faction home HERE?
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
! Permission.BYPASS.has(me)
|
!Permission.BYPASS.has(me)
|
||||||
&&
|
&&
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 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.econCostSethome, "to set the faction home", "for setting the faction home")) return;
|
if (!payForCommand(Conf.econCostSethome, "to set the faction home", "for setting the faction home")) return;
|
||||||
|
|
||||||
faction.setHome(me.getLocation());
|
faction.setHome(me.getLocation());
|
||||||
|
|
||||||
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
faction.msg("%s<i> set the home for your faction. You can now use:", fme.describeTo(myFaction, true));
|
||||||
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate());
|
faction.sendMessage(p.cmdBase.cmdHome.getUseageTemplate());
|
||||||
if (faction != myFaction)
|
if (faction != myFaction) {
|
||||||
{
|
fme.msg("<b>You have set the home for the " + faction.getTag(fme) + "<i> faction.");
|
||||||
fme.msg("<b>You have set the home for the "+faction.getTag(fme)+"<i> faction.");
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,165 +1,150 @@
|
|||||||
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 {
|
||||||
{
|
|
||||||
this.aliases.add("show");
|
|
||||||
this.aliases.add("who");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
public CmdShow() {
|
||||||
this.optionalArgs.put("faction tag", "yours");
|
this.aliases.add("show");
|
||||||
|
this.aliases.add("who");
|
||||||
|
|
||||||
this.permission = Permission.SHOW.node;
|
//this.requiredArgs.add("");
|
||||||
this.disableOnLock = false;
|
this.optionalArgs.put("faction tag", "yours");
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
this.permission = Permission.SHOW.node;
|
||||||
senderMustBeMember = false;
|
this.disableOnLock = false;
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
senderMustBePlayer = true;
|
||||||
public void perform()
|
senderMustBeMember = false;
|
||||||
{
|
senderMustBeModerator = false;
|
||||||
Faction faction = myFaction;
|
senderMustBeAdmin = false;
|
||||||
if (this.argIsSet(0))
|
}
|
||||||
{
|
|
||||||
faction = this.argAsFaction(0);
|
|
||||||
if (faction == null) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
@Override
|
||||||
if ( ! payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return;
|
public void perform() {
|
||||||
|
Faction faction = myFaction;
|
||||||
|
if (this.argIsSet(0)) {
|
||||||
|
faction = this.argAsFaction(0);
|
||||||
|
if (faction == null) return;
|
||||||
|
}
|
||||||
|
|
||||||
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
if (!payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return;
|
||||||
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
|
||||||
|
|
||||||
msg(p.txt.titleize(faction.getTag(fme)));
|
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
||||||
msg("<a>Description: <i>%s", faction.getDescription());
|
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
||||||
if ( ! faction.isNormal())
|
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String peaceStatus = "";
|
msg(p.txt.titleize(faction.getTag(fme)));
|
||||||
if (faction.isPeaceful())
|
msg("<a>Description: <i>%s", faction.getDescription());
|
||||||
{
|
if (!faction.isNormal()) {
|
||||||
peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
String peaceStatus = "";
|
||||||
|
if (faction.isPeaceful()) {
|
||||||
|
peaceStatus = " " + Conf.colorNeutral + "This faction is Peaceful";
|
||||||
|
}
|
||||||
|
|
||||||
double powerBoost = faction.getPowerBoost();
|
msg("<a>Joining: <i>" + (faction.getOpen() ? "no invitation is needed" : "invitation is required") + peaceStatus);
|
||||||
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);
|
|
||||||
|
|
||||||
if (faction.isPermanent())
|
double powerBoost = faction.getPowerBoost();
|
||||||
{
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||||
msg("<a>This faction is permanent, remaining even with no members.");
|
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
||||||
}
|
|
||||||
|
|
||||||
// show the land value
|
if (faction.isPermanent()) {
|
||||||
if (Econ.shouldBeUsed())
|
msg("<a>This faction is permanent, remaining even with no members.");
|
||||||
{
|
}
|
||||||
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
|
||||||
double refund = value * Conf.econClaimRefundMultiplier;
|
|
||||||
if (value > 0)
|
|
||||||
{
|
|
||||||
String stringValue = Econ.moneyString(value);
|
|
||||||
String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : "";
|
|
||||||
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Show bank contents
|
// show the land value
|
||||||
if(Conf.bankEnabled) {
|
if (Econ.shouldBeUsed()) {
|
||||||
msg("<a>Bank contains: <i>"+Econ.moneyString(Econ.getBalance(faction.getAccountId())));
|
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
||||||
}
|
double refund = value * Conf.econClaimRefundMultiplier;
|
||||||
}
|
if (value > 0) {
|
||||||
|
String stringValue = Econ.moneyString(value);
|
||||||
|
String stringRefund = (refund > 0.0) ? (" (" + Econ.moneyString(refund) + " depreciated)") : "";
|
||||||
|
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
||||||
|
}
|
||||||
|
|
||||||
String listpart;
|
//Show bank contents
|
||||||
|
if (Conf.bankEnabled) {
|
||||||
|
msg("<a>Bank contains: <i>" + Econ.moneyString(Econ.getBalance(faction.getAccountId())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// List relation
|
String listpart;
|
||||||
String allyList = p.txt.parse("<a>Allies: ");
|
|
||||||
String enemyList = p.txt.parse("<a>Enemies: ");
|
|
||||||
for (Faction otherFaction : Factions.i.get())
|
|
||||||
{
|
|
||||||
if (otherFaction == faction) continue;
|
|
||||||
|
|
||||||
Relation rel = otherFaction.getRelationTo(faction);
|
// List relation
|
||||||
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
|
String allyList = p.txt.parse("<a>Allies: ");
|
||||||
|
String enemyList = p.txt.parse("<a>Enemies: ");
|
||||||
|
for (Faction otherFaction : Factions.i.get()) {
|
||||||
|
if (otherFaction == faction) continue;
|
||||||
|
|
||||||
listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
|
Relation rel = otherFaction.getRelationTo(faction);
|
||||||
if (rel.isAlly())
|
if (!rel.isAlly() && !rel.isEnemy())
|
||||||
allyList += listpart;
|
continue; // if not ally or enemy, drop out now so we're not wasting time on it; good performance boost
|
||||||
else if (rel.isEnemy())
|
|
||||||
enemyList += listpart;
|
|
||||||
}
|
|
||||||
if (allyList.endsWith(", "))
|
|
||||||
allyList = allyList.substring(0, allyList.length()-2);
|
|
||||||
if (enemyList.endsWith(", "))
|
|
||||||
enemyList = enemyList.substring(0, enemyList.length()-2);
|
|
||||||
|
|
||||||
sendMessage(allyList);
|
listpart = otherFaction.getTag(fme) + p.txt.parse("<i>") + ", ";
|
||||||
sendMessage(enemyList);
|
if (rel.isAlly())
|
||||||
|
allyList += listpart;
|
||||||
|
else if (rel.isEnemy())
|
||||||
|
enemyList += listpart;
|
||||||
|
}
|
||||||
|
if (allyList.endsWith(", "))
|
||||||
|
allyList = allyList.substring(0, allyList.length() - 2);
|
||||||
|
if (enemyList.endsWith(", "))
|
||||||
|
enemyList = enemyList.substring(0, enemyList.length() - 2);
|
||||||
|
|
||||||
// List the members...
|
sendMessage(allyList);
|
||||||
String onlineList = p.txt.parse("<a>")+"Members online: ";
|
sendMessage(enemyList);
|
||||||
String offlineList = p.txt.parse("<a>")+"Members offline: ";
|
|
||||||
for (FPlayer follower : admins)
|
|
||||||
{
|
|
||||||
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
|
|
||||||
if (follower.isOnlineAndVisibleTo(me))
|
|
||||||
{
|
|
||||||
onlineList += listpart;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offlineList += listpart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (FPlayer follower : mods)
|
|
||||||
{
|
|
||||||
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
|
|
||||||
if
|
|
||||||
(follower.isOnlineAndVisibleTo(me))
|
|
||||||
{
|
|
||||||
onlineList += listpart;
|
|
||||||
} else {
|
|
||||||
offlineList += listpart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (FPlayer follower : normals) {
|
|
||||||
listpart = follower.getNameAndTitle(fme)+p.txt.parse("<i>")+", ";
|
|
||||||
if (follower.isOnlineAndVisibleTo(me)) {
|
|
||||||
onlineList += listpart;
|
|
||||||
} else {
|
|
||||||
offlineList += listpart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlineList.endsWith(", ")) {
|
// List the members...
|
||||||
onlineList = onlineList.substring(0, onlineList.length()-2);
|
String onlineList = p.txt.parse("<a>") + "Members online: ";
|
||||||
}
|
String offlineList = p.txt.parse("<a>") + "Members offline: ";
|
||||||
if (offlineList.endsWith(", ")) {
|
for (FPlayer follower : admins) {
|
||||||
offlineList = offlineList.substring(0, offlineList.length()-2);
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
}
|
if (follower.isOnlineAndVisibleTo(me)) {
|
||||||
|
onlineList += listpart;
|
||||||
|
} else {
|
||||||
|
offlineList += listpart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (FPlayer follower : mods) {
|
||||||
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
|
if
|
||||||
|
(follower.isOnlineAndVisibleTo(me)) {
|
||||||
|
onlineList += listpart;
|
||||||
|
} else {
|
||||||
|
offlineList += listpart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (FPlayer follower : normals) {
|
||||||
|
listpart = follower.getNameAndTitle(fme) + p.txt.parse("<i>") + ", ";
|
||||||
|
if (follower.isOnlineAndVisibleTo(me)) {
|
||||||
|
onlineList += listpart;
|
||||||
|
} else {
|
||||||
|
offlineList += listpart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendMessage(onlineList);
|
if (onlineList.endsWith(", ")) {
|
||||||
sendMessage(offlineList);
|
onlineList = onlineList.substring(0, onlineList.length() - 2);
|
||||||
}
|
}
|
||||||
|
if (offlineList.endsWith(", ")) {
|
||||||
|
offlineList = offlineList.substring(0, offlineList.length() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(onlineList);
|
||||||
|
sendMessage(offlineList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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,75 +7,70 @@ 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 {
|
||||||
{
|
|
||||||
this.aliases.add("tag");
|
|
||||||
|
|
||||||
this.requiredArgs.add("faction tag");
|
public CmdTag() {
|
||||||
//this.optionalArgs.put("", "");
|
this.aliases.add("tag");
|
||||||
|
|
||||||
this.permission = Permission.TAG.node;
|
this.requiredArgs.add("faction tag");
|
||||||
this.disableOnLock = true;
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
this.permission = Permission.TAG.node;
|
||||||
senderMustBeMember = false;
|
this.disableOnLock = true;
|
||||||
senderMustBeModerator = true;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
senderMustBePlayer = true;
|
||||||
public void perform()
|
senderMustBeMember = false;
|
||||||
{
|
senderMustBeModerator = true;
|
||||||
String tag = this.argAsString(0);
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO does not first test cover selfcase?
|
@Override
|
||||||
if (Factions.i.isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag()))
|
public void perform() {
|
||||||
{
|
String tag = this.argAsString(0);
|
||||||
msg("<b>That tag is already taken");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> errors = new ArrayList<String>();
|
// TODO does not first test cover selfcase?
|
||||||
errors.addAll(Factions.validateTag(tag));
|
if (Factions.i.isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag())) {
|
||||||
if (errors.size() > 0)
|
msg("<b>That tag is already taken");
|
||||||
{
|
return;
|
||||||
sendMessage(errors);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
ArrayList<String> errors = new ArrayList<String>();
|
||||||
if ( ! canAffordCommand(Conf.econCostTag, "to change the faction tag")) return;
|
errors.addAll(Factions.validateTag(tag));
|
||||||
|
if (errors.size() > 0) {
|
||||||
|
sendMessage(errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// trigger the faction rename event (cancellable)
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||||
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
if (!canAffordCommand(Conf.econCostTag, "to change the faction tag")) return;
|
||||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
|
||||||
if(renameEvent.isCancelled()) return;
|
|
||||||
|
|
||||||
// then make 'em pay (if applicable)
|
// trigger the faction rename event (cancellable)
|
||||||
if ( ! payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) return;
|
FactionRenameEvent renameEvent = new FactionRenameEvent(fme, tag);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||||
|
if (renameEvent.isCancelled()) return;
|
||||||
|
|
||||||
String oldtag = myFaction.getTag();
|
// then make 'em pay (if applicable)
|
||||||
myFaction.setTag(tag);
|
if (!payForCommand(Conf.econCostTag, "to change the faction tag", "for changing the faction tag")) return;
|
||||||
|
|
||||||
// Inform
|
String oldtag = myFaction.getTag();
|
||||||
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
|
myFaction.setTag(tag);
|
||||||
for (Faction faction : Factions.i.get())
|
|
||||||
{
|
|
||||||
if (faction == myFaction)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction)+oldtag, myFaction.getTag(faction));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Conf.spoutFactionTagsOverNames)
|
// Inform
|
||||||
{
|
myFaction.msg("%s<i> changed your faction tag to %s", fme.describeTo(myFaction, true), myFaction.getTag(myFaction));
|
||||||
SpoutFeatures.updateAppearances(myFaction);
|
for (Faction faction : Factions.i.get()) {
|
||||||
}
|
if (faction == myFaction) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction) + oldtag, myFaction.getTag(faction));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Conf.spoutFactionTagsOverNames) {
|
||||||
|
SpoutFeatures.updateAppearances(myFaction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,47 +6,43 @@ 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");
|
||||||
this.optionalArgs.put("title", "");
|
this.optionalArgs.put("title", "");
|
||||||
|
|
||||||
this.permission = Permission.TITLE.node;
|
this.permission = Permission.TITLE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
if (you == null) return;
|
||||||
if (you == null) return;
|
|
||||||
|
|
||||||
args.remove(0);
|
args.remove(0);
|
||||||
String title = TextUtil.implode(args, " ");
|
String title = TextUtil.implode(args, " ");
|
||||||
|
|
||||||
if ( ! canIAdministerYou(fme, you)) return;
|
if (!canIAdministerYou(fme, you)) return;
|
||||||
|
|
||||||
// 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.econCostTitle, "to change a players title", "for changing a players title")) return;
|
if (!payForCommand(Conf.econCostTitle, "to change a players title", "for changing a players title")) return;
|
||||||
|
|
||||||
you.setTitle(title);
|
you.setTitle(title);
|
||||||
|
|
||||||
// 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,133 +1,108 @@
|
|||||||
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("declaim");
|
||||||
this.aliases.add("unclaim");
|
|
||||||
this.aliases.add("declaim");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.UNCLAIM.node;
|
this.permission = Permission.UNCLAIM.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
FLocation flocation = new FLocation(fme);
|
||||||
FLocation flocation = new FLocation(fme);
|
Faction otherFaction = Board.getFactionAt(flocation);
|
||||||
Faction otherFaction = Board.getFactionAt(flocation);
|
|
||||||
|
|
||||||
if (otherFaction.isSafeZone())
|
if (otherFaction.isSafeZone()) {
|
||||||
{
|
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
||||||
if (Permission.MANAGE_SAFE_ZONE.has(sender))
|
Board.removeAt(flocation);
|
||||||
{
|
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||||
Board.removeAt(flocation);
|
msg("<i>Safe zone was unclaimed.");
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
|
||||||
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;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
return;
|
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||||
}
|
Board.removeAt(flocation);
|
||||||
else if (otherFaction.isWarZone())
|
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||||
{
|
msg("<i>War zone was unclaimed.");
|
||||||
if (Permission.MANAGE_WAR_ZONE.has(sender))
|
|
||||||
{
|
|
||||||
Board.removeAt(flocation);
|
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
|
||||||
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);
|
|
||||||
|
|
||||||
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
|
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
|
||||||
msg("<i>You unclaimed this land.");
|
msg("<i>You unclaimed this land.");
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(flocation, otherFaction, fme);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||||
if(unclaimEvent.isCancelled()) return;
|
if (unclaimEvent.isCancelled()) return;
|
||||||
|
|
||||||
if (Econ.shouldBeUsed())
|
if (Econ.shouldBeUsed()) {
|
||||||
{
|
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
|
||||||
|
|
||||||
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 {
|
||||||
}
|
if (!Econ.modifyMoney(fme, refund, "to unclaim this land", "for unclaiming this land")) return;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Board.removeAt(flocation);
|
Board.removeAt(flocation);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
|
||||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||||
|
|
||||||
if (Conf.logLandUnclaims)
|
if (Conf.logLandUnclaims)
|
||||||
P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag());
|
P.p.log(fme.getName() + " unclaimed land at (" + flocation.getCoordString() + ") from the faction: " + otherFaction.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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,52 +7,48 @@ 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("declaimall");
|
||||||
this.aliases.add("unclaimall");
|
|
||||||
this.aliases.add("declaimall");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.UNCLAIM_ALL.node;
|
this.permission = Permission.UNCLAIM_ALL.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
if (Econ.shouldBeUsed()) {
|
||||||
if (Econ.shouldBeUsed())
|
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
||||||
{
|
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
if (!Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land"))
|
||||||
if(Conf.bankEnabled && Conf.bankFactionPaysLandCosts)
|
return;
|
||||||
{
|
} else {
|
||||||
if ( ! Econ.modifyMoney(myFaction, 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;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
|
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
|
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
|
||||||
// this event cannot be cancelled
|
// this event cannot be cancelled
|
||||||
|
|
||||||
Board.unclaimAll(myFaction.getId());
|
Board.unclaimAll(myFaction.getId());
|
||||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
||||||
|
|
||||||
if (Conf.logLandUnclaims)
|
if (Conf.logLandUnclaims)
|
||||||
P.p.log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
|
P.p.log(fme.getName() + " unclaimed everything for the faction: " + myFaction.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,24 @@ 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("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.VERSION.node;
|
this.permission = Permission.VERSION.node;
|
||||||
this.disableOnLock = false;
|
this.disableOnLock = false;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,36 +6,33 @@ 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");
|
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
//this.requiredArgs.add("");
|
||||||
//this.optionalArgs.put("", "");
|
//this.optionalArgs.put("", "");
|
||||||
|
|
||||||
this.permission = Permission.MANAGE_WAR_ZONE.node;
|
this.permission = Permission.MANAGE_WAR_ZONE.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
senderMustBePlayer = false;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("unclaim all warzone land");
|
this.setHelpShort("unclaim all warzone land");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Board.unclaimAll(Factions.i.getWarZone().getId());
|
||||||
Board.unclaimAll(Factions.i.getWarZone().getId());
|
msg("<i>You unclaimed ALL war zone land.");
|
||||||
msg("<i>You unclaimed ALL war zone land.");
|
|
||||||
|
|
||||||
if (Conf.logLandUnclaims)
|
if (Conf.logLandUnclaims)
|
||||||
P.p.log(fme.getName()+" unclaimed all war zones.");
|
P.p.log(fme.getName() + " unclaimed all war zones.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,131 +1,128 @@
|
|||||||
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 CmdAdmin cmdAdmin = new CmdAdmin();
|
|
||||||
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
|
||||||
public CmdBoom cmdBoom = new CmdBoom();
|
|
||||||
public CmdBypass cmdBypass = new CmdBypass();
|
|
||||||
public CmdChat cmdChat = new CmdChat();
|
|
||||||
public CmdChatSpy cmdChatSpy = new CmdChatSpy();
|
|
||||||
public CmdClaim cmdClaim = new CmdClaim();
|
|
||||||
public CmdConfig cmdConfig = new CmdConfig();
|
|
||||||
public CmdCreate cmdCreate = new CmdCreate();
|
|
||||||
public CmdDeinvite cmdDeinvite = new CmdDeinvite();
|
|
||||||
public CmdDescription cmdDescription = new CmdDescription();
|
|
||||||
public CmdDisband cmdDisband = new CmdDisband();
|
|
||||||
public CmdHelp cmdHelp = new CmdHelp();
|
|
||||||
public CmdHome cmdHome = new CmdHome();
|
|
||||||
public CmdInvite cmdInvite = new CmdInvite();
|
|
||||||
public CmdJoin cmdJoin = new CmdJoin();
|
|
||||||
public CmdKick cmdKick = new CmdKick();
|
|
||||||
public CmdLeave cmdLeave = new CmdLeave();
|
|
||||||
public CmdList cmdList = new CmdList();
|
|
||||||
public CmdLock cmdLock = new CmdLock();
|
|
||||||
public CmdMap cmdMap = new CmdMap();
|
|
||||||
public CmdMod cmdMod = new CmdMod();
|
|
||||||
public CmdMoney cmdMoney = new CmdMoney();
|
|
||||||
public CmdOpen cmdOpen = new CmdOpen();
|
|
||||||
public CmdOwner cmdOwner = new CmdOwner();
|
|
||||||
public CmdOwnerList cmdOwnerList = new CmdOwnerList();
|
|
||||||
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
|
|
||||||
public CmdPermanent cmdPermanent = new CmdPermanent();
|
|
||||||
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
|
|
||||||
public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost();
|
|
||||||
public CmdPower cmdPower = new CmdPower();
|
|
||||||
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
|
|
||||||
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
|
|
||||||
public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral();
|
|
||||||
public CmdReload cmdReload = new CmdReload();
|
|
||||||
public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall();
|
|
||||||
public CmdSaveAll cmdSaveAll = new CmdSaveAll();
|
|
||||||
public CmdSethome cmdSethome = new CmdSethome();
|
|
||||||
public CmdShow cmdShow = new CmdShow();
|
|
||||||
public CmdTag cmdTag = new CmdTag();
|
|
||||||
public CmdTitle cmdTitle = new CmdTitle();
|
|
||||||
public CmdUnclaim cmdUnclaim = new CmdUnclaim();
|
|
||||||
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
|
|
||||||
public CmdVersion cmdVersion = new CmdVersion();
|
|
||||||
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
|
||||||
|
|
||||||
public FCmdRoot()
|
public class FCmdRoot extends FCommand {
|
||||||
{
|
public CmdAdmin cmdAdmin = new CmdAdmin();
|
||||||
super();
|
public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim();
|
||||||
this.aliases.addAll(Conf.baseCommandAliases);
|
public CmdBoom cmdBoom = new CmdBoom();
|
||||||
this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas
|
public CmdBypass cmdBypass = new CmdBypass();
|
||||||
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
|
public CmdChat cmdChat = new CmdChat();
|
||||||
|
public CmdChatSpy cmdChatSpy = new CmdChatSpy();
|
||||||
|
public CmdClaim cmdClaim = new CmdClaim();
|
||||||
|
public CmdConfig cmdConfig = new CmdConfig();
|
||||||
|
public CmdCreate cmdCreate = new CmdCreate();
|
||||||
|
public CmdDeinvite cmdDeinvite = new CmdDeinvite();
|
||||||
|
public CmdDescription cmdDescription = new CmdDescription();
|
||||||
|
public CmdDisband cmdDisband = new CmdDisband();
|
||||||
|
public CmdHelp cmdHelp = new CmdHelp();
|
||||||
|
public CmdHome cmdHome = new CmdHome();
|
||||||
|
public CmdInvite cmdInvite = new CmdInvite();
|
||||||
|
public CmdJoin cmdJoin = new CmdJoin();
|
||||||
|
public CmdKick cmdKick = new CmdKick();
|
||||||
|
public CmdLeave cmdLeave = new CmdLeave();
|
||||||
|
public CmdList cmdList = new CmdList();
|
||||||
|
public CmdLock cmdLock = new CmdLock();
|
||||||
|
public CmdMap cmdMap = new CmdMap();
|
||||||
|
public CmdMod cmdMod = new CmdMod();
|
||||||
|
public CmdMoney cmdMoney = new CmdMoney();
|
||||||
|
public CmdOpen cmdOpen = new CmdOpen();
|
||||||
|
public CmdOwner cmdOwner = new CmdOwner();
|
||||||
|
public CmdOwnerList cmdOwnerList = new CmdOwnerList();
|
||||||
|
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
|
||||||
|
public CmdPermanent cmdPermanent = new CmdPermanent();
|
||||||
|
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
|
||||||
|
public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost();
|
||||||
|
public CmdPower cmdPower = new CmdPower();
|
||||||
|
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
|
||||||
|
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
|
||||||
|
public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral();
|
||||||
|
public CmdReload cmdReload = new CmdReload();
|
||||||
|
public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall();
|
||||||
|
public CmdSaveAll cmdSaveAll = new CmdSaveAll();
|
||||||
|
public CmdSethome cmdSethome = new CmdSethome();
|
||||||
|
public CmdShow cmdShow = new CmdShow();
|
||||||
|
public CmdTag cmdTag = new CmdTag();
|
||||||
|
public CmdTitle cmdTitle = new CmdTitle();
|
||||||
|
public CmdUnclaim cmdUnclaim = new CmdUnclaim();
|
||||||
|
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
|
||||||
|
public CmdVersion cmdVersion = new CmdVersion();
|
||||||
|
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
||||||
|
|
||||||
//this.requiredArgs.add("");
|
public FCmdRoot() {
|
||||||
//this.optionalArgs.put("","")
|
super();
|
||||||
|
this.aliases.addAll(Conf.baseCommandAliases);
|
||||||
|
this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas
|
||||||
|
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
//this.requiredArgs.add("");
|
||||||
senderMustBeMember = false;
|
//this.optionalArgs.put("","")
|
||||||
senderMustBeModerator = false;
|
|
||||||
senderMustBeAdmin = false;
|
|
||||||
|
|
||||||
this.disableOnLock = false;
|
senderMustBePlayer = false;
|
||||||
|
senderMustBeMember = false;
|
||||||
|
senderMustBeModerator = false;
|
||||||
|
senderMustBeAdmin = false;
|
||||||
|
|
||||||
this.setHelpShort("The faction base command");
|
this.disableOnLock = false;
|
||||||
this.helpLong.add(p.txt.parseTags("<i>This command contains all faction stuff."));
|
|
||||||
|
|
||||||
//this.subCommands.add(p.cmdHelp);
|
this.setHelpShort("The faction base command");
|
||||||
|
this.helpLong.add(p.txt.parseTags("<i>This command contains all faction stuff."));
|
||||||
|
|
||||||
this.addSubCommand(this.cmdAdmin);
|
//this.subCommands.add(p.cmdHelp);
|
||||||
this.addSubCommand(this.cmdAutoClaim);
|
|
||||||
this.addSubCommand(this.cmdBoom);
|
|
||||||
this.addSubCommand(this.cmdBypass);
|
|
||||||
this.addSubCommand(this.cmdChat);
|
|
||||||
this.addSubCommand(this.cmdChatSpy);
|
|
||||||
this.addSubCommand(this.cmdClaim);
|
|
||||||
this.addSubCommand(this.cmdConfig);
|
|
||||||
this.addSubCommand(this.cmdCreate);
|
|
||||||
this.addSubCommand(this.cmdDeinvite);
|
|
||||||
this.addSubCommand(this.cmdDescription);
|
|
||||||
this.addSubCommand(this.cmdDisband);
|
|
||||||
this.addSubCommand(this.cmdHelp);
|
|
||||||
this.addSubCommand(this.cmdHome);
|
|
||||||
this.addSubCommand(this.cmdInvite);
|
|
||||||
this.addSubCommand(this.cmdJoin);
|
|
||||||
this.addSubCommand(this.cmdKick);
|
|
||||||
this.addSubCommand(this.cmdLeave);
|
|
||||||
this.addSubCommand(this.cmdList);
|
|
||||||
this.addSubCommand(this.cmdLock);
|
|
||||||
this.addSubCommand(this.cmdMap);
|
|
||||||
this.addSubCommand(this.cmdMod);
|
|
||||||
this.addSubCommand(this.cmdMoney);
|
|
||||||
this.addSubCommand(this.cmdOpen);
|
|
||||||
this.addSubCommand(this.cmdOwner);
|
|
||||||
this.addSubCommand(this.cmdOwnerList);
|
|
||||||
this.addSubCommand(this.cmdPeaceful);
|
|
||||||
this.addSubCommand(this.cmdPermanent);
|
|
||||||
this.addSubCommand(this.cmdPermanentPower);
|
|
||||||
this.addSubCommand(this.cmdPower);
|
|
||||||
this.addSubCommand(this.cmdPowerBoost);
|
|
||||||
this.addSubCommand(this.cmdRelationAlly);
|
|
||||||
this.addSubCommand(this.cmdRelationEnemy);
|
|
||||||
this.addSubCommand(this.cmdRelationNeutral);
|
|
||||||
this.addSubCommand(this.cmdReload);
|
|
||||||
this.addSubCommand(this.cmdSafeunclaimall);
|
|
||||||
this.addSubCommand(this.cmdSaveAll);
|
|
||||||
this.addSubCommand(this.cmdSethome);
|
|
||||||
this.addSubCommand(this.cmdShow);
|
|
||||||
this.addSubCommand(this.cmdTag);
|
|
||||||
this.addSubCommand(this.cmdTitle);
|
|
||||||
this.addSubCommand(this.cmdUnclaim);
|
|
||||||
this.addSubCommand(this.cmdUnclaimall);
|
|
||||||
this.addSubCommand(this.cmdVersion);
|
|
||||||
this.addSubCommand(this.cmdWarunclaimall);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
this.addSubCommand(this.cmdAdmin);
|
||||||
public void perform()
|
this.addSubCommand(this.cmdAutoClaim);
|
||||||
{
|
this.addSubCommand(this.cmdBoom);
|
||||||
this.commandChain.add(this);
|
this.addSubCommand(this.cmdBypass);
|
||||||
this.cmdHelp.execute(this.sender, this.args, this.commandChain);
|
this.addSubCommand(this.cmdChat);
|
||||||
}
|
this.addSubCommand(this.cmdChatSpy);
|
||||||
|
this.addSubCommand(this.cmdClaim);
|
||||||
|
this.addSubCommand(this.cmdConfig);
|
||||||
|
this.addSubCommand(this.cmdCreate);
|
||||||
|
this.addSubCommand(this.cmdDeinvite);
|
||||||
|
this.addSubCommand(this.cmdDescription);
|
||||||
|
this.addSubCommand(this.cmdDisband);
|
||||||
|
this.addSubCommand(this.cmdHelp);
|
||||||
|
this.addSubCommand(this.cmdHome);
|
||||||
|
this.addSubCommand(this.cmdInvite);
|
||||||
|
this.addSubCommand(this.cmdJoin);
|
||||||
|
this.addSubCommand(this.cmdKick);
|
||||||
|
this.addSubCommand(this.cmdLeave);
|
||||||
|
this.addSubCommand(this.cmdList);
|
||||||
|
this.addSubCommand(this.cmdLock);
|
||||||
|
this.addSubCommand(this.cmdMap);
|
||||||
|
this.addSubCommand(this.cmdMod);
|
||||||
|
this.addSubCommand(this.cmdMoney);
|
||||||
|
this.addSubCommand(this.cmdOpen);
|
||||||
|
this.addSubCommand(this.cmdOwner);
|
||||||
|
this.addSubCommand(this.cmdOwnerList);
|
||||||
|
this.addSubCommand(this.cmdPeaceful);
|
||||||
|
this.addSubCommand(this.cmdPermanent);
|
||||||
|
this.addSubCommand(this.cmdPermanentPower);
|
||||||
|
this.addSubCommand(this.cmdPower);
|
||||||
|
this.addSubCommand(this.cmdPowerBoost);
|
||||||
|
this.addSubCommand(this.cmdRelationAlly);
|
||||||
|
this.addSubCommand(this.cmdRelationEnemy);
|
||||||
|
this.addSubCommand(this.cmdRelationNeutral);
|
||||||
|
this.addSubCommand(this.cmdReload);
|
||||||
|
this.addSubCommand(this.cmdSafeunclaimall);
|
||||||
|
this.addSubCommand(this.cmdSaveAll);
|
||||||
|
this.addSubCommand(this.cmdSethome);
|
||||||
|
this.addSubCommand(this.cmdShow);
|
||||||
|
this.addSubCommand(this.cmdTag);
|
||||||
|
this.addSubCommand(this.cmdTitle);
|
||||||
|
this.addSubCommand(this.cmdUnclaim);
|
||||||
|
this.addSubCommand(this.cmdUnclaimall);
|
||||||
|
this.addSubCommand(this.cmdVersion);
|
||||||
|
this.addSubCommand(this.cmdWarunclaimall);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform() {
|
||||||
|
this.commandChain.add(this);
|
||||||
|
this.cmdHelp.execute(this.sender, this.args, this.commandChain);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,337 +1,284 @@
|
|||||||
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;
|
||||||
public Faction myFaction;
|
public Faction myFaction;
|
||||||
public boolean senderMustBeMember;
|
public boolean senderMustBeMember;
|
||||||
public boolean senderMustBeModerator;
|
public boolean senderMustBeModerator;
|
||||||
public boolean senderMustBeAdmin;
|
public boolean senderMustBeAdmin;
|
||||||
|
|
||||||
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.
|
||||||
disableOnLock = true;
|
disableOnLock = true;
|
||||||
|
|
||||||
// The money commands must be disabled if money should not be used.
|
// The money commands must be disabled if money should not be used.
|
||||||
isMoneyCommand = false;
|
isMoneyCommand = false;
|
||||||
|
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = false;
|
senderMustBeModerator = false;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain)
|
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
||||||
{
|
if (sender instanceof Player) {
|
||||||
if (sender instanceof Player)
|
this.fme = FPlayers.i.get((Player) sender);
|
||||||
{
|
this.myFaction = this.fme.getFaction();
|
||||||
this.fme = FPlayers.i.get((Player)sender);
|
} else {
|
||||||
this.myFaction = this.fme.getFaction();
|
this.fme = null;
|
||||||
}
|
this.myFaction = null;
|
||||||
else
|
}
|
||||||
{
|
super.execute(sender, args, commandChain);
|
||||||
this.fme = null;
|
}
|
||||||
this.myFaction = null;
|
|
||||||
}
|
|
||||||
super.execute(sender, args, commandChain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled()
|
public boolean isEnabled() {
|
||||||
{
|
if (p.getLocked() && this.disableOnLock) {
|
||||||
if (p.getLocked() && this.disableOnLock)
|
msg("<b>Factions was locked by an admin. Please try again later.");
|
||||||
{
|
return false;
|
||||||
msg("<b>Factions was locked by an admin. Please try again later.");
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isMoneyCommand && ! Conf.econEnabled)
|
if (this.isMoneyCommand && !Conf.econEnabled) {
|
||||||
{
|
msg("<b>Faction economy features are disabled on this server.");
|
||||||
msg("<b>Faction economy features are disabled on this server.");
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isMoneyCommand && ! Conf.bankEnabled)
|
if (this.isMoneyCommand && !Conf.bankEnabled) {
|
||||||
{
|
msg("<b>The faction bank system is disabled on this server.");
|
||||||
msg("<b>The faction bank system is disabled on this server.");
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot)
|
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
||||||
{
|
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
||||||
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
if (!superValid) return false;
|
||||||
if ( ! superValid) return false;
|
|
||||||
|
|
||||||
if ( ! (this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) return true;
|
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) return true;
|
||||||
|
|
||||||
if ( ! (sender instanceof Player)) return false;
|
if (!(sender instanceof Player)) return false;
|
||||||
|
|
||||||
FPlayer fplayer = FPlayers.i.get((Player)sender);
|
FPlayer fplayer = FPlayers.i.get((Player) sender);
|
||||||
|
|
||||||
if ( ! fplayer.hasFaction())
|
if (!fplayer.hasFaction()) {
|
||||||
{
|
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
||||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Role.MODERATOR))
|
if (this.senderMustBeModerator && !fplayer.getRole().isAtLeast(Role.MODERATOR)) {
|
||||||
{
|
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Role.ADMIN))
|
if (this.senderMustBeAdmin && !fplayer.getRole().isAtLeast(Role.ADMIN)) {
|
||||||
{
|
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// 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;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Argument Readers
|
// Argument Readers
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
return this.strAsFPlayer(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public FPlayer argAsFPlayer(int idx, FPlayer def)
|
|
||||||
{
|
|
||||||
return this.argAsFPlayer(idx, def, true);
|
|
||||||
}
|
|
||||||
public FPlayer argAsFPlayer(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsFPlayer(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BEST FPLAYER MATCH ======================
|
public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg) {
|
||||||
public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg)
|
return this.strAsFPlayer(this.argAsString(idx), def, msg);
|
||||||
{
|
}
|
||||||
FPlayer ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
public FPlayer argAsFPlayer(int idx, FPlayer def) {
|
||||||
{
|
return this.argAsFPlayer(idx, def, true);
|
||||||
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
}
|
||||||
if (fplayer != null)
|
|
||||||
{
|
|
||||||
ret = fplayer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
public FPlayer argAsFPlayer(int idx) {
|
||||||
{
|
return this.argAsFPlayer(idx, null);
|
||||||
this.msg("<b>No player match found for \"<p>%s<b>\".", name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
// BEST FPLAYER MATCH ======================
|
||||||
}
|
public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg) {
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg)
|
FPlayer ret = def;
|
||||||
{
|
|
||||||
return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def)
|
|
||||||
{
|
|
||||||
return this.argAsBestFPlayerMatch(idx, def, true);
|
|
||||||
}
|
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsBestFPlayerMatch(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FACTION ======================
|
if (name != null) {
|
||||||
public Faction strAsFaction(String name, Faction def, boolean msg)
|
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
||||||
{
|
if (fplayer != null) {
|
||||||
Faction ret = def;
|
ret = fplayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name != null)
|
if (msg && ret == null) {
|
||||||
{
|
this.msg("<b>No player match found for \"<p>%s<b>\".", name);
|
||||||
Faction faction = null;
|
}
|
||||||
|
|
||||||
// First we try an exact match
|
return ret;
|
||||||
if (faction == null)
|
}
|
||||||
{
|
|
||||||
faction = Factions.i.getByTag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next we match faction tags
|
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg) {
|
||||||
if (faction == null)
|
return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg);
|
||||||
{
|
}
|
||||||
faction = Factions.i.getBestTagMatch(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next we match player names
|
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def) {
|
||||||
if (faction == null)
|
return this.argAsBestFPlayerMatch(idx, def, true);
|
||||||
{
|
}
|
||||||
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
|
||||||
if (fplayer != null)
|
|
||||||
{
|
|
||||||
faction = fplayer.getFaction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faction != null)
|
public FPlayer argAsBestFPlayerMatch(int idx) {
|
||||||
{
|
return this.argAsBestFPlayerMatch(idx, null);
|
||||||
ret = faction;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
// FACTION ======================
|
||||||
{
|
public Faction strAsFaction(String name, Faction def, boolean msg) {
|
||||||
this.msg("<b>The faction or player \"<p>%s<b>\" could not be found.", name);
|
Faction ret = def;
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
if (name != null) {
|
||||||
}
|
Faction faction = null;
|
||||||
public Faction argAsFaction(int idx, Faction def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsFaction(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public Faction argAsFaction(int idx, Faction def)
|
|
||||||
{
|
|
||||||
return this.argAsFaction(idx, def, true);
|
|
||||||
}
|
|
||||||
public Faction argAsFaction(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsFaction(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// First we try an exact match
|
||||||
// Commonly used logic
|
if (faction == null) {
|
||||||
// -------------------------------------------- //
|
faction = Factions.i.getByTag(name);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canIAdministerYou(FPlayer i, FPlayer you)
|
// Next we match faction tags
|
||||||
{
|
if (faction == null) {
|
||||||
if ( ! i.getFaction().equals(you.getFaction()))
|
faction = Factions.i.getBestTagMatch(name);
|
||||||
{
|
}
|
||||||
i.sendMessage(p.txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN) )
|
// Next we match player names
|
||||||
{
|
if (faction == null) {
|
||||||
return true;
|
FPlayer fplayer = FPlayers.i.getBestIdMatch(name);
|
||||||
}
|
if (fplayer != null) {
|
||||||
|
faction = fplayer.getFaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (you.getRole().equals(Role.ADMIN))
|
if (faction != null) {
|
||||||
{
|
ret = faction;
|
||||||
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
}
|
||||||
}
|
}
|
||||||
else if (i.getRole().equals(Role.MODERATOR))
|
|
||||||
{
|
|
||||||
if ( i == you )
|
|
||||||
{
|
|
||||||
return true; //Moderators can control themselves
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
if (msg && ret == null) {
|
||||||
}
|
this.msg("<b>The faction or player \"<p>%s<b>\" could not be found.", name);
|
||||||
|
}
|
||||||
|
|
||||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
return ret;
|
||||||
public boolean payForCommand(double cost, String toDoThis, String forDoingThis)
|
}
|
||||||
{
|
|
||||||
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
|
||||||
|
|
||||||
if(Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
public Faction argAsFaction(int idx, Faction def, boolean msg) {
|
||||||
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
return this.strAsFaction(this.argAsString(idx), def, msg);
|
||||||
else
|
}
|
||||||
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
|
|
||||||
}
|
|
||||||
|
|
||||||
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
public Faction argAsFaction(int idx, Faction def) {
|
||||||
public boolean canAffordCommand(double cost, String toDoThis)
|
return this.argAsFaction(idx, def, true);
|
||||||
{
|
}
|
||||||
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
|
||||||
|
|
||||||
if(Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
public Faction argAsFaction(int idx) {
|
||||||
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
return this.argAsFaction(idx, null);
|
||||||
else
|
}
|
||||||
return Econ.hasAtLeast(fme, cost, toDoThis);
|
|
||||||
}
|
// -------------------------------------------- //
|
||||||
|
// Commonly used logic
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public boolean canIAdministerYou(FPlayer i, FPlayer you) {
|
||||||
|
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)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (you.getRole().equals(Role.ADMIN)) {
|
||||||
|
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
||||||
|
} else if (i.getRole().equals(Role.MODERATOR)) {
|
||||||
|
if (i == you) {
|
||||||
|
return true; //Moderators can control themselves
|
||||||
|
} else {
|
||||||
|
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||||
|
|
||||||
|
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
||||||
|
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
||||||
|
else
|
||||||
|
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
|
||||||
|
}
|
||||||
|
|
||||||
|
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
||||||
|
public boolean canAffordCommand(double cost, String toDoThis) {
|
||||||
|
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) return true;
|
||||||
|
|
||||||
|
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction())
|
||||||
|
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
||||||
|
else
|
||||||
|
return Econ.hasAtLeast(fme, cost, toDoThis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,98 +1,88 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
this.permission = Permission.RELATION.node;
|
this.permission = Permission.RELATION.node;
|
||||||
this.disableOnLock = true;
|
this.disableOnLock = true;
|
||||||
|
|
||||||
senderMustBePlayer = true;
|
senderMustBePlayer = true;
|
||||||
senderMustBeMember = false;
|
senderMustBeMember = false;
|
||||||
senderMustBeModerator = true;
|
senderMustBeModerator = true;
|
||||||
senderMustBeAdmin = false;
|
senderMustBeAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform() {
|
||||||
{
|
Faction them = this.argAsFaction(0);
|
||||||
Faction them = this.argAsFaction(0);
|
if (them == null) return;
|
||||||
if (them == null) return;
|
|
||||||
|
|
||||||
if ( ! them.isNormal())
|
if (!them.isNormal()) {
|
||||||
{
|
msg("<b>Nope! You can't.");
|
||||||
msg("<b>Nope! You can't.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (them == myFaction)
|
if (them == myFaction) {
|
||||||
{
|
msg("<b>Nope! You can't declare a relation to yourself :)");
|
||||||
msg("<b>Nope! You can't declare a relation to yourself :)");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (myFaction.getRelationWish(them) == targetRelation)
|
if (myFaction.getRelationWish(them) == targetRelation) {
|
||||||
{
|
msg("<b>You already have that relation wish set with %s.", them.getTag());
|
||||||
msg("<b>You already have that relation wish set with %s.", them.getTag());
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
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);
|
||||||
myFaction.setRelationWish(them, targetRelation);
|
myFaction.setRelationWish(them, targetRelation);
|
||||||
Relation currentRelation = myFaction.getRelationTo(them, true);
|
Relation currentRelation = myFaction.getRelationTo(them, true);
|
||||||
ChatColor currentRelationColor = currentRelation.getColor();
|
ChatColor currentRelationColor = currentRelation.getColor();
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
them.msg("<i>Your faction is now "+currentRelationColor+targetRelation.toString()+"<i> to "+currentRelationColor+myFaction.getTag());
|
them.msg("<i>Your faction is now " + currentRelationColor + targetRelation.toString() + "<i> to " + currentRelationColor + myFaction.getTag());
|
||||||
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.");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SpoutFeatures.updateAppearances(myFaction, them);
|
SpoutFeatures.updateAppearances(myFaction, them);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public class FPlayerJoinEvent extends Event implements Cancellable
|
FPlayer fplayer;
|
||||||
{
|
Faction faction;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
PlayerJoinReason reason;
|
||||||
|
boolean cancelled = false;
|
||||||
|
|
||||||
FPlayer fplayer;
|
public enum PlayerJoinReason {
|
||||||
Faction faction;
|
CREATE, LEADER, COMMAND
|
||||||
PlayerJoinReason reason;
|
}
|
||||||
boolean cancelled = false;
|
|
||||||
public enum PlayerJoinReason
|
|
||||||
{
|
|
||||||
CREATE, LEADER, COMMAND
|
|
||||||
}
|
|
||||||
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r)
|
|
||||||
{
|
|
||||||
fplayer = fp;
|
|
||||||
faction = f;
|
|
||||||
reason = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public FPlayerJoinEvent(FPlayer fp, Faction f, PlayerJoinReason r) {
|
||||||
{
|
fplayer = fp;
|
||||||
return fplayer;
|
faction = f;
|
||||||
}
|
reason = r;
|
||||||
public Faction getFaction()
|
}
|
||||||
{
|
|
||||||
return faction;
|
|
||||||
}
|
|
||||||
public PlayerJoinReason getReason()
|
|
||||||
{
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
public HandlerList getHandlers()
|
|
||||||
{
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return fplayer;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
@Override
|
public Faction getFaction() {
|
||||||
public boolean isCancelled()
|
return faction;
|
||||||
{
|
}
|
||||||
return cancelled;
|
|
||||||
}
|
public PlayerJoinReason getReason() {
|
||||||
@Override
|
return reason;
|
||||||
public void setCancelled(boolean c)
|
}
|
||||||
{
|
|
||||||
cancelled = c;
|
public HandlerList getHandlers() {
|
||||||
}
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean c) {
|
||||||
|
cancelled = c;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,71 +1,59 @@
|
|||||||
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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private PlayerLeaveReason reason;
|
||||||
|
FPlayer FPlayer;
|
||||||
|
Faction Faction;
|
||||||
|
boolean cancelled = false;
|
||||||
|
|
||||||
public class FPlayerLeaveEvent extends Event implements Cancellable
|
public enum PlayerLeaveReason {
|
||||||
{
|
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
|
||||||
private static final HandlerList handlers = new HandlerList();
|
}
|
||||||
private PlayerLeaveReason reason;
|
|
||||||
FPlayer FPlayer;
|
|
||||||
Faction Faction;
|
|
||||||
boolean cancelled = false;
|
|
||||||
|
|
||||||
public enum PlayerLeaveReason
|
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) {
|
||||||
{
|
FPlayer = p;
|
||||||
KICKED, DISBAND, RESET, JOINOTHER, LEAVE
|
Faction = f;
|
||||||
}
|
reason = r;
|
||||||
|
}
|
||||||
|
|
||||||
public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r)
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
FPlayer = p;
|
}
|
||||||
Faction = f;
|
|
||||||
reason = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public PlayerLeaveReason getReason() {
|
||||||
{
|
return reason;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerLeaveReason getReason()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return FPlayer;
|
||||||
return reason;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public Faction getFaction() {
|
||||||
{
|
return Faction;
|
||||||
return FPlayer;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
@Override
|
||||||
{
|
public boolean isCancelled() {
|
||||||
return Faction;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public void setCancelled(boolean c) {
|
||||||
{
|
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET) {
|
||||||
return cancelled;
|
cancelled = false;
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
@Override
|
cancelled = c;
|
||||||
public void setCancelled(boolean c)
|
}
|
||||||
{
|
|
||||||
if (reason == PlayerLeaveReason.DISBAND || reason == PlayerLeaveReason.RESET)
|
|
||||||
{
|
|
||||||
cancelled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cancelled = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
|
|
||||||
public class FactionCreateEvent extends Event implements Cancellable
|
private String factionTag;
|
||||||
{
|
private Player sender;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private boolean cancelled;
|
||||||
|
|
||||||
private String factionTag;
|
public FactionCreateEvent(Player sender, String tag) {
|
||||||
private Player sender;
|
this.factionTag = tag;
|
||||||
private boolean cancelled;
|
this.sender = sender;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
public FactionCreateEvent(Player sender, String tag)
|
public FPlayer getFPlayer() {
|
||||||
{
|
return FPlayers.i.get(sender);
|
||||||
this.factionTag = tag;
|
}
|
||||||
this.sender = sender;
|
|
||||||
this.cancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public String getFactionId() {
|
||||||
{
|
return Factions.i.getNextId();
|
||||||
return FPlayers.i.get(sender);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionTag() {
|
||||||
{
|
return factionTag;
|
||||||
return Factions.i.getNextId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionTag()
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
return factionTag;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
@Override
|
||||||
{
|
public boolean isCancelled() {
|
||||||
return handlers;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public void setCancelled(boolean c) {
|
||||||
{
|
this.cancelled = c;
|
||||||
return cancelled;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean 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,56 +1,47 @@
|
|||||||
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 {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public class FactionRelationEvent extends Event
|
private Faction fsender;
|
||||||
{
|
private Faction ftarget;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private Relation foldrel;
|
||||||
|
private Relation frel;
|
||||||
|
|
||||||
private Faction fsender;
|
public FactionRelationEvent(Faction sender, Faction target, Relation oldrel, Relation rel) {
|
||||||
private Faction ftarget;
|
fsender = sender;
|
||||||
private Relation foldrel;
|
ftarget = target;
|
||||||
private Relation frel;
|
foldrel = oldrel;
|
||||||
|
frel = rel;
|
||||||
|
}
|
||||||
|
|
||||||
public FactionRelationEvent(Faction sender, Faction target, Relation oldrel, Relation rel)
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
fsender = sender;
|
}
|
||||||
ftarget = target;
|
|
||||||
foldrel = oldrel;
|
|
||||||
frel = rel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public Relation getOldRelation() {
|
||||||
{
|
return foldrel;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Relation getOldRelation()
|
public Relation getRelation() {
|
||||||
{
|
return frel;
|
||||||
return foldrel;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Relation getRelation()
|
public Faction getFaction() {
|
||||||
{
|
return fsender;
|
||||||
return frel;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
public Faction getTargetFaction() {
|
||||||
{
|
return ftarget;
|
||||||
return fsender;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getTargetFaction()
|
|
||||||
{
|
|
||||||
return ftarget;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,74 +1,62 @@
|
|||||||
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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
public class FactionRenameEvent extends Event implements Cancellable
|
private boolean cancelled;
|
||||||
{
|
private FPlayer fplayer;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private Faction faction;
|
||||||
|
private String tag;
|
||||||
|
|
||||||
private boolean cancelled;
|
public FactionRenameEvent(FPlayer sender, String newTag) {
|
||||||
private FPlayer fplayer;
|
fplayer = sender;
|
||||||
private Faction faction;
|
faction = sender.getFaction();
|
||||||
private String tag;
|
tag = newTag;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
public FactionRenameEvent(FPlayer sender, String newTag)
|
public Faction getFaction() {
|
||||||
{
|
return (faction);
|
||||||
fplayer = sender;
|
}
|
||||||
faction = sender.getFaction();
|
|
||||||
tag = newTag;
|
|
||||||
this.cancelled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return (fplayer);
|
||||||
return(faction);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public Player getPlayer() {
|
||||||
{
|
return (fplayer.getPlayer());
|
||||||
return(fplayer);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer()
|
public String getOldFactionTag() {
|
||||||
{
|
return (faction.getTag());
|
||||||
return(fplayer.getPlayer());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getOldFactionTag()
|
public String getFactionTag() {
|
||||||
{
|
return (tag);
|
||||||
return(faction.getTag());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionTag()
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
return(tag);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
@Override
|
||||||
{
|
public boolean isCancelled() {
|
||||||
return handlers;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public void setCancelled(boolean c) {
|
||||||
{
|
this.cancelled = c;
|
||||||
return cancelled;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean c)
|
|
||||||
{
|
|
||||||
this.cancelled = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,80 +1,67 @@
|
|||||||
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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LandClaimEvent extends Event implements Cancellable
|
private boolean cancelled;
|
||||||
{
|
private FLocation location;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private Faction faction;
|
||||||
|
private FPlayer fplayer;
|
||||||
|
|
||||||
private boolean cancelled;
|
public LandClaimEvent(FLocation loc, Faction f, FPlayer p) {
|
||||||
private FLocation location;
|
cancelled = false;
|
||||||
private Faction faction;
|
location = loc;
|
||||||
private FPlayer fplayer;
|
faction = f;
|
||||||
|
fplayer = p;
|
||||||
|
}
|
||||||
|
|
||||||
public LandClaimEvent(FLocation loc, Faction f, FPlayer p)
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
cancelled = false;
|
}
|
||||||
location = loc;
|
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public FLocation getLocation() {
|
||||||
{
|
return this.location;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FLocation getLocation()
|
public Faction getFaction() {
|
||||||
{
|
return faction;
|
||||||
return this.location;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
public String getFactionId() {
|
||||||
{
|
return faction.getId();
|
||||||
return faction;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionTag() {
|
||||||
{
|
return faction.getTag();
|
||||||
return faction.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionTag()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return fplayer;
|
||||||
return faction.getTag();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public Player getPlayer() {
|
||||||
{
|
return fplayer.getPlayer();
|
||||||
return fplayer;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer()
|
@Override
|
||||||
{
|
public boolean isCancelled() {
|
||||||
return fplayer.getPlayer();
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public void setCancelled(boolean c) {
|
||||||
{
|
this.cancelled = c;
|
||||||
return cancelled;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean 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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LandUnclaimAllEvent extends Event
|
private Faction faction;
|
||||||
{
|
private FPlayer fplayer;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
private Faction faction;
|
public LandUnclaimAllEvent(Faction f, FPlayer p) {
|
||||||
private FPlayer fplayer;
|
faction = f;
|
||||||
|
fplayer = p;
|
||||||
|
}
|
||||||
|
|
||||||
public LandUnclaimAllEvent(Faction f, FPlayer p)
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
faction = f;
|
}
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public Faction getFaction() {
|
||||||
{
|
return faction;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
public String getFactionId() {
|
||||||
{
|
return faction.getId();
|
||||||
return faction;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionTag() {
|
||||||
{
|
return faction.getTag();
|
||||||
return faction.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionTag()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return fplayer;
|
||||||
return faction.getTag();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public Player getPlayer() {
|
||||||
{
|
return fplayer.getPlayer();
|
||||||
return fplayer;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer()
|
|
||||||
{
|
|
||||||
return fplayer.getPlayer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,79 +1,67 @@
|
|||||||
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;
|
private static final HandlerList handlers = new HandlerList();
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class LandUnclaimEvent extends Event implements Cancellable
|
private boolean cancelled;
|
||||||
{
|
private FLocation location;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private Faction faction;
|
||||||
|
private FPlayer fplayer;
|
||||||
|
|
||||||
private boolean cancelled;
|
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p) {
|
||||||
private FLocation location;
|
cancelled = false;
|
||||||
private Faction faction;
|
location = loc;
|
||||||
private FPlayer fplayer;
|
faction = f;
|
||||||
|
fplayer = p;
|
||||||
|
}
|
||||||
|
|
||||||
public LandUnclaimEvent(FLocation loc, Faction f, FPlayer p)
|
public HandlerList getHandlers() {
|
||||||
{
|
return handlers;
|
||||||
cancelled = false;
|
}
|
||||||
location = loc;
|
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerList getHandlers()
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public FLocation getLocation() {
|
||||||
{
|
return this.location;
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FLocation getLocation()
|
public Faction getFaction() {
|
||||||
{
|
return faction;
|
||||||
return this.location;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
public String getFactionId() {
|
||||||
{
|
return faction.getId();
|
||||||
return faction;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId()
|
public String getFactionTag() {
|
||||||
{
|
return faction.getTag();
|
||||||
return faction.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionTag()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return fplayer;
|
||||||
return faction.getTag();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public Player getPlayer() {
|
||||||
{
|
return fplayer.getPlayer();
|
||||||
return fplayer;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer()
|
@Override
|
||||||
{
|
public boolean isCancelled() {
|
||||||
return fplayer.getPlayer();
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled()
|
public void setCancelled(boolean c) {
|
||||||
{
|
cancelled = c;
|
||||||
return cancelled;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean c) {
|
|
||||||
cancelled = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,85 +1,72 @@
|
|||||||
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 {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancelled;
|
||||||
|
private Faction faction;
|
||||||
|
private FPlayer fplayer;
|
||||||
|
private String message;
|
||||||
|
|
||||||
public class PowerLossEvent extends Event implements Cancellable
|
public PowerLossEvent(Faction f, FPlayer p) {
|
||||||
{
|
cancelled = false;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
faction = f;
|
||||||
|
fplayer = p;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean cancelled;
|
@Override
|
||||||
private Faction faction;
|
public HandlerList getHandlers() {
|
||||||
private FPlayer fplayer;
|
return handlers;
|
||||||
private String message;
|
}
|
||||||
|
|
||||||
public PowerLossEvent(Faction f, FPlayer p)
|
public static HandlerList getHandlerList() {
|
||||||
{
|
return handlers;
|
||||||
cancelled = false;
|
}
|
||||||
faction = f;
|
|
||||||
fplayer = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public Faction getFaction() {
|
||||||
public HandlerList getHandlers()
|
return faction;
|
||||||
{
|
}
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList()
|
public String getFactionId() {
|
||||||
{
|
return faction.getId();
|
||||||
return handlers;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Faction getFaction()
|
public String getFactionTag() {
|
||||||
{
|
return faction.getTag();
|
||||||
return faction;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionId()
|
public FPlayer getFPlayer() {
|
||||||
{
|
return fplayer;
|
||||||
return faction.getId();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getFactionTag()
|
public Player getPlayer() {
|
||||||
{
|
return fplayer.getPlayer();
|
||||||
return faction.getTag();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FPlayer getFPlayer()
|
public String getMessage() {
|
||||||
{
|
return message;
|
||||||
return fplayer;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer()
|
public void setMessage(String message) {
|
||||||
{
|
this.message = message;
|
||||||
return fplayer.getPlayer();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
@Override
|
||||||
return message;
|
public boolean isCancelled() {
|
||||||
}
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
@Override
|
||||||
this.message = message;
|
public void setCancelled(boolean c) {
|
||||||
}
|
this.cancelled = c;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean isCancelled()
|
|
||||||
{
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean c)
|
|
||||||
{
|
|
||||||
this.cancelled = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
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,16 +1,16 @@
|
|||||||
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 String describeTo(RelationParticipator that);
|
||||||
|
|
||||||
public interface RelationParticipator
|
public String describeTo(RelationParticipator that, boolean ucfirst);
|
||||||
{
|
|
||||||
public String describeTo(RelationParticipator that);
|
|
||||||
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 ChatColor getColorTo(RelationParticipator to);
|
public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
|
||||||
|
|
||||||
|
public ChatColor getColorTo(RelationParticipator to);
|
||||||
}
|
}
|
||||||
|
@ -1,393 +1,332 @@
|
|||||||
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;
|
private static Economy econ = null;
|
||||||
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;
|
public static void setup() {
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
if (isSetup()) return;
|
||||||
|
|
||||||
|
String integrationFail = "Economy integration is " + (Conf.econEnabled ? "enabled, but" : "disabled, and") + " the plugin \"Vault\" ";
|
||||||
|
|
||||||
|
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
|
P.p.log(integrationFail + "is not installed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
if (rsp == null) {
|
||||||
|
P.p.log(integrationFail + "is not hooked into an economy plugin.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
econ = rsp.getProvider();
|
||||||
|
|
||||||
|
P.p.log("Economy integration through Vault plugin successful.");
|
||||||
|
|
||||||
|
if (!Conf.econEnabled)
|
||||||
|
P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
||||||
|
|
||||||
|
P.p.cmdBase.cmdHelp.updateHelp();
|
||||||
|
|
||||||
|
oldMoneyDoTransfer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldBeUsed() {
|
||||||
|
return Conf.econEnabled && econ != null && econ.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSetup() {
|
||||||
|
return econ != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class Econ
|
public static void modifyUniverseMoney(double delta) {
|
||||||
{
|
if (!shouldBeUsed()) return;
|
||||||
private static Economy econ = null;
|
|
||||||
|
|
||||||
public static void setup()
|
if (Conf.econUniverseAccount == null) return;
|
||||||
{
|
if (Conf.econUniverseAccount.length() == 0) return;
|
||||||
if (isSetup()) return;
|
if (!econ.hasAccount(Conf.econUniverseAccount)) return;
|
||||||
|
|
||||||
String integrationFail = "Economy integration is "+(Conf.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" ";
|
modifyBalance(Conf.econUniverseAccount, delta);
|
||||||
|
}
|
||||||
|
|
||||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null)
|
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about) {
|
||||||
{
|
if (!shouldBeUsed()) {
|
||||||
P.p.log(integrationFail+"is not installed.");
|
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())));
|
||||||
|
}
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) {
|
||||||
if (rsp == null)
|
Faction fI = RelationUtil.getFaction(i);
|
||||||
{
|
Faction fYou = RelationUtil.getFaction(you);
|
||||||
P.p.log(integrationFail+"is not hooked into an economy plugin.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
econ = rsp.getProvider();
|
|
||||||
|
|
||||||
P.p.log("Economy integration through Vault plugin successful.");
|
// This is a system invoker. Accept it.
|
||||||
|
if (fI == null) return true;
|
||||||
|
|
||||||
if ( ! Conf.econEnabled)
|
// Bypassing players can do any kind of transaction
|
||||||
P.p.log("NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true");
|
if (i instanceof FPlayer && ((FPlayer) i).isAdminBypassing()) return true;
|
||||||
|
|
||||||
P.p.cmdBase.cmdHelp.updateHelp();
|
// Players with the any withdraw can do.
|
||||||
|
if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer) i).getPlayer())) return true;
|
||||||
|
|
||||||
oldMoneyDoTransfer();
|
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
|
||||||
}
|
if (i == you) return true;
|
||||||
|
|
||||||
public static boolean shouldBeUsed()
|
// A faction can always transfer away the money of it's members and its own money...
|
||||||
{
|
// This will however probably never happen as a faction does not have free will.
|
||||||
return Conf.econEnabled && econ != null && econ.isEnabled();
|
// Ohh by the way... Yes it could. For daily rent to the faction.
|
||||||
}
|
if (i == fI && fI == fYou) return true;
|
||||||
|
|
||||||
public static boolean isSetup()
|
// 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 econ != null;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void modifyUniverseMoney(double delta)
|
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
|
||||||
{
|
return transferMoney(invoker, from, to, amount, true);
|
||||||
if (!shouldBeUsed()) return;
|
}
|
||||||
|
|
||||||
if (Conf.econUniverseAccount == null) return;
|
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) {
|
||||||
if (Conf.econUniverseAccount.length() == 0) return;
|
if (!shouldBeUsed()) return false;
|
||||||
if ( ! econ.hasAccount(Conf.econUniverseAccount)) return;
|
|
||||||
|
|
||||||
modifyBalance(Conf.econUniverseAccount, delta);
|
// The amount must be positive.
|
||||||
}
|
// If the amount is negative we must flip and multiply amount with -1.
|
||||||
|
if (amount < 0) {
|
||||||
|
amount *= -1;
|
||||||
|
EconomyParticipator temp = from;
|
||||||
|
from = to;
|
||||||
|
to = temp;
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about)
|
// Check the rights
|
||||||
{
|
if (!canIControllYou(invoker, from)) return false;
|
||||||
if (!shouldBeUsed())
|
|
||||||
{
|
|
||||||
P.p.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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)
|
// Is there enough money for the transaction to happen?
|
||||||
{
|
if (!econ.has(from.getAccountId(), amount)) {
|
||||||
Faction fI = RelationUtil.getFaction(i);
|
// There was not enough money to pay
|
||||||
Faction fYou = RelationUtil.getFaction(you);
|
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));
|
||||||
|
|
||||||
// This is a system invoker. Accept it.
|
return false;
|
||||||
if (fI == null) return true;
|
}
|
||||||
|
|
||||||
// Bypassing players can do any kind of transaction
|
// Transfer money
|
||||||
if (i instanceof FPlayer && ((FPlayer)i).isAdminBypassing()) return true;
|
EconomyResponse erw = econ.withdrawPlayer(from.getAccountId(), amount);
|
||||||
|
|
||||||
// Players with the any withdraw can do.
|
if (erw.transactionSuccess()) {
|
||||||
if (i instanceof FPlayer && Permission.MONEY_WITHDRAW_ANY.has(((FPlayer)i).getPlayer())) return true;
|
EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount);
|
||||||
|
if (erd.transactionSuccess()) {
|
||||||
|
if (notify) sendTransferInfo(invoker, from, to, amount);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// transaction failed, refund account
|
||||||
|
econ.depositPlayer(from.getAccountId(), amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
|
// if we get here something with the transaction failed
|
||||||
if (i == you) return true;
|
if (notify)
|
||||||
|
invoker.msg("Unable to transfer %s<b> to <h>%s<b> from <h>%s<b>.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true));
|
||||||
|
|
||||||
// A faction can always transfer away the money of it's members and its own money...
|
return false;
|
||||||
// This will however probably never happen as a faction does not have free will.
|
}
|
||||||
// Ohh by the way... Yes it could. For daily rent to the faction.
|
|
||||||
if (i == fI && fI == fYou) return true;
|
|
||||||
|
|
||||||
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
public static Set<FPlayer> getFplayers(EconomyParticipator ep) {
|
||||||
if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer)i).getRole().value >= Role.MODERATOR.value)) return true;
|
Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
||||||
|
|
||||||
// Otherwise you may not! ;,,;
|
if (ep == null) {
|
||||||
i.msg("<h>%s<i> lacks permission to control <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
// Add nothing
|
||||||
return false;
|
} else if (ep instanceof FPlayer) {
|
||||||
}
|
fplayers.add((FPlayer) ep);
|
||||||
|
} else if (ep instanceof Faction) {
|
||||||
|
fplayers.addAll(((Faction) ep).getFPlayers());
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount)
|
return fplayers;
|
||||||
{
|
}
|
||||||
return transferMoney(invoker, from, to, amount, true);
|
|
||||||
}
|
|
||||||
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify)
|
|
||||||
{
|
|
||||||
if ( ! shouldBeUsed()) return false;
|
|
||||||
|
|
||||||
// The amount must be positive.
|
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) {
|
||||||
// If the amount is negative we must flip and multiply amount with -1.
|
Set<FPlayer> recipients = new HashSet<FPlayer>();
|
||||||
if (amount < 0)
|
recipients.addAll(getFplayers(invoker));
|
||||||
{
|
recipients.addAll(getFplayers(from));
|
||||||
amount *= -1;
|
recipients.addAll(getFplayers(to));
|
||||||
EconomyParticipator temp = from;
|
|
||||||
from = to;
|
|
||||||
to = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the rights
|
if (invoker == null) {
|
||||||
if ( ! canIControllYou(invoker, from)) return false;
|
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));
|
||||||
|
}
|
||||||
|
} else if (invoker == from) {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
} else if (invoker == to) {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Is there enough money for the transaction to happen?
|
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) {
|
||||||
if ( ! econ.has(from.getAccountId(), amount))
|
if (!shouldBeUsed()) return true;
|
||||||
{
|
|
||||||
// There was not enough money to pay
|
|
||||||
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));
|
|
||||||
|
|
||||||
return false;
|
if (!econ.has(ep.getAccountId(), delta)) {
|
||||||
}
|
if (toDoThis != null && !toDoThis.isEmpty())
|
||||||
|
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer money
|
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis) {
|
||||||
EconomyResponse erw = econ.withdrawPlayer(from.getAccountId(), amount);
|
if (!shouldBeUsed()) return false;
|
||||||
|
|
||||||
if (erw.transactionSuccess()) {
|
String acc = ep.getAccountId();
|
||||||
EconomyResponse erd = econ.depositPlayer(to.getAccountId(), amount);
|
String You = ep.describeTo(ep, true);
|
||||||
if (erd.transactionSuccess()) {
|
|
||||||
if (notify) sendTransferInfo(invoker, from, to, amount);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// transaction failed, refund account
|
|
||||||
econ.depositPlayer(from.getAccountId(), amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we get here something with the transaction failed
|
if (delta == 0) {
|
||||||
if (notify)
|
// no money actually transferred?
|
||||||
invoker.msg("Unable to transfer %s<b> to <h>%s<b> from <h>%s<b>.", moneyString(amount), to.describeTo(invoker), from.describeTo(invoker, true));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<FPlayer> getFplayers(EconomyParticipator ep)
|
|
||||||
{
|
|
||||||
Set<FPlayer> fplayers = new HashSet<FPlayer>();
|
|
||||||
|
|
||||||
if (ep == null)
|
|
||||||
{
|
|
||||||
// Add nothing
|
|
||||||
}
|
|
||||||
else if (ep instanceof FPlayer)
|
|
||||||
{
|
|
||||||
fplayers.add((FPlayer)ep);
|
|
||||||
}
|
|
||||||
else if (ep instanceof Faction)
|
|
||||||
{
|
|
||||||
fplayers.addAll(((Faction)ep).getFPlayers());
|
|
||||||
}
|
|
||||||
|
|
||||||
return fplayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount)
|
|
||||||
{
|
|
||||||
Set<FPlayer> recipients = new HashSet<FPlayer>();
|
|
||||||
recipients.addAll(getFplayers(invoker));
|
|
||||||
recipients.addAll(getFplayers(from));
|
|
||||||
recipients.addAll(getFplayers(to));
|
|
||||||
|
|
||||||
if (invoker == null)
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (invoker == from)
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (invoker == to)
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis)
|
|
||||||
{
|
|
||||||
if ( ! shouldBeUsed()) return true;
|
|
||||||
|
|
||||||
if ( ! econ.has(ep.getAccountId(), delta))
|
|
||||||
{
|
|
||||||
if (toDoThis != null && !toDoThis.isEmpty())
|
|
||||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", ep.describeTo(ep, true), moneyString(delta), toDoThis);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean modifyMoney(EconomyParticipator ep, double delta, String toDoThis, String forDoingThis)
|
|
||||||
{
|
|
||||||
if ( ! shouldBeUsed()) return false;
|
|
||||||
|
|
||||||
String acc = ep.getAccountId();
|
|
||||||
String You = ep.describeTo(ep, true);
|
|
||||||
|
|
||||||
if (delta == 0)
|
|
||||||
{
|
|
||||||
// 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);
|
if (er.transactionSuccess()) {
|
||||||
if (er.transactionSuccess()) {
|
modifyUniverseMoney(-delta);
|
||||||
modifyUniverseMoney(-delta);
|
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
||||||
ep.msg("<h>%s<i> gained <h>%s<i> %s.", You, moneyString(delta), forDoingThis);
|
return true;
|
||||||
return true;
|
} else {
|
||||||
} else {
|
// transfer to account failed
|
||||||
// transfer to account failed
|
if (forDoingThis != null && !forDoingThis.isEmpty())
|
||||||
if (forDoingThis != null && !forDoingThis.isEmpty())
|
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
||||||
ep.msg("<h>%s<i> would have gained <h>%s<i> %s, but the deposit failed.", You, moneyString(delta), forDoingThis);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
// The player should loose money
|
||||||
else
|
// The player might not have enough.
|
||||||
{
|
|
||||||
// The player should loose money
|
|
||||||
// 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 {
|
||||||
}
|
// There was not enough money to pay
|
||||||
else
|
if (toDoThis != null && !toDoThis.isEmpty())
|
||||||
{
|
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
||||||
// There was not enough money to pay
|
return false;
|
||||||
if (toDoThis != null && !toDoThis.isEmpty())
|
}
|
||||||
ep.msg("<h>%s<i> can't afford <h>%s<i> %s.", You, moneyString(-delta), toDoThis);
|
}
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
||||||
{
|
faction.money = 0;
|
||||||
econ.depositPlayer(faction.getAccountId(), faction.money);
|
}
|
||||||
faction.money = 0;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
|
||||||
return Conf.econCostClaimWilderness
|
return Conf.econCostClaimWilderness
|
||||||
+ (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand)
|
+ (Conf.econCostClaimWilderness * Conf.econClaimAdditionalMultiplier * ownedLand)
|
||||||
- (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus: 0);
|
- (takingFromAnotherFaction ? Conf.econCostClaimFromFactionBonus : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
}
|
||||||
}
|
return amount;
|
||||||
return amount;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// 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();
|
else
|
||||||
else
|
return econ.depositPlayer(account, amount - current).transactionSuccess();
|
||||||
return econ.depositPlayer(account, amount - current).transactionSuccess();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean modifyBalance(String account, double amount)
|
public static boolean modifyBalance(String account, double amount) {
|
||||||
{
|
if (amount < 0)
|
||||||
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,111 +24,90 @@ 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");
|
||||||
{
|
if (ess != null && ess.isEnabled())
|
||||||
Plugin ess = Bukkit.getPluginManager().getPlugin("Essentials");
|
essentials = (IEssentials) ess;
|
||||||
if (ess != null && ess.isEnabled())
|
}
|
||||||
essentials = (IEssentials)ess;
|
|
||||||
}
|
|
||||||
|
|
||||||
// integrate chat
|
// integrate chat
|
||||||
if (essChat != null) return;
|
if (essChat != null) return;
|
||||||
|
|
||||||
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("EssentialsChat");
|
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("EssentialsChat");
|
||||||
if (test == null || !test.isEnabled()) return;
|
if (test == null || !test.isEnabled()) return;
|
||||||
|
|
||||||
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) {
|
||||||
}
|
// no? try older Essentials 2.x integration method
|
||||||
catch (ClassNotFoundException ex)
|
try {
|
||||||
{
|
EssentialsOldVersionFeatures.integrateChat(essChat);
|
||||||
// no? try older Essentials 2.x integration method
|
} catch (NoClassDefFoundError ex2) { /* no known integration method, then */ }
|
||||||
try
|
}
|
||||||
{
|
}
|
||||||
EssentialsOldVersionFeatures.integrateChat(essChat);
|
|
||||||
}
|
|
||||||
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) {
|
||||||
}
|
player.sendMessage(ChatColor.RED.toString() + e.getMessage());
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
return true;
|
||||||
player.sendMessage(ChatColor.RED.toString()+e.getMessage());
|
}
|
||||||
}
|
|
||||||
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);
|
||||||
{
|
P.p.log("Found and will integrate chat with newer " + essChat.getDescription().getFullName());
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new LocalChatListener(), P.p);
|
|
||||||
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) {
|
||||||
}
|
essChat = null;
|
||||||
catch (NoSuchMethodError ex)
|
}
|
||||||
{
|
}
|
||||||
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();
|
||||||
{
|
String format = event.getFormat();
|
||||||
Player speaker = event.getPlayer();
|
format = format.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(speaker));
|
||||||
String format = event.getFormat();
|
event.setFormat(format);
|
||||||
format = format.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(speaker));
|
// NOTE: above doesn't do relation coloring. if/when we can get a local recipient list from EssentialsLocalChatEvent, we'll probably
|
||||||
event.setFormat(format);
|
// want to pass it on to FactionsPlayerListener.onPlayerChat(PlayerChatEvent event) rather than duplicating code
|
||||||
// NOTE: above doesn't do relation coloring. if/when we can get a local recipient list from EssentialsLocalChatEvent, we'll probably
|
}
|
||||||
// want to pass it on to FactionsPlayerListener.onPlayerChat(PlayerChatEvent event) rather than duplicating code
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,59 +1,47 @@
|
|||||||
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() {
|
||||||
{
|
public boolean shouldHandleThisChat(AsyncPlayerChatEvent event) {
|
||||||
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener()
|
return P.p.shouldLetFactionsHandleThisChat(event);
|
||||||
{
|
}
|
||||||
public boolean shouldHandleThisChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
|
||||||
return P.p.shouldLetFactionsHandleThisChat(event);
|
|
||||||
}
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
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
|
public String modifyMessage(AsyncPlayerChatEvent event, Player target, String message) {
|
||||||
if (essChat.getDescription().getVersion().startsWith("2.8.") && Conf.chatTagReplaceString.contains("{"))
|
return message.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTagRelation(event.getPlayer(), target)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(event.getPlayer()));
|
||||||
{
|
}
|
||||||
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("Found and will integrate chat with " + essChat.getDescription().getFullName());
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (NoSuchMethodError ex)
|
|
||||||
{
|
|
||||||
essChat = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unhookChat()
|
// 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 != null)
|
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.");
|
||||||
essChat.removeEssentialsChatListener("Factions");
|
}
|
||||||
}
|
} catch (NoSuchMethodError ex) {
|
||||||
}
|
essChat = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unhookChat() {
|
||||||
|
if (essChat != null) {
|
||||||
|
essChat.removeEssentialsChatListener("Factions");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,90 +1,72 @@
|
|||||||
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;
|
private static LWC lwc;
|
||||||
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;
|
public static void setup() {
|
||||||
import com.griefcraft.lwc.LWCPlugin;
|
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("LWC");
|
||||||
import com.massivecraft.factions.Conf;
|
if (test == null || !test.isEnabled()) return;
|
||||||
import com.massivecraft.factions.FLocation;
|
|
||||||
import com.massivecraft.factions.FPlayers;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
|
|
||||||
public class LWCFeatures
|
lwc = ((LWCPlugin) test).getLWC();
|
||||||
{
|
P.p.log("Successfully hooked into LWC!" + (Conf.lwcIntegration ? "" : " Integration is currently disabled, though (\"lwcIntegration\")."));
|
||||||
private static LWC lwc;
|
}
|
||||||
|
|
||||||
public static void setup()
|
public static boolean getEnabled() {
|
||||||
{
|
return Conf.lwcIntegration && lwc != null;
|
||||||
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("LWC");
|
}
|
||||||
if(test == null || !test.isEnabled()) return;
|
|
||||||
|
|
||||||
lwc = ((LWCPlugin)test).getLWC();
|
public static void clearOtherChests(FLocation flocation, Faction faction) {
|
||||||
P.p.log("Successfully hooked into LWC!"+(Conf.lwcIntegration ? "" : " Integration is currently disabled, though (\"lwcIntegration\")."));
|
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
|
||||||
|
Chunk chunk = location.getChunk();
|
||||||
|
BlockState[] blocks = chunk.getTileEntities();
|
||||||
|
List<Block> chests = new LinkedList<Block>();
|
||||||
|
|
||||||
public static boolean getEnabled()
|
for (int x = 0; x < blocks.length; x++) {
|
||||||
{
|
if (blocks[x].getType() == Material.CHEST) {
|
||||||
return Conf.lwcIntegration && lwc != null;
|
chests.add(blocks[x].getBlock());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearOtherChests(FLocation flocation, Faction faction)
|
for (int x = 0; x < chests.size(); x++) {
|
||||||
{
|
if (lwc.findProtection(chests.get(x)) != null) {
|
||||||
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
if (!faction.getFPlayers().contains(FPlayers.i.get(lwc.findProtection(chests.get(x)).getOwner())))
|
||||||
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
lwc.findProtection(chests.get(x)).remove();
|
||||||
Chunk chunk = location.getChunk();
|
}
|
||||||
BlockState[] blocks = chunk.getTileEntities();
|
}
|
||||||
List<Block> chests = new LinkedList<Block>();
|
}
|
||||||
|
|
||||||
for(int x = 0; x < blocks.length; x++)
|
public static void clearAllChests(FLocation flocation) {
|
||||||
{
|
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
||||||
if(blocks[x].getType() == Material.CHEST)
|
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
||||||
{
|
Chunk chunk = location.getChunk();
|
||||||
chests.add(blocks[x].getBlock());
|
BlockState[] blocks = chunk.getTileEntities();
|
||||||
}
|
List<Block> chests = new LinkedList<Block>();
|
||||||
}
|
|
||||||
|
|
||||||
for(int x = 0; x < chests.size(); x++)
|
for (int x = 0; x < blocks.length; x++) {
|
||||||
{
|
if (blocks[x].getType() == Material.CHEST) {
|
||||||
if(lwc.findProtection(chests.get(x)) != null)
|
chests.add(blocks[x].getBlock());
|
||||||
{
|
}
|
||||||
if(!faction.getFPlayers().contains(FPlayers.i.get(lwc.findProtection(chests.get(x)).getOwner())))
|
}
|
||||||
lwc.findProtection(chests.get(x)).remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearAllChests(FLocation flocation)
|
for (int x = 0; x < chests.size(); x++) {
|
||||||
{
|
if (lwc.findProtection(chests.get(x)) != null) {
|
||||||
Location location = new Location(Bukkit.getWorld(flocation.getWorldName()), flocation.getX() * 16, 5, flocation.getZ() * 16);
|
lwc.findProtection(chests.get(x)).remove();
|
||||||
if (location.getWorld() == null) return; // world not loaded or something? cancel out to prevent error
|
}
|
||||||
Chunk chunk = location.getChunk();
|
}
|
||||||
BlockState[] blocks = chunk.getTileEntities();
|
}
|
||||||
List<Block> chests = new LinkedList<Block>();
|
|
||||||
|
|
||||||
for(int x = 0; x < blocks.length; x++)
|
|
||||||
{
|
|
||||||
if(blocks[x].getType() == Material.CHEST)
|
|
||||||
{
|
|
||||||
chests.add(blocks[x].getBlock());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int x = 0; x < chests.size(); x++)
|
|
||||||
{
|
|
||||||
if(lwc.findProtection(chests.get(x)) != null)
|
|
||||||
{
|
|
||||||
lwc.findProtection(chests.get(x)).remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,329 +1,298 @@
|
|||||||
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;
|
private transient static boolean spoutMe = false;
|
||||||
import org.bukkit.plugin.Plugin;
|
private transient static SpoutMainListener mainListener;
|
||||||
import org.bukkit.entity.Player;
|
private transient static boolean listenersHooked;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
public static void setup() {
|
||||||
import com.massivecraft.factions.struct.Role;
|
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Spout");
|
||||||
|
if (test == null || !test.isEnabled()) return;
|
||||||
|
|
||||||
import org.getspout.spoutapi.gui.Color;
|
setAvailable(true, test.getDescription().getFullName());
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
}
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
|
// set integration availability
|
||||||
|
public static void setAvailable(boolean enable, String pluginName) {
|
||||||
|
spoutMe = enable;
|
||||||
|
if (!spoutMe) return;
|
||||||
|
|
||||||
|
P.p.log("Found and will use features of " + pluginName);
|
||||||
|
|
||||||
|
if (!listenersHooked) {
|
||||||
|
listenersHooked = true;
|
||||||
|
mainListener = new SpoutMainListener();
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're successfully hooked into Spout
|
||||||
|
public static boolean enabled() {
|
||||||
|
return spoutMe;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If Spout is available and the specified Player is running the Spoutcraft client
|
||||||
|
public static boolean availableFor(Player player) {
|
||||||
|
return spoutMe && SpoutManager.getPlayer(player).isSpoutCraftEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class SpoutFeatures
|
// 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) {
|
||||||
private transient static boolean spoutMe = false;
|
if (!enabled())
|
||||||
private transient static SpoutMainListener mainListener;
|
return;
|
||||||
private transient static boolean listenersHooked;
|
|
||||||
|
|
||||||
public static void setup()
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
{
|
|
||||||
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Spout");
|
|
||||||
if (test == null || !test.isEnabled()) return;
|
|
||||||
|
|
||||||
setAvailable(true, test.getDescription().getFullName());
|
for (FPlayer player : players) {
|
||||||
}
|
if (fLoc == null)
|
||||||
|
mainListener.updateTerritoryDisplay(player, false);
|
||||||
|
else if (player.getLastStoodAt().equals(fLoc))
|
||||||
|
mainListener.updateTerritoryDisplay(player, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set integration availability
|
// update displayed current territory for specified player; returns false if unsuccessful
|
||||||
public static void setAvailable(boolean enable, String pluginName)
|
public static boolean updateTerritoryDisplay(FPlayer player) {
|
||||||
{
|
if (!enabled())
|
||||||
spoutMe = enable;
|
return false;
|
||||||
if (!spoutMe) return;
|
|
||||||
|
|
||||||
P.p.log("Found and will use features of "+pluginName);
|
return mainListener.updateTerritoryDisplay(player, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!listenersHooked)
|
// 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) {
|
||||||
listenersHooked = true;
|
if (!enabled())
|
||||||
mainListener = new SpoutMainListener();
|
return;
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're successfully hooked into Spout
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
public static boolean enabled()
|
|
||||||
{
|
|
||||||
return spoutMe;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If Spout is available and the specified Player is running the Spoutcraft client
|
for (FPlayer player : players) {
|
||||||
public static boolean availableFor(Player player)
|
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
|
||||||
{
|
mainListener.updateOwnerList(player);
|
||||||
return spoutMe && SpoutManager.getPlayer(player).isSpoutCraftEnabled();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update owner list for specified player
|
||||||
|
public static void updateOwnerList(FPlayer player) {
|
||||||
|
if (!enabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mainListener.updateOwnerList(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playerDisconnect(FPlayer player) {
|
||||||
|
if (!enabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mainListener.removeTerritoryLabels(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// update displayed current territory for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
// update all appearances between every player
|
||||||
public static void updateTerritoryDisplayLoc(FLocation fLoc)
|
public static void updateAppearances() {
|
||||||
{
|
if (!enabled())
|
||||||
if (!enabled())
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
|
|
||||||
for (FPlayer player : players)
|
for (FPlayer playerA : players) {
|
||||||
{
|
for (FPlayer playerB : players) {
|
||||||
if (fLoc == null)
|
updateSingle(playerB, playerA);
|
||||||
mainListener.updateTerritoryDisplay(player, false);
|
}
|
||||||
else if (player.getLastStoodAt().equals(fLoc))
|
}
|
||||||
mainListener.updateTerritoryDisplay(player, true);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update displayed current territory for specified player; returns false if unsuccessful
|
// update all appearances related to a specific player
|
||||||
public static boolean updateTerritoryDisplay(FPlayer player)
|
public static void updateAppearances(Player player) {
|
||||||
{
|
if (!enabled() || player == null)
|
||||||
if (!enabled())
|
return;
|
||||||
return false;
|
|
||||||
|
|
||||||
return mainListener.updateTerritoryDisplay(player, true);
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
}
|
FPlayer playerA = FPlayers.i.get(player);
|
||||||
|
|
||||||
// update owner list for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
|
for (FPlayer playerB : players) {
|
||||||
public static void updateOwnerListLoc(FLocation fLoc)
|
updateSingle(playerB, playerA);
|
||||||
{
|
updateSingle(playerA, playerB);
|
||||||
if (!enabled())
|
}
|
||||||
return;
|
}
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
// 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) {
|
||||||
|
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateAppearances(player);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
for (FPlayer player : players)
|
// update all appearances related to a single faction
|
||||||
{
|
public static void updateAppearances(Faction faction) {
|
||||||
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
|
if (!enabled() || faction == null)
|
||||||
mainListener.updateOwnerList(player);
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update owner list for specified player
|
Set<FPlayer> players = FPlayers.i.getOnline();
|
||||||
public static void updateOwnerList(FPlayer player)
|
Faction factionA;
|
||||||
{
|
|
||||||
if (!enabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
mainListener.updateOwnerList(player);
|
for (FPlayer playerA : players) {
|
||||||
}
|
factionA = playerA.getFaction();
|
||||||
|
|
||||||
public static void playerDisconnect(FPlayer player)
|
for (FPlayer playerB : players) {
|
||||||
{
|
if (factionA != faction && playerB.getFaction() != faction)
|
||||||
if (!enabled())
|
continue;
|
||||||
return;
|
|
||||||
|
|
||||||
mainListener.removeTerritoryLabels(player.getName());
|
updateSingle(playerB, playerA);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update all appearances between two factions
|
||||||
|
public static void updateAppearances(Faction factionA, Faction factionB) {
|
||||||
|
if (!enabled() || factionA == null || factionB == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true)) {
|
||||||
|
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true)) {
|
||||||
|
updateSingle(playerB, playerA);
|
||||||
|
updateSingle(playerA, playerB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// update all appearances between every player
|
// update a single appearance; internal use only by above public methods
|
||||||
public static void updateAppearances()
|
private static void updateSingle(FPlayer viewer, FPlayer viewed) {
|
||||||
{
|
if (viewer == null || viewed == null)
|
||||||
if (!enabled())
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
Faction viewedFaction = viewed.getFaction();
|
||||||
|
if (viewedFaction == null)
|
||||||
|
return;
|
||||||
|
|
||||||
for (FPlayer playerA : players)
|
// these still end up returning null on occasion at this point, mucking up the SpoutManager.getPlayer() method
|
||||||
{
|
if (viewer.getPlayer() == null || viewed.getPlayer() == null)
|
||||||
for (FPlayer playerB : players)
|
return;
|
||||||
{
|
|
||||||
updateSingle(playerB, playerA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update all appearances related to a specific player
|
SpoutPlayer pViewer = SpoutManager.getPlayer(viewer.getPlayer());
|
||||||
public static void updateAppearances(Player player)
|
SpoutPlayer pViewed = SpoutManager.getPlayer(viewed.getPlayer());
|
||||||
{
|
if (pViewed == null || pViewer == null)
|
||||||
if (!enabled() || player == null)
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
String viewedTitle = viewed.getTitle();
|
||||||
FPlayer playerA = FPlayers.i.get(player);
|
Role viewedRole = viewed.getRole();
|
||||||
|
|
||||||
for (FPlayer playerB : players)
|
if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed) {
|
||||||
{
|
if (viewedFaction.isNormal()) {
|
||||||
updateSingle(playerB, playerA);
|
String addTag = "";
|
||||||
updateSingle(playerA, playerB);
|
if (Conf.spoutFactionTagsOverNames)
|
||||||
}
|
addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
|
||||||
}
|
|
||||||
|
|
||||||
// as above method, but with a delay added; useful for after-login update which doesn't always propagate if done immediately
|
String rolePrefix = viewedRole.getPrefix();
|
||||||
public static void updateAppearancesShortly(final Player player)
|
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
|
||||||
{
|
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
||||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
updateAppearances(player);
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update all appearances related to a single faction
|
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
|
||||||
public static void updateAppearances(Faction faction)
|
} else {
|
||||||
{
|
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
|
||||||
if (!enabled() || faction == null)
|
}
|
||||||
return;
|
}
|
||||||
|
|
||||||
Set<FPlayer> players = FPlayers.i.getOnline();
|
if
|
||||||
Faction factionA;
|
(
|
||||||
|
(
|
||||||
|
Conf.spoutFactionAdminCapes
|
||||||
|
&&
|
||||||
|
viewedRole.equals(Role.ADMIN)
|
||||||
|
)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
Conf.spoutFactionModeratorCapes
|
||||||
|
&&
|
||||||
|
viewedRole.equals(Role.MODERATOR)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Relation relation = viewer.getRelationTo(viewed);
|
||||||
|
String cape = "";
|
||||||
|
if (!viewedFaction.isNormal()) {
|
||||||
|
// yeah, no cape if no faction
|
||||||
|
} else if (viewedFaction.isPeaceful())
|
||||||
|
cape = Conf.capePeaceful;
|
||||||
|
else if (relation.isNeutral())
|
||||||
|
cape = Conf.capeNeutral;
|
||||||
|
else if (relation.isMember())
|
||||||
|
cape = Conf.capeMember;
|
||||||
|
else if (relation.isEnemy())
|
||||||
|
cape = Conf.capeEnemy;
|
||||||
|
else if (relation.isAlly())
|
||||||
|
cape = Conf.capeAlly;
|
||||||
|
|
||||||
for (FPlayer playerA : players)
|
if (cape.isEmpty())
|
||||||
{
|
pViewed.resetCapeFor(pViewer);
|
||||||
factionA = playerA.getFaction();
|
else
|
||||||
|
pViewed.setCapeFor(pViewer, cape);
|
||||||
for (FPlayer playerB : players)
|
} else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes) {
|
||||||
{
|
pViewed.resetCapeFor(pViewer);
|
||||||
if (factionA != faction && playerB.getFaction() != faction)
|
}
|
||||||
continue;
|
}
|
||||||
|
|
||||||
updateSingle(playerB, playerA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update all appearances between two factions
|
|
||||||
public static void updateAppearances(Faction factionA, Faction factionB)
|
|
||||||
{
|
|
||||||
if (!enabled() || factionA == null || factionB == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true))
|
|
||||||
{
|
|
||||||
updateSingle(playerB, playerA);
|
|
||||||
updateSingle(playerA, playerB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// update a single appearance; internal use only by above public methods
|
// method to convert a Bukkit ChatColor to a Spout Color
|
||||||
private static void updateSingle(FPlayer viewer, FPlayer viewed)
|
protected static Color getSpoutColor(ChatColor inColor, int alpha) {
|
||||||
{
|
if (inColor == null)
|
||||||
if (viewer == null || viewed == null)
|
return SpoutFixedColor(191, 191, 191, alpha);
|
||||||
return;
|
|
||||||
|
|
||||||
Faction viewedFaction = viewed.getFaction();
|
switch (inColor.getChar()) {
|
||||||
if (viewedFaction == null)
|
case 0x1:
|
||||||
return;
|
return SpoutFixedColor(0, 0, 191, alpha);
|
||||||
|
case 0x2:
|
||||||
|
return SpoutFixedColor(0, 191, 0, alpha);
|
||||||
|
case 0x3:
|
||||||
|
return SpoutFixedColor(0, 191, 191, alpha);
|
||||||
|
case 0x4:
|
||||||
|
return SpoutFixedColor(191, 0, 0, alpha);
|
||||||
|
case 0x5:
|
||||||
|
return SpoutFixedColor(191, 0, 191, alpha);
|
||||||
|
case 0x6:
|
||||||
|
return SpoutFixedColor(191, 191, 0, alpha);
|
||||||
|
case 0x7:
|
||||||
|
return SpoutFixedColor(191, 191, 191, alpha);
|
||||||
|
case 0x8:
|
||||||
|
return SpoutFixedColor(64, 64, 64, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// these still end up returning null on occasion at this point, mucking up the SpoutManager.getPlayer() method
|
private static Color SpoutFixedColor(int r, int g, int b, int a) {
|
||||||
if (viewer.getPlayer() == null || viewed.getPlayer() == null)
|
return new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||||
return;
|
}
|
||||||
|
|
||||||
SpoutPlayer pViewer = SpoutManager.getPlayer(viewer.getPlayer());
|
|
||||||
SpoutPlayer pViewed = SpoutManager.getPlayer(viewed.getPlayer());
|
|
||||||
if (pViewed == null || pViewer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String viewedTitle = viewed.getTitle();
|
|
||||||
Role viewedRole = viewed.getRole();
|
|
||||||
|
|
||||||
if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed)
|
|
||||||
{
|
|
||||||
if (viewedFaction.isNormal())
|
|
||||||
{
|
|
||||||
String addTag = "";
|
|
||||||
if (Conf.spoutFactionTagsOverNames)
|
|
||||||
addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
|
|
||||||
|
|
||||||
String rolePrefix = viewedRole.getPrefix();
|
|
||||||
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
|
|
||||||
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
|
||||||
|
|
||||||
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
(
|
|
||||||
Conf.spoutFactionAdminCapes
|
|
||||||
&&
|
|
||||||
viewedRole.equals(Role.ADMIN)
|
|
||||||
)
|
|
||||||
||
|
|
||||||
(
|
|
||||||
Conf.spoutFactionModeratorCapes
|
|
||||||
&&
|
|
||||||
viewedRole.equals(Role.MODERATOR)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Relation relation = viewer.getRelationTo(viewed);
|
|
||||||
String cape = "";
|
|
||||||
if (!viewedFaction.isNormal())
|
|
||||||
{
|
|
||||||
// yeah, no cape if no faction
|
|
||||||
}
|
|
||||||
else if (viewedFaction.isPeaceful())
|
|
||||||
cape = Conf.capePeaceful;
|
|
||||||
else if (relation.isNeutral())
|
|
||||||
cape = Conf.capeNeutral;
|
|
||||||
else if (relation.isMember())
|
|
||||||
cape = Conf.capeMember;
|
|
||||||
else if (relation.isEnemy())
|
|
||||||
cape = Conf.capeEnemy;
|
|
||||||
else if (relation.isAlly())
|
|
||||||
cape = Conf.capeAlly;
|
|
||||||
|
|
||||||
if (cape.isEmpty())
|
|
||||||
pViewed.resetCapeFor(pViewer);
|
|
||||||
else
|
|
||||||
pViewed.setCapeFor(pViewer, cape);
|
|
||||||
}
|
|
||||||
else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes)
|
|
||||||
{
|
|
||||||
pViewed.resetCapeFor(pViewer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// method to convert a Bukkit ChatColor to a Spout Color
|
|
||||||
protected static Color getSpoutColor(ChatColor inColor, int alpha)
|
|
||||||
{
|
|
||||||
if (inColor == null)
|
|
||||||
return SpoutFixedColor(191, 191, 191, alpha);
|
|
||||||
|
|
||||||
switch (inColor.getChar())
|
|
||||||
{
|
|
||||||
case 0x1: return SpoutFixedColor(0, 0, 191, alpha);
|
|
||||||
case 0x2: return SpoutFixedColor(0, 191, 0, alpha);
|
|
||||||
case 0x3: return SpoutFixedColor(0, 191, 191, alpha);
|
|
||||||
case 0x4: return SpoutFixedColor(191, 0, 0, alpha);
|
|
||||||
case 0x5: return SpoutFixedColor(191, 0, 191, alpha);
|
|
||||||
case 0x6: return SpoutFixedColor(191, 191, 0, alpha);
|
|
||||||
case 0x7: return SpoutFixedColor(191, 191, 191, alpha);
|
|
||||||
case 0x8: return SpoutFixedColor(64, 64, 64, 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)
|
|
||||||
{
|
|
||||||
return new Color(r/255.0f, g/255.0f, b/255.0f, a/255.0f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,247 +1,217 @@
|
|||||||
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());
|
||||||
updateTerritoryDisplay(me, true);
|
updateTerritoryDisplay(me, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------//
|
//-----------------------------------------------------------------------------------------//
|
||||||
// Everything below this is handled in here to prevent errors on servers not running Spout
|
// Everything below this is handled in here to prevent errors on servers not running Spout
|
||||||
//-----------------------------------------------------------------------------------------//
|
//-----------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
private transient static Map<String, GenericLabel> territoryLabels = new HashMap<String, GenericLabel>();
|
private transient static Map<String, GenericLabel> territoryLabels = new HashMap<String, GenericLabel>();
|
||||||
private transient static Map<String, NoticeLabel> territoryChangeLabels = new HashMap<String, NoticeLabel>();
|
private transient static Map<String, NoticeLabel> territoryChangeLabels = new HashMap<String, NoticeLabel>();
|
||||||
private transient static Map<String, GenericLabel> ownerLabels = new HashMap<String, GenericLabel>();
|
private transient static Map<String, GenericLabel> ownerLabels = new HashMap<String, GenericLabel>();
|
||||||
private final static int SCREEN_WIDTH = 427;
|
private final static int SCREEN_WIDTH = 427;
|
||||||
// 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;
|
|
||||||
|
|
||||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(p);
|
SpoutPlayer sPlayer = SpoutManager.getPlayer(p);
|
||||||
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && ! Conf.spoutTerritoryNoticeShow))
|
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
doLabels(player, sPlayer, notify);
|
doLabels(player, sPlayer, notify);
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
FLocation here = player.getLastStoodAt();
|
FLocation here = player.getLastStoodAt();
|
||||||
Faction factionHere = Board.getFactionAt(here);
|
Faction factionHere = Board.getFactionAt(here);
|
||||||
|
|
||||||
doOwnerList(player, sPlayer, here, factionHere);
|
doOwnerList(player, sPlayer, here, factionHere);
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
// ----------------------
|
// ----------------------
|
||||||
// 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.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
label = new GenericLabel();
|
label.setScale(Conf.spoutTerritoryDisplaySize);
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
|
||||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
|
||||||
|
|
||||||
sPlayer.getMainScreen().attachWidget(P.p, label);
|
sPlayer.getMainScreen().attachWidget(P.p, label);
|
||||||
territoryLabels.put(player.getName(), label);
|
territoryLabels.put(player.getName(), label);
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg = tag;
|
String msg = tag;
|
||||||
|
|
||||||
if (Conf.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty())
|
if (Conf.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty())
|
||||||
msg += " - " + factionHere.getDescription();
|
msg += " - " + factionHere.getDescription();
|
||||||
|
|
||||||
label.setText(msg);
|
label.setText(msg);
|
||||||
alignLabel(label, msg);
|
alignLabel(label, msg);
|
||||||
label.setDirty(true);
|
label.setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------
|
// -----------------------
|
||||||
// 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.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds);
|
label.setScale(Conf.spoutTerritoryNoticeSize);
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
label.setY(Conf.spoutTerritoryNoticeTop);
|
||||||
label.setScale(Conf.spoutTerritoryNoticeSize);
|
sPlayer.getMainScreen().attachWidget(P.p, label);
|
||||||
label.setY(Conf.spoutTerritoryNoticeTop);
|
territoryChangeLabels.put(player.getName(), label);
|
||||||
sPlayer.getMainScreen().attachWidget(P.p, label);
|
}
|
||||||
territoryChangeLabels.put(player.getName(), label);
|
|
||||||
}
|
|
||||||
|
|
||||||
String msg = tag;
|
String msg = tag;
|
||||||
|
|
||||||
if (Conf.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty())
|
if (Conf.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty())
|
||||||
msg += " - " + factionHere.getDescription();
|
msg += " - " + factionHere.getDescription();
|
||||||
|
|
||||||
label.setText(msg);
|
label.setText(msg);
|
||||||
alignLabel(label, msg, 2);
|
alignLabel(label, msg, 2);
|
||||||
label.resetNotice();
|
label.resetNotice();
|
||||||
label.setDirty(true);
|
label.setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and owner list, of course
|
// and owner list, of course
|
||||||
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;
|
||||||
{
|
if (ownerLabels.containsKey(player.getName()))
|
||||||
GenericLabel label;
|
label = ownerLabels.get(player.getName());
|
||||||
if (ownerLabels.containsKey(player.getName()))
|
else {
|
||||||
label = ownerLabels.get(player.getName());
|
label = new GenericLabel();
|
||||||
else
|
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
{
|
label.setScale(Conf.spoutTerritoryDisplaySize);
|
||||||
label = new GenericLabel();
|
label.setY((int) (10 * Conf.spoutTerritoryDisplaySize));
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
sPlayer.getMainScreen().attachWidget(P.p, label);
|
||||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
ownerLabels.put(player.getName(), label);
|
||||||
label.setY((int)(10 * Conf.spoutTerritoryDisplaySize));
|
}
|
||||||
sPlayer.getMainScreen().attachWidget(P.p, label);
|
|
||||||
ownerLabels.put(player.getName(), label);
|
|
||||||
}
|
|
||||||
|
|
||||||
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())
|
||||||
msg = Conf.ownedLandMessage + msg;
|
msg = Conf.ownedLandMessage + msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
label.setText(msg);
|
label.setText(msg);
|
||||||
alignLabel(label, msg);
|
alignLabel(label, msg);
|
||||||
label.setDirty(true);
|
label.setDirty(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
int labelWidth = (int)((float)GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize);
|
|
||||||
if (labelWidth > SCREEN_WIDTH)
|
|
||||||
{
|
|
||||||
label.setX(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (alignment)
|
public void alignLabel(GenericLabel label, String text, int alignment) {
|
||||||
{
|
int labelWidth = (int) ((float) GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize);
|
||||||
case 1: // left aligned
|
if (labelWidth > SCREEN_WIDTH) {
|
||||||
label.setX(0);
|
label.setX(0);
|
||||||
break;
|
return;
|
||||||
case 2: // center aligned
|
}
|
||||||
label.setX((SCREEN_WIDTH - labelWidth) / 2);
|
|
||||||
break;
|
switch (alignment) {
|
||||||
default: // right aligned
|
case 1: // left aligned
|
||||||
label.setX(SCREEN_WIDTH - labelWidth);
|
label.setX(0);
|
||||||
}
|
break;
|
||||||
}
|
case 2: // center aligned
|
||||||
|
label.setX((SCREEN_WIDTH - labelWidth) / 2);
|
||||||
|
break;
|
||||||
|
default: // right aligned
|
||||||
|
label.setX(SCREEN_WIDTH - labelWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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,152 +1,133 @@
|
|||||||
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;
|
||||||
{
|
wg = null;
|
||||||
enabled = false;
|
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
||||||
wg = null;
|
} else {
|
||||||
P.p.log("Could not hook to WorldGuard. WorldGuard checks are disabled.");
|
wg = (WorldGuardPlugin) wgplug;
|
||||||
}
|
enabled = true;
|
||||||
else
|
P.p.log("Successfully hooked to WorldGuard.");
|
||||||
{
|
}
|
||||||
wg = (WorldGuardPlugin) wgplug;
|
}
|
||||||
enabled = true;
|
|
||||||
P.p.log("Successfully hooked to WorldGuard.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isEnabled()
|
public static boolean isEnabled() {
|
||||||
{
|
return enabled;
|
||||||
return enabled;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// PVP Flag check
|
// PVP Flag check
|
||||||
// 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.
|
||||||
{
|
return true;
|
||||||
// No WG hooks so we'll always bypass this check.
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld();
|
||||||
Vector pt = toVector(loc);
|
Vector pt = toVector(loc);
|
||||||
|
|
||||||
RegionManager regionManager = wg.getRegionManager(world);
|
RegionManager regionManager = wg.getRegionManager(world);
|
||||||
ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
|
ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
|
||||||
return set.allows(DefaultFlag.PVP);
|
return set.allows(DefaultFlag.PVP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player can build at location by worldguards rules.
|
// Check if player can build at location by worldguards rules.
|
||||||
// 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.
|
||||||
{
|
return false;
|
||||||
// No WG hooks so we'll always bypass this check.
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld();
|
||||||
Vector pt = toVector(loc);
|
Vector pt = toVector(loc);
|
||||||
|
|
||||||
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0)
|
if (wg.getRegionManager(world).getApplicableRegions(pt).size() > 0)
|
||||||
return wg.canBuild(player, loc);
|
return wg.canBuild(player, loc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for Regions in chunk the chunk
|
// Check for Regions in chunk the chunk
|
||||||
// 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.
|
||||||
{
|
return false;
|
||||||
// No WG hooks so we'll always bypass this check.
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
World world = loc.getWorld();
|
World world = loc.getWorld();
|
||||||
Chunk chunk = world.getChunkAt(loc);
|
Chunk chunk = world.getChunkAt(loc);
|
||||||
int minChunkX = chunk.getX() << 4;
|
int minChunkX = chunk.getX() << 4;
|
||||||
int minChunkZ = chunk.getZ() << 4;
|
int minChunkZ = chunk.getZ() << 4;
|
||||||
int maxChunkX = minChunkX + 15;
|
int maxChunkX = minChunkX + 15;
|
||||||
int maxChunkZ = minChunkZ + 15;
|
int maxChunkZ = minChunkZ + 15;
|
||||||
|
|
||||||
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
|
int worldHeight = world.getMaxHeight(); // Allow for heights other than default
|
||||||
|
|
||||||
BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ);
|
BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ);
|
||||||
BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ);
|
BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ);
|
||||||
|
|
||||||
RegionManager regionManager = wg.getRegionManager(world);
|
RegionManager regionManager = wg.getRegionManager(world);
|
||||||
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
ProtectedCuboidRegion region = new ProtectedCuboidRegion("wgfactionoverlapcheck", minChunk, maxChunk);
|
||||||
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
Map<String, ProtectedRegion> allregions = regionManager.getRegions();
|
||||||
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
List<ProtectedRegion> allregionslist = new ArrayList<ProtectedRegion>(allregions.values());
|
||||||
List<ProtectedRegion> overlaps;
|
List<ProtectedRegion> overlaps;
|
||||||
boolean foundregions = false;
|
boolean foundregions = false;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
overlaps = region.getIntersectingRegions(allregionslist);
|
||||||
overlaps = region.getIntersectingRegions(allregionslist);
|
if (overlaps == null || overlaps.isEmpty()) {
|
||||||
if(overlaps == null || overlaps.isEmpty())
|
foundregions = false;
|
||||||
{
|
} else {
|
||||||
foundregions = false;
|
foundregions = true;
|
||||||
}
|
}
|
||||||
else
|
} catch (Exception e) {
|
||||||
{
|
e.printStackTrace();
|
||||||
foundregions = true;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
region = null;
|
region = null;
|
||||||
allregionslist = null;
|
allregionslist = null;
|
||||||
overlaps = null;
|
overlaps = null;
|
||||||
|
|
||||||
return foundregions;
|
return foundregions;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +1,15 @@
|
|||||||
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
|
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
|
||||||
{
|
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P")) {
|
||||||
public static void setup()
|
P.p.log("Integration with the CAPI plugin was successful");
|
||||||
{
|
Bukkit.getPluginManager().registerEvents(new PluginCapiListener(P.p), P.p);
|
||||||
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
|
}
|
||||||
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P"))
|
}
|
||||||
{
|
|
||||||
P.p.log("Integration with the CAPI plugin was successful");
|
|
||||||
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,106 +11,99 @@ 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;
|
||||||
P p;
|
|
||||||
|
|
||||||
Set<String> myChannelIds = new LinkedHashSet<String>();
|
public class PluginCapiListener implements Listener {
|
||||||
|
P p;
|
||||||
|
|
||||||
public PluginCapiListener(P p)
|
Set<String> myChannelIds = new LinkedHashSet<String>();
|
||||||
{
|
|
||||||
this.p = p;
|
|
||||||
|
|
||||||
myChannelIds.add("faction");
|
public PluginCapiListener(P p) {
|
||||||
myChannelIds.add("allies");
|
this.p = p;
|
||||||
}
|
|
||||||
|
|
||||||
private String replacePlayerTags(String format, FPlayer me, FPlayer you)
|
myChannelIds.add("faction");
|
||||||
{
|
myChannelIds.add("allies");
|
||||||
String meFactionTag = me.getChatTag(you);
|
}
|
||||||
format = format.replace("{ME_FACTIONTAG}", meFactionTag.length() == 0 ? "" : meFactionTag);
|
|
||||||
format = format.replace("{ME_FACTIONTAG_PADR}", meFactionTag.length() == 0 ? "" : meFactionTag+" ");
|
|
||||||
format = format.replace("{ME_FACTIONTAG_PADL}", meFactionTag.length() == 0 ? "" : " "+meFactionTag);
|
|
||||||
format = format.replace("{ME_FACTIONTAG_PADB}", meFactionTag.length() == 0 ? "" : " "+meFactionTag+" ");
|
|
||||||
|
|
||||||
String youFactionTag = you.getChatTag(me);
|
private String replacePlayerTags(String format, FPlayer me, FPlayer you) {
|
||||||
format = format.replace("{YOU_FACTIONTAG}", youFactionTag.length() == 0 ? "" : youFactionTag);
|
String meFactionTag = me.getChatTag(you);
|
||||||
format = format.replace("{YOU_FACTIONTAG_PADR}", youFactionTag.length() == 0 ? "" : youFactionTag+" ");
|
format = format.replace("{ME_FACTIONTAG}", meFactionTag.length() == 0 ? "" : meFactionTag);
|
||||||
format = format.replace("{YOU_FACTIONTAG_PADL}", youFactionTag.length() == 0 ? "" : " "+youFactionTag);
|
format = format.replace("{ME_FACTIONTAG_PADR}", meFactionTag.length() == 0 ? "" : meFactionTag + " ");
|
||||||
format = format.replace("{YOU_FACTIONTAG_PADB}", youFactionTag.length() == 0 ? "" : " "+youFactionTag+" ");
|
format = format.replace("{ME_FACTIONTAG_PADL}", meFactionTag.length() == 0 ? "" : " " + meFactionTag);
|
||||||
|
format = format.replace("{ME_FACTIONTAG_PADB}", meFactionTag.length() == 0 ? "" : " " + meFactionTag + " ");
|
||||||
|
|
||||||
return format;
|
String youFactionTag = you.getChatTag(me);
|
||||||
}
|
format = format.replace("{YOU_FACTIONTAG}", youFactionTag.length() == 0 ? "" : youFactionTag);
|
||||||
|
format = format.replace("{YOU_FACTIONTAG_PADR}", youFactionTag.length() == 0 ? "" : youFactionTag + " ");
|
||||||
|
format = format.replace("{YOU_FACTIONTAG_PADL}", youFactionTag.length() == 0 ? "" : " " + youFactionTag);
|
||||||
|
format = format.replace("{YOU_FACTIONTAG_PADB}", youFactionTag.length() == 0 ? "" : " " + youFactionTag + " ");
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
return format;
|
||||||
public void onListChannelsEvent(CAPIListChannelsEvent event)
|
}
|
||||||
{
|
|
||||||
for (Channel c : Channels.i.getAll())
|
|
||||||
{
|
|
||||||
if (myChannelIds.contains(c.getId()))
|
|
||||||
{
|
|
||||||
event.getChannels().add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onMessageToChannel(CAPIMessageToChannelEvent event)
|
public void onListChannelsEvent(CAPIListChannelsEvent event) {
|
||||||
{
|
for (Channel c : Channels.i.getAll()) {
|
||||||
if (event.isCancelled()) return;
|
if (myChannelIds.contains(c.getId())) {
|
||||||
if ( ! myChannelIds.contains(event.getChannel().getId())) return;
|
event.getChannels().add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Player me = event.getMe();
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
FPlayer fme = FPlayers.i.get(me);
|
public void onMessageToChannel(CAPIMessageToChannelEvent event) {
|
||||||
Faction myFaction = fme.getFaction();
|
if (event.isCancelled()) return;
|
||||||
|
if (!myChannelIds.contains(event.getChannel().getId())) return;
|
||||||
|
|
||||||
if (event.getChannel().getId().equals("faction") && myFaction.isNormal())
|
Player me = event.getMe();
|
||||||
{
|
FPlayer fme = FPlayers.i.get(me);
|
||||||
event.getThem().addAll(myFaction.getOnlinePlayers());
|
Faction myFaction = fme.getFaction();
|
||||||
|
|
||||||
// Send to any players who are spying chat... could probably be implemented better than this
|
if (event.getChannel().getId().equals("faction") && myFaction.isNormal()) {
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
event.getThem().addAll(myFaction.getOnlinePlayers());
|
||||||
{
|
|
||||||
if(fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
|
||||||
fplayer.sendMessage("[FCspy] "+myFaction.getTag()+": "+event.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.getChannel().getId().equals("allies"))
|
|
||||||
{
|
|
||||||
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers())
|
|
||||||
{
|
|
||||||
FPlayer someFPlayer = FPlayers.i.get(somePlayer);
|
|
||||||
if (someFPlayer.getRelationTo(fme).isAtLeast(Relation.ALLY))
|
|
||||||
event.getThem().add(somePlayer);
|
|
||||||
// Send to any players who are spying chat
|
|
||||||
else if(someFPlayer.isSpyingChat())
|
|
||||||
someFPlayer.sendMessage("[ACspy]: " + event.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
// Send to any players who are spying chat... could probably be implemented better than this
|
||||||
public void onMessageToPlayer(CAPIMessageToPlayerEvent event)
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
{
|
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
||||||
if (event.isCancelled()) return;
|
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + event.getMessage());
|
||||||
event.setFormat(this.replacePlayerTags(event.getFormat(), FPlayers.i.get(event.getMe()), FPlayers.i.get(event.getYou())));
|
}
|
||||||
}
|
} else if (event.getChannel().getId().equals("allies")) {
|
||||||
|
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
FPlayer someFPlayer = FPlayers.i.get(somePlayer);
|
||||||
|
if (someFPlayer.getRelationTo(fme).isAtLeast(Relation.ALLY))
|
||||||
|
event.getThem().add(somePlayer);
|
||||||
|
// Send to any players who are spying chat
|
||||||
|
else if (someFPlayer.isSpyingChat())
|
||||||
|
someFPlayer.sendMessage("[ACspy]: " + event.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onSelectChannel(CAPISelectChannelEvent 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())));
|
||||||
String channelId = event.getChannel().getId();
|
}
|
||||||
if ( ! myChannelIds.contains(channelId)) return;
|
|
||||||
|
|
||||||
Player me = event.getMe();
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
FPlayer fme = FPlayers.i.get(me);
|
public void onSelectChannel(CAPISelectChannelEvent event) {
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
String channelId = event.getChannel().getId();
|
||||||
|
if (!myChannelIds.contains(channelId)) return;
|
||||||
|
|
||||||
if ( ! fme.hasFaction())
|
Player me = event.getMe();
|
||||||
{
|
FPlayer fme = FPlayers.i.get(me);
|
||||||
event.setFailMessage(p.txt.parse("<b>You must be member in a faction to use this channel."));
|
|
||||||
event.setCancelled(true);
|
if (!fme.hasFaction()) {
|
||||||
}
|
event.setFailMessage(p.txt.parse("<b>You must be member in a faction to use this channel."));
|
||||||
}
|
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,253 +11,208 @@ 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)
|
|
||||||
{
|
|
||||||
this.p = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
public FactionsBlockListener(P p) {
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
this.p = p;
|
||||||
{
|
}
|
||||||
if (event.isCancelled()) return;
|
|
||||||
if ( ! event.canBuild()) return;
|
|
||||||
|
|
||||||
// special case for flint&steel, which should only be prevented by DenyUsage list
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE)
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
{
|
if (event.isCancelled()) return;
|
||||||
return;
|
if (!event.canBuild()) return;
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false))
|
// special case for flint&steel, which should only be prevented by DenyUsage list
|
||||||
event.setCancelled(true);
|
if (event.getBlockPlaced().getType() == Material.FIRE) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false))
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
event.setCancelled(true);
|
||||||
{
|
}
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false))
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
{
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
event.setCancelled(true);
|
if (event.isCancelled()) return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
event.setCancelled(true);
|
||||||
{
|
}
|
||||||
if (event.isCancelled()) return;
|
}
|
||||||
|
|
||||||
if (event.getInstaBreak() && ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false))
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
{
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
event.setCancelled(true);
|
if (event.isCancelled()) return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
if (event.getInstaBreak() && !playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
event.setCancelled(true);
|
||||||
{
|
}
|
||||||
if (event.isCancelled()) return;
|
}
|
||||||
if ( ! Conf.pistonProtectionThroughDenyBuild) return;
|
|
||||||
|
|
||||||
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
if (!Conf.pistonProtectionThroughDenyBuild) return;
|
||||||
|
|
||||||
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
|
Faction pistonFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
||||||
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
|
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
|
||||||
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation()))
|
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
// if potentially pushing into air/water/lava in another territory, we need to check it out
|
||||||
return;
|
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* note that I originally was testing the territory of each affected block, but since I found that pistons can only push
|
* note that I originally was testing the territory of each affected block, but since I found that pistons can only push
|
||||||
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
|
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
|
||||||
* only the final target block as done above
|
* only the final target block as done above
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@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)
|
||||||
{
|
return true;
|
||||||
if ( ! Conf.safeZoneDenyBuild)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (otherFaction.isWarZone()) {
|
||||||
else if (otherFaction.isWarZone())
|
if (!Conf.warZoneDenyBuild)
|
||||||
{
|
return true;
|
||||||
if ( ! Conf.warZoneDenyBuild)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
Relation rel = pistonFaction.getRelationTo(otherFaction);
|
||||||
|
|
||||||
if (rel.confDenyBuild(otherFaction.hasPlayersOnline()))
|
if (rel.confDenyBuild(otherFaction.hasPlayersOnline()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
FPlayer me = FPlayers.i.get(name);
|
FPlayer me = FPlayers.i.get(name);
|
||||||
if (me.isAdminBypassing()) return true;
|
if (me.isAdminBypassing()) return true;
|
||||||
|
|
||||||
FLocation loc = new FLocation(location);
|
FLocation loc = new FLocation(location);
|
||||||
Faction otherFaction = Board.getFactionAt(loc);
|
Faction otherFaction = Board.getFactionAt(loc);
|
||||||
|
|
||||||
if (otherFaction.isNone())
|
if (otherFaction.isNone()) {
|
||||||
{
|
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName()))
|
if (!Conf.wildernessDenyBuild || 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.
|
||||||
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
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))
|
||||||
{
|
return true;
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
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))
|
||||||
{
|
return true;
|
||||||
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!justCheck)
|
if (!justCheck)
|
||||||
me.msg("<b>You can't "+action+" in a war zone.");
|
me.msg("<b>You can't " + action + " in a war zone.");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
Relation rel = myFaction.getRelationTo(otherFaction);
|
Relation rel = myFaction.getRelationTo(otherFaction);
|
||||||
boolean online = otherFaction.hasPlayersOnline();
|
boolean online = otherFaction.hasPlayersOnline();
|
||||||
boolean pain = !justCheck && rel.confPainBuild(online);
|
boolean pain = !justCheck && rel.confPainBuild(online);
|
||||||
boolean deny = rel.confDenyBuild(online);
|
boolean deny = rel.confDenyBuild(online);
|
||||||
|
|
||||||
// hurt the player for building/destroying in other territory?
|
// hurt the player for building/destroying in other territory?
|
||||||
if (pain)
|
if (pain) {
|
||||||
{
|
player.damage(Conf.actionDeniedPainAmount);
|
||||||
player.damage(Conf.actionDeniedPainAmount);
|
|
||||||
|
|
||||||
if (!deny)
|
if (!deny)
|
||||||
me.msg("<b>It is painful to try to "+action+" in the territory of "+otherFaction.getTag(myFaction));
|
me.msg("<b>It is painful to try to " + action + " in the territory of " + otherFaction.getTag(myFaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,175 +11,146 @@ 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)
|
|
||||||
{
|
|
||||||
this.p = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
|
public FactionsChatListener(P p) {
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
this.p = p;
|
||||||
public void onPlayerEarlyChat(PlayerChatEvent event)
|
}
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
Player talkingPlayer = event.getPlayer();
|
// this is for handling slashless command usage and faction/alliance chat, set at lowest priority so Factions gets to them first
|
||||||
String msg = event.getMessage();
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
FPlayer me = FPlayers.i.get(talkingPlayer);
|
public void onPlayerEarlyChat(PlayerChatEvent event) {
|
||||||
ChatMode chat = me.getChatMode();
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
// slashless factions commands need to be handled here if the user isn't in public chat mode
|
Player talkingPlayer = event.getPlayer();
|
||||||
if (chat != ChatMode.PUBLIC && p.handleCommand(talkingPlayer, msg, false, true))
|
String msg = event.getMessage();
|
||||||
{
|
FPlayer me = FPlayers.i.get(talkingPlayer);
|
||||||
if (Conf.logPlayerCommands)
|
ChatMode chat = me.getChatMode();
|
||||||
Bukkit.getLogger().log(Level.INFO, "[PLAYER_COMMAND] "+talkingPlayer.getName()+": "+msg);
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is it a faction chat message?
|
// slashless factions commands need to be handled here if the user isn't in public chat mode
|
||||||
if (chat == ChatMode.FACTION)
|
if (chat != ChatMode.PUBLIC && p.handleCommand(talkingPlayer, msg, false, true)) {
|
||||||
{
|
if (Conf.logPlayerCommands)
|
||||||
Faction myFaction = me.getFaction();
|
Bukkit.getLogger().log(Level.INFO, "[PLAYER_COMMAND] " + talkingPlayer.getName() + ": " + msg);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg);
|
// Is it a faction chat message?
|
||||||
myFaction.sendMessage(message);
|
if (chat == ChatMode.FACTION) {
|
||||||
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("FactionChat "+myFaction.getTag()+": "+message));
|
String message = String.format(Conf.factionChatFormat, me.describeTo(myFaction), msg);
|
||||||
|
myFaction.sendMessage(message);
|
||||||
|
|
||||||
//Send to any players who are spying chat
|
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("FactionChat " + myFaction.getTag() + ": " + message));
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
|
||||||
{
|
|
||||||
if(fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
|
||||||
fplayer.sendMessage("[FCspy] "+myFaction.getTag()+": "+message);
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
//Send to any players who are spying chat
|
||||||
return;
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
}
|
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
|
||||||
else if (chat == ChatMode.ALLIANCE)
|
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + message);
|
||||||
{
|
}
|
||||||
Faction myFaction = me.getFaction();
|
|
||||||
|
|
||||||
String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
} else if (chat == ChatMode.ALLIANCE) {
|
||||||
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
//Send message to our own faction
|
String message = String.format(Conf.allianceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg);
|
||||||
myFaction.sendMessage(message);
|
|
||||||
|
|
||||||
//Send to all our allies
|
//Send message to our own faction
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
myFaction.sendMessage(message);
|
||||||
{
|
|
||||||
if(myFaction.getRelationTo(fplayer) == Relation.ALLY)
|
|
||||||
fplayer.sendMessage(message);
|
|
||||||
|
|
||||||
//Send to any players who are spying chat
|
//Send to all our allies
|
||||||
else if(fplayer.isSpyingChat())
|
for (FPlayer fplayer : FPlayers.i.getOnline()) {
|
||||||
fplayer.sendMessage("[ACspy]: " + message);
|
if (myFaction.getRelationTo(fplayer) == Relation.ALLY)
|
||||||
}
|
fplayer.sendMessage(message);
|
||||||
|
|
||||||
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: "+message));
|
//Send to any players who are spying chat
|
||||||
|
else if (fplayer.isSpyingChat())
|
||||||
|
fplayer.sendMessage("[ACspy]: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message));
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
event.setCancelled(true);
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
return;
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
}
|
||||||
{
|
}
|
||||||
if (event.isCancelled()) return;
|
|
||||||
|
|
||||||
// Are we to insert the Faction tag into the format?
|
// 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
|
||||||
// If we are not to insert it - we are done.
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
if ( ! Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) return;
|
public void onPlayerChat(PlayerChatEvent event) {
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
|
||||||
Player talkingPlayer = event.getPlayer();
|
// Are we to insert the Faction tag into the format?
|
||||||
String msg = event.getMessage();
|
// If we are not to insert it - we are done.
|
||||||
String eventFormat = event.getFormat();
|
if (!Conf.chatTagEnabled || Conf.chatTagHandledByAnotherPlugin) return;
|
||||||
FPlayer me = FPlayers.i.get(talkingPlayer);
|
|
||||||
int InsertIndex = 0;
|
|
||||||
|
|
||||||
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString))
|
Player talkingPlayer = event.getPlayer();
|
||||||
{
|
String msg = event.getMessage();
|
||||||
// we're using the "replace" method of inserting the faction tags
|
String eventFormat = event.getFormat();
|
||||||
// if they stuck "[FACTION_TITLE]" in there, go ahead and do it too
|
FPlayer me = FPlayers.i.get(talkingPlayer);
|
||||||
if (eventFormat.contains("[FACTION_TITLE]"))
|
int InsertIndex = 0;
|
||||||
{
|
|
||||||
eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle());
|
|
||||||
}
|
|
||||||
InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString);
|
|
||||||
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
|
|
||||||
Conf.chatTagPadAfter = false;
|
|
||||||
Conf.chatTagPadBefore = false;
|
|
||||||
}
|
|
||||||
else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString))
|
|
||||||
{
|
|
||||||
// we're using the "insert after string" method
|
|
||||||
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length();
|
|
||||||
}
|
|
||||||
else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString))
|
|
||||||
{
|
|
||||||
// we're using the "insert before string" method
|
|
||||||
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we'll fall back to using the index place method
|
|
||||||
InsertIndex = Conf.chatTagInsertIndex;
|
|
||||||
if (InsertIndex > eventFormat.length())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");
|
if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) {
|
||||||
String formatEnd = ((Conf.chatTagPadAfter && !me.getChatTag().isEmpty()) ? " " : "") + eventFormat.substring(InsertIndex);
|
// 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 (eventFormat.contains("[FACTION_TITLE]")) {
|
||||||
|
eventFormat = eventFormat.replace("[FACTION_TITLE]", me.getTitle());
|
||||||
|
}
|
||||||
|
InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString);
|
||||||
|
eventFormat = eventFormat.replace(Conf.chatTagReplaceString, "");
|
||||||
|
Conf.chatTagPadAfter = false;
|
||||||
|
Conf.chatTagPadBefore = false;
|
||||||
|
} else if (!Conf.chatTagInsertAfterString.isEmpty() && eventFormat.contains(Conf.chatTagInsertAfterString)) {
|
||||||
|
// we're using the "insert after string" method
|
||||||
|
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertAfterString) + Conf.chatTagInsertAfterString.length();
|
||||||
|
} else if (!Conf.chatTagInsertBeforeString.isEmpty() && eventFormat.contains(Conf.chatTagInsertBeforeString)) {
|
||||||
|
// we're using the "insert before string" method
|
||||||
|
InsertIndex = eventFormat.indexOf(Conf.chatTagInsertBeforeString);
|
||||||
|
} else {
|
||||||
|
// we'll fall back to using the index place method
|
||||||
|
InsertIndex = Conf.chatTagInsertIndex;
|
||||||
|
if (InsertIndex > eventFormat.length())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd;
|
String formatStart = eventFormat.substring(0, InsertIndex) + ((Conf.chatTagPadBefore && !me.getChatTag().isEmpty()) ? " " : "");
|
||||||
|
String formatEnd = ((Conf.chatTagPadAfter && !me.getChatTag().isEmpty()) ? " " : "") + eventFormat.substring(InsertIndex);
|
||||||
|
|
||||||
// Relation Colored?
|
String nonColoredMsgFormat = formatStart + me.getChatTag().trim() + formatEnd;
|
||||||
if (Conf.chatTagRelationColored)
|
|
||||||
{
|
|
||||||
// We must choke the standard message and send out individual messages to all players
|
|
||||||
// Why? Because the relations will differ.
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
for (Player listeningPlayer : event.getRecipients())
|
// Relation Colored?
|
||||||
{
|
if (Conf.chatTagRelationColored) {
|
||||||
FPlayer you = FPlayers.i.get(listeningPlayer);
|
// We must choke the standard message and send out individual messages to all players
|
||||||
String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd;
|
// Why? Because the relations will differ.
|
||||||
try
|
event.setCancelled(true);
|
||||||
{
|
|
||||||
listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg));
|
|
||||||
}
|
|
||||||
catch (UnknownFormatConversionException ex)
|
|
||||||
{
|
|
||||||
Conf.chatTagInsertIndex = 0;
|
|
||||||
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, "For a more proper fix, please read this regarding chat configuration: http://massivecraft.com/plugins/factions/config#Chat_configuration");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write to the log... We will write the non colored message.
|
for (Player listeningPlayer : event.getRecipients()) {
|
||||||
String nonColoredMsg = ChatColor.stripColor(String.format(nonColoredMsgFormat, talkingPlayer.getDisplayName(), msg));
|
FPlayer you = FPlayers.i.get(listeningPlayer);
|
||||||
Bukkit.getLogger().log(Level.INFO, nonColoredMsg);
|
String yourFormat = formatStart + me.getChatTag(you).trim() + formatEnd;
|
||||||
}
|
try {
|
||||||
else
|
listeningPlayer.sendMessage(String.format(yourFormat, talkingPlayer.getDisplayName(), msg));
|
||||||
{
|
} catch (UnknownFormatConversionException ex) {
|
||||||
// No relation color.
|
Conf.chatTagInsertIndex = 0;
|
||||||
event.setFormat(nonColoredMsgFormat);
|
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, "For a more proper fix, please read this regarding chat configuration: http://massivecraft.com/plugins/factions/config#Chat_configuration");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write to the log... We will write the non colored message.
|
||||||
|
String nonColoredMsg = ChatColor.stripColor(String.format(nonColoredMsgFormat, talkingPlayer.getDisplayName(), msg));
|
||||||
|
Bukkit.getLogger().log(Level.INFO, nonColoredMsg);
|
||||||
|
} else {
|
||||||
|
// No relation color.
|
||||||
|
event.setFormat(nonColoredMsgFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,69 +1,63 @@
|
|||||||
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
|
||||||
Block block = event.getToBlock();
|
Block block = event.getToBlock();
|
||||||
int source = event.getBlock().getTypeId();
|
int source = event.getBlock().getTypeId();
|
||||||
int target = block.getTypeId();
|
int target = block.getTypeId();
|
||||||
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11))
|
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11))
|
||||||
block.setTypeId(0);
|
block.setTypeId(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
|
||||||
Location target = event.getTo();
|
Location target = event.getTo();
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
|
|
||||||
// blocks who occupy less than 1 block width or length wise need to be handled differently
|
// blocks who occupy less than 1 block width or length wise need to be handled differently
|
||||||
Material mat = event.getTo().getBlock().getType();
|
Material mat = event.getTo().getBlock().getType();
|
||||||
if (
|
if (
|
||||||
((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65))
|
((mat == Material.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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges
|
// simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges
|
||||||
target.setX(target.getBlockX() + 0.5);
|
target.setX(target.getBlockX() + 0.5);
|
||||||
target.setZ(target.getBlockZ() + 0.5);
|
target.setZ(target.getBlockZ() + 0.5);
|
||||||
event.setTo(target);
|
event.setTo(target);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean clippingThrough(Location target, Location from, double thickness)
|
public static boolean clippingThrough(Location target, Location from, double thickness) {
|
||||||
{
|
return
|
||||||
return
|
(
|
||||||
(
|
(from.getX() > target.getX() && (from.getX() - target.getX() < thickness))
|
||||||
(from.getX() > target.getX() && (from.getX() - target.getX() < thickness))
|
|| (target.getX() > from.getX() && (target.getX() - from.getX() < thickness))
|
||||||
|| (target.getX() > from.getX() && (target.getX() - from.getX() < thickness))
|
|| (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness))
|
||||||
|| (from.getZ() > target.getZ() && (from.getZ() - target.getZ() < thickness))
|
|| (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))
|
||||||
|| (target.getZ() > from.getZ() && (target.getZ() - from.getZ() < thickness))
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,42 +1,36 @@
|
|||||||
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)
|
|
||||||
{
|
|
||||||
this.p = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
public FactionsServerListener(P p) {
|
||||||
public void onPluginDisable(PluginDisableEvent event)
|
this.p = p;
|
||||||
{
|
}
|
||||||
String name = event.getPlugin().getDescription().getName();
|
|
||||||
if (name.equals("Spout"))
|
|
||||||
{
|
|
||||||
SpoutFeatures.setAvailable(false, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPluginEnable(PluginEnableEvent event)
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
{
|
String name = event.getPlugin().getDescription().getName();
|
||||||
Plugin plug = event.getPlugin();
|
if (name.equals("Spout")) {
|
||||||
String name = plug.getDescription().getName();
|
SpoutFeatures.setAvailable(false, "");
|
||||||
if (name.equals("Spout"))
|
}
|
||||||
{
|
}
|
||||||
SpoutFeatures.setAvailable(true, plug.getDescription().getFullName());
|
|
||||||
}
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
}
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
Plugin plug = event.getPlugin();
|
||||||
|
String name = plug.getDescription().getName();
|
||||||
|
if (name.equals("Spout")) {
|
||||||
|
SpoutFeatures.setAvailable(true, plug.getDescription().getFullName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,40 +1,34 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
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,87 +1,81 @@
|
|||||||
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 {
|
||||||
|
MANAGE_SAFE_ZONE("managesafezone"),
|
||||||
|
MANAGE_WAR_ZONE("managewarzone"),
|
||||||
|
OWNERSHIP_BYPASS("ownershipbypass"),
|
||||||
|
ADMIN("admin"),
|
||||||
|
ADMIN_ANY("admin.any"),
|
||||||
|
AUTOCLAIM("autoclaim"),
|
||||||
|
BYPASS("bypass"),
|
||||||
|
CHAT("chat"),
|
||||||
|
CHATSPY("chatspy"),
|
||||||
|
CLAIM("claim"),
|
||||||
|
CLAIM_RADIUS("claim.radius"),
|
||||||
|
CONFIG("config"),
|
||||||
|
CREATE("create"),
|
||||||
|
DEINVITE("deinvite"),
|
||||||
|
DESCRIPTION("description"),
|
||||||
|
DISBAND("disband"),
|
||||||
|
DISBAND_ANY("disband.any"),
|
||||||
|
HELP("help"),
|
||||||
|
HOME("home"),
|
||||||
|
INVITE("invite"),
|
||||||
|
JOIN("join"),
|
||||||
|
JOIN_ANY("join.any"),
|
||||||
|
JOIN_OTHERS("join.others"),
|
||||||
|
KICK("kick"),
|
||||||
|
KICK_ANY("kick.any"),
|
||||||
|
LEAVE("leave"),
|
||||||
|
LIST("list"),
|
||||||
|
LOCK("lock"),
|
||||||
|
MAP("map"),
|
||||||
|
MOD("mod"),
|
||||||
|
MOD_ANY("mod.any"),
|
||||||
|
MONEY_BALANCE("money.balance"),
|
||||||
|
MONEY_BALANCE_ANY("money.balance.any"),
|
||||||
|
MONEY_DEPOSIT("money.deposit"),
|
||||||
|
MONEY_WITHDRAW("money.withdraw"),
|
||||||
|
MONEY_WITHDRAW_ANY("money.withdraw.any"),
|
||||||
|
MONEY_F2F("money.f2f"),
|
||||||
|
MONEY_F2P("money.f2p"),
|
||||||
|
MONEY_P2F("money.p2f"),
|
||||||
|
NO_BOOM("noboom"),
|
||||||
|
OPEN("open"),
|
||||||
|
OWNER("owner"),
|
||||||
|
OWNERLIST("ownerlist"),
|
||||||
|
SET_PEACEFUL("setpeaceful"),
|
||||||
|
SET_PERMANENT("setpermanent"),
|
||||||
|
SET_PERMANENTPOWER("setpermanentpower"),
|
||||||
|
POWERBOOST("powerboost"),
|
||||||
|
POWER("power"),
|
||||||
|
POWER_ANY("power.any"),
|
||||||
|
RELATION("relation"),
|
||||||
|
RELOAD("reload"),
|
||||||
|
SAVE("save"),
|
||||||
|
SETHOME("sethome"),
|
||||||
|
SETHOME_ANY("sethome.any"),
|
||||||
|
SHOW("show"),
|
||||||
|
TAG("tag"),
|
||||||
|
TITLE("title"),
|
||||||
|
UNCLAIM("unclaim"),
|
||||||
|
UNCLAIM_ALL("unclaimall"),
|
||||||
|
VERSION("version"),;
|
||||||
|
|
||||||
public enum Permission
|
public final String node;
|
||||||
{
|
|
||||||
MANAGE_SAFE_ZONE("managesafezone"),
|
|
||||||
MANAGE_WAR_ZONE("managewarzone"),
|
|
||||||
OWNERSHIP_BYPASS("ownershipbypass"),
|
|
||||||
ADMIN("admin"),
|
|
||||||
ADMIN_ANY("admin.any"),
|
|
||||||
AUTOCLAIM("autoclaim"),
|
|
||||||
BYPASS("bypass"),
|
|
||||||
CHAT("chat"),
|
|
||||||
CHATSPY("chatspy"),
|
|
||||||
CLAIM("claim"),
|
|
||||||
CLAIM_RADIUS("claim.radius"),
|
|
||||||
CONFIG("config"),
|
|
||||||
CREATE("create"),
|
|
||||||
DEINVITE("deinvite"),
|
|
||||||
DESCRIPTION("description"),
|
|
||||||
DISBAND("disband"),
|
|
||||||
DISBAND_ANY("disband.any"),
|
|
||||||
HELP("help"),
|
|
||||||
HOME("home"),
|
|
||||||
INVITE("invite"),
|
|
||||||
JOIN("join"),
|
|
||||||
JOIN_ANY("join.any"),
|
|
||||||
JOIN_OTHERS("join.others"),
|
|
||||||
KICK("kick"),
|
|
||||||
KICK_ANY("kick.any"),
|
|
||||||
LEAVE("leave"),
|
|
||||||
LIST("list"),
|
|
||||||
LOCK("lock"),
|
|
||||||
MAP("map"),
|
|
||||||
MOD("mod"),
|
|
||||||
MOD_ANY("mod.any"),
|
|
||||||
MONEY_BALANCE("money.balance"),
|
|
||||||
MONEY_BALANCE_ANY("money.balance.any"),
|
|
||||||
MONEY_DEPOSIT("money.deposit"),
|
|
||||||
MONEY_WITHDRAW("money.withdraw"),
|
|
||||||
MONEY_WITHDRAW_ANY("money.withdraw.any"),
|
|
||||||
MONEY_F2F("money.f2f"),
|
|
||||||
MONEY_F2P("money.f2p"),
|
|
||||||
MONEY_P2F("money.p2f"),
|
|
||||||
NO_BOOM("noboom"),
|
|
||||||
OPEN("open"),
|
|
||||||
OWNER("owner"),
|
|
||||||
OWNERLIST("ownerlist"),
|
|
||||||
SET_PEACEFUL("setpeaceful"),
|
|
||||||
SET_PERMANENT("setpermanent"),
|
|
||||||
SET_PERMANENTPOWER("setpermanentpower"),
|
|
||||||
POWERBOOST("powerboost"),
|
|
||||||
POWER("power"),
|
|
||||||
POWER_ANY("power.any"),
|
|
||||||
RELATION("relation"),
|
|
||||||
RELOAD("reload"),
|
|
||||||
SAVE("save"),
|
|
||||||
SETHOME("sethome"),
|
|
||||||
SETHOME_ANY("sethome.any"),
|
|
||||||
SHOW("show"),
|
|
||||||
TAG("tag"),
|
|
||||||
TITLE("title"),
|
|
||||||
UNCLAIM("unclaim"),
|
|
||||||
UNCLAIM_ALL("unclaimall"),
|
|
||||||
VERSION("version"),
|
|
||||||
;
|
|
||||||
|
|
||||||
public final String node;
|
Permission(final String node) {
|
||||||
|
this.node = "factions." + node;
|
||||||
|
}
|
||||||
|
|
||||||
Permission(final String node)
|
public boolean has(CommandSender sender, boolean informSenderIfNot) {
|
||||||
{
|
return P.p.perm.has(sender, this.node, informSenderIfNot);
|
||||||
this.node = "factions."+node;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean has(CommandSender sender, boolean informSenderIfNot)
|
public boolean has(CommandSender sender) {
|
||||||
{
|
return has(sender, false);
|
||||||
return P.p.perm.has(sender, this.node, informSenderIfNot);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean has(CommandSender sender)
|
|
||||||
{
|
|
||||||
return has(sender, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,146 +1,125 @@
|
|||||||
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 {
|
||||||
|
MEMBER(3, "member"),
|
||||||
|
ALLY(2, "ally"),
|
||||||
|
NEUTRAL(1, "neutral"),
|
||||||
|
ENEMY(0, "enemy");
|
||||||
|
|
||||||
public enum Relation
|
public final int value;
|
||||||
{
|
public final String nicename;
|
||||||
MEMBER(3, "member"),
|
|
||||||
ALLY(2, "ally"),
|
|
||||||
NEUTRAL(1, "neutral"),
|
|
||||||
ENEMY(0, "enemy");
|
|
||||||
|
|
||||||
public final int value;
|
private Relation(final int value, final String nicename) {
|
||||||
public final String nicename;
|
this.value = value;
|
||||||
|
this.nicename = nicename;
|
||||||
|
}
|
||||||
|
|
||||||
private Relation(final int value, final String nicename)
|
@Override
|
||||||
{
|
public String toString() {
|
||||||
this.value = value;
|
return this.nicename;
|
||||||
this.nicename = nicename;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public boolean isMember() {
|
||||||
public String toString()
|
return this == MEMBER;
|
||||||
{
|
}
|
||||||
return this.nicename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMember()
|
public boolean isAlly() {
|
||||||
{
|
return this == ALLY;
|
||||||
return this == MEMBER;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlly()
|
public boolean isNeutral() {
|
||||||
{
|
return this == NEUTRAL;
|
||||||
return this == ALLY;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNeutral()
|
public boolean isEnemy() {
|
||||||
{
|
return this == ENEMY;
|
||||||
return this == NEUTRAL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnemy()
|
public boolean isAtLeast(Relation relation) {
|
||||||
{
|
return this.value >= relation.value;
|
||||||
return this == ENEMY;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAtLeast(Relation relation)
|
public boolean isAtMost(Relation relation) {
|
||||||
{
|
return this.value <= relation.value;
|
||||||
return this.value >= relation.value;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAtMost(Relation relation)
|
public ChatColor getColor() {
|
||||||
{
|
if (this == MEMBER)
|
||||||
return this.value <= relation.value;
|
return Conf.colorMember;
|
||||||
}
|
else if (this == ALLY)
|
||||||
|
return Conf.colorAlly;
|
||||||
|
else if (this == NEUTRAL)
|
||||||
|
return Conf.colorNeutral;
|
||||||
|
else
|
||||||
|
return Conf.colorEnemy;
|
||||||
|
}
|
||||||
|
|
||||||
public ChatColor getColor()
|
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
||||||
{
|
public boolean confDenyBuild(boolean online) {
|
||||||
if (this == MEMBER)
|
if (isMember())
|
||||||
return Conf.colorMember;
|
return false;
|
||||||
else if (this == ALLY)
|
|
||||||
return Conf.colorAlly;
|
|
||||||
else if (this == NEUTRAL)
|
|
||||||
return Conf.colorNeutral;
|
|
||||||
else
|
|
||||||
return Conf.colorEnemy;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
if (online) {
|
||||||
public boolean confDenyBuild(boolean online)
|
if (isEnemy())
|
||||||
{
|
return Conf.territoryEnemyDenyBuild;
|
||||||
if (isMember())
|
else if (isAlly())
|
||||||
return false;
|
return Conf.territoryAllyDenyBuild;
|
||||||
|
else
|
||||||
|
return Conf.territoryDenyBuild;
|
||||||
|
} else {
|
||||||
|
if (isEnemy())
|
||||||
|
return Conf.territoryEnemyDenyBuildWhenOffline;
|
||||||
|
else if (isAlly())
|
||||||
|
return Conf.territoryAllyDenyBuildWhenOffline;
|
||||||
|
else
|
||||||
|
return Conf.territoryDenyBuildWhenOffline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (online)
|
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
||||||
{
|
public boolean confPainBuild(boolean online) {
|
||||||
if (isEnemy())
|
if (isMember())
|
||||||
return Conf.territoryEnemyDenyBuild;
|
return false;
|
||||||
else if (isAlly())
|
|
||||||
return Conf.territoryAllyDenyBuild;
|
|
||||||
else
|
|
||||||
return Conf.territoryDenyBuild;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isEnemy())
|
|
||||||
return Conf.territoryEnemyDenyBuildWhenOffline;
|
|
||||||
else if (isAlly())
|
|
||||||
return Conf.territoryAllyDenyBuildWhenOffline;
|
|
||||||
else
|
|
||||||
return Conf.territoryDenyBuildWhenOffline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
if (online) {
|
||||||
public boolean confPainBuild(boolean online)
|
if (isEnemy())
|
||||||
{
|
return Conf.territoryEnemyPainBuild;
|
||||||
if (isMember())
|
else if (isAlly())
|
||||||
return false;
|
return Conf.territoryAllyPainBuild;
|
||||||
|
else
|
||||||
|
return Conf.territoryPainBuild;
|
||||||
|
} else {
|
||||||
|
if (isEnemy())
|
||||||
|
return Conf.territoryEnemyPainBuildWhenOffline;
|
||||||
|
else if (isAlly())
|
||||||
|
return Conf.territoryAllyPainBuildWhenOffline;
|
||||||
|
else
|
||||||
|
return Conf.territoryPainBuildWhenOffline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (online)
|
// return appropriate Conf setting for DenyUseage based on this relation
|
||||||
{
|
public boolean confDenyUseage() {
|
||||||
if (isEnemy())
|
if (isMember())
|
||||||
return Conf.territoryEnemyPainBuild;
|
return false;
|
||||||
else if (isAlly())
|
else if (isEnemy())
|
||||||
return Conf.territoryAllyPainBuild;
|
return Conf.territoryEnemyDenyUseage;
|
||||||
else
|
else if (isAlly())
|
||||||
return Conf.territoryPainBuild;
|
return Conf.territoryAllyDenyUseage;
|
||||||
}
|
else
|
||||||
else
|
return Conf.territoryDenyUseage;
|
||||||
{
|
}
|
||||||
if (isEnemy())
|
|
||||||
return Conf.territoryEnemyPainBuildWhenOffline;
|
|
||||||
else if (isAlly())
|
|
||||||
return Conf.territoryAllyPainBuildWhenOffline;
|
|
||||||
else
|
|
||||||
return Conf.territoryPainBuildWhenOffline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return appropriate Conf setting for DenyUseage based on this relation
|
public double getRelationCost() {
|
||||||
public boolean confDenyUseage()
|
if (isEnemy())
|
||||||
{
|
return Conf.econCostEnemy;
|
||||||
if (isMember())
|
else if (isAlly())
|
||||||
return false;
|
return Conf.econCostAlly;
|
||||||
else if (isEnemy())
|
else
|
||||||
return Conf.territoryEnemyDenyUseage;
|
return Conf.econCostNeutral;
|
||||||
else if (isAlly())
|
}
|
||||||
return Conf.territoryAllyDenyUseage;
|
|
||||||
else
|
|
||||||
return Conf.territoryDenyUseage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRelationCost()
|
|
||||||
{
|
|
||||||
if (isEnemy())
|
|
||||||
return Conf.econCostEnemy;
|
|
||||||
else if (isAlly())
|
|
||||||
return Conf.econCostAlly;
|
|
||||||
else
|
|
||||||
return Conf.econCostNeutral;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,49 +2,41 @@ 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");
|
|
||||||
|
|
||||||
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;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,97 +1,89 @@
|
|||||||
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
|
|
||||||
{
|
|
||||||
N('N'),
|
|
||||||
NE('/'),
|
|
||||||
E('E'),
|
|
||||||
SE('\\'),
|
|
||||||
S('S'),
|
|
||||||
SW('/'),
|
|
||||||
W('W'),
|
|
||||||
NW('\\');
|
|
||||||
|
|
||||||
public final char asciiChar;
|
public class AsciiCompass {
|
||||||
|
public enum Point {
|
||||||
|
N('N'),
|
||||||
|
NE('/'),
|
||||||
|
E('E'),
|
||||||
|
SE('\\'),
|
||||||
|
S('S'),
|
||||||
|
SW('/'),
|
||||||
|
W('W'),
|
||||||
|
NW('\\');
|
||||||
|
|
||||||
private Point(final char asciiChar)
|
public final char asciiChar;
|
||||||
{
|
|
||||||
this.asciiChar = asciiChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private Point(final char asciiChar) {
|
||||||
public String toString()
|
this.asciiChar = asciiChar;
|
||||||
{
|
}
|
||||||
return String.valueOf(this.asciiChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(boolean isActive, ChatColor colorActive, String colorDefault)
|
@Override
|
||||||
{
|
public String toString() {
|
||||||
return (isActive ? colorActive : colorDefault)+String.valueOf(this.asciiChar);
|
return String.valueOf(this.asciiChar);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static AsciiCompass.Point getCompassPointForDirection(double inDegrees)
|
public String toString(boolean isActive, ChatColor colorActive, String colorDefault) {
|
||||||
{
|
return (isActive ? colorActive : colorDefault) + String.valueOf(this.asciiChar);
|
||||||
double degrees = (inDegrees - 180) % 360 ;
|
}
|
||||||
if (degrees < 0)
|
}
|
||||||
degrees += 360;
|
|
||||||
|
|
||||||
if (0 <= degrees && degrees < 22.5)
|
public static AsciiCompass.Point getCompassPointForDirection(double inDegrees) {
|
||||||
return AsciiCompass.Point.N;
|
double degrees = (inDegrees - 180) % 360;
|
||||||
else if (22.5 <= degrees && degrees < 67.5)
|
if (degrees < 0)
|
||||||
return AsciiCompass.Point.NE;
|
degrees += 360;
|
||||||
else if (67.5 <= degrees && degrees < 112.5)
|
|
||||||
return AsciiCompass.Point.E;
|
|
||||||
else if (112.5 <= degrees && degrees < 157.5)
|
|
||||||
return AsciiCompass.Point.SE;
|
|
||||||
else if (157.5 <= degrees && degrees < 202.5)
|
|
||||||
return AsciiCompass.Point.S;
|
|
||||||
else if (202.5 <= degrees && degrees < 247.5)
|
|
||||||
return AsciiCompass.Point.SW;
|
|
||||||
else if (247.5 <= degrees && degrees < 292.5)
|
|
||||||
return AsciiCompass.Point.W;
|
|
||||||
else if (292.5 <= degrees && degrees < 337.5)
|
|
||||||
return AsciiCompass.Point.NW;
|
|
||||||
else if (337.5 <= degrees && degrees < 360.0)
|
|
||||||
return AsciiCompass.Point.N;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault)
|
if (0 <= degrees && degrees < 22.5)
|
||||||
{
|
return AsciiCompass.Point.N;
|
||||||
ArrayList<String> ret = new ArrayList<String>();
|
else if (22.5 <= degrees && degrees < 67.5)
|
||||||
String row;
|
return AsciiCompass.Point.NE;
|
||||||
|
else if (67.5 <= degrees && degrees < 112.5)
|
||||||
|
return AsciiCompass.Point.E;
|
||||||
|
else if (112.5 <= degrees && degrees < 157.5)
|
||||||
|
return AsciiCompass.Point.SE;
|
||||||
|
else if (157.5 <= degrees && degrees < 202.5)
|
||||||
|
return AsciiCompass.Point.S;
|
||||||
|
else if (202.5 <= degrees && degrees < 247.5)
|
||||||
|
return AsciiCompass.Point.SW;
|
||||||
|
else if (247.5 <= degrees && degrees < 292.5)
|
||||||
|
return AsciiCompass.Point.W;
|
||||||
|
else if (292.5 <= degrees && degrees < 337.5)
|
||||||
|
return AsciiCompass.Point.NW;
|
||||||
|
else if (337.5 <= degrees && degrees < 360.0)
|
||||||
|
return AsciiCompass.Point.N;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
row = "";
|
public static ArrayList<String> getAsciiCompass(Point point, ChatColor colorActive, String colorDefault) {
|
||||||
row += Point.NW.toString(Point.NW == point, colorActive, colorDefault);
|
ArrayList<String> ret = new ArrayList<String>();
|
||||||
row += Point.N.toString(Point.N == point, colorActive, colorDefault);
|
String row;
|
||||||
row += Point.NE.toString(Point.NE == point, colorActive, colorDefault);
|
|
||||||
ret.add(row);
|
|
||||||
|
|
||||||
row = "";
|
row = "";
|
||||||
row += Point.W.toString(Point.W == point, colorActive, colorDefault);
|
row += Point.NW.toString(Point.NW == point, colorActive, colorDefault);
|
||||||
row += colorDefault+"+";
|
row += Point.N.toString(Point.N == point, colorActive, colorDefault);
|
||||||
row += Point.E.toString(Point.E == point, colorActive, colorDefault);
|
row += Point.NE.toString(Point.NE == point, colorActive, colorDefault);
|
||||||
ret.add(row);
|
ret.add(row);
|
||||||
|
|
||||||
row = "";
|
row = "";
|
||||||
row += Point.SW.toString(Point.SW == point, colorActive, colorDefault);
|
row += Point.W.toString(Point.W == point, colorActive, colorDefault);
|
||||||
row += Point.S.toString(Point.S == point, colorActive, colorDefault);
|
row += colorDefault + "+";
|
||||||
row += Point.SE.toString(Point.SE == point, colorActive, colorDefault);
|
row += Point.E.toString(Point.E == point, colorActive, colorDefault);
|
||||||
ret.add(row);
|
ret.add(row);
|
||||||
|
|
||||||
return ret;
|
row = "";
|
||||||
}
|
row += Point.SW.toString(Point.SW == point, colorActive, colorDefault);
|
||||||
|
row += Point.S.toString(Point.S == point, colorActive, colorDefault);
|
||||||
|
row += Point.SE.toString(Point.SE == point, colorActive, colorDefault);
|
||||||
|
ret.add(row);
|
||||||
|
|
||||||
public static ArrayList<String> getAsciiCompass(double inDegrees, ChatColor colorActive, String colorDefault)
|
return ret;
|
||||||
{
|
}
|
||||||
return getAsciiCompass(getCompassPointForDirection(inDegrees), colorActive, colorDefault);
|
|
||||||
}
|
public static ArrayList<String> getAsciiCompass(double inDegrees, ChatColor colorActive, String colorDefault) {
|
||||||
|
return getAsciiCompass(getCompassPointForDirection(inDegrees), colorActive, colorDefault);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,94 +1,79 @@
|
|||||||
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 {
|
||||||
|
private transient boolean readyToGo = false;
|
||||||
|
private transient boolean finished = false;
|
||||||
|
private transient ArrayList<FPlayer> fplayers;
|
||||||
|
private transient ListIterator<FPlayer> iterator;
|
||||||
|
private transient double toleranceMillis;
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
public AutoLeaveProcessTask() {
|
||||||
import com.massivecraft.factions.Faction;
|
fplayers = new ArrayList<FPlayer>(FPlayers.i.get());
|
||||||
import com.massivecraft.factions.FPlayer;
|
this.iterator = fplayers.listIterator();
|
||||||
import com.massivecraft.factions.FPlayers;
|
this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000;
|
||||||
import com.massivecraft.factions.P;
|
this.readyToGo = true;
|
||||||
import com.massivecraft.factions.struct.Role;
|
this.finished = false;
|
||||||
|
}
|
||||||
|
|
||||||
public class AutoLeaveProcessTask extends BukkitRunnable
|
public void run() {
|
||||||
{
|
if (Conf.autoLeaveAfterDaysOfInactivity <= 0.0 || Conf.autoLeaveRoutineMaxMillisecondsPerTick <= 0.0) {
|
||||||
private transient boolean readyToGo = false;
|
this.stop();
|
||||||
private transient boolean finished = false;
|
return;
|
||||||
private transient ArrayList<FPlayer> fplayers;
|
}
|
||||||
private transient ListIterator<FPlayer> iterator;
|
|
||||||
private transient double toleranceMillis;
|
|
||||||
|
|
||||||
public AutoLeaveProcessTask()
|
if (!readyToGo) return;
|
||||||
{
|
// this is set so it only does one iteration at a time, no matter how frequently the timer fires
|
||||||
fplayers = new ArrayList<FPlayer>(FPlayers.i.get());
|
readyToGo = false;
|
||||||
this.iterator = fplayers.listIterator();
|
// 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
|
||||||
this.toleranceMillis = Conf.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000;
|
long loopStartTime = System.currentTimeMillis();
|
||||||
this.readyToGo = true;
|
|
||||||
this.finished = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run()
|
while (iterator.hasNext()) {
|
||||||
{
|
long now = System.currentTimeMillis();
|
||||||
if (Conf.autoLeaveAfterDaysOfInactivity <= 0.0 || Conf.autoLeaveRoutineMaxMillisecondsPerTick <= 0.0)
|
|
||||||
{
|
|
||||||
this.stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! readyToGo) return;
|
// if this iteration has been running for maximum time, stop to take a breather until next tick
|
||||||
// this is set so it only does one iteration at a time, no matter how frequently the timer fires
|
if (now > loopStartTime + Conf.autoLeaveRoutineMaxMillisecondsPerTick) {
|
||||||
readyToGo = false;
|
readyToGo = true;
|
||||||
// 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
|
return;
|
||||||
long loopStartTime = System.currentTimeMillis();
|
}
|
||||||
|
|
||||||
while(iterator.hasNext())
|
FPlayer fplayer = iterator.next();
|
||||||
{
|
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) {
|
||||||
long now = System.currentTimeMillis();
|
if (Conf.logFactionLeave || Conf.logFactionKick)
|
||||||
|
P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");
|
||||||
|
|
||||||
// if this iteration has been running for maximum time, stop to take a breather until next tick
|
// if player is faction admin, sort out the faction since he's going away
|
||||||
if (now > loopStartTime + Conf.autoLeaveRoutineMaxMillisecondsPerTick)
|
if (fplayer.getRole() == Role.ADMIN) {
|
||||||
{
|
Faction faction = fplayer.getFaction();
|
||||||
readyToGo = true;
|
if (faction != null)
|
||||||
return;
|
fplayer.getFaction().promoteNewLeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer fplayer = iterator.next();
|
fplayer.leave(false);
|
||||||
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis)
|
iterator.remove(); // go ahead and remove this list's link to the FPlayer object
|
||||||
{
|
fplayer.detach();
|
||||||
if (Conf.logFactionLeave || Conf.logFactionKick)
|
}
|
||||||
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
|
// looks like we've finished
|
||||||
if (fplayer.getRole() == Role.ADMIN)
|
this.stop();
|
||||||
{
|
}
|
||||||
Faction faction = fplayer.getFaction();
|
|
||||||
if (faction != null)
|
|
||||||
fplayer.getFaction().promoteNewLeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
fplayer.leave(false);
|
// we're done, shut down
|
||||||
iterator.remove(); // go ahead and remove this list's link to the FPlayer object
|
public void stop() {
|
||||||
fplayer.detach();
|
readyToGo = false;
|
||||||
}
|
finished = true;
|
||||||
}
|
|
||||||
|
|
||||||
// looks like we've finished
|
this.cancel();
|
||||||
this.stop();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// we're done, shut down
|
public boolean isFinished() {
|
||||||
public void stop()
|
return finished;
|
||||||
{
|
}
|
||||||
readyToGo = false;
|
|
||||||
finished = true;
|
|
||||||
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFinished()
|
|
||||||
{
|
|
||||||
return finished;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,26 +3,23 @@ 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;
|
|
||||||
|
|
||||||
task = new AutoLeaveProcessTask();
|
task = new AutoLeaveProcessTask();
|
||||||
task.runTaskTimer(P.p, 1, 1);
|
task.runTaskTimer(P.p, 1, 1);
|
||||||
|
|
||||||
// maybe setting has been changed? if so, restart this task at new rate
|
// maybe setting has been changed? if so, restart this task at new rate
|
||||||
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes)
|
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes)
|
||||||
P.p.startAutoLeaveTask(true);
|
P.p.startAutoLeaveTask(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,99 +9,86 @@ 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;
|
private double y;
|
||||||
private double y;
|
private double z;
|
||||||
private double z;
|
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;
|
this.z = z;
|
||||||
this.z = z;
|
this.yaw = yaw;
|
||||||
this.yaw = yaw;
|
this.pitch = pitch;
|
||||||
this.pitch = pitch;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// This returns the actual Location
|
// This returns the actual Location
|
||||||
public final Location getLocation()
|
public final Location getLocation() {
|
||||||
{
|
// make sure Location is initialized before returning it
|
||||||
// make sure Location is initialized before returning it
|
initLocation();
|
||||||
initLocation();
|
return location;
|
||||||
return location;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// change the Location
|
// change the Location
|
||||||
public final void setLocation(Location loc)
|
public final void setLocation(Location loc) {
|
||||||
{
|
this.location = loc;
|
||||||
this.location = loc;
|
this.worldName = loc.getWorld().getName();
|
||||||
this.worldName = loc.getWorld().getName();
|
this.x = loc.getX();
|
||||||
this.x = loc.getX();
|
this.y = loc.getY();
|
||||||
this.y = loc.getY();
|
this.z = loc.getZ();
|
||||||
this.z = loc.getZ();
|
this.yaw = loc.getYaw();
|
||||||
this.yaw = loc.getYaw();
|
this.pitch = loc.getPitch();
|
||||||
this.pitch = loc.getPitch();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
// get World; hopefully it's initialized at this point
|
// get World; hopefully it's initialized at this point
|
||||||
World world = Bukkit.getWorld(worldName);
|
World world = Bukkit.getWorld(worldName);
|
||||||
if (world == null) return;
|
if (world == null) return;
|
||||||
|
|
||||||
// store the Location for future calls, and pass it on
|
// store the Location for future calls, and pass it on
|
||||||
location = new Location(world, x, y, z, yaw, pitch);
|
location = new Location(world, x, y, z, yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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,128 +1,104 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>();
|
Map<FLocation, Set<String>> locationMap = new ConcurrentHashMap<FLocation, Set<String>>();
|
||||||
Set<String> nameSet;
|
Set<String> nameSet;
|
||||||
Iterator<JsonElement> iter;
|
Iterator<JsonElement> iter;
|
||||||
String worldName;
|
String worldName;
|
||||||
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]+");
|
||||||
{
|
x = Integer.parseInt(coords[0]);
|
||||||
coords = entry2.getKey().trim().split("[,\\s]+");
|
z = Integer.parseInt(coords[1]);
|
||||||
x = Integer.parseInt(coords[0]);
|
|
||||||
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());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
locationMap.put(new FLocation(worldName, x, z), nameSet);
|
locationMap.put(new FLocation(worldName, x, z), nameSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return locationMap;
|
return locationMap;
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex)
|
ex.printStackTrace();
|
||||||
{
|
P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets.");
|
||||||
ex.printStackTrace();
|
return null;
|
||||||
P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets.");
|
}
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
Iterator<String> iter;
|
||||||
Iterator<String> iter;
|
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());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
obj.get(locWorld).getAsJsonObject().add(loc.getCoordString(), nameArray);
|
obj.get(locWorld).getAsJsonObject().add(loc.getCoordString(), nameArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex)
|
ex.printStackTrace();
|
||||||
{
|
P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets.");
|
||||||
ex.printStackTrace();
|
return obj;
|
||||||
P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets.");
|
}
|
||||||
return obj;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,63 @@
|
|||||||
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;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public class MiscUtil
|
String name = entity.getClass().getSimpleName();
|
||||||
{
|
name = name.substring(5); // Remove "Craft"
|
||||||
public static EntityType creatureTypeFromEntity(Entity entity)
|
|
||||||
{
|
|
||||||
if ( ! (entity instanceof Creature))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String name = entity.getClass().getSimpleName();
|
return EntityType.fromName(name);
|
||||||
name = name.substring(5); // Remove "Craft"
|
}
|
||||||
|
|
||||||
return EntityType.fromName(name);
|
// Inclusive range
|
||||||
}
|
public static long[] range(long start, long end) {
|
||||||
|
long[] values = new long[(int) Math.abs(end - start) + 1];
|
||||||
|
|
||||||
// Inclusive range
|
if (end < start) {
|
||||||
public static long[] range(long start, long end) {
|
long oldstart = start;
|
||||||
long[] values = new long[(int) Math.abs(end - start) + 1];
|
start = end;
|
||||||
|
end = oldstart;
|
||||||
|
}
|
||||||
|
|
||||||
if (end < start) {
|
for (long i = start; i <= end; i++) {
|
||||||
long oldstart = start;
|
values[(int) (i - start)] = i;
|
||||||
start = end;
|
}
|
||||||
end = oldstart;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (long i = start; i <= end; i++) {
|
return values;
|
||||||
values[(int) (i - start)] = i;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return values;
|
/// TODO create tag whitelist!!
|
||||||
}
|
public static HashSet<String> substanceChars = new HashSet<String>(Arrays.asList(new String[]{
|
||||||
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||||
|
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||||
|
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
|
||||||
|
"s", "t", "u", "v", "w", "x", "y", "z"
|
||||||
|
}));
|
||||||
|
|
||||||
/// TODO create tag whitelist!!
|
public static String getComparisonString(String str) {
|
||||||
public static HashSet<String> substanceChars = new HashSet<String>(Arrays.asList(new String []{
|
String ret = "";
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
|
||||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
||||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
|
|
||||||
"s", "t", "u", "v", "w", "x", "y", "z"
|
|
||||||
}));
|
|
||||||
|
|
||||||
public static String getComparisonString(String str)
|
str = ChatColor.stripColor(str);
|
||||||
{
|
str = str.toLowerCase();
|
||||||
String ret = "";
|
|
||||||
|
|
||||||
str = ChatColor.stripColor(str);
|
for (char c : str.toCharArray()) {
|
||||||
str = str.toLowerCase();
|
if (substanceChars.contains(String.valueOf(c))) {
|
||||||
|
ret += c;
|
||||||
for (char c : str.toCharArray())
|
}
|
||||||
{
|
}
|
||||||
if (substanceChars.contains(String.valueOf(c)))
|
return ret.toLowerCase();
|
||||||
{
|
}
|
||||||
ret += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user