Even more command fixes.

This commit is contained in:
Olof Larsson 2013-04-16 11:05:49 +02:00
parent a84582ba21
commit e874ea60df
31 changed files with 216 additions and 158 deletions

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.cmd.arg.ARFaction;
public abstract class CmdFactionsCapeAbstract extends FCommand
{
@ -20,9 +21,6 @@ public abstract class CmdFactionsCapeAbstract extends FCommand
@Override
public boolean validCall(CommandSender sender, List<String> args)
{
if ( ! super.validCall(sender, args)) return false;
this.capeFaction = null;
this.currentCape = null;
@ -32,7 +30,7 @@ public abstract class CmdFactionsCapeAbstract extends FCommand
return false;
}
this.capeFaction = this.argAsFaction(this.requiredArgs.size(), this.myFaction);
this.capeFaction = this.arg(this.requiredArgs.size(), ARFaction.get(), this.myFaction);
if (this.capeFaction == null) return false;
// Do we have permission to manage the cape of that faction?

View File

@ -15,6 +15,7 @@ public class CmdFactionsCapeSet extends CmdFactionsCapeAbstract
this.addAliases("set");
this.addRequiredArg("url");
this.setErrorOnToManyArgs(false);
this.addRequirements(ReqHasPerm.get(Perm.CAPE_SET.node));
}
@ -22,7 +23,7 @@ public class CmdFactionsCapeSet extends CmdFactionsCapeAbstract
@Override
public void perform()
{
String newCape = this.argAsString(0);
String newCape = this.argConcatFrom(0);
if (isUrlValid(newCape))
{

View File

@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.util.SpiralTask;
import com.massivecraft.mcore.cmd.arg.ARInteger;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
import com.massivecraft.mcore.ps.PS;
@ -26,9 +28,12 @@ public class CmdFactionsClaim extends FCommand
@Override
public void perform()
{
// Read and validate input
final Faction forFaction = this.argAsFaction(0, myFaction);
int radius = this.argAsInt(1, 1);
Faction forFaction = this.arg(0, ARFaction.get());
if (forFaction == null) return;
Integer radius = this.arg(1, ARInteger.get(), 1);
if (radius == null) return;
if (radius < 1)
{
@ -40,9 +45,9 @@ public class CmdFactionsClaim extends FCommand
{
// single chunk
fme.attemptClaim(forFaction, me.getLocation(), true);
return;
}
else
{
// radius claim
if (! Perm.CLAIM_RADIUS.has(sender, false))
{
@ -50,6 +55,7 @@ public class CmdFactionsClaim extends FCommand
return;
}
// TODO: I do not beleive in the spiral-task. Get rid of this. The failcount can be precalculated.
new SpiralTask(PS.valueOf(me), radius)
{
private int failCount = 0;
@ -70,6 +76,6 @@ public class CmdFactionsClaim extends FCommand
return true;
}
};
}
}
}

View File

@ -31,7 +31,7 @@ public class CmdFactionsCreate extends FCommand
@Override
public void perform()
{
String tag = this.argAsString(0);
String tag = this.arg(0);
if (fme.hasFaction())
{

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsDeinvite extends FCommand
@ -15,6 +16,7 @@ public class CmdFactionsDeinvite extends FCommand
this.addRequirements(ReqHasPerm.get(Perm.DEINVITE.node));
// TODO: Base on faction permissions instead?
senderMustBeMember = false;
senderMustBeOfficer = true;
senderMustBeLeader = false;
@ -23,7 +25,7 @@ public class CmdFactionsDeinvite extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
if (you.getFaction() == myFaction)

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsDemote extends FCommand
@ -24,7 +25,7 @@ public class CmdFactionsDemote extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
if (you.getFaction() != myFaction)

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import org.bukkit.Bukkit;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FactionDisbandEvent;
import com.massivecraft.factions.integration.Econ;
@ -30,8 +31,7 @@ public class CmdFactionsDisband extends FCommand
@Override
public void perform()
{
// The faction, default to your own.. but null if console sender.
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
if ( ! FPerm.DISBAND.has(sender, faction, true)) return;

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -23,11 +24,7 @@ public class CmdFactionsFlag extends FCommand
@Override
public void perform()
{
Faction faction = myFaction;
if (this.argIsSet(0))
{
faction = this.argAsFaction(0);
}
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
if ( ! this.argIsSet(1))

View File

@ -3,7 +3,10 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
@ -24,7 +27,7 @@ public class CmdFactionsInvite extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
if (you.getFaction() == myFaction)

View File

@ -8,6 +8,8 @@ import com.massivecraft.factions.FPlayerColl;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -26,10 +28,12 @@ public class CmdFactionsJoin extends FCommand
@Override
public void perform()
{
Faction faction = this.argAsFaction(0);
Faction faction = this.arg(0, ARFaction.get());
if (faction == null) return;
FPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);
FPlayer fplayer = this.arg(1, ARFPlayer.getStartAny(), fme);
if (fplayer == null) return;
boolean samePlayer = fplayer == fme;
if (!samePlayer && ! Perm.JOIN_OTHERS.has(sender, false))

View File

@ -9,6 +9,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -27,7 +28,7 @@ public class CmdFactionsKick extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(1, ARFPlayer.getStartAny());
if (you == null) return;
if (fme == you)

View File

@ -7,6 +7,8 @@ import com.massivecraft.factions.FPlayerColl;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FPlayerJoinEvent;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -27,10 +29,10 @@ public class CmdFactionsLeader extends FCommand
@Override
public void perform()
{
FPlayer newLeader = this.argAsBestFPlayerMatch(0);
FPlayer newLeader = this.arg(0, ARFPlayer.getStartAny());
if (newLeader == null) return;
Faction targetFaction = this.argAsFaction(1, myFaction);
Faction targetFaction = this.arg(1, ARFaction.get(), myFaction);
if (targetFaction == null) return;
FPlayer targetFactionCurrentLeader = targetFaction.getFPlayerLeader();

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
@ -21,13 +22,9 @@ public class CmdFactionsMoneyBalance extends FCommand
@Override
public void perform()
{
Faction faction = myFaction;
if (this.argIsSet(0))
{
faction = this.argAsFaction(0);
}
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
if (faction != myFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;
Econ.sendBalanceInfo(fme, faction);

View File

@ -1,10 +1,13 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.arg.ARDouble;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -29,9 +32,13 @@ public class CmdFactionsMoneyDeposit extends FCommand
@Override
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator faction = this.argAsFaction(1, myFaction);
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction faction = this.arg(1, ARFaction.get(), myFaction);
if (faction == null) return;
boolean success = Econ.transferMoney(fme, fme, faction, amount);
if (success && ConfServer.logMoneyTransactions)

View File

@ -1,10 +1,13 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.arg.ARDouble;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -29,10 +32,13 @@ public class CmdFactionsMoneyTransferFf extends FCommand
@Override
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1);
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get());
if (from == null) return;
EconomyParticipator to = this.argAsFaction(2);
Faction to = this.arg(2, ARFaction.get());
if (to == null) return;
boolean success = Econ.transferMoney(fme, from, to, amount);

View File

@ -1,10 +1,15 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.arg.ARDouble;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -29,10 +34,13 @@ public class CmdFactionsMoneyTransferFp extends FCommand
@Override
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsFaction(1);
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get());
if (from == null) return;
EconomyParticipator to = this.argAsBestFPlayerMatch(2);
FPlayer to = this.arg(2, ARFPlayer.getStartAny());
if (to == null) return;
boolean success = Econ.transferMoney(fme, from, to, amount);

View File

@ -1,10 +1,15 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.arg.ARDouble;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -29,10 +34,13 @@ public class CmdFactionsMoneyTransferPf extends FCommand
@Override
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator from = this.argAsBestFPlayerMatch(1);
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
FPlayer from = this.arg(1, ARFPlayer.getStartAny());
if (from == null) return;
EconomyParticipator to = this.argAsFaction(2);
Faction to = this.arg(2, ARFaction.get());
if (to == null) return;
boolean success = Econ.transferMoney(fme, from, to, amount);

View File

@ -1,10 +1,13 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.arg.ARDouble;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -28,9 +31,12 @@ public class CmdFactionsMoneyWithdraw extends FCommand
@Override
public void perform()
{
double amount = this.argAsDouble(0, 0d);
EconomyParticipator faction = this.argAsFaction(1, myFaction);
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction faction = this.arg(1, ARFaction.get(), myFaction);
if (faction == null) return;
boolean success = Econ.transferMoney(fme, faction, fme, amount);
if (success && ConfServer.logMoneyTransactions)

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsOfficer extends FCommand
@ -21,7 +22,7 @@ public class CmdFactionsOfficer extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
boolean permAny = Perm.OFFICER_ANY.has(sender, false);

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionColl;
import com.massivecraft.factions.Perm;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsOpen extends FCommand
@ -22,22 +23,25 @@ public class CmdFactionsOpen extends FCommand
@Override
public void perform()
{
Boolean target = this.arg(0, ARBoolean.get(), !myFaction.isOpen());
if (target == null) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(ConfServer.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return;
myFaction.setOpen(this.argAsBool(0, ! myFaction.isOpen()));
myFaction.setOpen(target);
String open = myFaction.isOpen() ? "open" : "closed";
String descTarget = myFaction.isOpen() ? "open" : "closed";
// Inform
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), open);
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), descTarget);
for (Faction faction : FactionColl.get().getAll())
{
if (faction == myFaction)
{
continue;
}
faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), open);
faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), descTarget);
}
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -13,7 +14,7 @@ public class CmdFactionsPerm extends FCommand
{
this.addAliases("perm");
this.addOptionalArg("faction", "your");
this.addOptionalArg("faction", "you");
this.addOptionalArg("perm", "all");
this.addOptionalArg("relation", "read");
this.addOptionalArg("yes/no", "read");
@ -25,11 +26,7 @@ public class CmdFactionsPerm extends FCommand
@Override
public void perform()
{
Faction faction = myFaction;
if (this.argIsSet(0))
{
faction = this.argAsFaction(0);
}
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
if ( ! this.argIsSet(1))

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsPower extends FCommand
@ -20,7 +21,7 @@ public class CmdFactionsPower extends FCommand
@Override
public void perform()
{
FPlayer target = this.argAsBestFPlayerMatch(0, fme);
FPlayer target = this.arg(0, ARFPlayer.getStartAny(), fme);
if (target == null) return;
if (target != fme && ! Perm.POWER_ANY.has(sender, true)) return;

View File

@ -22,7 +22,7 @@ public class CmdFactionsPowerBoost extends FCommand
@Override
public void perform()
{
String type = this.argAsString(0).toLowerCase();
String type = this.arg(0).toLowerCase();
boolean doPlayer = true;
if (type.equals("f") || type.equals("faction"))
{

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsPromote extends FCommand
@ -24,7 +25,7 @@ public class CmdFactionsPromote extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
if (you.getFaction() != myFaction)

View File

@ -7,6 +7,7 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.event.FactionRelationEvent;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -28,7 +29,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
@Override
public void perform()
{
Faction them = this.argAsFaction(0);
Faction them = this.arg(0, ARFaction.get());
if (them == null) return;
/*if ( ! them.isNormal())

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
import com.massivecraft.mcore.ps.PS;
@ -30,7 +31,7 @@ public class CmdFactionsSethome extends FCommand
return;
}
Faction faction = this.argAsFaction(0, myFaction);
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
// Can the player set the home for this faction?

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPlayer;
@ -30,12 +31,8 @@ public class CmdFactionsShow extends FCommand
@Override
public void perform()
{
Faction faction = myFaction;
if (this.argIsSet(0))
{
faction = this.argAsFaction(0);
Faction faction = this.arg(0, ARFaction.get(), myFaction);
if (faction == null) return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(ConfServer.econCostShow, "to show faction information", "for showing faction information")) return;

View File

@ -30,7 +30,7 @@ public class CmdFactionsTag extends FCommand
@Override
public void perform()
{
String tag = this.argAsString(0);
String tag = this.arg(0);
// TODO does not first test cover selfcase?
if (FactionColl.get().isTagTaken(tag) && ! MiscUtil.getComparisonString(tag).equals(myFaction.getComparisonTag()))

View File

@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.mcore.cmd.arg.ARString;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.Txt;
@ -24,11 +26,11 @@ public class CmdFactionsTitle extends FCommand
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
FPlayer you = this.arg(0, ARFPlayer.getStartAny());
if (you == null) return;
args.remove(0);
String title = Txt.implode(args, " ");
String title = this.argConcatFrom(1, ARString.get(), "");
if (title == null) return;
if ( ! canIAdministerYou(fme, you)) return;

View File

@ -1,9 +1,13 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayerColl;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.util.Txt;
public abstract class FCommand extends MCommand
{
@ -16,4 +20,66 @@ public abstract class FCommand extends MCommand
this.fme = FPlayerColl.get().get(this.sender);
this.myFaction = this.fme.getFaction();
}
// -------------------------------------------- //
// COMMONLY USED LOGIC
// -------------------------------------------- //
public boolean canIAdministerYou(FPlayer i, FPlayer you)
{
if ( ! i.getFaction().equals(you.getFaction()))
{
i.sendMessage(Txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
return false;
}
if (i.getRole().isMoreThan(you.getRole()) || i.getRole().equals(Rel.LEADER) )
{
return true;
}
if (you.getRole().equals(Rel.LEADER))
{
i.sendMessage(Txt.parse("<b>Only the faction admin can do that."));
}
else if (i.getRole().equals(Rel.OFFICER))
{
if ( i == you )
{
return true; //Moderators can control themselves
}
else
{
i.sendMessage(Txt.parse("<b>Moderators can't control each other..."));
}
}
else
{
i.sendMessage(Txt.parse("<b>You must be a faction moderator to do that."));
}
return false;
}
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost, String toDoThis, String forDoingThis)
{
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.hasAdminMode()) return true;
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fme.hasFaction())
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
else
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
}
// like above, but just make sure they can pay; returns true unless person can't afford the cost
public boolean canAffordCommand(double cost, String toDoThis)
{
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.hasAdminMode()) return true;
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fme.hasFaction())
return Econ.hasAtLeast(myFaction, cost, toDoThis);
else
return Econ.hasAtLeast(fme, cost, toDoThis);
}
}

View File

@ -379,65 +379,5 @@ public abstract class FCommandOld extends MCommand<Factions>
return this.argAsRel(idx, null);
}
// -------------------------------------------- //
// Commonly used logic
// -------------------------------------------- //
public boolean canIAdministerYou(FPlayer i, FPlayer you)
{
if ( ! i.getFaction().equals(you.getFaction()))
{
i.sendMessage(Txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
return false;
}
if (i.getRole().isMoreThan(you.getRole()) || i.getRole().equals(Rel.LEADER) )
{
return true;
}
if (you.getRole().equals(Rel.LEADER))
{
i.sendMessage(Txt.parse("<b>Only the faction admin can do that."));
}
else if (i.getRole().equals(Rel.OFFICER))
{
if ( i == you )
{
return true; //Moderators can control themselves
}
else
{
i.sendMessage(Txt.parse("<b>Moderators can't control each other..."));
}
}
else
{
i.sendMessage(Txt.parse("<b>You must be a faction moderator to do that."));
}
return false;
}
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
public boolean payForCommand(double cost, String toDoThis, String forDoingThis)
{
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.hasAdminMode()) return true;
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fme.hasFaction())
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
else
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
}
// like above, but just make sure they can pay; returns true unless person can't afford the cost
public boolean canAffordCommand(double cost, String toDoThis)
{
if ( ! Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.hasAdminMode()) return true;
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fme.hasFaction())
return Econ.hasAtLeast(myFaction, cost, toDoThis);
else
return Econ.hasAtLeast(fme, cost, toDoThis);
}
}