MassiveCore Change

This commit is contained in:
Magnus Ulf 2015-05-06 17:04:35 +02:00 committed by Olof Larsson
parent fef69f347e
commit 22cb629107
51 changed files with 239 additions and 232 deletions

View File

@ -21,8 +21,8 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
this.addAliases("f", "faction"); this.addAliases("f", "faction");
// Args // Args
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
this.addOptionalArg("yes/no", "toggle"); this.addArg(ARBoolean.get(), "yes/no", "toggle");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node)); this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node));
@ -36,8 +36,8 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
public void innerPerform() throws MassiveException public void innerPerform() throws MassiveException
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get()); Faction faction = this.readArg();
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId())); boolean newValue = this.readArg(!ta.isFactionIdGranted(faction.getId()));
// MPerm // MPerm
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return; if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;

View File

@ -21,8 +21,8 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
this.addAliases("p", "player"); this.addAliases("p", "player");
// Args // Args
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
this.addOptionalArg("yes/no", "toggle"); this.addArg(ARBoolean.get(), "yes/no", "toggle");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node)); this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node));
@ -36,8 +36,8 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
public void innerPerform() throws MassiveException public void innerPerform() throws MassiveException
{ {
// Args // Args
MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); MPlayer mplayer = this.readArg();
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(mplayer.getId())); boolean newValue = this.readArg(!ta.isPlayerIdGranted(mplayer.getId()));
// MPerm // MPerm
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return; if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;

View File

@ -20,7 +20,7 @@ public class CmdFactionsAdmin extends FactionsCommand
this.addAliases("admin"); this.addAliases("admin");
// Args // Args
this.addOptionalArg("on/off", "flip"); this.addArg(ARBoolean.get(), "on/off", "flip");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node)); this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node));
@ -34,7 +34,7 @@ public class CmdFactionsAdmin extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode()); boolean target = this.readArg(!msender.isUsingAdminMode());
// Apply // Apply
msender.setUsingAdminMode(target); msender.setUsingAdminMode(target);

View File

@ -12,6 +12,8 @@ import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsCreate; import com.massivecraft.factions.event.EventFactionsCreate;
import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.store.MStore;
@ -27,7 +29,7 @@ public class CmdFactionsCreate extends FactionsCommand
this.addAliases("create"); this.addAliases("create");
// Args // Args
this.addRequiredArg("name"); this.addArg(ARString.get(), "name");
// Requirements // Requirements
this.addRequirements(ReqHasntFaction.get()); this.addRequirements(ReqHasntFaction.get());
@ -39,10 +41,10 @@ public class CmdFactionsCreate extends FactionsCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveException
{ {
// Args // Args
String newName = this.arg(0); String newName = this.readArg();
// Verify // Verify
if (FactionColl.get().isNameTaken(newName)) if (FactionColl.get().isNameTaken(newName))

View File

@ -5,6 +5,8 @@ import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsDescriptionChange; import com.massivecraft.factions.event.EventFactionsDescriptionChange;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
@ -20,8 +22,7 @@ public class CmdFactionsDescription extends FactionsCommand
this.addAliases("desc"); this.addAliases("desc");
// Args // Args
this.addRequiredArg("desc"); this.addArg(ARString.get(), "desc", true);
this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node)); this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
@ -33,10 +34,10 @@ public class CmdFactionsDescription extends FactionsCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveException
{ {
// Args // Args
String newDescription = this.argConcatFrom(0); String newDescription = this.readArg();
// MPerm // MPerm
if ( ! MPerm.getPermDesc().has(msender, msenderFaction, true)) return; if ( ! MPerm.getPermDesc().has(msender, msenderFaction, true)) return;

View File

@ -29,7 +29,7 @@ public class CmdFactionsDisband extends FactionsCommand
this.addAliases("disband"); this.addAliases("disband");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node)); this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node));
@ -43,7 +43,7 @@ public class CmdFactionsDisband extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
// MPerm // MPerm
if ( ! MPerm.getPermDisband().has(msender, faction, true)) return; if ( ! MPerm.getPermDisband().has(msender, faction, true)) return;

View File

@ -28,7 +28,7 @@ public class CmdFactionsFaction extends FactionsCommand
this.addAliases("f", "faction"); this.addAliases("f", "faction");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.FACTION.node)); this.addRequirements(ReqHasPerm.get(Perm.FACTION.node));
@ -42,7 +42,7 @@ public class CmdFactionsFaction extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
final Faction faction = this.arg(0, ARFaction.get(), msenderFaction); final Faction faction = this.readArg(msenderFaction);
final CommandSender sender = this.sender; final CommandSender sender = this.sender;

View File

@ -22,7 +22,7 @@ public class CmdFactionsFlagList extends FactionsCommand
this.addAliases("l", "list"); this.addAliases("l", "list");
// Args // Args
this.addOptionalArg("page", "1"); this.addArg(ARInteger.get(), "page", "1");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.FLAG_LIST.node)); this.addRequirements(ReqHasPerm.get(Perm.FLAG_LIST.node));
@ -36,7 +36,7 @@ public class CmdFactionsFlagList extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); int pageHumanBased = this.readArg(1);
//Create messages //Create messages
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<String>();

View File

