Halfway through refactoring of commands and permissions

This commit is contained in:
Olof Larsson 2011-10-09 14:53:38 +02:00
parent 227d54dc5f
commit 10f535e637
54 changed files with 1478 additions and 1312 deletions

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import java.util.*; import java.util.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
@ -10,6 +11,9 @@ public class Conf
// not worth saving between server restarts, I think // not worth saving between server restarts, I think
public static transient Set<String> adminBypassPlayers = Collections.synchronizedSet(new HashSet<String>()); public static transient Set<String> adminBypassPlayers = Collections.synchronizedSet(new HashSet<String>());
public static List<String> baseCommandAliases = new ArrayList<String>();
public static boolean allowNoSlashCommand = true;
// Colors // Colors
public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorMember = ChatColor.GREEN;
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
@ -68,8 +72,6 @@ public class Conf
public static String factionChatFormat = "%s"+ChatColor.WHITE+" %s"; public static String factionChatFormat = "%s"+ChatColor.WHITE+" %s";
public static String allianceChatFormat = "%s"+ChatColor.WHITE+" %s"; public static String allianceChatFormat = "%s"+ChatColor.WHITE+" %s";
public static boolean allowNoSlashCommand = true;
public static double autoLeaveAfterDaysOfInactivity = 14.0; public static double autoLeaveAfterDaysOfInactivity = 14.0;
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
@ -239,6 +241,8 @@ public class Conf
static static
{ {
baseCommandAliases.add("f");
territoryEnemyDenyCommands.add("home"); territoryEnemyDenyCommands.add("home");
territoryEnemyDenyCommands.add("sethome"); territoryEnemyDenyCommands.add("sethome");
territoryEnemyDenyCommands.add("spawn"); territoryEnemyDenyCommands.add("spawn");

View File

@ -1,23 +1,15 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import java.io.*;
import java.lang.reflect.Type;
import java.util.*;
import java.util.logging.Level;
import java.util.Map.Entry;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.google.gson.reflect.TypeToken;
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.integration.Worldguard; import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.ChatMode;
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.persist.Entity;
import com.massivecraft.factions.zcore.persist.PlayerEntity; import com.massivecraft.factions.zcore.persist.PlayerEntity;
@ -70,12 +62,46 @@ public class FPlayer extends PlayerEntity
// FIELD: autoClaimEnabled // FIELD: autoClaimEnabled
private transient boolean autoClaimEnabled; private transient boolean autoClaimEnabled;
public boolean isAutoClaimEnabled()
{
if (this.factionId.equals("0")) return false;
return autoClaimEnabled;
}
public void setIsAutoClaimEnabled(boolean enabled)
{
this.autoClaimEnabled = enabled;
if (enabled)
{
this.autoSafeZoneEnabled = false;
this.autoWarZoneEnabled = false;
}
}
// FIELD: autoSafeZoneEnabled // FIELD: autoSafeZoneEnabled
private transient boolean autoSafeZoneEnabled; private transient boolean autoSafeZoneEnabled;
public boolean isAutoSafeClaimEnabled() { return autoSafeZoneEnabled; }
public void setIsAutoSafeClaimEnabled(boolean enabled)
{
this.autoSafeZoneEnabled = enabled;
if (enabled)
{
this.autoClaimEnabled = false;
this.autoWarZoneEnabled = false;
}
}
// FIELD: autoWarZoneEnabled // FIELD: autoWarZoneEnabled
private transient boolean autoWarZoneEnabled; private transient boolean autoWarZoneEnabled;
public boolean isAutoWarClaimEnabled() { return autoWarZoneEnabled; }
public void setIsAutoWarClaimEnabled(boolean enabled)
{
this.autoWarZoneEnabled = enabled;
if (enabled)
{
this.autoClaimEnabled = false;
this.autoSafeZoneEnabled = false;
}
}
// FIELD: loginPvpDisabled // FIELD: loginPvpDisabled
private transient boolean loginPvpDisabled; private transient boolean loginPvpDisabled;
@ -113,10 +139,11 @@ public class FPlayer extends PlayerEntity
public void resetFactionData() public void resetFactionData()
{ {
// clean up any territory ownership in old faction, if there is one // clean up any territory ownership in old faction, if there is one
if (this.factionId > 0 && Factions.i.exists(this.factionId)) Faction currentFaction = this.getFaction();
if (currentFaction != null && currentFaction.isNormal())
{ {
// TODO: Get faction function... currentFaction.clearClaimOwnership(this.getId());
Factions.i.get(factionId).clearClaimOwnership(this.getId());
} }
this.factionId = "0"; // The default neutral faction this.factionId = "0"; // The default neutral faction
@ -156,48 +183,7 @@ public class FPlayer extends PlayerEntity
return lastLoginTime; return lastLoginTime;
} }
public boolean autoClaimEnabled()
{
if (this.factionId.equals("0")) return false;
return autoClaimEnabled;
}
public void enableAutoClaim(boolean enabled)
{
this.autoClaimEnabled = enabled;
if (enabled)
{
this.autoSafeZoneEnabled = false;
this.autoWarZoneEnabled = false;
}
}
public boolean autoSafeZoneEnabled()
{
return autoSafeZoneEnabled;
}
public void enableAutoSafeZone(boolean enabled)
{
this.autoSafeZoneEnabled = enabled;
if (enabled)
{
this.autoClaimEnabled = false;
this.autoWarZoneEnabled = false;
}
}
public boolean autoWarZoneEnabled()
{
return autoWarZoneEnabled;
}
public void enableAutoWarZone(boolean enabled)
{
this.autoWarZoneEnabled = enabled;
if (enabled)
{
this.autoClaimEnabled = false;
this.autoSafeZoneEnabled = false;
}
}
public void setLastLoginTime(long lastLoginTime) public void setLastLoginTime(long lastLoginTime)
{ {
@ -513,8 +499,8 @@ public class FPlayer extends PlayerEntity
public boolean isInOthersTerritory() public boolean isInOthersTerritory()
{ {
String idHere = Board.getIdAt(new FLocation(this)); Faction factionHere = Board.getFactionAt(new FLocation(this));
return idHere > 0 && idHere != this.factionId; return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction();
} }
public boolean isInAllyTerritory() public boolean isInAllyTerritory()
@ -892,4 +878,9 @@ public class FPlayer extends PlayerEntity
} }
return true; return true;
}*/ }*/
public void sendMessageParsed(String str, Object... args)
{
this.sendMessage(P.p.txt.parse(str, args));
}
} }

View File

@ -409,6 +409,16 @@ public class Faction extends Entity
//----------------------------------------------// //----------------------------------------------//
// Messages // Messages
//----------------------------------------------// //----------------------------------------------//
public void sendMessageParsed(String message, Object... args)
{
message = P.p.txt.parse(message, args);
for (FPlayer fplayer : this.getFPlayersWhereOnline(true))
{
fplayer.sendMessage(message);
}
}
public void sendMessage(String message) public void sendMessage(String message)
{ {
for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) for (FPlayer fplayer : this.getFPlayersWhereOnline(true))

View File

@ -44,9 +44,6 @@ import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.massivecraft.factions.integration.EssentialsFeatures; import com.massivecraft.factions.integration.EssentialsFeatures;
/**
* The data is saved to disk every 30min and on plugin disable.
*/
public class P extends MPlugin public class P extends MPlugin
{ {
// Our single plugin instance // Our single plugin instance
@ -58,6 +55,8 @@ public class P extends MPlugin
public final FactionsEntityListener entityListener; public final FactionsEntityListener entityListener;
public final FactionsBlockListener blockListener; public final FactionsBlockListener blockListener;
public CmdBase cmdBase;
public P() public P()
{ {
p = this; p = this;
@ -82,6 +81,10 @@ public class P extends MPlugin
Factions.i.loadFromDisc(); Factions.i.loadFromDisc();
Board.load(); Board.load();
// Add Base Commands
this.cmdBase = new CmdBase();
this.getBaseCommands().add(cmdBase);
//setupPermissions(); //setupPermissions();
integrateEssentialsChat(); integrateEssentialsChat();
setupSpout(this); setupSpout(this);
@ -96,7 +99,7 @@ public class P extends MPlugin
//Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>(){}.getType(); //Type mapFLocToStringSetType = new TypeToken<Map<FLocation, Set<String>>>(){}.getType();
// Add the commands // Add the commands
commands.add(new FCommandHelp()); /*commands.add(new FCommandHelp());
commands.add(new FCommandAdmin()); commands.add(new FCommandAdmin());
commands.add(new FCommandAutoClaim()); commands.add(new FCommandAutoClaim());
commands.add(new FCommandAutoSafeclaim()); commands.add(new FCommandAutoSafeclaim());
@ -144,7 +147,7 @@ public class P extends MPlugin
commands.add(new FCommandVersion()); commands.add(new FCommandVersion());
commands.add(new FCommandWarclaim()); commands.add(new FCommandWarclaim());
commands.add(new FCommandWarunclaimall()); commands.add(new FCommandWarunclaimall());
commands.add(new FCommandWithdraw()); commands.add(new FCommandWithdraw());*/
// Register events // Register events
PluginManager pm = this.getServer().getPluginManager(); PluginManager pm = this.getServer().getPluginManager();

View File

@ -0,0 +1,42 @@
package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
public class CmdBase extends FCommand
{
//public CmdAccept cmdAccept = new CmdAccept();
public CmdBase()
{
super();
this.aliases.addAll(Conf.baseCommandAliases);
this.allowNoSlashAccess = Conf.allowNoSlashCommand;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
this.setHelpShort("The faction base command");
this.helpLong.add(p.txt.tags("<i>This command contains all faction stuff."));
/*this.subCommands.add(p.cmdHelp);
this.subCommands.add(new CmdIntend());
this.subCommands.add(new CmdInfect());
this.subCommands.add(cmdAccept);
this.subCommands.add(new CmdList());
this.subCommands.add(new CmdSetfood());
this.subCommands.add(new CmdSetinfection());
this.subCommands.add(new CmdTurn());
this.subCommands.add(new CmdCure());
this.subCommands.add(new CmdVersion());*/
}
@Override
public void perform()
{
//this.commandChain.add(this);
//p.cmdHelp.execute(this.sender, this.args, this.commandChain);
}
}

View File

@ -19,9 +19,16 @@ import com.massivecraft.factions.zcore.MCommand;
public abstract class FCommand extends MCommand<P> public abstract class FCommand extends MCommand<P>
{ {
//TODO: Legacy to handle //TODO: Legacy to handle
//public boolean senderIsConsole; private static boolean lock = false;
//private static boolean lock = false; // TODO: Move these messages to the locked command??
// TODO: I lost the check for this code somewhere as well :/
public void setIsLocked(boolean isLocked) { lock = isLocked; }
public boolean isLocked() { return lock; }
public void sendLockMessage()
{
// TODO: CCOLOR!!!
me.sendMessage("Factions is locked. Please try again later");
}
public FPlayer fme; public FPlayer fme;
public boolean senderMustBeMember; public boolean senderMustBeMember;
@ -70,19 +77,47 @@ public abstract class FCommand extends MCommand<P>
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.helpShort)); 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.helpShort)); sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
return false; return false;
} }
return true; return true;
} }
// -------------------------------------------- //
// Assertions
// -------------------------------------------- //
public boolean assertHasFaction()
{
if (me == null) return true;
if ( ! fme.hasFaction())
{
sendMessage("You are not member of any faction.");
return false;
}
return true;
}
public boolean assertMinRole(Role role)
{
if (me == null) return true;
if (fme.getRole().value < role.value)
{
sendMessageParsed("<b>You <h>must be "+role+"<b> to "+this.getHelpShort()+".");
return false;
}
return true;
}
// -------------------------------------------- // // -------------------------------------------- //
// Argument Readers // Argument Readers
// -------------------------------------------- // // -------------------------------------------- //
@ -232,12 +267,12 @@ public abstract class FCommand extends MCommand<P>
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost // if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost) public boolean payForCommand(double cost)
{ {
if ( ! Econ.enabled() || this.me == null || cost == 0.0 || Conf.adminBypassPlayers.contains(me.getName())) if ( ! Econ.enabled() || this.fme == null || cost == 0.0 || Conf.adminBypassPlayers.contains(fme.getName()))
{ {
return true; return true;
} }
String desc = this.helpShort.toLowerCase(); String desc = this.getHelpShort().toLowerCase();
Faction faction = fme.getFaction(); Faction faction = fme.getFaction();
@ -260,7 +295,7 @@ public abstract class FCommand extends MCommand<P>
} }
else else
{ {
if (!Econ.deductMoney(me.getName(), cost)) if (!Econ.deductMoney(fme.getName(), cost))
{ {
sendMessage("It costs "+costString+" to "+desc+", which you can't currently afford."); sendMessage("It costs "+costString+" to "+desc+", which you can't currently afford.");
return false; return false;
@ -280,7 +315,7 @@ public abstract class FCommand extends MCommand<P>
} }
else else
{ {
Econ.addMoney(me.getName(), -cost); Econ.addMoney(fme.getName(), -cost);
} }
@ -288,31 +323,4 @@ public abstract class FCommand extends MCommand<P>
} }
return true; return true;
} }
// TODO: Move these messages to the locked command??
// TODO: I lost the check for this code somewhere as well :/
public void setIsLocked(boolean isLocked)
{
if( isLocked )
{
sendMessage("Factions is now locked");
}
else
{
sendMessage("Factions in now unlocked");
}
lock = isLocked;
}
public boolean isLocked()
{
return lock;
}
public void sendLockMessage()
{
me.sendMessage("Factions is locked. Please try again later");
}
} }

View File

@ -1,64 +1,68 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandAdmin extends FCommand { public class FCommandAdmin extends FCommand
{
public FCommandAdmin() { public FCommandAdmin()
aliases.add("admin"); {
super();
this.aliases.add("admin");
requiredParameters.add("player name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
helpDescription = "Hand over your admin rights"; this.permission = Permission.COMMAND_ADMIN.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.ADMIN)) { FPlayer fyou = this.argAsBestFPlayerMatch(0);
if (fyou == null) return;
Faction myFaction = fme.getFaction();
if (fyou.getFaction() != myFaction)
{
sendMessageParsed("%s<i> is not a member in your faction.", fyou.getNameAndRelevant(fme));
return; return;
} }
String playerName = parameters.get(0); if (fyou == fme)
{
FPlayer you = findFPlayer(playerName, false); sendMessageParsed("<b>The target player musn't be yourself.");
if (you == null) {
return; return;
} }
Faction myFaction = me.getFaction(); fme.setRole(Role.MODERATOR);
fyou.setRole(Role.ADMIN);
if (you.getFaction() != myFaction) {
sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member in your faction.");
return;
}
if (you == me) {
sendMessage("The target player musn't be yourself.");
return;
}
me.setRole(Role.MODERATOR);
you.setRole(Role.ADMIN);
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayers.i.getOnline())
if (fplayer.getFaction() == me.getFaction()) { {
fplayer.sendMessage(me.getNameAndRelevant(me)+Conf.colorSystem+" gave "+you.getNameAndRelevant(me)+Conf.colorSystem+" the leadership of your faction."); if (fplayer.getFaction() == myFaction)
} else { {
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" gave "+you.getNameAndRelevant(fplayer)+Conf.colorSystem+" the leadership of "+myFaction.getTag(fplayer)); fplayer.sendMessageParsed("%s<i> gave %s<i> the leadership of your faction.", fme.getNameAndRelevant(fme), fyou.getNameAndRelevant(fme));
}
else
{
fplayer.sendMessageParsed("%s<i> gave %s<i> the leadership of %s", fme.getNameAndRelevant(fplayer), fyou.getNameAndRelevant(fplayer), myFaction.getTag(fplayer));
} }
} }
} }

