Converting the command structure

This commit is contained in:
Olof Larsson
2011-10-08 23:22:02 +02:00
parent 0ce9cce9d3
commit 227d54dc5f
58 changed files with 582 additions and 538 deletions

View File

@@ -1,319 +0,0 @@
package com.massivecraft.factions.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.TextUtil;
public class FBaseCommand {
public List<String> aliases;
public List<String> requiredParameters;
public List<String> optionalParameters;
public String helpNameAndParams;
public String helpDescription;
public CommandSender sender;
public boolean senderMustBePlayer;
public boolean senderIsConsole;
public Player player;
public FPlayer me;
public List<String> parameters;
private static boolean lock = false;
public FBaseCommand() {
aliases = new ArrayList<String>();
requiredParameters = new ArrayList<String>();
optionalParameters = new ArrayList<String>();
senderMustBePlayer = true;
senderIsConsole = false;
helpNameAndParams = "fail!";
helpDescription = "no description";
}
public List<String> getAliases() {
return aliases;
}
public void execute(CommandSender sender, List<String> parameters) {
this.sender = sender;
this.parameters = parameters;
if ( ! validateCall()) {
return;
}
if (sender instanceof Player) {
this.player = (Player)sender;
this.me = FPlayer.get(this.player);
senderIsConsole = false;
}
else {
senderIsConsole = true;
}
perform();
}
public void perform() {
}
public void sendMessage(String message) {
sender.sendMessage(Conf.colorSystem+message);
}
public void sendMessage(List<String> messages) {
for(String message : messages) {
this.sendMessage(message);
}
}
public boolean validateCall() {
if ( this.senderMustBePlayer && senderIsConsole ) {
sendMessage("This command can only be used by ingame players.");
return false;
}
if( ! hasPermission(sender)) {
sendMessage("You lack the permissions to "+this.helpDescription.toLowerCase()+".");
return false;
}
// make sure player doesn't have their access to the command revoked
Iterator<String> iter = aliases.iterator();
while (iter.hasNext()) {
if (P.isCommandDisabled(sender, iter.next())) {
sendMessage("You lack the permissions to "+this.helpDescription.toLowerCase()+".");
return false;
}
}
if (parameters.size() < requiredParameters.size()) {
sendMessage("Usage: "+this.getUseageTemplate(false));
return false;
}
return true;
}
public boolean hasPermission(CommandSender sender) {
return P.hasPermParticipate(sender);
}
// -------------------------------------------- //
// Help and usage description
// -------------------------------------------- //
public String getUseageTemplate(boolean withDescription) {
String ret = "";
ret += Conf.colorCommand;
ret += P.p.getBaseCommand()+ " " +TextUtil.implode(this.getAliases(), ",")+" ";
List<String> parts = new ArrayList<String>();
for (String requiredParameter : this.requiredParameters) {
parts.add("["+requiredParameter+"]");
}
for (String optionalParameter : this.optionalParameters) {
parts.add("*["+optionalParameter+"]");
}
ret += Conf.colorParameter;
ret += TextUtil.implode(parts, " ");
if (withDescription) {
ret += " "+Conf.colorSystem + this.helpDescription;
}
return ret;
}
public String getUseageTemplate() {
return getUseageTemplate(true);
}
// -------------------------------------------- //
// Assertions
// -------------------------------------------- //
public boolean assertHasFaction() {
if ( ! me.hasFaction()) {
sendMessage("You are not member of any faction.");
return false;
}
return true;
}
public boolean assertMinRole(Role role) {
if (me.getRole().value < role.value) {
sendMessage("You must be "+role+" to "+this.helpDescription+".");
return false;
}
return true;
}
// -------------------------------------------- //
// Commonly used logic
// -------------------------------------------- //
public FPlayer findFPlayer(String playerName, boolean defaultToMe) {
FPlayer fp = FPlayer.find(playerName);
if (fp == null) {
if (defaultToMe) {
return me;
}
sendMessage("The player \""+playerName+"\" could not be found");
}
return fp;
}
public FPlayer findFPlayer(String playerName) {
return findFPlayer(playerName, false);
}
public Faction findFaction(String factionName, boolean defaultToMine) {
// First we search faction names
Faction faction = Faction.findByTag(factionName);
if (faction != null) {
return faction;
}
// Next we search player names
FPlayer fp = FPlayer.find(factionName);
if (fp != null) {
return fp.getFaction();
}
if (defaultToMine && !senderIsConsole) {
return me.getFaction();
}
sendMessage(Conf.colorSystem+"No faction or player \""+factionName+"\" was found");
return null;
}
public Faction findFaction(String factionName) {
return findFaction(factionName, false);
}
public boolean canIAdministerYou(FPlayer i, FPlayer you) {
if ( ! i.getFaction().equals(you.getFaction())) {
i.sendMessage(you.getNameAndRelevant(i)+Conf.colorSystem+" is not in the same faction as you.");
return false;
}
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN) ) {
return true;
}
if (you.getRole().equals(Role.ADMIN)) {
i.sendMessage(Conf.colorSystem+"Only the faction admin can do that.");
} else if (i.getRole().equals(Role.MODERATOR)) {
if ( i == you ) {
return true; //Moderators can control themselves
} else {
i.sendMessage(Conf.colorSystem+"Moderators can't control each other...");
}
} else {
i.sendMessage(Conf.colorSystem+"You must be a faction moderator to do that.");
}
return false;
}
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost) {
if (!Econ.enabled() || this.me == null || cost == 0.0 || Conf.adminBypassPlayers.contains(me.getName())) {
return true;
}
String desc = this.helpDescription.toLowerCase();
Faction faction = me.getFaction();
// pay up
if (cost > 0.0) {
String costString = Econ.moneyString(cost);
if(Conf.bankFactionPaysCosts && me.hasFaction() ) {
if(!faction.removeMoney(cost)) {
sendMessage("It costs "+costString+" to "+desc+", which your faction can't currently afford.");
return false;
} else {
sendMessage(faction.getTag()+" has paid "+costString+" to "+desc+".");
}
} else {
if (!Econ.deductMoney(me.getName(), cost)) {
sendMessage("It costs "+costString+" to "+desc+", which you can't currently afford.");
return false;
}
sendMessage("You have paid "+costString+" to "+desc+".");
}
}
// wait... we pay you to use this command?
else {
String costString = Econ.moneyString(-cost);
if(Conf.bankFactionPaysCosts && me.hasFaction() ) {
faction.addMoney(-cost);
sendMessage(faction.getTag()+" has been paid "+costString+" to "+desc+".");
} else {
Econ.addMoney(me.getName(), -cost);
}
sendMessage("You have been paid "+costString+" to "+desc+".");
}
return true;
}
public static final List<String> aliasTrue = new ArrayList<String>(Arrays.asList("true", "yes", "y", "ok", "on", "+"));
public static final List<String> aliasFalse = new ArrayList<String>(Arrays.asList("false", "no", "n", "off", "-"));
public boolean parseBool(String str) {
return aliasTrue.contains(str.toLowerCase());
}
public void setLock(boolean newLock) {
if( newLock ) {
sendMessage("Factions is now locked");
} else {
sendMessage("Factions in now unlocked");
}
lock = newLock;
}
public boolean isLocked() {
return lock;
}
public void sendLockMessage() {
me.sendMessage("Factions is locked. Please try again later");
}
}