@ -23,9 +23,9 @@ public class CmdFactionsFlagSet extends FactionsCommand
this.addAliases("set"); this.addAliases("set");
// Args // Args
this.addRequiredArg("flag"); this.addArg(ARMFlag.get(), "flag");
this.addRequiredArg("yes/no"); this.addArg(ARBoolean.get(), "yes/no");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.FLAG_SET.node)); this.addRequirements(ReqHasPerm.get(Perm.FLAG_SET.node));
@ -39,9 +39,9 @@ public class CmdFactionsFlagSet extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
MFlag flag = this.arg(0, ARMFlag.get()); MFlag flag = this.readArg();
Boolean value = this.arg(1, ARBoolean.get()); boolean value = this.readArg();
Faction faction = this.arg(2, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
// Do the sender have the right to change flags for this faction? // Do the sender have the right to change flags for this faction?
if ( ! MPerm.getPermFlags().has(msender, faction, true)) return; if ( ! MPerm.getPermFlags().has(msender, faction, true)) return;

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
@ -9,7 +10,8 @@ import com.massivecraft.factions.cmd.arg.ARMFlag;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARList; import com.massivecraft.massivecore.cmd.arg.ARAll;
import com.massivecraft.massivecore.cmd.arg.ARSet;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -25,9 +27,8 @@ public class CmdFactionsFlagShow extends FactionsCommand
this.addAliases("s", "show"); this.addAliases("s", "show");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
this.addOptionalArg("flags", "all"); this.addArg(ARAll.get(ARSet.get(ARMFlag.get(), false)), "flags", "all", true);
this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.FLAG_SHOW.node)); this.addRequirements(ReqHasPerm.get(Perm.FLAG_SHOW.node));
@ -41,30 +42,13 @@ public class CmdFactionsFlagShow extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Arg: Faction // Arg: Faction
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
Collection<MFlag> mflags = this.readArg(MFlag.getAll());
List<MFlag> flags = new ArrayList<MFlag>();
// Case: Show All
if ( ! this.argIsSet(1) || "all".equalsIgnoreCase(this.arg(1)))
{
for (MFlag mflag : MFlag.getAll())
{
if (!mflag.isVisible() && ! msender.isUsingAdminMode()) continue;
flags.add(mflag);
}
}
else
{
// Arg: MFlag. Maybe we should use ARSet but that is currently buggy.
List<MFlag> mflags = this.arg(this.argConcatFrom(1), ARList.get(ARMFlag.get()));
flags.addAll(mflags);
}
// Create messages // Create messages
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<String>();
messages.add(Txt.titleize("Flag for " + faction.describeTo(msender, true))); messages.add(Txt.titleize("Flag for " + faction.describeTo(msender, true)));
for (MFlag mflag : flags) for (MFlag mflag : mflags)
{ {
messages.add(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true)); messages.add(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, true));
} }

View File

@ -37,7 +37,7 @@ public class CmdFactionsHome extends FactionsCommandHome
this.addAliases("home"); this.addAliases("home");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
@ -58,7 +58,7 @@ public class CmdFactionsHome extends FactionsCommandHome
} }
// Args // Args
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
PS home = faction.getHome(); PS home = faction.getHome();
String homeDesc = "home for " + faction.describeTo(msender, false); String homeDesc = "home for " + faction.describeTo(msender, false);

View File

@ -1,6 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import java.util.Set; import java.util.Collection;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
@ -23,8 +23,7 @@ public class CmdFactionsInviteAdd extends FactionsCommand
this.addAliases("a", "add"); this.addAliases("a", "add");
// Args // Args
this.addRequiredArg("players"); this.addArg(ARSet.get(ARMPlayer.getAny(), true), "players", true);
this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.INVITE_ADD.node)); this.addRequirements(ReqHasPerm.get(Perm.INVITE_ADD.node));
@ -38,7 +37,7 @@ public class CmdFactionsInviteAdd extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Set<MPlayer> mplayers = this.argConcatFrom(0, ARSet.get(ARMPlayer.getAny(), true)); Collection<MPlayer> mplayers = this.readArg();
// MPerm // MPerm
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return; if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;

View File

@ -27,8 +27,8 @@ public class CmdFactionsInviteList extends FactionsCommand
this.addAliases("l", "list"); this.addAliases("l", "list");
// Args // Args
this.addOptionalArg("page", "1"); this.addArg(ARInteger.get(), "page", "1");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.INVITE_LIST.node)); this.addRequirements(ReqHasPerm.get(Perm.INVITE_LIST.node));
@ -42,9 +42,9 @@ public class CmdFactionsInviteList extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); int pageHumanBased = this.readArg(1);
Faction faction = this.arg(1, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
if ( faction != msenderFaction && ! Perm.INVITE_LIST_OTHER.has(sender, true)) return; if ( faction != msenderFaction && ! Perm.INVITE_LIST_OTHER.has(sender, true)) return;

View File

@ -12,7 +12,6 @@ import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsInvitedChange; import com.massivecraft.factions.event.EventFactionsInvitedChange;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARSet; import com.massivecraft.massivecore.cmd.arg.ARSet;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsInviteRemove extends FactionsCommand public class CmdFactionsInviteRemove extends FactionsCommand
@ -26,8 +25,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand
this.addAliases("r", "remove"); this.addAliases("r", "remove");
// Args // Args
this.addRequiredArg("players/all"); this.addArg(ARSet.get(ARMPlayer.getAny(), true), "players/all", true);
this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.INVITE_REMOVE.node)); this.addRequirements(ReqHasPerm.get(Perm.INVITE_REMOVE.node));
@ -44,7 +42,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand
boolean all = false; boolean all = false;
// Args // Args
if (this.arg(0, ARString.get()).equalsIgnoreCase("all")) if ("all".equalsIgnoreCase(this.argAt(0)))
{ {
List<MPlayer> invitedPlayers = msenderFaction.getInvitedMPlayers(); List<MPlayer> invitedPlayers = msenderFaction.getInvitedMPlayers();
// Doesn't show up if list is empty. Test at home if it worked. // Doesn't show up if list is empty. Test at home if it worked.
@ -58,9 +56,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand
} }
else else
{ {
Set<MPlayer> senderInput = this.argConcatFrom(0, ARSet.get(ARMPlayer.getAny(), true)); mplayers = this.readArgAt(0);
mplayers.addAll(senderInput);
} }
// MPerm // MPerm