View File

@ -3,65 +3,64 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Permission;
public class FCommandAutoClaim extends FCommand { public class FCommandAutoClaim extends FCommand
{
public FCommandAutoClaim() { public FCommandAutoClaim()
aliases.add("autoclaim"); {
super();
optionalParameters.add("on|off"); this.aliases.add("autoclaim");
helpDescription = "Auto-claim land as you walk around"; //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flipp");
this.permission = Permission.COMMAND_AUTOCLAIM.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
// default: toggle existing value boolean enabled = this.argAsBool(0, ! fme.isAutoClaimEnabled());
boolean enable = !me.autoClaimEnabled();
fme.setIsAutoClaimEnabled(enabled);
// if on|off is specified, use that instead if ( ! enabled)
if (parameters.size() > 0) {
enable = parseBool(parameters.get(0)); sendMessageParsed("<i>Auto-claiming of land disabled.");
me.enableAutoClaim(enable);
if (!enable) {
sendMessage("Auto-claiming of land disabled.");
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
FLocation flocation = new FLocation(me); FLocation flocation = new FLocation(fme);
if ( ! assertMinRole(Role.MODERATOR)) { if (Conf.worldsNoClaiming.contains(flocation.getWorldName()))
me.enableAutoClaim(false); {
sendMessageParsed("<b>Sorry, this world has land claiming disabled.");
fme.setIsAutoClaimEnabled(false);
return; return;
} }
if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) { if (myFaction.getLandRounded() >= myFaction.getPowerRounded())
sendMessage("Sorry, this world has land claiming disabled."); {
me.enableAutoClaim(false); sendMessageParsed("<b>You can't claim more land! You need more power!");
fme.setIsAutoClaimEnabled(false);
return; return;
} }
if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) { sendMessageParsed("<i>Auto-claiming of land enabled.");
sendMessage("You can't claim more land! You need more power!"); fme.attemptClaim(false);
me.enableAutoClaim(false);
return;
}
sendMessage("Auto-claiming of land enabled.");
me.attemptClaim(false);
} }
} }

View File