View File

@@ -0,0 +1,318 @@
package com.massivecraft.factions.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.MCommand;
public abstract class FCommand extends MCommand<P>
{
//TODO: Legacy to handle
//public boolean senderIsConsole;
//private static boolean lock = false;
public FPlayer fme;
public boolean senderMustBeMember;
public boolean senderMustBeModerator;
public boolean senderMustBeAdmin;
public FCommand()
{
super(P.p);
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain)
{
if (sender instanceof Player)
{
this.fme = FPlayers.i.get((Player)sender);
}
else
{
this.fme = null;
}
super.execute(sender, args, commandChain);
}
@Override
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot)
{
boolean superValid = super.validSenderType(sender, informSenderIfNot);
if ( ! superValid) return false;
if ( ! (this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) return true;
if ( ! (sender instanceof Player)) return false;
FPlayer fplayer = FPlayers.i.get((Player)sender);
if ( ! fplayer.hasFaction())
{
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
return false;
}
if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Role.MODERATOR))
{
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.helpShort));
return false;
}
if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Role.ADMIN))
{
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.helpShort));
return false;
}
return true;
}
// -------------------------------------------- //
// Argument Readers
// -------------------------------------------- //
// ARG AS FPLAYER
public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg)
{
FPlayer ret = def;
String name = this.argAsString(idx);
if (name != null)
{
FPlayer fplayer = FPlayers.i.get(name);
if (fplayer != null)
{
ret = fplayer;
}
}
if (msg && ret == null)
{
this.sendMessage(p.txt.parse("<b>The player \"<p>%s<b>\" could not be found.", name));
}
return ret;
}
public FPlayer argAsFPlayer(int idx, FPlayer def)
{
return this.argAsFPlayer(idx, def, true);
}
public FPlayer argAsFPlayer(int idx)
{
return this.argAsFPlayer(idx, null);
}
// ARG AS BEST FPLAYER MATCH
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg)
{
FPlayer ret = def;
String name = this.argAsString(idx);
if (name != null)
{
FPlayer fplayer = FPlayers.i.find(name);
if (fplayer != null)
{
ret = fplayer;
}
}
if (msg && ret == null)
{
this.sendMessage(p.txt.parse("<b>The player \"<p>%s<b>\" could not be found.", name));
}
return ret;
}
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def)
{
return this.argAsBestFPlayerMatch(idx, def, true);
}
public FPlayer argAsBestFPlayerMatch(int idx)
{
return this.argAsBestFPlayerMatch(idx, null);
}
// ARG AS FACTION
public Faction argAsFaction(int idx, Faction def, boolean msg)
{
Faction ret = def;
String name = this.argAsString(idx);
if (name != null)
{
// First we search faction names
Faction faction = Factions.i.findByTag(name);
if (faction != null)
{
ret = faction;
}
// Next we search player names
FPlayer fplayer = FPlayers.i.find(name);
if (fplayer != null)
{
ret = fplayer.getFaction();
}
}
if (msg && ret == null)
{
this.sendMessage(p.txt.parse("<b>The faction or player \"<p>%s<b>\" could not be found.", name));
}
return ret;
}
public Faction argAsFaction(int idx, Faction def)
{
return this.argAsFaction(idx, def, true);
}
public Faction argAsFaction(int idx)
{
return this.argAsFaction(idx, null);
}
// -------------------------------------------- //
// Commonly used logic
// -------------------------------------------- //
public boolean canIAdministerYou(FPlayer i, FPlayer you)
{
if ( ! i.getFaction().equals(you.getFaction()))
{
i.sendMessage(p.txt.parse("%s <b>is not in the same faction as you.",you.getNameAndRelevant(i)));
return false;
}
if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN) )
{
return true;
}
if (you.getRole().equals(Role.ADMIN))
{
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
}
else if (i.getRole().equals(Role.MODERATOR))
{
if ( i == you )
{
return true; //Moderators can control themselves
}
else
{
i.sendMessage(p.txt.parse("<b>Moderators can't control each other..."));
}
}
else
{
i.sendMessage(p.txt.parse("<b>You must be a faction moderator to do that."));
}
return false;
}
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost)
{
if ( ! Econ.enabled() || this.me == null || cost == 0.0 || Conf.adminBypassPlayers.contains(me.getName()))
{
return true;
}
String desc = this.helpShort.toLowerCase();
Faction faction = fme.getFaction();
// pay up
if (cost > 0.0)
{
String costString = Econ.moneyString(cost);
if(Conf.bankFactionPaysCosts && fme.hasFaction() )
{
if(!faction.removeMoney(cost))
{
sendMessage("It costs "+costString+" to "+desc+", which your faction can't currently afford.");
return false;
}
else
{
sendMessage(faction.getTag()+" has paid "+costString+" to "+desc+".");
}
}
else
{
if (!Econ.deductMoney(me.getName(), cost))
{
sendMessage("It costs "+costString+" to "+desc+", which you can't currently afford.");
return false;
}
sendMessage("You have paid "+costString+" to "+desc+".");
}
}
// wait... we pay you to use this command?
else
{
String costString = Econ.moneyString(-cost);
if(Conf.bankFactionPaysCosts && fme.hasFaction() )
{
faction.addMoney(-cost);
sendMessage(faction.getTag()+" has been paid "+costString+" to "+desc+".");
}
else
{
Econ.addMoney(me.getName(), -cost);
}
sendMessage("You have been paid "+costString+" to "+desc+".");
}
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

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandAdmin extends FBaseCommand {
public class FCommandAdmin extends FCommand {
public FCommandAdmin() {
aliases.add("admin");

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandAutoClaim extends FBaseCommand {
public class FCommandAutoClaim extends FCommand {
public FCommandAutoClaim() {
aliases.add("autoclaim");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandAutoSafeclaim extends FBaseCommand {
public class FCommandAutoSafeclaim extends FCommand {
public FCommandAutoSafeclaim() {
aliases.add("autosafe");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandAutoWarclaim extends FBaseCommand {
public class FCommandAutoWarclaim extends FCommand {
public FCommandAutoWarclaim() {
aliases.add("autowar");

View File

@@ -6,7 +6,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandBalance extends FBaseCommand {
public class FCommandBalance extends FCommand {
public FCommandBalance() {
aliases.add("balance");

View File

@@ -6,7 +6,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
public class FCommandBypass extends FBaseCommand {
public class FCommandBypass extends FCommand {
public FCommandBypass() {
aliases.add("bypass");
@@ -21,14 +21,14 @@ public class FCommandBypass extends FBaseCommand {
@Override
public void perform() {
if ( ! Conf.adminBypassPlayers.contains(player.getName())) {
Conf.adminBypassPlayers.add(player.getName());
if ( ! Conf.adminBypassPlayers.contains(me.getName())) {
Conf.adminBypassPlayers.add(me.getName());
me.sendMessage("You have enabled admin bypass mode. You will be able to build or destroy anywhere.");
P.log(player.getName() + " has ENABLED admin bypass mode.");
P.log(me.getName() + " has ENABLED admin bypass mode.");
} else {
Conf.adminBypassPlayers.remove(player.getName());
Conf.adminBypassPlayers.remove(me.getName());
me.sendMessage("You have disabled admin bypass mode.");
P.log(player.getName() + " DISABLED admin bypass mode.");
P.log(me.getName() + " DISABLED admin bypass mode.");
}
}
}

View File

@@ -3,7 +3,7 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.ChatMode;
public class FCommandChat extends FBaseCommand {
public class FCommandChat extends FCommand {
public FCommandChat() {
aliases.add("chat");

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.commands;
public class FCommandClaim extends FBaseCommand {
public class FCommandClaim extends FCommand {
public FCommandClaim() {
aliases.add("claim");

View File

@@ -15,7 +15,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures;
public class FCommandConfig extends FBaseCommand {
public class FCommandConfig extends FCommand {
private static HashMap<String, String> properFieldNames = new HashMap<String, String>();
@@ -222,7 +222,7 @@ public class FCommandConfig extends FBaseCommand {
if (!success.isEmpty()) {
sendMessage(success);
if (sender instanceof Player) {
P.log(success + " Command was run by "+player.getName()+".");
P.log(success + " Command was run by "+me.getName()+".");
}
}
// save change to disk

View File

@@ -11,7 +11,7 @@ import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
public class FCommandCreate extends FBaseCommand {
public class FCommandCreate extends FCommand {
public FCommandCreate() {
aliases.add("create");

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandDeinvite extends FBaseCommand {
public class FCommandDeinvite extends FCommand {
public FCommandDeinvite() {
aliases.add("deinvite");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
public class FCommandDeposit extends FBaseCommand {
public class FCommandDeposit extends FCommand {
public FCommandDeposit() {
aliases.add("deposit");
@@ -49,7 +49,7 @@ public class FCommandDeposit extends FBaseCommand {
faction.addMoney(amount);
sendMessage("You have deposited "+amountString+" into "+faction.getTag()+"'s bank.");
sendMessage(faction.getTag()+" now has "+Econ.moneyString(faction.getMoney()));
P.log(player.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank.");
P.log(me.getName() + " deposited "+amountString+" into "+faction.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) {

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.TextUtil;
public class FCommandDescription extends FBaseCommand {
public class FCommandDescription extends FCommand {
public FCommandDescription() {
aliases.add("desc");

View File

@@ -9,7 +9,7 @@ import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Role;
public class FCommandDisband extends FBaseCommand {
public class FCommandDisband extends FCommand {
public FCommandDisband() {
aliases.add("disband");
@@ -75,7 +75,7 @@ public class FCommandDisband extends FBaseCommand {
if (amount > 0.0) {
String amountString = Econ.moneyString(amount);
sendMessage("You have been given the disbanded faction's bank, totaling "+amountString+".");
P.log(player.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
P.log(me.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
}
}

View File

@@ -9,7 +9,7 @@ import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.util.TextUtil;
public class FCommandHelp extends FBaseCommand {
public class FCommandHelp extends FCommand {
public FCommandHelp() {
aliases.add("help");

View File

@@ -12,7 +12,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
public class FCommandHome extends FBaseCommand {
public class FCommandHome extends FCommand {
public FCommandHome() {
aliases.add("home");
@@ -49,12 +49,12 @@ public class FCommandHome extends FBaseCommand {
return;
}
if (!Conf.homesTeleportAllowedFromDifferentWorld && player.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.");
return;
}
Faction faction = Board.getFactionAt(new FLocation(player.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 (
@@ -62,15 +62,15 @@ public class FCommandHome extends FBaseCommand {
&& !faction.isSafeZone()
&& (!me.isInOwnTerritory() || (me.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))
) {
Location loc = player.getLocation();
Location loc = me.getLocation();
World w = loc.getWorld();
double x = loc.getX();
double y = loc.getY();
double z = loc.getZ();
for (Player p : player.getServer().getOnlinePlayers())
for (Player p : me.getServer().getOnlinePlayers())
{
if (p == null || !p.isOnline() || p.isDead() || p == player || p.getWorld() != w)
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
continue;
FPlayer fp = FPlayer.get(p);
@@ -97,7 +97,7 @@ public class FCommandHome extends FBaseCommand {
return;
}
player.teleport(myFaction.getHome());
me.teleport(myFaction.getHome());
}
}

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandInvite extends FBaseCommand {
public class FCommandInvite extends FCommand {
public FCommandInvite() {
aliases.add("invite");

View File

@@ -3,7 +3,7 @@ package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
public class FCommandJoin extends FBaseCommand {
public class FCommandJoin extends FCommand {
public FCommandJoin() {
aliases.add("join");

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandKick extends FBaseCommand {
public class FCommandKick extends FCommand {
public FCommandKick() {
aliases.add("kick");

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
public class FCommandLeave extends FBaseCommand {
public class FCommandLeave extends FCommand {
public FCommandLeave() {
aliases.add("leave");

View File

@@ -11,7 +11,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.util.TextUtil;
public class FCommandList extends FBaseCommand {
public class FCommandList extends FCommand {
public FCommandList() {
aliases.add("list");

View File

@@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.P;
public class FCommandLock extends FBaseCommand {
public class FCommandLock extends FCommand {
public FCommandLock() {
aliases.add("lock");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
public class FCommandMap extends FBaseCommand {
public class FCommandMap extends FCommand {
public FCommandMap() {
aliases.add("map");

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandMod extends FBaseCommand {
public class FCommandMod extends FCommand {
public FCommandMod() {
aliases.add("mod");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
public class FCommandNoBoom extends FBaseCommand {
public class FCommandNoBoom extends FCommand {
public FCommandNoBoom() {
aliases.add("noboom");

View File

@@ -4,7 +4,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandOpen extends FBaseCommand {
public class FCommandOpen extends FCommand {
public FCommandOpen() {
aliases.add("open");

View File

@@ -9,7 +9,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Role;
public class FCommandOwner extends FBaseCommand {
public class FCommandOwner extends FCommand {
public FCommandOwner() {
aliases.add("owner");
@@ -21,7 +21,7 @@ public class FCommandOwner extends FBaseCommand {
@Override
public void perform() {
boolean hasBypass = P.hasPermAdminBypass(player);
boolean hasBypass = P.hasPermAdminBypass(me);
if ( ! hasBypass && ! assertHasFaction()) {
return;

View File

@@ -10,7 +10,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandOwnerList extends FBaseCommand {
public class FCommandOwnerList extends FCommand {
public FCommandOwnerList() {
aliases.add("ownerlist");
@@ -20,7 +20,7 @@ public class FCommandOwnerList extends FBaseCommand {
@Override
public void perform() {
boolean hasBypass = P.hasPermAdminBypass(player);
boolean hasBypass = P.hasPermAdminBypass(me);
if ( ! hasBypass && ! assertHasFaction()) {
return;

View File

@@ -8,9 +8,11 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Role;
public class FCommandPay extends FBaseCommand {
public class FCommandPay extends FCommand
{
public FCommandPay() {
public FCommandPay()
{
aliases.add("pay");
helpDescription = "Pay another faction from your bank";
@@ -63,7 +65,7 @@ public class FCommandPay extends FBaseCommand {
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(player.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
P.log(me.getName() + " paid "+amountString+" from "+us.getTag()+"'s bank to "+them.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == us || fplayer.getFaction() == them) {

View File

@@ -8,7 +8,7 @@ import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
public class FCommandPeaceful extends FBaseCommand {
public class FCommandPeaceful extends FCommand {
public FCommandPeaceful() {
aliases.add("peaceful");

View File

@@ -8,7 +8,7 @@ import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
public class FCommandPermanent extends FBaseCommand {
public class FCommandPermanent extends FCommand {
public FCommandPermanent() {
aliases.add("permanent");

View File

@@ -8,7 +8,7 @@ import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
public class FCommandPower extends FBaseCommand {
public class FCommandPower extends FCommand {
public FCommandPower() {
aliases.add("power");
@@ -30,7 +30,7 @@ public class FCommandPower extends FBaseCommand {
public void perform() {
FPlayer target;
if (parameters.size() > 0) {
if (!P.hasPermViewAnyPower(player)) {
if (!P.hasPermViewAnyPower(me)) {
me.sendMessage("You do not have the appropriate permission to view another player's power level.");
return;
}

View File

@@ -8,7 +8,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandReload extends FBaseCommand {
public class FCommandReload extends FCommand {
public FCommandReload() {
aliases.add("reload");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandSafeclaim extends FBaseCommand {
public class FCommandSafeclaim extends FCommand {
public FCommandSafeclaim() {
aliases.add("safeclaim");

View File

@@ -6,7 +6,7 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandSafeunclaimall extends FBaseCommand {
public class FCommandSafeunclaimall extends FCommand {
public FCommandSafeunclaimall() {
aliases.add("safeunclaimall");

View File

@@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.P;
public class FCommandSaveAll extends FBaseCommand {
public class FCommandSaveAll extends FCommand {
public FCommandSaveAll() {
aliases.add("saveall");

View File

@@ -5,7 +5,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
public class FCommandSethome extends FBaseCommand {
public class FCommandSethome extends FCommand {
public FCommandSethome() {
aliases.add("sethome");
@@ -38,7 +38,7 @@ public class FCommandSethome extends FBaseCommand {
Faction myFaction = me.getFaction();
if (parameters.size() > 0) {
if (!P.hasPermAdminBypass(player)) {
if (!P.hasPermAdminBypass(me)) {
me.sendMessage("You cannot set the home of another faction without adminBypass permission.");
return;
}
@@ -51,7 +51,7 @@ public class FCommandSethome extends FBaseCommand {
}
}
if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory() && !P.hasPermAdminBypass(player)) {
if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory() && !P.hasPermAdminBypass(me)) {
me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
return;
}
@@ -61,7 +61,7 @@ public class FCommandSethome extends FBaseCommand {
return;
}
myFaction.setHome(player.getLocation());
myFaction.setHome(me.getLocation());
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
myFaction.sendMessage(new FCommandHome().getUseageTemplate());

View File

@@ -13,7 +13,7 @@ import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.TextUtil;
public class FCommandShow extends FBaseCommand {
public class FCommandShow extends FCommand {
public FCommandShow() {
aliases.add("show");

View File

@@ -9,7 +9,7 @@ import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.TextUtil;
public class FCommandTag extends FBaseCommand {
public class FCommandTag extends FCommand {
public FCommandTag() {
aliases.add("tag");

View File

@@ -6,7 +6,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.util.TextUtil;
public class FCommandTitle extends FBaseCommand {
public class FCommandTitle extends FCommand {
public FCommandTitle() {
aliases.add("title");
@@ -54,7 +54,7 @@ public class FCommandTitle extends FBaseCommand {
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction));
if (Conf.spoutFactionTitlesOverNames) {
SpoutFeatures.updateAppearances(player);
SpoutFeatures.updateAppearances(me);
}
}

View File

@@ -8,7 +8,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Role;
public class FCommandUnclaim extends FBaseCommand {
public class FCommandUnclaim extends FCommand {
public FCommandUnclaim() {
aliases.add("unclaim");
@@ -47,7 +47,7 @@ public class FCommandUnclaim extends FBaseCommand {
return;
}
if (Conf.adminBypassPlayers.contains(player.getName())) {
if (Conf.adminBypassPlayers.contains(me.getName())) {
Board.removeAt(flocation);
otherFaction.sendMessage(me.getNameAndRelevant(otherFaction)+Conf.colorSystem+" unclaimed some of your land.");
@@ -81,7 +81,7 @@ public class FCommandUnclaim extends FBaseCommand {
faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+".";
} else {
Econ.addMoney(player.getName(), refund);
Econ.addMoney(me.getName(), refund);
moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
}
}
@@ -95,7 +95,7 @@ public class FCommandUnclaim extends FBaseCommand {
}
moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+".";
} else {
if (!Econ.deductMoney(player.getName(), -refund)) {
if (!Econ.deductMoney(me.getName(), -refund)) {
sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
return;
}

View File

@@ -6,7 +6,7 @@ import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Role;
public class FCommandUnclaimall extends FBaseCommand {
public class FCommandUnclaimall extends FCommand {
public FCommandUnclaimall() {
aliases.add("unclaimall");
@@ -42,7 +42,7 @@ public class FCommandUnclaimall extends FBaseCommand {
faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+".";
} else {
Econ.addMoney(player.getName(), refund);
Econ.addMoney(me.getName(), refund);
moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
}
}
@@ -56,7 +56,7 @@ public class FCommandUnclaimall extends FBaseCommand {
}
moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+".";
} else {
if (!Econ.deductMoney(player.getName(), -refund)) {
if (!Econ.deductMoney(me.getName(), -refund)) {
sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
return;
}

View File

@@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.P;
public class FCommandVersion extends FBaseCommand {
public class FCommandVersion extends FCommand {
public FCommandVersion() {
aliases.add("version");

View File

@@ -7,7 +7,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandWarclaim extends FBaseCommand {
public class FCommandWarclaim extends FCommand {
public FCommandWarclaim() {
aliases.add("warclaim");

View File

@@ -6,7 +6,7 @@ import com.massivecraft.factions.Board;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
public class FCommandWarunclaimall extends FBaseCommand {
public class FCommandWarunclaimall extends FCommand {
public FCommandWarunclaimall() {
aliases.add("warunclaimall");

View File

@@ -8,7 +8,7 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Role;
public class FCommandWithdraw extends FBaseCommand {
public class FCommandWithdraw extends FCommand {
public FCommandWithdraw() {
aliases.add("withdraw");
@@ -55,7 +55,7 @@ public class FCommandWithdraw extends FBaseCommand {
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(player.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank.");
P.log(me.getName() + " withdrew "+amountString+" from "+faction.getTag()+"'s bank.");
for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) {

View File

@@ -10,7 +10,7 @@ import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
public class FRelationCommand extends FBaseCommand {
public class FRelationCommand extends FCommand {
public FRelationCommand() {
requiredParameters.add("faction tag");