View File

@ -26,8 +26,8 @@ public class CmdFactionsJoin extends FactionsCommand
this.addAliases("join"); this.addAliases("join");
// Args // Args
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
this.addOptionalArg("player", "you"); this.addArg(ARMPlayer.getAny(), "player", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.JOIN.node)); this.addRequirements(ReqHasPerm.get(Perm.JOIN.node));
@ -41,9 +41,9 @@ public class CmdFactionsJoin extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get()); Faction faction = this.readArg();
MPlayer mplayer = this.arg(1, ARMPlayer.getAny(), msender); MPlayer mplayer = this.readArg(msender);
Faction mplayerFaction = mplayer.getFaction(); Faction mplayerFaction = mplayer.getFaction();
boolean samePlayer = mplayer == msender; boolean samePlayer = mplayer == msender;

View File

@ -27,7 +27,7 @@ public class CmdFactionsKick extends FactionsCommand
this.addAliases("kick"); this.addAliases("kick");
// Args // Args
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.KICK.node)); this.addRequirements(ReqHasPerm.get(Perm.KICK.node));
@ -41,7 +41,7 @@ public class CmdFactionsKick extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Arg // Arg
MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); MPlayer mplayer = this.readArg();
// Validate // Validate
if (msender == mplayer) if (msender == mplayer)

View File

@ -30,7 +30,7 @@ public class CmdFactionsList extends FactionsCommand
this.addAliases("l", "list"); this.addAliases("l", "list");
// Args // Args
this.addOptionalArg("page", "1"); this.addArg(ARInteger.get(), "page", "1");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.LIST.node)); this.addRequirements(ReqHasPerm.get(Perm.LIST.node));
@ -44,7 +44,7 @@ public class CmdFactionsList extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
final Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); final int pageHumanBased = this.readArg(1);
// NOTE: The faction list is quite slow and mostly thread safe. // NOTE: The faction list is quite slow and mostly thread safe.
// We run it asynchronously to spare the primary server thread. // We run it asynchronously to spare the primary server thread.

View File

@ -25,7 +25,7 @@ public class CmdFactionsMap extends FactionsCommand
this.addAliases("map"); this.addAliases("map");
// Args // Args
this.addOptionalArg("on/off", "once"); this.addArg(ARBoolean.get(), "on/off", "once");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MAP.node)); this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
@ -39,13 +39,13 @@ public class CmdFactionsMap extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
if ( ! this.argIsSet(0)) if ( ! this.argIsSet())
{ {
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL); showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL);
return; return;
} }
if (this.arg(0, ARBoolean.get(), !msender.isMapAutoUpdating())) if (this.readArg(!msender.isMapAutoUpdating()))
{ {
// And show the map once // And show the map once
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT); showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT);

View File

@ -20,7 +20,7 @@ public class CmdFactionsMoneyBalance extends FactionsCommand
this.addAliases("b", "balance"); this.addAliases("b", "balance");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
@ -34,7 +34,7 @@ public class CmdFactionsMoneyBalance extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return; if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;

View File

@ -27,8 +27,8 @@ public class CmdFactionsMoneyDeposit extends FactionsCommand
this.addAliases("d", "deposit"); this.addAliases("d", "deposit");
// Args // Args
this.addRequiredArg("amount"); this.addArg(ARDouble.get(), "amount");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
@ -42,9 +42,9 @@ public class CmdFactionsMoneyDeposit extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Double amount = this.arg(0, ARDouble.get()); double amount = this.readArg();
Faction faction = this.arg(1, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
boolean success = Econ.transferMoney(msender, msender, faction, amount); boolean success = Econ.transferMoney(msender, msender, faction, amount);

View File

@ -28,9 +28,9 @@ public class CmdFactionsMoneyTransferFf extends FactionsCommand
this.addAliases("ff"); this.addAliases("ff");
// Args // Args
this.addRequiredArg("amount"); this.addArg(ARDouble.get(), "amount");
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
@ -44,9 +44,9 @@ public class CmdFactionsMoneyTransferFf extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Double amount = this.arg(0, ARDouble.get()); double amount = this.readArg();
Faction from = this.arg(1, ARFaction.get()); Faction from = this.readArg();
Faction to = this.arg(2, ARFaction.get()); Faction to = this.readArg();
boolean success = Econ.transferMoney(msender, from, to, amount); boolean success = Econ.transferMoney(msender, from, to, amount);

View File

@ -30,9 +30,9 @@ public class CmdFactionsMoneyTransferFp extends FactionsCommand
this.addAliases("fp"); this.addAliases("fp");
// Args // Args
this.addRequiredArg("amount"); this.addArg(ARDouble.get(), "amount");
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
@ -46,9 +46,9 @@ public class CmdFactionsMoneyTransferFp extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Double amount = this.arg(0, ARDouble.get()); double amount = this.readArg();
Faction from = this.arg(1, ARFaction.get()); Faction from = this.readArg();
MPlayer to = this.arg(2, ARMPlayer.getAny()); MPlayer to = this.readArg();
boolean success = Econ.transferMoney(msender, from, to, amount); boolean success = Econ.transferMoney(msender, from, to, amount);

View File

@ -30,9 +30,9 @@ public class CmdFactionsMoneyTransferPf extends FactionsCommand
this.addAliases("pf"); this.addAliases("pf");
// Args // Args
this.addRequiredArg("amount"); this.addArg(ARDouble.get(), "amount");
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
@ -46,9 +46,9 @@ public class CmdFactionsMoneyTransferPf extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Double amount = this.arg(0, ARDouble.get()); double amount = this.readArg();
MPlayer from = this.arg(1, ARMPlayer.getAny()); MPlayer from = this.readArg();
Faction to = this.arg(2, ARFaction.get()); Faction to = this.readArg();
boolean success = Econ.transferMoney(msender, from, to, amount); boolean success = Econ.transferMoney(msender, from, to, amount);

View File

@ -29,8 +29,8 @@ public class CmdFactionsMoneyWithdraw extends FactionsCommand
this.addAliases("w", "withdraw"); this.addAliases("w", "withdraw");
// Args // Args
this.addRequiredArg("amount"); this.addArg(ARDouble.get(), "amount");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node)); this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
@ -44,8 +44,8 @@ public class CmdFactionsMoneyWithdraw extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Double amount = this.arg(0, ARDouble.get()); Double amount = this.readArg();
Faction from = this.arg(1, ARFaction.get(), msenderFaction); Faction from = this.readArg(msenderFaction);
MPlayer to = msender; MPlayer to = msender;