@ -1,54 +1,58 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission;
public class FCommandAutoSafeclaim extends FCommand { public class FCommandAutoSafeclaim extends FCommand
{
public FCommandAutoSafeclaim() { public FCommandAutoSafeclaim()
aliases.add("autosafe"); {
super();
optionalParameters.add("on|off"); this.aliases.add("autosafe");
helpDescription = "Auto-claim land for the safezone"; //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flipp");
this.permission = Permission.MANAGE_SAFE_ZONE.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
this.setHelpShort("Auto-claim land for the safezone");
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermManageSafeZone(sender); {
} if( isLocked() )
{
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
boolean enable = !me.autoSafeZoneEnabled(); boolean enabled = this.argAsBool(0, ! fme.isAutoSafeClaimEnabled());
fme.setIsAutoSafeClaimEnabled(enabled);
if (parameters.size() > 0) if ( ! enabled)
enable = parseBool(parameters.get(0)); {
sendMessageParsed("<i>Auto-claiming of safe zone disabled.");
me.enableAutoSafeZone(enable);
if (!enable) {
sendMessage("Auto-claiming of safe zone disabled.");
return; return;
} }
sendMessage("Auto-claiming of safe zone enabled."); sendMessageParsed("<i>Auto-claiming of safe zone enabled.");
FLocation playerFlocation = new FLocation(me); FLocation playerFlocation = new FLocation(fme);
if (!Board.getFactionAt(playerFlocation).isSafeZone()) { if (!Board.getFactionAt(playerFlocation).isSafeZone())
Board.setFactionAt(Faction.getSafeZone(), playerFlocation); {
sendMessage("This land is now a safe zone."); Board.setFactionAt(Factions.i.getSafeZone(), playerFlocation);
sendMessageParsed("<i>This land is now a safe zone.");
} }
} }

View File

@ -1,54 +1,61 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission;
public class FCommandAutoWarclaim extends FCommand { public class FCommandAutoWarclaim extends FCommand
{
public FCommandAutoWarclaim() { public FCommandAutoWarclaim()
{
super();
this.aliases.add("autosafe");
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flipp");
this.permission = Permission.MANAGE_WAR_ZONE.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
aliases.add("autowar"); aliases.add("autowar");
optionalParameters.add("on|off"); this.setHelpShort("Auto-claim land for the warzone");
helpDescription = "Auto-claim land for the warzone";
}
@Override
public boolean hasPermission(CommandSender sender) {
return P.hasPermManageWarZone(sender);
} }
@Override @Override
public void perform() { public void perform() {
if( isLocked() ) { if ( isLocked() )
{
sendLockMessage(); sendLockMessage();
return; return;
} }
boolean enable = !me.autoWarZoneEnabled(); boolean enabled = this.argAsBool(0, ! fme.isAutoWarClaimEnabled());
if (parameters.size() > 0) fme.setIsAutoWarClaimEnabled(enabled);
enable = parseBool(parameters.get(0));
me.enableAutoWarZone(enable); if ( ! enabled)
{
if (!enable) { sendMessageParsed("<i>Auto-claiming of war zone disabled.");
sendMessage("Auto-claiming of war zone disabled.");
return; return;
} }
sendMessage("Auto-claiming of war zone enabled."); sendMessageParsed("<i>Auto-claiming of war zone enabled.");
FLocation playerFlocation = new FLocation(me); FLocation playerFlocation = new FLocation(fme);
if (!Board.getFactionAt(playerFlocation).isWarZone()) { if (!Board.getFactionAt(playerFlocation).isWarZone())
Board.setFactionAt(Faction.getWarZone(), playerFlocation); {
sendMessage("This land is now a war zone."); Board.setFactionAt(Factions.i.getWarZone(), playerFlocation);
sendMessageParsed("<i>This land is now a war zone.");
} }
} }

View File

@ -2,49 +2,52 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandBalance extends FCommand
public class FCommandBalance extends FCommand { {
public FCommandBalance()
public FCommandBalance() { {
aliases.add("balance"); super();
aliases.add("money"); this.aliases.add("balance");
this.aliases.add("money");
optionalParameters.add("faction tag"); //this.requiredArgs.add("player name");
this.optionalArgs.put("factiontag", "yours");
helpDescription = "Show faction's current balance"; this.permission = Permission.COMMAND_BALANCE.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
if ( ! Conf.bankEnabled)
{
return; return;
} }
if (!Conf.bankEnabled) { Faction faction = this.argAsFaction(0, fme.getFaction());
// TODO MAKE HIERARCHIAL COMMAND STRUCTURE HERE
if ( faction != fme.getFaction() && ! Permission.VIEW_ANY_FACTION_BALANCE.has(sender))
{
sendMessageParsed("<b>You do not have sufficient permissions to view the bank balance of other factions.");
return; return;
} }
Faction faction; if (faction == null)
{
if (parameters.size() > 0) { sendMessageParsed("<b>Faction %s<b> could not be found.", args.get(0));
if (!P.hasPermViewAnyFactionBalance(sender)) {
sendMessage("You do not have sufficient permissions to view the bank balance of other factions.");
return;
}
faction = findFaction(parameters.get(0), true);
} else {
faction = me.getFaction();
}
if(faction == null) {
sendMessage("Faction "+parameters.get(0)+" could not be found.");
return; return;
} }
sendMessage(Conf.colorChrome+faction.getTag()+" balance: "+ Econ.moneyString(faction.getMoney())); sendMessageParsed("<a>%s balance: %s", faction.getTag(), Econ.moneyString(faction.getMoney()));
} }
} }

View File

@ -1,34 +1,43 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
public class FCommandBypass extends FCommand { public class FCommandBypass extends FCommand
{
public FCommandBypass() { public FCommandBypass()
aliases.add("bypass"); {
super();
this.aliases.add("bypass");
helpDescription = "Enable admin bypass mode; build/destroy anywhere"; //this.requiredArgs.add("");
} this.optionalArgs.put("on/off", "flipp");
@Override this.permission = Permission.ADMIN_BYPASS.node;
public boolean hasPermission(CommandSender sender) {
return P.hasPermAdminBypass(sender); senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! Conf.adminBypassPlayers.contains(me.getName())) { {
Conf.adminBypassPlayers.add(me.getName()); // TODO: Move this to a transient field in the model??
me.sendMessage("You have enabled admin bypass mode. You will be able to build or destroy anywhere."); if ( ! Conf.adminBypassPlayers.contains(fme.getName()))
P.log(me.getName() + " has ENABLED admin bypass mode."); {
} else { Conf.adminBypassPlayers.add(fme.getName());
Conf.adminBypassPlayers.remove(me.getName()); fme.sendMessageParsed("<i>You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
me.sendMessage("You have disabled admin bypass mode."); P.p.log(fme.getName() + " has ENABLED admin bypass mode.");
P.log(me.getName() + " DISABLED admin bypass mode."); }
else
{
Conf.adminBypassPlayers.remove(fme.getName());
fme.sendMessageParsed("<i>You have disabled admin bypass mode.");
P.p.log(fme.getName() + " DISABLED admin bypass mode.");
} }
} }
} }

View File

@ -2,56 +2,71 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Permission;
public class FCommandChat extends FCommand { public class FCommandChat extends FCommand
{
public FCommandChat() { public FCommandChat()
aliases.add("chat"); {
aliases.add("c"); super();
this.aliases.add("c");
this.aliases.add("chat");
optionalParameters.add("mode"); //this.requiredArgs.add("");
this.optionalArgs.put("mode", "next");
helpDescription = "Change chat mode"; this.permission = Permission.COMMAND_CHAT.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! Conf.factionOnlyChat ) { {
sendMessage("Faction-only chat is disabled on this server."); if ( ! Conf.factionOnlyChat )
return; {
} sendMessageParsed("<b>Faction-only chat is disabled on this server.");
if ( ! assertHasFaction()) {
return; return;
} }
if( this.parameters.size() >= 1 ) { String modeString = this.argAsString(0).toLowerCase();
String mode = this.parameters.get(0); ChatMode modeTarget = fme.getChatMode().getNext();
if(mode.startsWith("p")) {
me.setChatMode(ChatMode.PUBLIC);
sendMessage("Public chat mode.");
} else if(mode.startsWith("a")) {
me.setChatMode(ChatMode.ALLIANCE);
sendMessage("Alliance only chat mode.");
} else if(mode.startsWith("f")) {
me.setChatMode(ChatMode.FACTION);
sendMessage("Faction only chat mode.");
} else {
sendMessage("Unrecognised chat mode. Please enter either 'a','f' or 'p'");
}
} else {
if(me.getChatMode() == ChatMode.PUBLIC) { if (modeString != null)
me.setChatMode(ChatMode.ALLIANCE); {
sendMessage("Alliance only chat mode."); if(modeString.startsWith("p"))
} else if (me.getChatMode() == ChatMode.ALLIANCE ) { {
me.setChatMode(ChatMode.FACTION); modeTarget = ChatMode.PUBLIC;
sendMessage("Faction only chat mode.");
} else {
me.setChatMode(ChatMode.PUBLIC);
sendMessage("Public chat mode.");
} }
else if (modeString.startsWith("a"))
{
modeTarget = ChatMode.ALLIANCE;
}
else if(modeString.startsWith("f"))
{
modeTarget = ChatMode.FACTION;
}
sendMessageParsed("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
return;
}
fme.setChatMode(modeTarget);
if(fme.getChatMode() == ChatMode.PUBLIC)
{
sendMessageParsed("<i>Public chat mode.");
}
else if (fme.getChatMode() == ChatMode.ALLIANCE )
{
sendMessageParsed("<i>Alliance only chat mode.");
}
else
{
sendMessageParsed("<i>Faction only chat mode.");
} }
} }
} }

View File

@ -1,25 +1,38 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
public class FCommandClaim extends FCommand { import com.massivecraft.factions.struct.Permission;
public class FCommandClaim extends FCommand
{
public FCommandClaim() { public FCommandClaim()
aliases.add("claim"); {
super();
this.aliases.add("claim");
helpDescription = "Claim the land where you are standing"; //this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_CLAIM.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
aliases.add("claim");
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
me.attemptClaim(true); fme.attemptClaim(true);
} }
} }

View File

@ -14,122 +14,148 @@ 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;
public class FCommandConfig extends FCommand { public class FCommandConfig extends FCommand
{
private static HashMap<String, String> properFieldNames = new HashMap<String, String>(); private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
public FCommandConfig() { public FCommandConfig()
aliases.add("config"); {
super();
this.aliases.add("config");
this.requiredArgs.add("setting");
this.requiredArgs.add("value");
this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_CONFIG.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
requiredParameters.add("setting"); senderMustBeModerator = false;
requiredParameters.add("value"); senderMustBeAdmin = false;
helpDescription = "change a conf.json setting";
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermConfigure(sender); {
} if( isLocked() )
{
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
// store a lookup map of lowercase field names paired with proper capitalization field names // store a lookup map of lowercase field names paired with proper capitalization field names
// that way, if the person using this command messes up the capitalization, we can fix that // that way, if the person using this command messes up the capitalization, we can fix that
if (properFieldNames.isEmpty()) { if (properFieldNames.isEmpty())
{
Field[] fields = Conf.class.getDeclaredFields(); Field[] fields = Conf.class.getDeclaredFields();
for(int i = 0; i < fields.length; i++) { for(int i = 0; i < fields.length; i++)
{
properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName()); properFieldNames.put(fields[i].getName().toLowerCase(), fields[i].getName());
} }
} }
String field = parameters.get(0).toLowerCase(); String field = this.argAsString(0).toLowerCase();
if (field.startsWith("\"") && field.endsWith("\"")) { if (field.startsWith("\"") && field.endsWith("\""))
{
field = field.substring(1, field.length() - 1); field = field.substring(1, field.length() - 1);
} }
String fieldName = properFieldNames.get(field); String fieldName = properFieldNames.get(field);
if (fieldName == null || fieldName.isEmpty()) { if (fieldName == null || fieldName.isEmpty())
sendMessage("No configuration setting \""+parameters.get(0)+"\" exists."); {
sendMessageParsed("<b>No configuration setting \"<h>%s<b>\" exists.", field);
return; return;
} }
String success = ""; String success = "";
String value = parameters.get(1); String value = args.get(1);
for(int i = 2; i < parameters.size(); i++) { for(int i = 2; i < args.size(); i++)
value += ' ' + parameters.get(i); {
value += ' ' + args.get(i);
} }
try { try
{
Field target = Conf.class.getField(fieldName); Field target = Conf.class.getField(fieldName);
// boolean // boolean
if (target.getType() == boolean.class) { if (target.getType() == boolean.class)
if (aliasTrue.contains(value.toLowerCase())) { {
if (aliasTrue.contains(value.toLowerCase()))
{
target.setBoolean(null, true); target.setBoolean(null, true);
success = "\""+fieldName+"\" option set to true (enabled)."; success = "\""+fieldName+"\" option set to true (enabled).";
} }
else if (aliasFalse.contains(value.toLowerCase())) { else if (aliasFalse.contains(value.toLowerCase()))
{
target.setBoolean(null, false); target.setBoolean(null, false);
success = "\""+fieldName+"\" option set to false (disabled)."; success = "\""+fieldName+"\" option set to false (disabled).";
} }
else { else
{
sendMessage("Cannot set \""+fieldName+"\": boolean value required (true or false)."); sendMessage("Cannot set \""+fieldName+"\": boolean value required (true or false).");
return; return;
} }
} }
// int // int
else if (target.getType() == int.class) { else if (target.getType() == int.class)
try { {
try
{
int intVal = Integer.parseInt(value); int intVal = Integer.parseInt(value);
target.setInt(null, intVal); target.setInt(null, intVal);
success = "\""+fieldName+"\" option set to "+intVal+"."; success = "\""+fieldName+"\" option set to "+intVal+".";
} }
catch(NumberFormatException ex) { catch(NumberFormatException ex)
{
sendMessage("Cannot set \""+fieldName+"\": integer (whole number) value required."); sendMessage("Cannot set \""+fieldName+"\": integer (whole number) value required.");
return; return;
} }
} }
// double // double
else if (target.getType() == double.class) { else if (target.getType() == double.class)
try { {
try
{
double doubleVal = Double.parseDouble(value); double doubleVal = Double.parseDouble(value);
target.setDouble(null, doubleVal); target.setDouble(null, doubleVal);
success = "\""+fieldName+"\" option set to "+doubleVal+"."; success = "\""+fieldName+"\" option set to "+doubleVal+".";
} }
catch(NumberFormatException ex) { catch(NumberFormatException ex)
{
sendMessage("Cannot set \""+fieldName+"\": double (numeric) value required."); sendMessage("Cannot set \""+fieldName+"\": double (numeric) value required.");
return; return;
} }
} }
// String // String
else if (target.getType() == String.class) { else if (target.getType() == String.class)
{
target.set(null, value); target.set(null, value);
success = "\""+fieldName+"\" option set to \""+value+"\"."; success = "\""+fieldName+"\" option set to \""+value+"\".";
} }
// ChatColor // ChatColor
else if (target.getType() == ChatColor.class) { else if (target.getType() == ChatColor.class)
{
ChatColor newColor = null; ChatColor newColor = null;
try { try
{
newColor = ChatColor.valueOf(value.toUpperCase()); newColor = ChatColor.valueOf(value.toUpperCase());
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex)
{
} }
if (newColor == null) { if (newColor == null)
{
sendMessage("Cannot set \""+fieldName+"\": \""+value.toUpperCase()+"\" is not a valid color."); sendMessage("Cannot set \""+fieldName+"\": \""+value.toUpperCase()+"\" is not a valid color.");
return; return;
} }
@ -138,25 +164,32 @@ public class FCommandConfig extends FCommand {
} }
// Set<?> or other parameterized collection // Set<?> or other parameterized collection
else if (target.getGenericType() instanceof ParameterizedType) { else if (target.getGenericType() instanceof ParameterizedType)
{
ParameterizedType targSet = (ParameterizedType)target.getGenericType(); ParameterizedType targSet = (ParameterizedType)target.getGenericType();
Type innerType = targSet.getActualTypeArguments()[0]; Type innerType = targSet.getActualTypeArguments()[0];
// not a Set, somehow, and that should be the only collection we're using in Conf.java // not a Set, somehow, and that should be the only collection we're using in Conf.java
if (targSet.getRawType() != Set.class) { if (targSet.getRawType() != Set.class)
{
sendMessage("\""+fieldName+"\" is not a data collection type which can be modified with this command."); sendMessage("\""+fieldName+"\" is not a data collection type which can be modified with this command.");
return; return;
} }
// Set<Material> // Set<Material>
else if (innerType == Material.class) { else if (innerType == Material.class)
{
Material newMat = null; Material newMat = null;
try { try
{
newMat = Material.valueOf(value.toUpperCase()); newMat = Material.valueOf(value.toUpperCase());
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex)
{
} }
if (newMat == null) { if (newMat == null)
{
sendMessage("Cannot change \""+fieldName+"\" set: \""+value.toUpperCase()+"\" is not a valid material."); sendMessage("Cannot change \""+fieldName+"\" set: \""+value.toUpperCase()+"\" is not a valid material.");
return; return;
} }
@ -165,13 +198,15 @@ public class FCommandConfig extends FCommand {
Set<Material> matSet = (Set<Material>)target.get(null); Set<Material> matSet = (Set<Material>)target.get(null);
// Material already present, so remove it // Material already present, so remove it
if (matSet.contains(newMat)) { if (matSet.contains(newMat))
{
matSet.remove(newMat); matSet.remove(newMat);
target.set(null, matSet); target.set(null, matSet);
success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" removed."; success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" removed.";
} }
// Material not present yet, add it // Material not present yet, add it
else { else
{
matSet.add(newMat); matSet.add(newMat);
target.set(null, matSet); target.set(null, matSet);
success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" added."; success = "\""+fieldName+"\" set: Material \""+value.toUpperCase()+"\" added.";
@ -179,18 +214,21 @@ public class FCommandConfig extends FCommand {
} }
// Set<String> // Set<String>
else if (innerType == String.class) { else if (innerType == String.class)
{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Set<String> stringSet = (Set<String>)target.get(null); Set<String> stringSet = (Set<String>)target.get(null);
// String already present, so remove it // String already present, so remove it
if (stringSet.contains(value)) { if (stringSet.contains(value))
{
stringSet.remove(value); stringSet.remove(value);
target.set(null, stringSet); target.set(null, stringSet);
success = "\""+fieldName+"\" set: \""+value+"\" removed."; success = "\""+fieldName+"\" set: \""+value+"\" removed.";
} }
// String not present yet, add it // String not present yet, add it
else { else
{
stringSet.add(value); stringSet.add(value);
target.set(null, stringSet); target.set(null, stringSet);
success = "\""+fieldName+"\" set: \""+value+"\" added."; success = "\""+fieldName+"\" set: \""+value+"\" added.";
@ -198,31 +236,37 @@ public class FCommandConfig extends FCommand {
} }
// Set of unknown type // Set of unknown type
else { else
{
sendMessage("\""+fieldName+"\" is not a data type set which can be modified with this command."); sendMessage("\""+fieldName+"\" is not a data type set which can be modified with this command.");
return; return;
} }
} }
// unknown type // unknown type
else { else
{
sendMessage("\""+fieldName+"\" is not a data type which can be modified with this command."); sendMessage("\""+fieldName+"\" is not a data type which can be modified with this command.");
return; return;
} }
} }
catch (NoSuchFieldException ex) { catch (NoSuchFieldException ex)
{
sendMessage("Configuration setting \""+fieldName+"\" couldn't be matched, though it should be... please report this error."); sendMessage("Configuration setting \""+fieldName+"\" couldn't be matched, though it should be... please report this error.");
return; return;
} }
catch (IllegalAccessException ex) { catch (IllegalAccessException ex)
{
sendMessage("Error setting configuration setting \""+fieldName+"\" to \""+value+"\"."); sendMessage("Error setting configuration setting \""+fieldName+"\" to \""+value+"\".");
return; return;
} }
if (!success.isEmpty()) { if (!success.isEmpty())
{
sendMessage(success); sendMessage(success);
if (sender instanceof Player) { if (sender instanceof Player)
P.log(success + " Command was run by "+me.getName()+"."); {
P.p.log(success + " Command was run by "+fme.getName()+".");
} }
} }
// save change to disk // save change to disk

View File

@ -2,68 +2,77 @@ package com.massivecraft.factions.commands;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandCreate extends FCommand { public class FCommandCreate extends FCommand
{
public FCommandCreate() { public FCommandCreate()
aliases.add("create"); {
super();
this.aliases.add("create");
requiredParameters.add("faction tag"); this.requiredArgs.add("faction tag");
//this.optionalArgs.put("", "");
helpDescription = "Create a new faction";
this.permission = Permission.CREATE.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermCreate(sender); {
} if( isLocked() )
{
@Override
public void perform() {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
String tag = parameters.get(0); String tag = this.argAsString(0);
if (me.hasFaction()) { if (fme.hasFaction())
{
sendMessage("You must leave your current faction first."); sendMessage("You must leave your current faction first.");
return; return;
} }
if (Faction.isTagTaken(tag)) { if (Factions.i.isTagTaken(tag))
{
sendMessage("That tag is already in use."); sendMessage("That tag is already in use.");
return; return;
} }
ArrayList<String> tagValidationErrors = Faction.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 '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.econCostCreate)) { if (!payForCommand(Conf.econCostCreate))
{
return; return;
} }
Faction faction = Faction.create(); Faction faction = Factions.i.create();
faction.setTag(tag); faction.setTag(tag);
me.setRole(Role.ADMIN); fme.setRole(Role.ADMIN);
me.setFaction(faction); fme.setFaction(faction);
for (FPlayer follower : FPlayer.getAllOnline()) { for (FPlayer follower : FPlayers.i.getOnline())
follower.sendMessage(me.getNameAndRelevant(follower)+Conf.colorSystem+" created a new faction "+faction.getTag(follower)); {
follower.sendMessageParsed("%s<i> created a new faction %s", fme.getNameAndRelevant(follower), faction.getTag(follower));
} }
sendMessage("You should now: " + new FCommandDescription().getUseageTemplate()); sendMessage("You should now: " + new FCommandDescription().getUseageTemplate());

View File

@ -1,55 +1,54 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
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;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Permission;
public class FCommandDeinvite extends FCommand { public class FCommandDeinvite extends FCommand
{
public FCommandDeinvite() { public FCommandDeinvite()
aliases.add("deinvite"); {
aliases.add("deinv"); super();
this.aliases.add("deinvite");
this.aliases.add("deinv");
requiredParameters.add("player name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
helpDescription = "Remove a pending invitation"; this.permission = Permission.COMMAND_DEINVITE.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
String playerName = parameters.get(0); FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
FPlayer you = findFPlayer(playerName, false); Faction myFaction = fme.getFaction();
if (you == null) {
return;
}
Faction myFaction = me.getFaction(); if (you.getFaction() == myFaction)
{
if ( ! assertMinRole(Role.MODERATOR)) { sendMessageParsed("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
return; sendMessageParsed("<i>You might want to: %s", new FCommandKick().getUseageTemplate(false));
}
if (you.getFaction() == myFaction) {
sendMessage(you.getName()+" is already a member of "+myFaction.getTag());
sendMessage("You might want to: " + new FCommandKick().getUseageTemplate(false));
return; return;
} }
myFaction.deinvite(you); myFaction.deinvite(you);
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" revoked your invitation to "+myFaction.getTag(you)); you.sendMessageParsed("%s<i> revoked your invitation to %s", fme.getNameAndRelevant(you), myFaction.getTag(you));
myFaction.sendMessage(me.getNameAndRelevant(me)+Conf.colorSystem+" revoked "+you.getNameAndRelevant(me)+"'s"+Conf.colorSystem+" invitation."); myFaction.sendMessageParsed("%s<i> revoked %s's<i> invitation.", fme.getNameAndRelevant(fme), you.getNameAndRelevant(fme));
} }
} }

View File

@ -2,58 +2,61 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
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.FPlayer; import com.massivecraft.factions.FPlayer;
public class FCommandDeposit extends FCommand { public class FCommandDeposit extends FCommand
{
public FCommandDeposit() { public FCommandDeposit()
aliases.add("deposit"); {
super();
this.aliases.add("deposit");
helpDescription = "Deposit money into your faction's bank"; this.requiredArgs.add("amount");
requiredParameters.add("amount"); //this.optionalArgs
this.permission = Permission.COMMAND_DEPOSIT.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if ( ! Conf.bankEnabled) return;
}
if (!Conf.bankEnabled) { Faction faction = fme.getFaction();
return;
}
double amount = 0.0; double amount = this.argAsDouble(0, 0);
Faction faction = me.getFaction(); if( amount > 0.0 )
{
if (parameters.size() == 1) {
try {
amount = Double.parseDouble(parameters.get(0));
} catch (NumberFormatException e) {
// wasn't valid
}
}
if( amount > 0.0 ) {
String amountString = Econ.moneyString(amount); String amountString = Econ.moneyString(amount);
if( !Econ.deductMoney(me.getName(), amount ) ) { if( ! Econ.deductMoney(fme.getName(), amount ) )
sendMessage("You cannot afford to deposit that much."); {
sendMessageParsed("<b>You cannot afford to deposit that much.");
} }
else else
{ {
faction.addMoney(amount); faction.addMoney(amount);
sendMessage("You have deposited "+amountString+" into "+faction.getTag()+"'s bank."); sendMessage("You have deposited "+amountString+" into "+faction.getTag()+"'s bank.");
sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney())); sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney()));
P.log(me.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank."); P.p.log(fme.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayers.i.getOnline())
if (fplayer.getFaction() == faction) { {
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has deposited "+amountString); if (fplayer.getFaction() == faction)
{
fplayer.sendMessageParsed("%s has deposited %s", fme.getNameAndRelevant(fplayer), amountString);
} }
} }
} }

View File

@ -2,45 +2,50 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.util.TextUtil; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TextUtil;
public class FCommandDescription extends FCommand { public class FCommandDescription extends FCommand
{
public FCommandDescription() { public FCommandDescription()
aliases.add("desc"); {
super();
this.aliases.add("desc");
requiredParameters.add("desc"); this.requiredArgs.add("desc");
//this.optionalArgs
helpDescription = "Change the faction description"; this.permission = Permission.COMMAND_DESCRIPTION.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.MODERATOR)) {
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.econCostDesc)) { if ( ! payForCommand(Conf.econCostDesc))
{
return; return;
} }
me.getFaction().setDescription(TextUtil.implode(parameters)); fme.getFaction().setDescription(TextUtil.implode(args, " "));
// Broadcast the description to everyone // Broadcast the description to everyone
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayers.i.getOnline())
fplayer.sendMessage("The faction "+fplayer.getRelationColor(me)+me.getFaction().getTag()+Conf.colorSystem+" changed their description to:"); {
fplayer.sendMessage(me.getFaction().getDescription()); fplayer.sendMessageParsed("The faction "+fplayer.getRelationColor(fme)+fme.getFaction().getTag()+"<i> changed their description to:");
fplayer.sendMessageParsed("<i>"+fme.getFaction().getDescription());
} }
} }

View File

@ -2,85 +2,88 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
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.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer; 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.Role; import com.massivecraft.factions.struct.Role;
public class FCommandDisband extends FCommand { public class FCommandDisband extends FCommand
{
public FCommandDisband() { public FCommandDisband()
aliases.add("disband"); {
super();
this.aliases.add("disband");
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours");
this.permission = Permission.COMMAND_DISBAND.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
optionalParameters.add("faction tag"); senderMustBeModerator = false;
senderMustBeAdmin = false;
helpDescription = "Disband a faction";
} }
@Override @Override
public void perform() { public void perform()
{
Faction faction = null; // The faction, default to your own.. but null if console sender.
Faction faction = this.argAsFaction(0, fme == null ? null : fme.getFaction());
if( parameters.size() > 0) { if (faction == null) return;
faction = Faction.findByTag(parameters.get(0));
boolean isMyFaction = fme == null ? false : faction == fme.getFaction();
if( faction == null || !faction.isNormal()) {
sendMessage("Faction \"" + parameters.get(0) + "\" not found"); if (isMyFaction)
{
if ( ! assertMinRole(Role.ADMIN)) return;
}
else
{
if ( ! Permission.COMMAND_DISBAND_ANY.has(me, true))
{
return; return;
} }
if ( ! P.hasPermDisband(sender)) {
if (me.getFaction() == faction) {
parameters.clear();
}
else {
sendMessage("You do not have sufficient permission to disband other factions.");
return;
}
}
} }
if (parameters.isEmpty()) {
if ( ! assertHasFaction()) {
return;
}
if ( ! assertMinRole(Role.ADMIN)) {
return;
}
faction = me.getFaction(); if (faction.isPermanent())
{
if (faction.isPermanent() && !P.hasPermDisband(sender)) { sendMessageParsed("<i>This faction is designated as permanent, so you cannot disband it.");
sendMessage("Your faction is designated as permanent, so you cannot disband it."); return;
return;
}
} }
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayers.i.getOnline())
if (fplayer.getFaction() == faction) { {
fplayer.sendMessage((senderIsConsole ? "A server admin" : me.getNameAndRelevant(fplayer))+Conf.colorSystem+" disbanded your faction."); String who = senderIsConsole ? "A server admin" : fme.getNameAndRelevant(fplayer);
} else { if (fplayer.getFaction() == faction)
fplayer.sendMessage((senderIsConsole ? "A server admin" : me.getNameAndRelevant(fplayer))+Conf.colorSystem+" disbanded the faction "+faction.getTag(fplayer)+"."); {
fplayer.sendMessageParsed("<h>%s<i> disbanded your faction.", who);
}
else
{
fplayer.sendMessageParsed("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
} }
} }
if (Conf.bankEnabled) { if (Conf.bankEnabled)
{
double amount = faction.getMoney(); double amount = faction.getMoney();
Econ.addMoney(me.getName(), amount ); //Give all the faction's money to the disbander Econ.addMoney(fme.getId(), amount); //Give all the faction's money to the disbander
if (amount > 0.0) { if (amount > 0.0)
{
String amountString = Econ.moneyString(amount); String amountString = Econ.moneyString(amount);
sendMessage("You have been given the disbanded faction's bank, totaling "+amountString+"."); sendMessageParsed("<i>You have been given the disbanded faction's bank, totaling %s.", amountString);
P.log(me.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.delete( faction.getId() ); faction.detach();
SpoutFeatures.updateAppearances(); SpoutFeatures.updateAppearances();
} }
} }

View File

@ -2,44 +2,45 @@ package com.massivecraft.factions.commands;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.util.TextUtil; import com.massivecraft.factions.struct.Permission;
public class FCommandHelp extends FCommand { public class FCommandHelp extends FCommand
{
public FCommandHelp() { public FCommandHelp()
aliases.add("help"); {
aliases.add("h"); super();
aliases.add("?"); this.aliases.add("help");
this.aliases.add("h");
this.aliases.add("?");
optionalParameters.add("page"); //this.requiredArgs.add("");
this.optionalArgs.put("page", "1");
helpDescription = "Display a help page"; this.permission = Permission.COMMAND_HELP.node;
}
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return true; {
} int page = this.argAsInt(0, 1);
@Override sendMessage(p.txt.titleize("Factions Help ("+page+"/"+helpPages.size()+")"));
public void perform() {
int page = 1;
if (parameters.size() > 0) {
try {
page = Integer.parseInt(parameters.get(0));
} catch (NumberFormatException e) {
// wasn't an integer
}
}
sendMessage(TextUtil.titleize("Factions Help ("+page+"/"+helpPages.size()+")"));
page -= 1; page -= 1;
if (page < 0 || page >= helpPages.size()) {
sendMessage("This page does not exist"); if (page < 0 || page >= helpPages.size())
{
sendMessageParsed("<b>This page does not exist");
return; return;
} }
sendMessage(helpPages.get(page)); sendMessage(helpPages.get(page));
@ -51,7 +52,8 @@ public class FCommandHelp extends FCommand {
public static ArrayList<ArrayList<String>> helpPages; public static ArrayList<ArrayList<String>> helpPages;
public static void updateHelp() { public static void updateHelp()
{
helpPages = new ArrayList<ArrayList<String>>(); helpPages = new ArrayList<ArrayList<String>>();
ArrayList<String> pageLines; ArrayList<String> pageLines;
@ -79,7 +81,8 @@ public class FCommandHelp extends FCommand {
pageLines.add( new FCommandSethome().getUseageTemplate() ); pageLines.add( new FCommandSethome().getUseageTemplate() );
helpPages.add(pageLines); helpPages.add(pageLines);
if (Econ.enabled() && Conf.bankEnabled) { if (Econ.enabled() && Conf.bankEnabled)
{
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
pageLines.add( "" ); pageLines.add( "" );
pageLines.add( "Your faction has a bank which is used to pay for certain" ); pageLines.add( "Your faction has a bank which is used to pay for certain" );
@ -162,7 +165,7 @@ public class FCommandHelp extends FCommand {
pageLines.add( new FCommandWarclaim().getUseageTemplate() ); pageLines.add( new FCommandWarclaim().getUseageTemplate() );
pageLines.add( new FCommandAutoWarclaim().getUseageTemplate() ); pageLines.add( new FCommandAutoWarclaim().getUseageTemplate() );
pageLines.add( new FCommandWarunclaimall().getUseageTemplate() ); pageLines.add( new FCommandWarunclaimall().getUseageTemplate() );
pageLines.add("Note: " + Conf.colorCommand + "f unclaim" + Conf.colorSystem + " works on safe/war zones as well."); pageLines.add("Note: " + new FCommandUnclaim().getUseageTemplate(false) + P.p.txt.parse("<i>") + " works on safe/war zones as well.");
helpPages.add(pageLines); helpPages.add(pageLines);
pageLines = new ArrayList<String>(); pageLines = new ArrayList<String>();
@ -178,7 +181,8 @@ public class FCommandHelp extends FCommand {
helpPages.add(pageLines); helpPages.add(pageLines);
} }
static { static
{
updateHelp(); updateHelp();
} }
} }

View File

@ -8,60 +8,88 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
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;
public class FCommandHome extends FCommand { public class FCommandHome extends FCommand
{
public FCommandHome() { public FCommandHome()
aliases.add("home"); {
super();
this.aliases.add("home");
helpDescription = "Teleport to the faction home"; //this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_HOME.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; // TODO: Hide this command on help also.
} if ( ! Conf.homesEnabled)
{
if ( ! Conf.homesEnabled) { fme.sendMessage("Sorry, Faction homes are disabled on this server.");
me.sendMessage("Sorry, Faction homes are disabled on this server.");
return; return;
} }
if ( ! Conf.homesTeleportCommandEnabled) { if ( ! Conf.homesTeleportCommandEnabled)
me.sendMessage("Sorry, the ability to teleport to Faction homes is disabled on this server."); {
fme.sendMessage("Sorry, the ability to teleport to Faction homes is disabled on this server.");
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
if ( ! myFaction.hasHome()) { if ( ! myFaction.hasHome())
me.sendMessage("You faction does not have a home. " + (me.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); {
me.sendMessage(new FCommandSethome().getUseageTemplate()); fme.sendMessage("You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:"));
fme.sendMessage(new FCommandSethome().getUseageTemplate());
return; return;
} }
if (!Conf.homesTeleportAllowedFromEnemyTerritory && me.isInEnemyTerritory()) { if ( ! Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory())
me.sendMessage("You cannot teleport to your faction home while in the territory of an enemy faction."); {
fme.sendMessage("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())
me.sendMessage("You cannot teleport to your faction home while in a different world."); {
fme.sendMessage("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()));
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if ( if
Conf.homesTeleportAllowedEnemyDistance > 0 (
&& !faction.isSafeZone() Conf.homesTeleportAllowedEnemyDistance > 0
&& (!me.isInOwnTerritory() || (me.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) &&
) { ! faction.isSafeZone()
&&
(
! fme.isInOwnTerritory()
||
(
fme.isInOwnTerritory()
&&
! Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory
)
)
)
{
Location loc = me.getLocation(); Location loc = me.getLocation();
World w = loc.getWorld(); World w = loc.getWorld();
double x = loc.getX(); double x = loc.getX();
@ -70,11 +98,11 @@ public class FCommandHome extends FCommand {
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 == fme || p.getWorld() != w)
continue; continue;
FPlayer fp = FPlayer.get(p); FPlayer fp = FPlayers.i.get(p);
if (me.getRelation(fp) != Relation.ENEMY) if (fme.getRelation(fp) != Relation.ENEMY)
continue; continue;
Location l = p.getLocation(); Location l = p.getLocation();
@ -87,13 +115,14 @@ public class FCommandHome extends FCommand {
if (dx > max || dy > max || dz > max) if (dx > max || dy > max || dz > max)
continue; continue;
me.sendMessage("You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you."); fme.sendMessage("You cannot teleport to your faction home while an enemy is within " + Conf.homesTeleportAllowedEnemyDistance + " blocks of you.");
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.econCostHome)) { if ( ! payForCommand(Conf.econCostHome))
{
return; return;
} }

View File

@ -3,58 +3,58 @@ package com.massivecraft.factions.commands;
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;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Permission;
public class FCommandInvite extends FCommand { public class FCommandInvite extends FCommand
{
public FCommandInvite() { public FCommandInvite()
aliases.add("invite"); {
aliases.add("inv"); super();
this.aliases.add("invite");
this.aliases.add("inv");
requiredParameters.add("player name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
helpDescription = "Invite a player"; this.permission = Permission.COMMAND_INVITE.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.MODERATOR)) { FPlayer you = this.argAsBestFPlayerMatch(0);
return; if (you == null) return;
}
String playerName = parameters.get(0); Faction myFaction = fme.getFaction();
FPlayer you = findFPlayer(playerName, false); if (you.getFaction() == myFaction)
if (you == null) { {
return; sendMessageParsed("%s<i> is already a member of %s", you.getName(), myFaction.getTag());
} sendMessageParsed("<i>You might want to: " + new FCommandKick().getUseageTemplate(false));
Faction myFaction = me.getFaction();
if (you.getFaction() == myFaction) {
sendMessage(you.getName()+" is already a member of "+myFaction.getTag());
sendMessage("You might want to: " + new FCommandKick().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)) { if ( ! payForCommand(Conf.econCostInvite))
{
return; return;
} }
myFaction.invite(you); myFaction.invite(you);
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" invited you to "+myFaction.getTag(you)); you.sendMessageParsed("%s<i> invited you to %s", fme.getNameAndRelevant(you), myFaction.getTag(you));
myFaction.sendMessage(me.getNameAndRelevant(me)+Conf.colorSystem+" invited "+you.getNameAndRelevant(me)+Conf.colorSystem+" to your faction."); myFaction.sendMessageParsed("%s<i> invited %s<i> to your faction.", fme.getNameAndRelevant(fme), you.getNameAndRelevant(fme));
} }
} }

View File

@ -2,69 +2,80 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
public class FCommandJoin extends FCommand { public class FCommandJoin extends FCommand
{
public FCommandJoin() { public FCommandJoin()
aliases.add("join"); {
super();
this.aliases.add("join");
requiredParameters.add("faction name"); this.requiredArgs.add("faction name");
//this.optionalArgs.put("", "");
helpDescription = "Join a faction"; this.permission = Permission.COMMAND_JOIN.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
{
if( isLocked() ) { if( isLocked() )
{
sendLockMessage(); sendLockMessage();
return; return;
} }
String factionName = parameters.get(0); Faction faction = this.argAsFaction(0);
if (faction == null) return;
Faction faction = findFaction(factionName);
if (faction == null) {
return;
}
if ( ! faction.isNormal()) { if ( ! faction.isNormal())
sendMessage("You may only join normal factions. This is a system faction."); {
sendMessageParsed("<b>You may only join normal factions. This is a system faction.");
return; return;
} }
if (faction == me.getFaction()) { if (faction == fme.getFaction())
sendMessage("You are already a member of "+faction.getTag(me)); {
sendMessageParsed("<b>You are already a member of %s", faction.getTag(fme));
return; return;
} }
if (me.hasFaction()) { if (fme.hasFaction())
sendMessage("You must leave your current faction first."); {
sendMessageParsed("<b>You must leave your current faction first.");
return; return;
} }
if (!Conf.CanLeaveWithNegativePower && me.getPower() < 0) { if (!Conf.CanLeaveWithNegativePower && fme.getPower() < 0)
sendMessage("You cannot join a faction until your power is positive."); {
sendMessageParsed("<b>You cannot join a faction until your power is positive.");
return; return;
} }
if( ! faction.getOpen() && ! faction.isInvited(me)) { if( ! faction.getOpen() && ! faction.isInvited(fme))
sendMessage("This guild requires invitation."); {
faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" tried to join your faction."); sendMessageParsed("<i>This guild requires invitation.");
faction.sendMessageParsed("%s<i> tried to join your faction.", fme.getNameAndRelevant(faction));
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.econCostJoin)) { if (!payForCommand(Conf.econCostJoin))
{
return; return;
} }
me.sendMessage(Conf.colorSystem+"You successfully joined "+faction.getTag(me)); fme.sendMessageParsed("<i>You successfully joined %s", faction.getTag(fme));
faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" joined your faction."); faction.sendMessageParsed("<i>%s joined your faction.", fme.getNameAndRelevant(faction));
me.resetFactionData(); fme.resetFactionData();
me.setFaction(faction); fme.setFaction(faction);
faction.deinvite(me); faction.deinvite(fme);
} }
} }

View File

@ -2,81 +2,98 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.struct.Permission;
public class FCommandKick extends FCommand { public class FCommandKick extends FCommand
{
public FCommandKick() { public FCommandKick()
aliases.add("kick"); {
super();
this.aliases.add("kick");
requiredParameters.add("player name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
helpDescription = "Kick a player from the faction"; this.permission = Permission.COMMAND_KICK.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
{
if( isLocked() ) { if( isLocked() )
{
sendLockMessage(); sendLockMessage();
return; return;
} }
String playerName = parameters.get(0); FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
FPlayer you = findFPlayer(playerName, false); if (fme == you)
if (you == null) { {
return; sendMessageParsed("<b>You cannot kick yourself.");
} sendMessageParsed("<i>You might want to: %s", new FCommandLeave().getUseageTemplate(false));
if (me == you) {
sendMessage("You cannot kick yourself.");
sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate(false));
return; return;
} }
Faction yourFaction = you.getFaction(); Faction yourFaction = you.getFaction();
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
// players with admin-level "disband" permission can bypass these requirements // players with admin-level "disband" permission can bypass these requirements
if (!P.hasPermDisband(sender)) { if ( ! Permission.COMMAND_KICK_ANY.has(sender))
if (yourFaction != myFaction) { {
sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member of "+myFaction.getTag(me)); if (yourFaction != myFaction)
{
sendMessageParsed("%s<b> is not a member of %s", you.getNameAndRelevant(fme), myFaction.getTag(fme));
return; return;
} }
if (you.getRole().value >= me.getRole().value) { // TODO add more informative messages. if (you.getRole().value >= fme.getRole().value)
sendMessage("Your rank is too low to kick this player."); {
// TODO add more informative messages.
sendMessageParsed("<b>Your rank is too low to kick this player.");
return; return;
} }
if (!Conf.CanLeaveWithNegativePower && you.getPower() < 0) { if ( ! Conf.CanLeaveWithNegativePower && you.getPower() < 0)
sendMessage("You cannot kick that member until their power is positive."); {
sendMessageParsed("<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 '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.econCostKick)) { if ( ! payForCommand(Conf.econCostKick))
{
return; return;
} }
yourFaction.sendMessage(me.getNameAndRelevant(yourFaction)+Conf.colorSystem+" kicked "+you.getNameAndRelevant(yourFaction)+Conf.colorSystem+" from the faction! :O"); yourFaction.sendMessageParsed("%s<i> kicked %s<i> from the faction! :O", fme.getNameAndRelevant(yourFaction), you.getNameAndRelevant(yourFaction));
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" kicked you from "+yourFaction.getTag(you)+Conf.colorSystem+"! :O"); you.sendMessageParsed("%s<i> kicked you from %s<i>! :O", fme.getNameAndRelevant(you), yourFaction.getTag(you));
if (yourFaction != myFaction) { if (yourFaction != myFaction)
me.sendMessage(Conf.colorSystem+"You kicked "+you.getNameAndRelevant(myFaction)+Conf.colorSystem+" from the faction "+yourFaction.getTag(me)+Conf.colorSystem+"!"); {
fme.sendMessageParsed("<i>You kicked %s<i> from the faction %s<i>!", you.getNameAndRelevant(myFaction), yourFaction.getTag(fme));
} }
yourFaction.deinvite(you); yourFaction.deinvite(you);
you.resetFactionData(); you.resetFactionData();
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.isPermanent()) { if (yourFaction.getFPlayers().isEmpty() && !yourFaction.isPermanent())
{
// Remove this faction // Remove this faction
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayers.i.getOnline())
fplayer.sendMessage("The faction "+yourFaction.getTag(fplayer)+Conf.colorSystem+" was disbanded."); {
fplayer.sendMessageParsed("The faction %s<i> was disbanded.", yourFaction.getTag(fplayer));
} }
Faction.delete(yourFaction.getId()); yourFaction.detach();
} }
} }

View File

@ -1,32 +1,35 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender; import com.massivecraft.factions.struct.Permission;
public class FCommandLeave extends FCommand { public class FCommandLeave extends FCommand {
public FCommandLeave() { public FCommandLeave()
aliases.add("leave"); {
super();
this.aliases.add("leave");
helpDescription = "Leave your faction"; //this.requiredArgs.add("");
//this.optionalArgs.put("", "");
this.permission = Permission.COMMAND_LEAVE.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return true; {
} if ( isLocked() )
{
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
me.leave(true); fme.leave(true);
} }
} }

View File

@ -4,55 +4,45 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.util.TextUtil; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission;
public class FCommandList extends FCommand { public class FCommandList extends FCommand
{
public FCommandList() { public FCommandList()
aliases.add("list"); {
aliases.add("ls"); super();
this.aliases.add("list");
this.aliases.add("ls");
//this.requiredArgs.add("");
this.optionalArgs.put("page", "1");
this.permission = Permission.COMMAND_LIST.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
optionalParameters.add("page"); senderMustBeModerator = false;
senderMustBeAdmin = false;
helpDescription = "Show a list of the factions";
}
@Override
public boolean hasPermission(CommandSender sender) {
return true;
} }
@Override @Override
public void perform() { public void perform()
ArrayList<Faction> FactionList = new ArrayList<Faction>(Faction.getAll()); {
FactionList.remove(Faction.getNone());
FactionList.remove(Faction.getSafeZone());
FactionList.remove(Faction.getWarZone());
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostList)) { if ( ! payForCommand(Conf.econCostList)) return;
return;
} ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
factionList.remove(Factions.i.getNone());
int page = 1; factionList.remove(Factions.i.getSafeZone());
if (parameters.size() > 0) { factionList.remove(Factions.i.getWarZone());
try {
page = Integer.parseInt(parameters.get(0));
} catch (NumberFormatException e) {
// wasn't an integer
}
}
page -= 1;
// Sort by total followers first // Sort by total followers first
Collections.sort(FactionList, new Comparator<Faction>(){ Collections.sort(factionList, new Comparator<Faction>(){
@Override @Override
public int compare(Faction f1, Faction f2) { public int compare(Faction f1, Faction f2) {
if (f1.getFPlayers().size() < f2.getFPlayers().size()) if (f1.getFPlayers().size() < f2.getFPlayers().size())
@ -64,7 +54,7 @@ public class FCommandList extends FCommand {
}); });
// Then sort by how many members are online now // Then sort by how many members are online now
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) {
if (f1.getFPlayersWhereOnline(true).size() < f2.getFPlayersWhereOnline(true).size()) if (f1.getFPlayersWhereOnline(true).size() < f2.getFPlayersWhereOnline(true).size())
@ -74,29 +64,22 @@ public class FCommandList extends FCommand {
return 0; return 0;
} }
}); });
FactionList.add(0, Faction.getNone());
int maxPage = (int)Math.floor((double)FactionList.size() / 9D); ArrayList<String> lines = new ArrayList<String>();
if (page < 0 || page > maxPage) { lines.add(p.txt.parse("Factionless <i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
sendMessage("The faction list is only " + (maxPage+1) + " page(s) long"); for (Faction faction : factionList)
return; {
} lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getTag(fme),
String header = "Faction List"; faction.getFPlayersWhereOnline(true).size(),
if (maxPage > 1) header += " (page " + (page+1) + " of " + (maxPage+1) + ")"; faction.getFPlayers().size(),
sendMessage(TextUtil.titleize(header)); faction.getLandRounded(),
faction.getPowerRounded(),
int maxPos = (page+1) * 9; faction.getPowerMaxRounded())
if (maxPos > FactionList.size()) maxPos = FactionList.size(); );
for (int pos = page * 9; pos < maxPos; pos++) {
Faction faction = FactionList.get(pos);
if (faction.getId() == 0) {
sendMessage("Factionless"+Conf.colorSystem+" "+faction.getFPlayersWhereOnline(true).size() + " online");
} else {
sendMessage(faction.getTag(me)+Conf.colorSystem+" "+faction.getFPlayersWhereOnline(true).size()+"/"+faction.getFPlayers().size()+" online, "+faction.getLandRounded()+"/"+faction.getPowerRounded()+"/"+faction.getPowerMaxRounded());
}
} }
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Faction List"));
} }
} }

View File

@ -1,36 +1,44 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.P;
public class FCommandLock extends FCommand { public class FCommandLock extends FCommand {
public FCommandLock() { // TODO: This solution needs refactoring.
aliases.add("lock"); /*
factions.lock:
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
default: op
*/
public FCommandLock()
{
super();
this.aliases.add("lock");
//this.requiredArgs.add("");
this.optionalArgs.put("on/off", "flipp");
this.permission = Permission.COMMAND_LOCK.node;
senderMustBePlayer = false; senderMustBePlayer = false;
senderMustBeMember = false;
optionalParameters.add("on|off"); senderMustBeModerator = false;
senderMustBeAdmin = false;
helpDescription = "lock all write stuff";
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return P.hasPermLock(sender); {
} setIsLocked(this.argAsBool(0, ! isLocked()));
@Override if( isLocked() )
public void perform() { {
if( parameters.size() > 0 ) { sendMessageParsed("<i>Factions is now locked");
setLock( parseBool( parameters.get(0) )); }
} else { else
if( isLocked() ) { {
sendMessage("Factions is locked"); sendMessageParsed("<i>Factions in now unlocked");
} else {
sendMessage("Factions is not locked");
}
} }
} }

View File

@ -1,61 +1,66 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.struct.Permission;
public class FCommandMap extends FCommand { public class FCommandMap extends FCommand
{
public FCommandMap() { public FCommandMap()
aliases.add("map"); {
super();
this.aliases.add("map");
optionalParameters.add("on|off"); //this.requiredArgs.add("");
this.optionalArgs.put("on/off", "once");
helpDescription = "Show territory map, set optional auto update"; this.permission = Permission.COMMAND_MAP.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public boolean hasPermission(CommandSender sender) { public void perform()
return true; {
} if (this.argIsSet(0))
{
@Override if (this.argAsBool(0, ! fme.isMapAutoUpdating()))
public void perform() { {
if (parameters.size() > 0) {
String mapAutoUpdating = parameters.get(0);
if (parseBool(mapAutoUpdating)) {
// Turn on // Turn on
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostMap)) { if ( ! payForCommand(Conf.econCostMap)) return;
return;
}
me.setMapAutoUpdating(true); fme.setMapAutoUpdating(true);
sendMessage("Map auto update ENABLED."); sendMessageParsed("<i>Map auto update <green>ENABLED.");
// And show the map once // And show the map once
showMap(); showMap();
} else { }
else
{
// Turn off // Turn off
me.setMapAutoUpdating(false); fme.setMapAutoUpdating(false);
sendMessage("Map auto update DISABLED."); sendMessageParsed("<i>Map auto update <red>DISABLED.");
} }
} else { }
else
{
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostMap)) { if ( ! payForCommand(Conf.econCostMap)) return;
return;
}
showMap(); showMap();
} }
} }
public void showMap() { public void showMap()
sendMessage(Board.getMap(me.getFaction(), new FLocation(me), me.getPlayer().getLocation().getYaw())); {
sendMessage(Board.getMap(fme.getFaction(), new FLocation(fme), fme.getPlayer().getLocation().getYaw()));
} }
} }

View File

@ -1,62 +1,66 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
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;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandMod extends FCommand { public class FCommandMod extends FCommand
{
public FCommandMod() { public FCommandMod()
aliases.add("mod"); {
super();
this.aliases.add("mod");
requiredParameters.add("player name"); this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
helpDescription = "Give or revoke moderator rights"; this.permission = Permission.COMMAND_MOD.node;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = true;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
return; if( isLocked() )
} {
if( isLocked() ) {
sendLockMessage(); sendLockMessage();
return; return;
} }
if ( ! assertMinRole(Role.ADMIN)) { FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
Faction myFaction = fme.getFaction();
if (you.getFaction() != myFaction)
{
sendMessageParsed("%s<b> is not a member in your faction.", you.getNameAndRelevant(fme));
return; return;
} }
String playerName = parameters.get(0); if (you == fme)
{
FPlayer you = findFPlayer(playerName, false); sendMessageParsed("<b>The target player musn't be yourself.");
if (you == null) {
return;
}
Faction myFaction = me.getFaction();
if (you.getFaction() != myFaction) {
sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member in your faction.");
return;
}
if (you == me) {
sendMessage("The target player musn't be yourself.");
return; return;
} }
if (you.getRole() == Role.MODERATOR) { if (you.getRole() == Role.MODERATOR)
{
// Revoke // Revoke
you.setRole(Role.NORMAL); you.setRole(Role.NORMAL);
myFaction.sendMessage(you.getNameAndRelevant(myFaction)+Conf.colorSystem+" is no longer moderator in your faction."); myFaction.sendMessageParsed("%s<i> is no longer moderator in your faction.", you.getNameAndRelevant(myFaction));
} else { }
else
{
// Give // Give
you.setRole(Role.MODERATOR); you.setRole(Role.MODERATOR);
myFaction.sendMessage(you.getNameAndRelevant(myFaction)+Conf.colorSystem+" was promoted to moderator in your faction."); myFaction.sendMessageParsed("%s<i> was promoted to moderator in your faction.", you.getNameAndRelevant(myFaction));
} }
} }

View File

@ -35,10 +35,10 @@ public class FCommandNoBoom extends FCommand {
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
if (!myFaction.isPeaceful()) { if (!myFaction.isPeaceful()) {
me.sendMessage("This command is only usable by factions which are specially designated as peaceful."); fme.sendMessage("This command is only usable by factions which are specially designated as peaceful.");
return; return;
} }
@ -52,7 +52,7 @@ public class FCommandNoBoom extends FCommand {
String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled"; String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled";
// Inform // Inform
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" has "+enabled+" explosions in your faction's territory."); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" has "+enabled+" explosions in your faction's territory.");
} }
} }

View File

@ -24,24 +24,26 @@ public class FCommandOpen extends FCommand {
return; return;
} }
if ( ! assertMinRole(Role.MODERATOR)) { if ( ! assertMinRole(Role.MODERATOR))
{
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.econCostOpen)) { if (!payForCommand(Conf.econCostOpen))
{
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
myFaction.setOpen( ! me.getFaction().getOpen()); myFaction.setOpen( ! fme.getFaction().getOpen());
String open = myFaction.getOpen() ? "open" : "closed"; String open = myFaction.getOpen() ? "open" : "closed";
// Inform // Inform
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open);
for (Faction faction : Faction.getAll()) { for (Faction faction : Faction.getAll()) {
if (faction == me.getFaction()) { if (faction == fme.getFaction()) {
continue; continue;
} }
faction.sendMessage(Conf.colorSystem+"The faction "+myFaction.getTag(faction)+Conf.colorSystem+" is now "+open); faction.sendMessage(Conf.colorSystem+"The faction "+myFaction.getTag(faction)+Conf.colorSystem+" is now "+open);

View File

@ -21,7 +21,7 @@ public class FCommandOwner extends FCommand {
@Override @Override
public void perform() { public void perform() {
boolean hasBypass = P.hasPermAdminBypass(me); boolean hasBypass = P.hasPermAdminBypass(fme);
if ( ! hasBypass && ! assertHasFaction()) { if ( ! hasBypass && ! assertHasFaction()) {
return; return;
@ -33,14 +33,14 @@ public class FCommandOwner extends FCommand {
} }
if ( ! Conf.ownedAreasEnabled) { if ( ! Conf.ownedAreasEnabled) {
me.sendMessage("Sorry, but owned areas are disabled on this server."); fme.sendMessage("Sorry, but owned areas are disabled on this server.");
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) { if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
me.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction."); fme.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction.");
return; return;
} }
@ -48,17 +48,17 @@ public class FCommandOwner extends FCommand {
return; return;
} }
FLocation flocation = new FLocation(me); FLocation flocation = new FLocation(fme);
if (Board.getIdAt(flocation) != myFaction.getId()) { if (Board.getIdAt(flocation) != myFaction.getId()) {
if (!hasBypass) { if (!hasBypass) {
me.sendMessage("This land is not claimed by your faction, so you can't set ownership of it."); fme.sendMessage("This land is not claimed by your faction, so you can't set ownership of it.");
return; return;
} }
myFaction = Board.getFactionAt(flocation); myFaction = Board.getFactionAt(flocation);
if (!myFaction.isNormal()) { if (!myFaction.isNormal()) {
me.sendMessage("This land is not claimed by a faction. Ownership is not possible."); fme.sendMessage("This land is not claimed by a faction. Ownership is not possible.");
return; return;
} }
} }
@ -68,7 +68,7 @@ public class FCommandOwner extends FCommand {
if (parameters.size() > 0) { if (parameters.size() > 0) {
target = findFPlayer(parameters.get(0), false); target = findFPlayer(parameters.get(0), false);
} else { } else {
target = me; target = fme;
} }
if (target == null) { if (target == null) {
return; return;
@ -77,20 +77,20 @@ public class FCommandOwner extends FCommand {
String playerName = target.getName(); String playerName = target.getName();
if (target.getFaction().getId() != myFaction.getId()) { if (target.getFaction().getId() != myFaction.getId()) {
me.sendMessage(playerName + " is not a member of this faction."); fme.sendMessage(playerName + " is not a member of this faction.");
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 (parameters.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) { if (parameters.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
myFaction.clearClaimOwnership(flocation); myFaction.clearClaimOwnership(flocation);
me.sendMessage("You have cleared ownership for this claimed area."); fme.sendMessage("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);
me.sendMessage("You have removed ownership of this claimed land from "+playerName+"."); fme.sendMessage("You have removed ownership of this claimed land from "+playerName+".");
return; return;
} }
@ -100,6 +100,6 @@ public class FCommandOwner extends FCommand {
} }
myFaction.setPlayerAsOwner(playerName, flocation); myFaction.setPlayerAsOwner(playerName, flocation);
me.sendMessage("You have added "+playerName+" to the owner list for this claimed land."); fme.sendMessage("You have added "+playerName+" to the owner list for this claimed land.");
} }
} }

View File

@ -20,29 +20,29 @@ public class FCommandOwnerList extends FCommand {
@Override @Override
public void perform() { public void perform() {
boolean hasBypass = P.hasPermAdminBypass(me); boolean hasBypass = P.hasPermAdminBypass(fme);
if ( ! hasBypass && ! assertHasFaction()) { if ( ! hasBypass && ! assertHasFaction()) {
return; return;
} }
if ( ! Conf.ownedAreasEnabled) { if ( ! Conf.ownedAreasEnabled) {
me.sendMessage("Owned areas are disabled on this server."); fme.sendMessage("Owned areas are disabled on this server.");
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
FLocation flocation = new FLocation(me); FLocation flocation = new FLocation(fme);
if (Board.getIdAt(flocation) != myFaction.getId()) { if (Board.getIdAt(flocation) != myFaction.getId()) {
if (!hasBypass) { if (!hasBypass) {
me.sendMessage("This land is not claimed by your faction."); fme.sendMessage("This land is not claimed by your faction.");
return; return;
} }
myFaction = Board.getFactionAt(flocation); myFaction = Board.getFactionAt(flocation);
if (!myFaction.isNormal()) { if (!myFaction.isNormal()) {
me.sendMessage("This land is not claimed by any faction, thus no owners."); fme.sendMessage("This land is not claimed by any faction, thus no owners.");
return; return;
} }
} }
@ -50,10 +50,10 @@ public class FCommandOwnerList extends FCommand {
String owners = myFaction.getOwnerListString(flocation); String owners = myFaction.getOwnerListString(flocation);
if (owners == null || owners.isEmpty()) { if (owners == null || owners.isEmpty()) {
me.sendMessage("No owners are set here; everyone in the faction has access."); fme.sendMessage("No owners are set here; everyone in the faction has access.");
return; return;
} }
me.sendMessage("Current owner(s) of this land: "+owners); fme.sendMessage("Current owner(s) of this land: "+owners);
} }
} }

View File

@ -2,77 +2,70 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
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.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandPay extends FCommand public class FCommandPay extends FCommand
{ {
public FCommandPay() public FCommandPay()
{ {
aliases.add("pay"); this.aliases.add("pay");
helpDescription = "Pay another faction from your bank"; this.requiredArgs.add("faction");
requiredParameters.add("faction"); this.requiredArgs.add("amount");
requiredParameters.add("amount"); //this.optionalArgs.put("factiontag", "yours");
this.permission = Permission.COMMAND_PAY.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform() {
if ( ! assertHasFaction()) { if ( ! Conf.bankEnabled) return;
if ( ! Conf.bankMembersCanWithdraw && ! assertMinRole(Role.MODERATOR))
{
sendMessageParsed("<b>Only faction moderators or admins are able to pay another faction.");
return; return;
} }
if (!Conf.bankEnabled) { Faction us = fme.getFaction();
return; Faction them = this.argAsFaction(0);
} if ( them == null ) return;
double amount = this.argAsDouble(1, 0d);
if ( !Conf.bankMembersCanWithdraw && !assertMinRole(Role.MODERATOR)) {
sendMessage("Only faction moderators or admins are able to pay another faction.");
return;
}
double amount = 0.0;
Faction us = me.getFaction();
Faction them = null;
if (parameters.size() == 2) {
try {
them = Faction.findByTag(parameters.get(0));
amount = Double.parseDouble(parameters.get(1));
} catch (NumberFormatException e) {
// wasn't valid
}
}
if(them == null) {
sendMessage("Faction "+parameters.get(0)+" could not be found.");
return;
}
if( amount > 0.0 ) { if( amount > 0.0 )
{
String amountString = Econ.moneyString(amount); String amountString = Econ.moneyString(amount);
if( amount > us.getMoney() ) { if( amount > us.getMoney() )
{
amount = us.getMoney(); amount = us.getMoney();
} }
us.removeMoney(amount); us.removeMoney(amount);
them.addMoney(amount); them.addMoney(amount);
sendMessage("You have paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
sendMessage(us.getTag()+" now has "+Econ.moneyString(us.getMoney()));
P.log(me.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayer.getAllOnline()) { sendMessageParsed("<i>You have paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
if (fplayer.getFaction() == us || fplayer.getFaction() == them) { sendMessageParsed("<i>"+us.getTag()+" now has "+Econ.moneyString(us.getMoney()));
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has sent "+amountString+" from "+us.getTag()+" to "+them.getTag() ); P.p.log(fme.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == us || fplayer.getFaction() == them)
{
fplayer.sendMessageParsed(fme.getNameAndRelevant(fplayer)+"<i> has sent "+amountString+" from "+us.getTag()+" to "+them.getTag());
} }
} }
} }
} }
} }

View File

@ -46,9 +46,9 @@ public class FCommandPeaceful extends FCommand {
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction.");
} else { } else {
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
} }
} }

View File

@ -46,9 +46,9 @@ public class FCommandPermanent extends FCommand {
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction."); fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction.");
} else { } else {
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
} }
} }
} }

View File

@ -30,8 +30,8 @@ public class FCommandPower extends FCommand {
public void perform() { public void perform() {
FPlayer target; FPlayer target;
if (parameters.size() > 0) { if (parameters.size() > 0) {
if (!P.hasPermViewAnyPower(me)) { if (!P.hasPermViewAnyPower(fme)) {
me.sendMessage("You do not have the appropriate permission to view another player's power level."); fme.sendMessage("You do not have the appropriate permission to view another player's power level.");
return; return;
} }
target = findFPlayer(parameters.get(0), false); target = findFPlayer(parameters.get(0), false);
@ -39,7 +39,7 @@ public class FCommandPower extends FCommand {
sendMessage("From the console, you must specify a player (f power <player name>)."); sendMessage("From the console, you must specify a player (f power <player name>).");
return; return;
} else { } else {
target = me; target = fme;
} }
if (target == null) { if (target == null) {
@ -51,7 +51,7 @@ public class FCommandPower extends FCommand {
return; return;
} }
sendMessage(target.getNameAndRelevant(me)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded()); sendMessage(target.getNameAndRelevant(fme)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded());
} }
} }

View File

@ -32,7 +32,7 @@ public class FCommandSafeclaim extends FCommand {
} }
// The current location of the player // The current location of the player
FLocation playerFlocation = new FLocation(me); FLocation playerFlocation = new FLocation(fme);
// Was a radius set? // Was a radius set?
if (parameters.size() > 0) { if (parameters.size() > 0) {

View File

@ -31,28 +31,28 @@ public class FCommandSethome extends FCommand {
} }
if ( ! Conf.homesEnabled) { if ( ! Conf.homesEnabled) {
me.sendMessage("Sorry, Faction homes are disabled on this server."); fme.sendMessage("Sorry, Faction homes are disabled on this server.");
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
if (parameters.size() > 0) { if (parameters.size() > 0) {
if (!P.hasPermAdminBypass(me)) { if (!P.hasPermAdminBypass(fme)) {
me.sendMessage("You cannot set the home of another faction without adminBypass permission."); fme.sendMessage("You cannot set the home of another faction without adminBypass permission.");
return; return;
} }
myFaction = findFaction(parameters.get(0), true); myFaction = findFaction(parameters.get(0), true);
if (myFaction == null) { if (myFaction == null) {
me.sendMessage("No such faction seems to exist."); fme.sendMessage("No such faction seems to exist.");
return; return;
} }
} }
if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory() && !P.hasPermAdminBypass(me)) { if (Conf.homesMustBeInClaimedTerritory && !fme.isInOwnTerritory() && !P.hasPermAdminBypass(fme)) {
me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory."); fme.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
return; return;
} }
@ -61,12 +61,12 @@ public class FCommandSethome extends FCommand {
return; return;
} }
myFaction.setHome(me.getLocation()); myFaction.setHome(fme.getLocation());
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:"); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
myFaction.sendMessage(new FCommandHome().getUseageTemplate()); myFaction.sendMessage(new FCommandHome().getUseageTemplate());
if (myFaction != me.getFaction()) { if (myFaction != fme.getFaction()) {
me.sendMessage("You have set the home for the "+myFaction.getTag(me)+Conf.colorSystem+" faction."); fme.sendMessage("You have set the home for the "+myFaction.getTag(fme)+Conf.colorSystem+" faction.");
} }
} }

View File

@ -40,7 +40,7 @@ public class FCommandShow extends FCommand {
sendMessage("From the command line, you must specify a faction tag (f who <faction tag>)."); sendMessage("From the command line, you must specify a faction tag (f who <faction tag>).");
return; return;
} else { } else {
faction = me.getFaction(); faction = fme.getFaction();
} }
if (faction == null) { if (faction == null) {
@ -56,7 +56,7 @@ public class FCommandShow extends FCommand {
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR); Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL); Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
sendMessage(TextUtil.titleize(faction.getTag(me))); sendMessage(TextUtil.titleize(faction.getTag(fme)));
sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription()); sendMessage(Conf.colorChrome+"Description: "+Conf.colorSystem+faction.getDescription());
if ( ! faction.isNormal()) { if ( ! faction.isNormal()) {
return; return;
@ -99,7 +99,7 @@ public class FCommandShow extends FCommand {
if (otherFaction == faction) { if (otherFaction == faction) {
continue; continue;
} }
listpart = otherFaction.getTag(me)+Conf.colorSystem+", "; listpart = otherFaction.getTag(fme)+Conf.colorSystem+", ";
if (otherFaction.getRelation(faction).isAlly()) { if (otherFaction.getRelation(faction).isAlly()) {
allyList += listpart; allyList += listpart;
} else if (otherFaction.getRelation(faction).isEnemy()) { } else if (otherFaction.getRelation(faction).isEnemy()) {
@ -120,7 +120,7 @@ public class FCommandShow extends FCommand {
String onlineList = Conf.colorChrome+"Members online: "; String onlineList = Conf.colorChrome+"Members online: ";
String offlineList = Conf.colorChrome+"Members offline: "; String offlineList = Conf.colorChrome+"Members offline: ";
for (FPlayer follower : admins) { for (FPlayer follower : admins) {
listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", "; listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", ";
if (follower.isOnline()) { if (follower.isOnline()) {
onlineList += listpart; onlineList += listpart;
} else { } else {
@ -128,7 +128,7 @@ public class FCommandShow extends FCommand {
} }
} }
for (FPlayer follower : mods) { for (FPlayer follower : mods) {
listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", "; listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", ";
if (follower.isOnline()) { if (follower.isOnline()) {
onlineList += listpart; onlineList += listpart;
} else { } else {
@ -136,7 +136,7 @@ public class FCommandShow extends FCommand {
} }
} }
for (FPlayer follower : normals) { for (FPlayer follower : normals) {
listpart = follower.getNameAndTitle(me)+Conf.colorSystem+", "; listpart = follower.getNameAndTitle(fme)+Conf.colorSystem+", ";
if (follower.isOnline()) { if (follower.isOnline()) {
onlineList += listpart; onlineList += listpart;
} else { } else {

View File

@ -37,7 +37,7 @@ public class FCommandTag extends FCommand {
String tag = parameters.get(0); String tag = parameters.get(0);
// TODO does not first test cover selfcase? // TODO does not first test cover selfcase?
if (Faction.isTagTaken(tag) && ! TextUtil.getComparisonString(tag).equals(me.getFaction().getComparisonTag())) { if (Faction.isTagTaken(tag) && ! TextUtil.getComparisonString(tag).equals(fme.getFaction().getComparisonTag())) {
sendMessage("That tag is already taken"); sendMessage("That tag is already taken");
return; return;
} }
@ -54,18 +54,18 @@ public class FCommandTag extends FCommand {
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
String oldtag = myFaction.getTag(); String oldtag = myFaction.getTag();
myFaction.setTag(tag); myFaction.setTag(tag);
// Inform // Inform
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed your faction tag to "+Conf.colorMember+myFaction.getTag()); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed your faction tag to "+Conf.colorMember+myFaction.getTag());
for (Faction faction : Faction.getAll()) { for (Faction faction : Faction.getAll()) {
if (faction == me.getFaction()) { if (faction == fme.getFaction()) {
continue; continue;
} }
faction.sendMessage(Conf.colorSystem+"The faction "+me.getRelationColor(faction)+oldtag+Conf.colorSystem+" changed their name to "+myFaction.getTag(faction)); faction.sendMessage(Conf.colorSystem+"The faction "+fme.getRelationColor(faction)+oldtag+Conf.colorSystem+" changed their name to "+myFaction.getTag(faction));
} }
if (Conf.spoutFactionTagsOverNames) { if (Conf.spoutFactionTagsOverNames) {

View File

@ -38,7 +38,7 @@ public class FCommandTitle extends FCommand {
return; return;
} }
if ( ! canIAdministerYou(me, you)) { if ( ! canIAdministerYou(fme, you)) {
return; return;
} }
@ -50,11 +50,11 @@ public class FCommandTitle extends FCommand {
you.setTitle(title); you.setTitle(title);
// Inform // Inform
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction)); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction));
if (Conf.spoutFactionTitlesOverNames) { if (Conf.spoutFactionTitlesOverNames) {
SpoutFeatures.updateAppearances(me); SpoutFeatures.updateAppearances(fme);
} }
} }

View File

@ -25,7 +25,7 @@ public class FCommandUnclaim extends FCommand {
return; return;
} }
FLocation flocation = new FLocation(me); FLocation flocation = new FLocation(fme);
Faction otherFaction = Board.getFactionAt(flocation); Faction otherFaction = Board.getFactionAt(flocation);
if (otherFaction.isSafeZone()) { if (otherFaction.isSafeZone()) {
@ -47,10 +47,10 @@ public class FCommandUnclaim extends FCommand {
return; return;
} }
if (Conf.adminBypassPlayers.contains(me.getName())) { if (Conf.adminBypassPlayers.contains(fme.getName())) {
Board.removeAt(flocation); Board.removeAt(flocation);
otherFaction.sendMessage(me.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land."); otherFaction.sendMessage(fme.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land.");
sendMessage("You unclaimed this land."); sendMessage("You unclaimed this land.");
return; return;
} }
@ -63,7 +63,7 @@ public class FCommandUnclaim extends FCommand {
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
if ( myFaction != otherFaction) { if ( myFaction != otherFaction) {
@ -77,25 +77,25 @@ public class FCommandUnclaim extends FCommand {
// a real refund // a real refund
if (refund > 0.0) { if (refund > 0.0) {
if(Conf.bankFactionPaysLandCosts) { if(Conf.bankFactionPaysLandCosts) {
Faction faction = me.getFaction(); Faction faction = fme.getFaction();
faction.addMoney(refund); faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+".";
} else { } else {
Econ.addMoney(me.getName(), refund); Econ.addMoney(fme.getName(), refund);
moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
} }
} }
// wait, you're charging people to unclaim land? outrageous // wait, you're charging people to unclaim land? outrageous
else if (refund < 0.0) { else if (refund < 0.0) {
if(Conf.bankFactionPaysLandCosts) { if(Conf.bankFactionPaysLandCosts) {
Faction faction = me.getFaction(); Faction faction = fme.getFaction();
if(!faction.removeMoney(-refund)) { if(!faction.removeMoney(-refund)) {
sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford.");
return; return;
} }
moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+".";
} else { } else {
if (!Econ.deductMoney(me.getName(), -refund)) { if (!Econ.deductMoney(fme.getName(), -refund)) {
sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford."); sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
return; return;
} }
@ -109,7 +109,7 @@ public class FCommandUnclaim extends FCommand {
} }
Board.removeAt(flocation); Board.removeAt(flocation);
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack);
} }
} }

View File

@ -30,7 +30,7 @@ public class FCommandUnclaimall extends FCommand {
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
String moneyBack = ""; String moneyBack = "";
if (Econ.enabled()) { if (Econ.enabled()) {
@ -38,25 +38,25 @@ public class FCommandUnclaimall extends FCommand {
// a real refund // a real refund
if (refund > 0.0) { if (refund > 0.0) {
if(Conf.bankFactionPaysLandCosts) { if(Conf.bankFactionPaysLandCosts) {
Faction faction = me.getFaction(); Faction faction = fme.getFaction();
faction.addMoney(refund); faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+".";
} else { } else {
Econ.addMoney(me.getName(), refund); Econ.addMoney(fme.getName(), refund);
moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
} }
} }
// wait, you're charging people to unclaim land? outrageous // wait, you're charging people to unclaim land? outrageous
else if (refund < 0.0) { else if (refund < 0.0) {
if(Conf.bankFactionPaysLandCosts) { if(Conf.bankFactionPaysLandCosts) {
Faction faction = me.getFaction(); Faction faction = fme.getFaction();
if(!faction.removeMoney(-refund)) { if(!faction.removeMoney(-refund)) {
sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford."); sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which your faction can't currently afford.");
return; return;
} }
moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+".";
} else { } else {
if (!Econ.deductMoney(me.getName(), -refund)) { if (!Econ.deductMoney(fme.getName(), -refund)) {
sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which you can't currently afford."); sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
return; return;
} }
@ -71,7 +71,7 @@ public class FCommandUnclaimall extends FCommand {
} }
Board.unclaimAll(myFaction.getId()); Board.unclaimAll(myFaction.getId());
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your faction's land."+moneyBack); myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your faction's land."+moneyBack);
} }
} }

View File

@ -31,7 +31,7 @@ public class FCommandWarclaim extends FCommand {
} }
// The current location of the player // The current location of the player
FLocation playerFlocation = new FLocation(me); FLocation playerFlocation = new FLocation(fme);
// Was a radius set? // Was a radius set?
if (parameters.size() > 0) { if (parameters.size() > 0) {

View File

@ -2,64 +2,70 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
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.Faction;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
public class FCommandWithdraw extends FCommand { public class FCommandWithdraw extends FCommand
{
public FCommandWithdraw() { public FCommandWithdraw()
aliases.add("withdraw"); {
this.aliases.add("withdraw");
helpDescription = "Withdraw money from your faction's bank"; this.requiredArgs.add("amount");
requiredParameters.add("amount"); //this.optionalArgs.put("factiontag", "yours");
this.permission = Permission.COMMAND_WITHDRAW.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
} }
@Override @Override
public void perform() { public void perform()
if ( ! assertHasFaction()) { {
if ( ! Conf.bankEnabled) return;
if ( ! Conf.bankMembersCanWithdraw && ! assertMinRole(Role.MODERATOR))
{
sendMessageParsed("<b>Only faction moderators or admins are able to withdraw from the bank.");
return; return;
} }
if (!Conf.bankEnabled) { Faction faction = fme.getFaction();
return;
}
if ( !Conf.bankMembersCanWithdraw && !assertMinRole(Role.MODERATOR)) { double amount = this.argAsDouble(0, 0d);
sendMessage("Only faction moderators or admins are able to withdraw from the bank.");
return;
}
double amount = 0.0; if( amount > 0.0 )
{
Faction faction = me.getFaction();
if (parameters.size() == 1) {
try {
amount = Double.parseDouble(parameters.get(0));
} catch (NumberFormatException e) {
// wasn't valid
}
}
if( amount > 0.0 ) {
String amountString = Econ.moneyString(amount); String amountString = Econ.moneyString(amount);
if( amount > faction.getMoney() ) { if( amount > faction.getMoney() )
{
amount = faction.getMoney(); amount = faction.getMoney();
} }
faction.removeMoney(amount); // TODO: Improve messages.
Econ.addMoney(me.getName(), amount);
sendMessage("You have withdrawn "+amountString+" from "+faction.getTag()+"'s bank.");
sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney()));
P.log(me.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayer.getAllOnline()) { faction.removeMoney(amount);
if (fplayer.getFaction() == faction) { Econ.addMoney(fme.getName(), amount);
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has withdrawn "+amountString); sendMessageParsed("<i>You have withdrawn "+amountString+" from "+faction.getTag()+"'s bank.");
sendMessageParsed("<i>"+faction.getTag()+" now has "+Econ.moneyString(faction.getMoney()));
P.p.log(fme.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank.");
// TODO: FAction.getOnlineMembers().
for (FPlayer fplayer : FPlayers.i.getOnline())
{
if (fplayer.getFaction() == faction)
{
fplayer.sendMessageParsed("%s<i> has withdrawn %s", fme.getNameAndRelevant(fplayer), amountString);
} }
} }
} }

View File

@ -32,7 +32,7 @@ public class FRelationCommand extends FCommand {
return; return;
} }
Faction myFaction = me.getFaction(); Faction myFaction = fme.getFaction();
Faction otherFaction = findFaction(otherFactionName, false); Faction otherFaction = findFaction(otherFactionName, false);
if (otherFaction == null) { if (otherFaction == null) {
return; return;

View File

@ -236,7 +236,7 @@ public class FactionsPlayerListener extends PlayerListener
} }
} }
if (me.autoClaimEnabled()) if (me.isAutoClaimEnabled())
{ {
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
// TODO: Why is this ("cost") here and unused??? Should it be used somewhere Brettflan? :) // TODO: Why is this ("cost") here and unused??? Should it be used somewhere Brettflan? :)
@ -247,26 +247,26 @@ public class FactionsPlayerListener extends PlayerListener
if (me.getRole().value < Role.MODERATOR.value) if (me.getRole().value < Role.MODERATOR.value)
{ {
me.sendMessage("You must be "+Role.MODERATOR+" to claim land."); me.sendMessage("You must be "+Role.MODERATOR+" to claim land.");
me.enableAutoClaim(false); me.setIsAutoClaimEnabled(false);
} }
else if (Conf.worldsNoClaiming.contains(to.getWorldName())) else if (Conf.worldsNoClaiming.contains(to.getWorldName()))
{ {
me.sendMessage("Sorry, this world has land claiming disabled."); me.sendMessage("Sorry, this world has land claiming disabled.");
me.enableAutoClaim(false); me.setIsAutoClaimEnabled(false);
} }
else if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) else if (myFaction.getLandRounded() >= myFaction.getPowerRounded())
{ {
me.sendMessage("You can't claim more land! You need more power!"); me.sendMessage("You can't claim more land! You need more power!");
me.enableAutoClaim(false); me.setIsAutoClaimEnabled(false);
} }
else else
me.attemptClaim(false); me.attemptClaim(false);
} }
else if (me.autoSafeZoneEnabled()) else if (me.isAutoSafeClaimEnabled())
{ {
if ( ! Permission.MANAGE_SAFE_ZONE.has(player)) if ( ! Permission.MANAGE_SAFE_ZONE.has(player))
{ {
me.enableAutoSafeZone(false); me.setIsAutoSafeClaimEnabled(false);
} }
else else
{ {
@ -279,11 +279,11 @@ public class FactionsPlayerListener extends PlayerListener
} }
} }
} }
else if (me.autoWarZoneEnabled()) else if (me.isAutoWarClaimEnabled())
{ {
if ( ! Permission.MANAGE_WAR_ZONE.has(player)) if ( ! Permission.MANAGE_WAR_ZONE.has(player))
{ {
me.enableAutoWarZone(false); me.setIsAutoWarClaimEnabled(false);
} }
else else
{ {

View File

@ -1,6 +1,7 @@
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");
@ -8,21 +9,32 @@ public enum ChatMode {
public final int value; public final int value;
public final String nicename; public final String nicename;
private ChatMode(final int value, final String nicename) { private ChatMode(final int value, final String nicename)
{
this.value = value; this.value = value;
this.nicename = nicename; this.nicename = nicename;
} }
public boolean isAtLeast(ChatMode role) { public boolean isAtLeast(ChatMode role)
{
return this.value >= role.value; return this.value >= role.value;
} }
public boolean isAtMost(ChatMode role) { public boolean isAtMost(ChatMode role)
{
return this.value <= role.value; return this.value <= role.value;
} }
@Override @Override
public String toString() { public String toString()
{
return this.nicename; return this.nicename;
} }
public ChatMode getNext()
{
if (this == PUBLIC) return ALLIANCE;
if (this == ALLIANCE)return FACTION;
return PUBLIC;
}
} }

View File

@ -6,27 +6,53 @@ import com.massivecraft.factions.P;
public enum Permission public enum Permission
{ {
PARTICIPATE("factions.participate"), PARTICIPATE("participate"),
CREATE("factions.create"), CREATE("create"),
VIEW_ANY_POWER("factions.viewAnyPower"), VIEW_ANY_POWER("viewAnyPower"),
PEACEFUL_EXPLOTION_TOGGLE("factions.peacefulExplosionToggle"), VIEW_ANY_FACTION_BALANCE("viewAnyFactionBalance"),
ADMIN_BYPASS("factions.adminBypass"), PEACEFUL_EXPLOTION_TOGGLE("peacefulExplosionToggle"),
CONFIG("factions.config"), ADMIN_BYPASS("adminBypass"),
DISBAN("factions.disband"), CONFIG("config"),
LOCK("factions.lock"), DISBAND("disband"),
MANAGE_SAFE_ZONE("factions.manageSafeZone"), LOCK("lock"),
MANAGE_WAR_ZONE("factions.manageWarZone"), MANAGE_SAFE_ZONE("manageSafeZone"),
OWNERSHIP_BYPASS("factions.ownershipBypass"), MANAGE_WAR_ZONE("manageWarZone"),
RELOAD("factions.reload"), OWNERSHIP_BYPASS("ownershipBypass"),
SAVE_ALL("factions.saveall"), RELOAD("reload"),
SET_PEACEFUL("factions.setPeaceful"), SAVE_ALL("saveall"),
SET_PEACEFUL("setPeaceful"),
SET_PERMANENT("setPermanent"),
COMMAND_ADMIN("command.admin"),
COMMAND_AUTOCLAIM("command.autoClaim"),
COMMAND_BALANCE("command.balance"),
COMMAND_WITHDRAW("command.withdraw"),
COMMAND_PAY("command.pay"),
COMMAND_CHAT("command.chat"),
COMMAND_CLAIM("command.claim"),
COMMAND_CONFIG("command.config"),
COMMAND_DEINVITE("command.deinvite"),
COMMAND_DEPOSIT("command.deposit"),
COMMAND_DESCRIPTION("command.description"),
COMMAND_DISBAND("command.disband"),
COMMAND_DISBAND_ANY("command.disband.any"),
COMMAND_HELP("command.help"),
COMMAND_HOME("command.home"),
COMMAND_INVITE("command.invite"),
COMMAND_JOIN("command.join"),
COMMAND_KICK("command.kick"),
COMMAND_KICK_ANY("command.kick.any"),
COMMAND_LEAVE("command.leave"),
COMMAND_LIST("command.list"),
COMMAND_LOCK("command.lock"),
COMMAND_MAP("command.map"),
COMMAND_MOD("command.mod"),
; ;
public final String node; public final String node;
Permission(final String node) Permission(final String node)
{ {
this.node = node; this.node = "factions."+node;
} }
public boolean has(CommandSender sender, boolean informSenderIfNot) public boolean has(CommandSender sender, boolean informSenderIfNot)

View File

@ -27,8 +27,25 @@ public abstract class MCommand<T extends MPlugin>
public List<String> requiredArgs; public List<String> requiredArgs;
public LinkedHashMap<String, String> optionalArgs; public LinkedHashMap<String, String> optionalArgs;
// Help info // FIELD: Help Short
public String helpShort; // This field may be left blank and will in such case be loaded from the permissions node instead.
// Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff".
private String helpShort;
public void setHelpShort(String val) { this.helpShort = val; }
public String getHelpShort()
{
if (this.helpShort == null)
{
String pdesc = p.perm.getPermissionDescription(this.permission);
if (pdesc != null)
{
return pdesc;
}
return "*no short help available*";
}
return this.helpShort;
}
public List<String> helpLong; public List<String> helpLong;
public CommandVisibility visibility; public CommandVisibility visibility;
@ -39,6 +56,7 @@ public abstract class MCommand<T extends MPlugin>
// Information available on execution of the command // Information available on execution of the command
public CommandSender sender; // Will always be set public CommandSender sender; // Will always be set
public Player me; // Will only be set when the sender is a player public Player me; // Will only be set when the sender is a player
public boolean senderIsConsole;
public List<String> args; // Will contain the arguments, or and empty list if there are none. public List<String> args; // Will contain the arguments, or and empty list if there are none.
public List<MCommand<?>> commandChain; // The command chain used to execute this command public List<MCommand<?>> commandChain; // The command chain used to execute this command
@ -56,7 +74,7 @@ public abstract class MCommand<T extends MPlugin>
this.requiredArgs = new ArrayList<String>(); this.requiredArgs = new ArrayList<String>();
this.optionalArgs = new LinkedHashMap<String, String>(); this.optionalArgs = new LinkedHashMap<String, String>();
this.helpShort = "*Default helpShort*"; this.helpShort = null;
this.helpLong = new ArrayList<String>(); this.helpLong = new ArrayList<String>();
this.visibility = CommandVisibility.VISIBLE; this.visibility = CommandVisibility.VISIBLE;
} }
@ -69,10 +87,12 @@ public abstract class MCommand<T extends MPlugin>
if (sender instanceof Player) if (sender instanceof Player)
{ {
this.me = (Player)sender; this.me = (Player)sender;
this.senderIsConsole = false;
} }
else else
{ {
this.me = null; this.me = null;
this.senderIsConsole = true;
} }
this.args = args; this.args = args;
this.commandChain = commandChain; this.commandChain = commandChain;
@ -255,38 +275,38 @@ public abstract class MCommand<T extends MPlugin>
// Message Sending Helpers // Message Sending Helpers
// -------------------------------------------- // // -------------------------------------------- //
public void sendMessage(String msg, boolean parseColors) public void sendMessageParsed(String str, Object... args)
{ {
if (parseColors) sender.sendMessage(p.txt.parse(str, args));
{
sender.sendMessage(p.txt.tags(msg));
return;
}
sender.sendMessage(msg);
} }
public void sendMessage(String msg) public void sendMessage(String msg)
{ {
this.sendMessage(msg, false); sender.sendMessage(msg);
}
public void sendMessage(List<String> msgs, boolean parseColors)
{
for(String msg : msgs)
{
this.sendMessage(msg, parseColors);
}
} }
public void sendMessage(List<String> msgs) public void sendMessage(List<String> msgs)
{ {
sendMessage(msgs, false); for(String msg : msgs)
{
this.sendMessage(msg);
}
} }
// -------------------------------------------- // // -------------------------------------------- //
// Argument Readers // Argument Readers
// -------------------------------------------- // // -------------------------------------------- //
// Is set?
public boolean argIsSet(int idx)
{
if (this.args.size() < idx+1)
{
return false;
}
return true;
}
// STRING // STRING
public String argAsString(int idx, String def) public String argAsString(int idx, String def)
{ {

View File

@ -26,6 +26,14 @@ public class PlayerEntity extends Entity
// Message Sending Helpers // Message Sending Helpers
// -------------------------------------------- // // -------------------------------------------- //
/*
public void sendMessageParsed(String str, Object... args)
{
this.sendMessage(p.txt.parse(str, args));
}
Refference issue!!
*/
public void sendMessage(String msg) public void sendMessage(String msg)
{ {
Player player = this.getPlayer(); Player player = this.getPlayer();

View File

@ -39,254 +39,114 @@ permissions:
factions.setPermanent: true factions.setPermanent: true
factions.commandDisable.none: true factions.commandDisable.none: true
factions.participate: factions.participate:
description: Allows the player to participate in a faction description: participate in a faction
default: true default: true
factions.create: factions.create:
description: Allows the player to create a new faction description: create a new faction
default: true default: true
factions.viewAnyPower: factions.viewAnyPower:
description: Allows the player to view the power level of anyone else description: view the power level of anyone else
default: true default: true
factions.viewAnyFactionBalance: factions.viewAnyFactionBalance:
description: Allows the player to view the faction bank balance for any faction description: view the faction bank balance for any faction
default: true default: true
factions.peacefulExplosionToggle: factions.peacefulExplosionToggle:
description: Allows peaceful faction admins and moderators to disable explosions in their territory description: disable explosions in your territory as a peaceful faction admin or moderator
default: true default: true
factions.adminBypass: factions.adminBypass:
description: Allows the player to bypass many normal restrictions, and use the bypass command description: enable admin bypass mode (build/destroy anywhere)
default: op default: op
factions.config: factions.config:
description: Can use /f config command to change conf.json options description: use /f config command to change conf.json options
default: op
factions.disband:
description: Can use the /f disband <faction> command to disband any faction
default: op
factions.lock:
description: Can use the /f lock [on/off] command to temporarily lock the data files from being overwritten
default: op default: op
factions.manageSafeZone: factions.manageSafeZone:
description: Allows the player to claim land as a safe zone, and to build/destroy within safe zones description: claim land as a safe zone and build/destroy within safe zones
default: op default: op
factions.manageWarZone: factions.manageWarZone:
description: Allows the player to claim land as a war zone, and to build/destroy within war zones description: claim land as a war zone and build/destroy within war zones
default: op default: op
factions.ownershipBypass: factions.ownershipBypass:
description: Allows the player to bypass ownership restrictions within own faction's territory description: bypass ownership restrictions within own faction's territory
default: op default: op
factions.reload: factions.reload:
description: Can use the /f reload command to reload data file(s) from disk description: use the /f reload command to reload data file(s) from disk
default: op default: op
factions.saveall: factions.saveall:
description: Can use the /f saveall command to save all data to disk description: use the /f saveall command to save all data to disk
default: op default: op
factions.setPeaceful: factions.setPeaceful:
description: Can designate specific factions as "peaceful" (no PvP, no land stealing, etc.) description: designate specific factions as "peaceful" (no PvP, no land stealing, etc.)
default: op default: op
factions.setPermanent: factions.setPermanent:
description: Can designate specific factions as permanent (not disbanded even with no members) description: designate specific factions as permanent (not disbanded even with no members)
default: op default: op
factions.commandDisable.none:
description: no commands disabled (ignore all other commandDisable permissions) factions.command.admin:
description: hand over your admin rights
default: true
factions.command.autoClaim:
description: auto-claim land as you walk around
default: true
factions.command.balance:
description: show current faction balance
default: true
factions.command.withdraw:
description: withdraw money from your faction bank
default: true
factions.command.pay:
description: pay another faction from your bank
default: true
factions.command.chat:
description: change chat mode
default: true
factions.command.claim:
description: claim the land where you are standing
default: true
factions.command.config:
description: change a conf.json setting
default: op default: op
factions.commandDisable.admin: factions.command.deinvite:
description: admin command disabled description: remove a pending invitation
default: false default: true
factions.commandDisable.autoclaim: factions.command.deposit:
description: autoclaim command disabled description: deposit money into your faction bank
default: false default: true
factions.commandDisable.autosafe: factions.command.description:
description: autosafe command disabled description: change the faction description
default: false default: true
factions.commandDisable.autowar: factions.command.disband:
description: autowar command disabled description: disband a faction
default: false default: true
factions.commandDisable.balance: factions.command.disband.any:
description: balance/money command disabled description: disband an other faction
default: false default: op
factions.commandDisable.bypass: factions.command.help:
description: bypass command disabled description: display a help page
default: false default: true
factions.commandDisable.chat: factions.command.home:
description: chat command disabled description: teleport to the faction home
default: false default: true
factions.commandDisable.c: factions.command.join:
description: chat command disabled description: join a faction
default: false default: true
factions.commandDisable.claim: factions.command.kick:
description: claim command disabled description: kick a player from the faction
default: false default: true
factions.commandDisable.create: factions.command.kick.any:
description: create command disabled description: kick anyone from any faction
default: false default: op
factions.commandDisable.deinvite: factions.command.leave:
description: deinvite command disabled description: leave your faction
default: false default: true
factions.commandDisable.deinv: factions.command.list:
description: deinvite command disabled description: see a list of the factions
default: false default: true
factions.commandDisable.deposit: factions.command.lock:
description: deposit command disabled description: lock all write stuff
default: false default: op
factions.commandDisable.desc: factions.command.map:
description: desc command disabled description: show territory map, set optional auto update
default: false default: true
factions.commandDisable.disband: factions.command.mod:
description: disband command disabled description: give or revoke moderator rights
default: false default: true
factions.commandDisable.help:
description: help command disabled
default: false
factions.commandDisable.h:
description: help command disabled
default: false
factions.commandDisable.?:
description: help command disabled
default: false
factions.commandDisable.home:
description: home command disabled
default: false
factions.commandDisable.invite:
description: invite command disabled
default: false
factions.commandDisable.inv:
description: invite command disabled
default: false
factions.commandDisable.join:
description: join command disabled
default: false
factions.commandDisable.kick:
description: kick command disabled
default: false
factions.commandDisable.leave:
description: leave command disabled
default: false
factions.commandDisable.list:
description: list command disabled
default: false
factions.commandDisable.ls:
description: list command disabled
default: false
factions.commandDisable.lock:
description: lock command disabled
default: false
factions.commandDisable.map:
description: map command disabled
default: false
factions.commandDisable.mod:
description: mod command disabled
default: false
factions.commandDisable.money:
description: balance/money command disabled
default: false
factions.commandDisable.noboom:
description: noboom command disabled
default: false
factions.commandDisable.open:
description: open command disabled
default: false
factions.commandDisable.close:
description: open command disabled
default: false
factions.commandDisable.owner:
description: owner command disabled
default: false
factions.commandDisable.ownerlist:
description: ownerlist command disabled
default: false
factions.commandDisable.pay:
description: pay command disabled
default: false
factions.commandDisable.peaceful:
description: peaceful command disabled
default: false
factions.commandDisable.permanent:
description: permanent command disabled
default: false
factions.commandDisable.power:
description: power command disabled
default: false
factions.commandDisable.pow:
description: power command disabled
default: false
factions.commandDisable.ally:
description: ally command disabled
default: false
factions.commandDisable.enemy:
description: enemy command disabled
default: false
factions.commandDisable.neutral:
description: neutral command disabled
default: false
factions.commandDisable.reload:
description: reload command disabled
default: false
factions.commandDisable.safeclaim:
description: safeclaim command disabled
default: false
factions.commandDisable.safe:
description: safeclaim command disabled
default: false
factions.commandDisable.safeunclaimall:
description: safeunclaimall command disabled
default: false
factions.commandDisable.safedeclaimall:
description: safeunclaimall command disabled
default: false
factions.commandDisable.saveall:
description: saveall command disabled
default: false
factions.commandDisable.save:
description: saveall command disabled
default: false
factions.commandDisable.sethome:
description: sethome command disabled
default: false
factions.commandDisable.show:
description: show command disabled
default: false
factions.commandDisable.who:
description: show command disabled
default: false
factions.commandDisable.tag:
description: tag command disabled
default: false
factions.commandDisable.title:
description: title command disabled
default: false
factions.commandDisable.unclaim:
description: unclaim command disabled
default: false
factions.commandDisable.declaim:
description: unclaim command disabled
default: false
factions.commandDisable.unclaimall:
description: unclaimall command disabled
default: false
factions.commandDisable.declaimall:
description: unclaimall command disabled
default: false
factions.commandDisable.version:
description: version command disabled
default: false
factions.commandDisable.warclaim:
description: warclaim command disabled
default: false
factions.commandDisable.war:
description: warclaim command disabled
default: false
factions.commandDisable.warunclaimall:
description: warunclaimall command disabled
default: false
factions.commandDisable.wardeclaimall:
description: warunclaimall command disabled
default: false
factions.commandDisable.withdraw:
description: withdraw command disabled
default: false
factions.commandDisable.worldnoclaim:
description: worldnoclaim command disabled
default: false
factions.commandDisable.worldnopowerloss:
description: worldnopowerloss command disabled
default: false