View File

@ -5,6 +5,8 @@ import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsMotdChange; import com.massivecraft.factions.event.EventFactionsMotdChange;
import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
@ -22,8 +24,7 @@ public class CmdFactionsMotd extends FactionsCommand
this.addAliases("motd"); this.addAliases("motd");
// Args // Args
this.addOptionalArg("new", "read"); this.addArg(ARString.get(), "new", "read", true);
this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.MOTD.node)); this.addRequirements(ReqHasPerm.get(Perm.MOTD.node));
@ -34,7 +35,7 @@ public class CmdFactionsMotd extends FactionsCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveException
{ {
// Read // Read
if ( ! this.argIsSet(0)) if ( ! this.argIsSet(0))
@ -47,7 +48,7 @@ public class CmdFactionsMotd extends FactionsCommand
if ( ! MPerm.getPermMotd().has(msender, msenderFaction, true)) return; if ( ! MPerm.getPermMotd().has(msender, msenderFaction, true)) return;
// Args // Args
String target = this.argConcatFrom(0); String target = this.readArg();
target = target.trim(); target = target.trim();
target = Txt.parse(target); target = Txt.parse(target);

View File

@ -10,6 +10,7 @@ import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.event.EventFactionsNameChange;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsName extends FactionsCommand public class CmdFactionsName extends FactionsCommand
@ -24,8 +25,8 @@ public class CmdFactionsName extends FactionsCommand
this.addAliases("name"); this.addAliases("name");
// Args // Args
this.addRequiredArg("new name"); this.addArg(ARString.get(), "new name");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.NAME.node)); this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
@ -39,9 +40,8 @@ public class CmdFactionsName extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
String newName = this.arg(0); String newName = this.readArg();
Faction faction = this.readArg(msenderFaction);
Faction faction = this.arg(1, ARFaction.get(), msenderFaction);
// MPerm // MPerm
if ( ! MPerm.getPermName().has(msender, faction, true)) return; if ( ! MPerm.getPermName().has(msender, faction, true)) return;

View File

@ -22,7 +22,7 @@ public class CmdFactionsPermList extends FactionsCommand
this.addAliases("l", "list"); this.addAliases("l", "list");
// Args // Args
this.addOptionalArg("page", "1"); this.addArg(ARInteger.get(), "page", "1");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.PERM_LIST.node)); this.addRequirements(ReqHasPerm.get(Perm.PERM_LIST.node));
@ -36,7 +36,7 @@ public class CmdFactionsPermList extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); int pageHumanBased = this.readArg(1);
// Create messages // Create messages
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<String>();

View File

@ -28,10 +28,10 @@ public class CmdFactionsPermSet extends FactionsCommand
this.addAliases("set"); this.addAliases("set");
// Args // Args
this.addRequiredArg("perm"); this.addArg(ARMPerm.get(), "perm");
this.addRequiredArg("relation"); this.addArg(ARRel.get(), "relation");
this.addRequiredArg("yes/no"); this.addArg(ARBoolean.get(), "yes/no");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.PERM_SET.node)); this.addRequirements(ReqHasPerm.get(Perm.PERM_SET.node));
@ -45,10 +45,10 @@ public class CmdFactionsPermSet extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
MPerm perm = this.arg(0, ARMPerm.get()); MPerm perm = this.readArg();
Rel rel = this.arg(1, ARRel.get()); Rel rel = this.readArg();
Boolean value = this.arg(2, ARBoolean.get()); Boolean value = this.readArg();
Faction faction = this.arg(3, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
// Do the sender have the right to change perms for this faction? // Do the sender have the right to change perms for this faction?
if ( ! MPerm.getPermPerms().has(msender, faction, true)) return; if ( ! MPerm.getPermPerms().has(msender, faction, true)) return;

View File

@ -9,7 +9,8 @@ import com.massivecraft.factions.cmd.arg.ARMPerm;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARList; import com.massivecraft.massivecore.cmd.arg.ARAll;
import com.massivecraft.massivecore.cmd.arg.ARSet;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -25,9 +26,8 @@ public class CmdFactionsPermShow extends FactionsCommand
this.addAliases("s", "show"); this.addAliases("s", "show");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
this.addOptionalArg("perms", "all"); this.addArg(ARAll.get(ARSet.get(ARMPerm.get(), false)), "perms", "all", true);
this.setErrorOnToManyArgs(false);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.PERM_SHOW.node)); this.addRequirements(ReqHasPerm.get(Perm.PERM_SHOW.node));
@ -41,33 +41,15 @@ public class CmdFactionsPermShow extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Arg: Faction // Arg: Faction
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
List<MPerm> mperms = this.readArg(MPerm.getAll());
List<MPerm> perms = new ArrayList<MPerm>();
// Case: Show All
if ( ! this.argIsSet(1) || "all".equalsIgnoreCase(this.arg(1)))
{
for (MPerm mperm : MPerm.getAll())
{
if ( ! mperm.isVisible() && ! msender.isUsingAdminMode()) continue;
perms.add(mperm);
}
}
// Case: Show Some
else
{
// Arg perm. Maybe we should use ARSet but that is currently buggy.
List<MPerm> mperms = this.arg(this.argConcatFrom(1), ARList.get(ARMPerm.get()));
perms.addAll(mperms);
}
// Create messages // Create messages
List<String> messages = new ArrayList<String>(); List<String> messages = new ArrayList<String>();
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true))); messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
messages.add(MPerm.getStateHeaders()); messages.add(MPerm.getStateHeaders());
for (MPerm mperm : perms) for (MPerm mperm : mperms)
{ {
messages.add(Txt.parse(mperm.getStateInfo(faction.getPermitted(mperm), true))); messages.add(Txt.parse(mperm.getStateInfo(faction.getPermitted(mperm), true)));
} }

View File

@ -27,7 +27,7 @@ public class CmdFactionsPlayer extends FactionsCommand
this.addAliases("p", "player"); this.addAliases("p", "player");
// Args // Args
this.addOptionalArg("player", "you"); this.addArg(ARMPlayer.getAny(), "player", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node)); this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node));
@ -41,7 +41,7 @@ public class CmdFactionsPlayer extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
MPlayer mplayer = this.arg(0, ARMPlayer.getAny(), msender); MPlayer mplayer = this.readArg(msender);
// INFO: Title // INFO: Title
msg(Txt.titleize("Player " + mplayer.describeTo(msender))); msg(Txt.titleize("Player " + mplayer.describeTo(msender)));

View File

@ -7,11 +7,19 @@ import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.ArgSetting;
import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsPowerBoost extends FactionsCommand public class CmdFactionsPowerBoost extends FactionsCommand
{ {
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private ArgSetting setting = ArgSetting.of(ARMPlayer.getAny(), false, "name", null);
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
@ -22,9 +30,9 @@ public class CmdFactionsPowerBoost extends FactionsCommand
this.addAliases("powerboost"); this.addAliases("powerboost");
// Args // Args
this.addRequiredArg("p|f|player|faction"); this.addArg(ARString.get(), "p|f|player|faction");
this.addRequiredArg("name"); this.addArg(setting);
this.addRequiredArg("#"); this.addArg(ARDouble.get(), "#");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node)); this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
@ -37,7 +45,7 @@ public class CmdFactionsPowerBoost extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String type = this.arg(0).toLowerCase(); String type = this.<String>readArg().toLowerCase();
boolean doPlayer = true; boolean doPlayer = true;
if (type.equals("f") || type.equals("faction")) if (type.equals("f") || type.equals("faction"))
{ {
@ -50,20 +58,22 @@ public class CmdFactionsPowerBoost extends FactionsCommand
return; return;
} }
Double targetPower = this.arg(2, ARDouble.get()); double targetPower = this.readArgAt(2);
String target; String target;
if (doPlayer) if (doPlayer)
{ {
MPlayer targetPlayer = this.arg(1, ARMPlayer.getAny()); setting.setReader(ARMPlayer.getAny());
MPlayer targetPlayer = this.readArgAt(1);
targetPlayer.setPowerBoost(targetPower); targetPlayer.setPowerBoost(targetPower);
target = "Player \""+targetPlayer.getName()+"\""; target = "Player \""+targetPlayer.getName()+"\"";
} }
else else
{ {
Faction targetFaction = this.arg(1, ARFaction.get()); setting.setReader(ARFaction.get());
Faction targetFaction = this.readArgAt(1);
targetFaction.setPowerBoost(targetPower); targetFaction.setPowerBoost(targetPower);
target = "Faction \""+targetFaction.getName()+"\""; target = "Faction \""+targetFaction.getName()+"\"";

View File

@ -48,6 +48,9 @@ public class CmdFactionsRank extends FactionsCommand
private Rel targetRank = null; private Rel targetRank = null;
private Rel rank = null; private Rel rank = null;
// This one is permanent
private ARRank rankReader = new ARRank();
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
@ -58,9 +61,9 @@ public class CmdFactionsRank extends FactionsCommand
this.addAliases("rank"); this.addAliases("rank");
// Args // Args
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
this.addOptionalArg("action", "show"); this.addArg(rankReader, "action", "show");
this.addOptionalArg("faction", "their"); this.addArg(ARFaction.get(), "faction", "their");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.RANK.node)); this.addRequirements(ReqHasPerm.get(Perm.RANK.node));
@ -123,22 +126,25 @@ public class CmdFactionsRank extends FactionsCommand
private void registerFields() throws MassiveException private void registerFields() throws MassiveException
{ {
// Getting the target and faction. // Getting the target and faction.
target = this.arg(0, ARMPlayer.getAny(), msender); target = this.readArg(msender);
targetFaction = target.getFaction(); targetFaction = target.getFaction();
// Rank if any passed.
if (this.argIsSet(1))
{
rank = this.arg(1, ARRank.get(target.getRole()));
}
// Changing peoples faction.
endFaction = this.arg(2, ARFaction.get(), targetFaction);
factionChange = (endFaction != targetFaction);
// Ranks // Ranks
senderRank = msender.getRole(); senderRank = msender.getRole();
targetRank = target.getRole(); targetRank = target.getRole();
// Rank if any passed.
if (this.argIsSet(1))
{
this.rankReader.setStartRank(targetRank);
rank = this.readArg();
}
// Changing peoples faction.
endFaction = this.readArgAt(2, targetFaction);
factionChange = (endFaction != targetFaction);
} }
private void unregisterFields() private void unregisterFields()

View File

@ -1,6 +1,8 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.arg.ARMPlayer;
import com.massivecraft.massivecore.cmd.VisibilityMode; import com.massivecraft.massivecore.cmd.VisibilityMode;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
@ -25,8 +27,8 @@ public class CmdFactionsRankOld extends FactionsCommand
this.addAliases(rankName); this.addAliases(rankName);
// Args // Args
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
this.addOptionalArg("faction", "their"); this.addArg(ARFaction.get(), "faction", "their");
// VisibilityMode // VisibilityMode
this.setVisibilityMode(VisibilityMode.INVISIBLE); this.setVisibilityMode(VisibilityMode.INVISIBLE);
@ -39,7 +41,7 @@ public class CmdFactionsRankOld extends FactionsCommand
@Override @Override
public void perform() public void perform()
{ {
Factions.get().getOuterCmdFactions().cmdFactionsRank.execute(sender, MUtil.list(this.arg(0), this.rankName, this.arg(1))); Factions.get().getOuterCmdFactions().cmdFactionsRank.execute(sender, MUtil.list(this.argAt(0), this.rankName, this.argAt(1)));
} }
} }

View File

@ -23,7 +23,7 @@ public abstract class CmdFactionsRelationAbstract extends FactionsCommand
public CmdFactionsRelationAbstract() public CmdFactionsRelationAbstract()
{ {
// Aliases // Aliases
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node)); this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
@ -38,7 +38,7 @@ public abstract class CmdFactionsRelationAbstract extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Faction otherFaction = this.arg(0, ARFaction.get()); Faction otherFaction = this.readArg();
Rel newRelation = targetRelation; Rel newRelation = targetRelation;

View File

@ -19,7 +19,7 @@ public class CmdFactionsSeeChunk extends FactionsCommand
this.addAliases("sc", "seechunk"); this.addAliases("sc", "seechunk");
// Args // Args
this.addOptionalArg("active", "toggle"); this.addArg(ARBoolean.get(), "active", "toggle");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.SEECHUNK.node)); this.addRequirements(ReqHasPerm.get(Perm.SEECHUNK.node));
@ -36,11 +36,11 @@ public class CmdFactionsSeeChunk extends FactionsCommand
// Args // Args
boolean old = msender.isSeeingChunk(); boolean old = msender.isSeeingChunk();
boolean targetDefault = !old; boolean targetDefault = !old;
Boolean target = this.arg(0, ARBoolean.get(), targetDefault); boolean target = this.readArg(targetDefault);
String targetDesc = Txt.parse(target ? "<g>ON": "<b>OFF"); String targetDesc = Txt.parse(target ? "<g>ON": "<b>OFF");
// NoChange // NoChange
if (target.equals(old)) if (target == old)
{ {
msg("<i>See Chunk is already %s<i>.", targetDesc); msg("<i>See Chunk is already %s<i>.", targetDesc);
return; return;

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import java.util.Collections;
import java.util.List;
import java.util.Set; import java.util.Set;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
@ -7,9 +9,7 @@ import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARWorldId;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
@ -17,6 +17,13 @@ import com.massivecraft.massivecore.util.MUtil;
public class CmdFactionsSetAll extends CmdFactionsSetXAll public class CmdFactionsSetAll extends CmdFactionsSetXAll
{ {
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final List<String> LIST_ALL = Collections.unmodifiableList(MUtil.list("a", "al", "all"));
public static final List<String> LIST_MAP = Collections.singletonList("map");
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
@ -30,7 +37,6 @@ public class CmdFactionsSetAll extends CmdFactionsSetXAll
this.addAliases("all"); this.addAliases("all");
// Requirements // Requirements
this.addRequirements(ReqIsPlayer.get());
String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node; String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node;
this.addRequirements(ReqHasPerm.get(node)); this.addRequirements(ReqHasPerm.get(node));
} }
@ -52,7 +58,7 @@ public class CmdFactionsSetAll extends CmdFactionsSetXAll
Faction oldFaction = this.getOldFaction(); Faction oldFaction = this.getOldFaction();
if (oldFaction == null) return null; if (oldFaction == null) return null;
if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase())) if (LIST_ALL.contains(this.argAt(0).toLowerCase()))
{ {
chunks = BoardColl.get().getChunks(oldFaction); chunks = BoardColl.get().getChunks(oldFaction);
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " all."); this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " all.");
@ -61,7 +67,7 @@ public class CmdFactionsSetAll extends CmdFactionsSetXAll
else else
{ {
String worldId = null; String worldId = null;
if (MUtil.list("map").contains(this.arg(0).toLowerCase())) if (LIST_MAP.contains(this.argAt(0).toLowerCase()))
{ {
if (me != null) if (me != null)
{ {
@ -75,7 +81,7 @@ public class CmdFactionsSetAll extends CmdFactionsSetXAll
} }
else else
{ {
worldId = this.arg(0, ARWorldId.get()); worldId = this.argAt(0);
if (worldId == null) return null; if (worldId == null) return null;
} }
Board board = BoardColl.get().get(worldId); Board board = BoardColl.get().get(worldId);

View File

@ -39,7 +39,7 @@ public class CmdFactionsSetAuto extends FactionsCommand
// Args // Args
if (claim) if (claim)
{ {
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
} }
// Requirements // Requirements
@ -59,7 +59,7 @@ public class CmdFactionsSetAuto extends FactionsCommand
final Faction newFaction; final Faction newFaction;
if (claim) if (claim)
{ {
newFaction = this.arg(0, ARFaction.get(), msenderFaction); newFaction = this.readArg(msenderFaction);
} }
else else
{ {

View File

@ -2,13 +2,11 @@ package com.massivecraft.factions.cmd;
import java.util.Set; import java.util.Set;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
public abstract class CmdFactionsSetX extends FactionsCommand public abstract class CmdFactionsSetX extends FactionsCommand
{ {
// -------------------------------------------- // // -------------------------------------------- //
@ -69,7 +67,7 @@ public abstract class CmdFactionsSetX extends FactionsCommand
{ {
if (this.isClaim()) if (this.isClaim())
{ {
return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction); return this.readArgAt(this.getFactionArgIndex(), msenderFaction);
} }
else else
{ {

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARString;
public abstract class CmdFactionsSetXAll extends CmdFactionsSetX public abstract class CmdFactionsSetXAll extends CmdFactionsSetX
{ {
@ -16,11 +17,11 @@ public abstract class CmdFactionsSetXAll extends CmdFactionsSetX
super(claim); super(claim);
// Args // Args
this.addRequiredArg("all|map"); this.addArg(ARString.get(), "all|map");
this.addRequiredArg("faction"); this.addArg(ARFaction.get(), "faction");
if (claim) if (claim)
{ {
this.addRequiredArg("newfaction"); this.addArg(ARFaction.get(), "newfaction");
this.setFactionArgIndex(2); this.setFactionArgIndex(2);
} }
} }
@ -31,7 +32,7 @@ public abstract class CmdFactionsSetXAll extends CmdFactionsSetX
public Faction getOldFaction() throws MassiveException public Faction getOldFaction() throws MassiveException
{ {
return this.arg(1, ARFaction.get()); return this.readArgAt(1);
} }
} }

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.arg.ARInteger;
@ -17,10 +18,10 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
super(claim); super(claim);
// Args // Args
this.addOptionalArg("radius", "1"); this.addArg(ARInteger.get(), "radius", "1");
if (claim) if (claim)
{ {
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
this.setFactionArgIndex(1); this.setFactionArgIndex(1);
} }
} }
@ -31,8 +32,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
public Integer getRadius() throws MassiveException public Integer getRadius() throws MassiveException
{ {
Integer radius = this.arg(0, ARInteger.get(), 1); int radius = this.readArg(1);
if (radius == null) return radius;
// Radius Claim Min // Radius Claim Min
if (radius < 1) if (radius < 1)

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX
{ {
// -------------------------------------------- // // -------------------------------------------- //
@ -14,7 +16,7 @@ public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX
// Args // Args
if (claim) if (claim)
{ {
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
this.setFactionArgIndex(0); this.setFactionArgIndex(0);
} }
} }

View File

@ -23,7 +23,7 @@ public class CmdFactionsSethome extends FactionsCommandHome
this.addAliases("sethome"); this.addAliases("sethome");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node)); this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node));
@ -38,7 +38,7 @@ public class CmdFactionsSethome extends FactionsCommandHome
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
PS newHome = PS.valueOf(me.getLocation()); PS newHome = PS.valueOf(me.getLocation());

View File

@ -21,8 +21,8 @@ public class CmdFactionsSetpower extends FactionsCommand
this.addAliases("sp", "setpower"); this.addAliases("sp", "setpower");
// Args // Args
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
this.addRequiredArg("power"); this.addArg(ARDouble.get(), "power");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.SETPOWER.node)); this.addRequirements(ReqHasPerm.get(Perm.SETPOWER.node));
@ -36,8 +36,8 @@ public class CmdFactionsSetpower extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); MPlayer mplayer = this.readArg();
Double power = this.arg(1, ARDouble.get()); double power = this.readArg();
// Power // Power
double oldPower = mplayer.getPower(); double oldPower = mplayer.getPower();
@ -48,7 +48,7 @@ public class CmdFactionsSetpower extends FactionsCommand
double maxDifference = 0.1d; double maxDifference = 0.1d;
if (difference < maxDifference) if (difference < maxDifference)
{ {
msender.msg("%s's <i>power is already <h>%.2f<i>.", mplayer.getDisplayName(msender), newPower); msg("%s's <i>power is already <h>%.2f<i>.", mplayer.getDisplayName(msender), newPower);
return; return;
} }
@ -58,7 +58,7 @@ public class CmdFactionsSetpower extends FactionsCommand
if (event.isCancelled()) return; if (event.isCancelled()) return;
// Inform // Inform
msender.msg("<i>You changed %s's <i>power from <h>%.2f <i>to <h>%.2f<i>.", mplayer.getDisplayName(msender), oldPower, newPower); msg("<i>You changed %s's <i>power from <h>%.2f <i>to <h>%.2f<i>.", mplayer.getDisplayName(msender), oldPower, newPower);
if (msender != mplayer) if (msender != mplayer)
{ {
mplayer.msg("%s <i>changed your power from <h>%.2f <i>to <h>%.2f<i>.", msender.getDisplayName(mplayer), oldPower, newPower); mplayer.msg("%s <i>changed your power from <h>%.2f <i>to <h>%.2f<i>.", msender.getDisplayName(mplayer), oldPower, newPower);

View File

@ -34,9 +34,9 @@ public class CmdFactionsStatus extends FactionsCommand
this.addAliases("s", "status"); this.addAliases("s", "status");
// Args // Args
this.addOptionalArg("page", "1"); this.addArg(ARInteger.get(), "page", "1");
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
this.addOptionalArg("sort by", "time"); this.addArg(ARSortMPlayer.get(), "sort by", "time");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.STATUS.node)); this.addRequirements(ReqHasPerm.get(Perm.STATUS.node));
@ -50,9 +50,9 @@ public class CmdFactionsStatus extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); Integer pageHumanBased = this.readArg(1);
Faction faction = this.arg(1, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
Comparator<MPlayer> sortedBy = this.arg(2, ARSortMPlayer.get(), PlayerInactivityComparator.get()); Comparator<MPlayer> sortedBy = this.readArg(PlayerInactivityComparator.get());
// MPerm // MPerm
if ( ! MPerm.getPermStatus().has(msender, faction, true)) return; if ( ! MPerm.getPermStatus().has(msender, faction, true)) return;

View File

@ -24,8 +24,8 @@ public class CmdFactionsTitle extends FactionsCommand
this.addAliases("title"); this.addAliases("title");
// Args // Args
this.addRequiredArg("player"); this.addArg(ARMPlayer.getAny(), "player");
this.addOptionalArg("title", ""); this.addArg(ARString.get(), "title", "", true);
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node)); this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
@ -39,8 +39,8 @@ public class CmdFactionsTitle extends FactionsCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
MPlayer you = this.arg(0, ARMPlayer.getAny()); MPlayer you = this.readArg();
String newTitle = this.argConcatFrom(1, ARString.get(), ""); String newTitle = this.readArg("");
newTitle = Txt.parse(newTitle); newTitle = Txt.parse(newTitle);
if (!Perm.TITLE_COLOR.has(sender, false)) if (!Perm.TITLE_COLOR.has(sender, false))

View File

@ -20,7 +20,7 @@ public class CmdFactionsUnsethome extends FactionsCommandHome
this.addAliases("unsethome"); this.addAliases("unsethome");
// Args // Args
this.addOptionalArg("faction", "you"); this.addArg(ARFaction.get(), "faction", "you");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.UNSETHOME.node)); this.addRequirements(ReqHasPerm.get(Perm.UNSETHOME.node));
@ -34,7 +34,7 @@ public class CmdFactionsUnsethome extends FactionsCommandHome
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
Faction faction = this.arg(0, ARFaction.get(), msenderFaction); Faction faction = this.readArg(msenderFaction);
// Any and MPerm // Any and MPerm
if ( ! MPerm.getPermSethome().has(msender, faction, true)) return; if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;

View File

@ -24,7 +24,7 @@ public class CmdFactionsXPlaceholder extends FactionsCommand
this.setDesc("Use " + extensionName); this.setDesc("Use " + extensionName);
// Args // Args
this.setErrorOnToManyArgs(false); this.setGivingErrorOnTooManyArgs(false);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -1,17 +1,19 @@
package com.massivecraft.factions.cmd.arg; package com.massivecraft.factions.cmd.arg;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.Set;
import java.util.TreeSet;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.massivecore.CaseInsensitiveComparator;
import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.arg.ARAbstract; import com.massivecraft.massivecore.cmd.arg.ARAbstract;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.IdUtil;
public class ARFaction extends ARAbstract<Faction> public class ARFaction extends ARAbstract<Faction>
@ -63,11 +65,11 @@ public class ARFaction extends ARAbstract<Faction>
@Override @Override
public Collection<String> getTabList(CommandSender sender, String arg) public Collection<String> getTabList(CommandSender sender, String arg)
{ {
List<String> ret = new MassiveList<String>(); Set<String> ret = new TreeSet<String>(CaseInsensitiveComparator.get());
for (Faction faction : FactionColl.get().getAll()) for (Faction faction : FactionColl.get().getAll())
{ {
ret.add(faction.getName()); ret.add(ChatColor.stripColor(faction.getName()));
} }
return ret; return ret;

View File

@ -8,9 +8,10 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
import com.massivecraft.massivecore.cmd.arg.ARAllAble;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class ARMFlag extends ARAbstractSelect<MFlag> public class ARMFlag extends ARAbstractSelect<MFlag> implements ARAllAble<MFlag>
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -76,6 +77,12 @@ public class ARMFlag extends ARAbstractSelect<MFlag>
{ {
return this.altNames(sender); return this.altNames(sender);
} }
@Override
public Collection<MFlag> getAll(CommandSender sender)
{
return MFlag.getAll();
}
// -------------------------------------------- // // -------------------------------------------- //
// UTIL // UTIL

View File

@ -8,9 +8,10 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
import com.massivecraft.massivecore.cmd.arg.ARAllAble;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class ARMPerm extends ARAbstractSelect<MPerm> public class ARMPerm extends ARAbstractSelect<MPerm> implements ARAllAble<MPerm>
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
@ -76,6 +77,12 @@ public class ARMPerm extends ARAbstractSelect<MPerm>
{ {
return this.altNames(sender); return this.altNames(sender);
} }
@Override
public Collection<MPerm> getAll(CommandSender sender)
{
return MPerm.getAll();
}
// -------------------------------------------- // // -------------------------------------------- //
// UTIL // UTIL

View File

@ -54,8 +54,9 @@ public class ARRank extends ARAbstractSelect<Rel>
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
private final Rel startRank; private Rel startRank;
public Rel getStartRank() { return this.startRank; } public Rel getStartRank() { return this.startRank; }
public void setStartRank(Rel startRank) { this.startRank = startRank; }
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE // OVERRIDE