No compiletime errors anymore, how kewl. Let's test.
This commit is contained in:
parent
97a2ed1fd8
commit
4b9bdf0d94
14
plugin.yml
14
plugin.yml
@ -44,13 +44,13 @@ permissions:
|
|||||||
factions.list: {description: see a list of the factions}
|
factions.list: {description: see a list of the factions}
|
||||||
factions.lock: {description: lock all write stuff}
|
factions.lock: {description: lock all write stuff}
|
||||||
factions.map: {description: show the territory map, and set optional auto update}
|
factions.map: {description: show the territory map, and set optional auto update}
|
||||||
factions.money.balance: {description: show your factions current money balance}
|
factions.money.balance: {description: show money balance for a faction}
|
||||||
factions.money.balance.any: {description: show money balance for factions other than your own}
|
factions.money.balance.any: {description: show money balance for another faction}
|
||||||
factions.money.deposit: {description: deposit money into a faction bank}
|
factions.money.deposit: {description: deposit money to faction bank}
|
||||||
factions.money.f2f: {description: transfer money from faction to faction}
|
factions.money.f2f: {description: transfer f --> f}
|
||||||
factions.money.f2p: {description: transfer money from faction to player}
|
factions.money.f2p: {description: transfer f --> p}
|
||||||
factions.money.p2f: {description: transfer money from player to faction}
|
factions.money.p2f: {description: transfer p --> f}
|
||||||
factions.money.withdraw: {description: withdraw money from your faction bank}
|
factions.money.withdraw: {description: withdraw money from faction bank}
|
||||||
factions.officer: {description: give or revoke officer rights}
|
factions.officer: {description: give or revoke officer rights}
|
||||||
factions.officer.any: {description: give or revoke officer rights for any player in any faction}
|
factions.officer.any: {description: give or revoke officer rights for any player in any faction}
|
||||||
factions.open: {description: switch if invitation is required to join}
|
factions.open: {description: switch if invitation is required to join}
|
||||||
|
49
src/com/massivecraft/factions/FactionListComparator.java
Normal file
49
src/com/massivecraft/factions/FactionListComparator.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package com.massivecraft.factions;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
|
||||||
|
public class FactionListComparator implements Comparator<Faction>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static FactionListComparator i = new FactionListComparator();
|
||||||
|
public static FactionListComparator get() { return i; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE: COMPARATOR
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Faction f1, Faction f2)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
// Null --> Low
|
||||||
|
if (f1 == null && f2 == null) ret = 0;
|
||||||
|
if (f1 == null) ret = -1;
|
||||||
|
if (f2 == null) ret = +1;
|
||||||
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
|
// None --> High
|
||||||
|
if (f1.isNone() && f2.isNone()) ret = 0;
|
||||||
|
if (f1.isNone()) ret = +1;
|
||||||
|
if (f2.isNone()) ret = -1;
|
||||||
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
|
// Players Online --> High
|
||||||
|
ret = f1.getFPlayersWhereOnline(true).size() - f2.getFPlayersWhereOnline(true).size();
|
||||||
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
|
// Players Total --> High
|
||||||
|
ret = f1.getFPlayers().size() - f2.getFPlayers().size();
|
||||||
|
if (ret != 0) return ret;
|
||||||
|
|
||||||
|
// Tie by Id
|
||||||
|
return MUtil.compare(f1.getId(), f2.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,9 +3,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.mcore.cmd.HelpCommand;
|
import com.massivecraft.mcore.cmd.HelpCommand;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactions extends FCommand
|
public class CmdFactions extends FCommand
|
||||||
{
|
{
|
||||||
@ -57,8 +55,8 @@ public class CmdFactions extends FCommand
|
|||||||
// TODO: When is this required? Should this be added to MCore?
|
// TODO: When is this required? Should this be added to MCore?
|
||||||
this.aliases.removeAll(Collections.singletonList(null));
|
this.aliases.removeAll(Collections.singletonList(null));
|
||||||
|
|
||||||
this.setHelpShort("The faction base command");
|
this.setDesc("The faction base command");
|
||||||
this.helpLong.add(Txt.parse("<i>This command contains all faction stuff."));
|
this.setHelp("This command contains all faction stuff.");
|
||||||
|
|
||||||
this.addSubCommand(HelpCommand.get());
|
this.addSubCommand(HelpCommand.get());
|
||||||
this.addSubCommand(this.cmdFactionsList);
|
this.addSubCommand(this.cmdFactionsList);
|
||||||
|
@ -6,6 +6,8 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
@ -21,9 +23,9 @@ public class CmdFactionsAccess extends FCommand
|
|||||||
this.addOptionalArg("view|p|player|f|faction", "view");
|
this.addOptionalArg("view|p|player|f|faction", "view");
|
||||||
this.addOptionalArg("name", "you");
|
this.addOptionalArg("name", "you");
|
||||||
|
|
||||||
this.setHelpShort("view or grant access for the claimed territory you are in");
|
this.setDesc("view or grant access for the claimed territory you are in");
|
||||||
|
|
||||||
// TODO: Missing permission node here!
|
// TODO: Missing permission node here!?
|
||||||
this.addRequirements(ReqIsPlayer.get());
|
this.addRequirements(ReqIsPlayer.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,14 +73,14 @@ public class CmdFactionsAccess extends FCommand
|
|||||||
|
|
||||||
if (doPlayer)
|
if (doPlayer)
|
||||||
{
|
{
|
||||||
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1, fme);
|
FPlayer targetPlayer = this.arg(1, ARFPlayer.getStartAny(), fme);
|
||||||
if (targetPlayer == null) return;
|
if (targetPlayer == null) return;
|
||||||
added = territory.toggleFPlayer(targetPlayer);
|
added = territory.toggleFPlayer(targetPlayer);
|
||||||
target = "Player \""+targetPlayer.getName()+"\"";
|
target = "Player \""+targetPlayer.getName()+"\"";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Faction targetFaction = this.argAsFaction(1, myFaction);
|
Faction targetFaction = this.arg(1, ARFaction.get(), myFaction);
|
||||||
if (targetFaction == null) return;
|
if (targetFaction == null) return;
|
||||||
added = territory.toggleFaction(targetFaction);
|
added = territory.toggleFaction(targetFaction);
|
||||||
target = "Faction \""+targetFaction.getTag()+"\"";
|
target = "Faction \""+targetFaction.getTag()+"\"";
|
||||||
|
@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public class CmdFactionsDeinvite extends FCommand
|
public class CmdFactionsDeinvite extends FCommand
|
||||||
@ -16,11 +18,7 @@ public class CmdFactionsDeinvite extends FCommand
|
|||||||
this.addRequiredArg("player");
|
this.addRequiredArg("player");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.DEINVITE.node));
|
this.addRequirements(ReqHasPerm.get(Perm.DEINVITE.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
// TODO: Base on faction permissions instead?
|
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeOfficer = true;
|
|
||||||
senderMustBeLeader = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,8 @@ import com.massivecraft.factions.ConfServer;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayerColl;
|
import com.massivecraft.factions.FPlayerColl;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
@ -17,8 +19,7 @@ public class CmdFactionsDescription extends FCommand
|
|||||||
this.setErrorOnToManyArgs(false);
|
this.setErrorOnToManyArgs(false);
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
|
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.integration.EssentialsFeatures;
|
import com.massivecraft.factions.integration.EssentialsFeatures;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||||
@ -31,8 +32,7 @@ public class CmdFactionsHome extends FCommand
|
|||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
|
this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
|
||||||
this.addRequirements(ReqIsPlayer.get());
|
this.addRequirements(ReqIsPlayer.get());
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.RECRUIT));
|
||||||
senderMustBeMember = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,11 +3,11 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||||
|
|
||||||
@ -21,8 +21,7 @@ public class CmdFactionsInvite extends FCommand
|
|||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
|
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
|
||||||
this.addRequirements(ReqIsPlayer.get());
|
this.addRequirements(ReqIsPlayer.get());
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +47,7 @@ public class CmdFactionsLeader extends FCommand
|
|||||||
// Follow the standard rules
|
// Follow the standard rules
|
||||||
if (fme.getRole() != Rel.LEADER || targetFaction != myFaction)
|
if (fme.getRole() != Rel.LEADER || targetFaction != myFaction)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Txt.parse("<b>You must be leader of the faction to %s.", this.getHelpShort()));
|
sender.sendMessage(Txt.parse("<b>You must be leader of the faction to %s.", this.getDesc()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public class CmdFactionsLeave extends FCommand {
|
public class CmdFactionsLeave extends FCommand {
|
||||||
@ -10,8 +12,7 @@ public class CmdFactionsLeave extends FCommand {
|
|||||||
this.addAliases("leave");
|
this.addAliases("leave");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
|
this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.RECRUIT));
|
||||||
senderMustBeMember = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.List;
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionColl;
|
import com.massivecraft.factions.FactionColl;
|
||||||
|
import com.massivecraft.factions.FactionListComparator;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.mcore.cmd.arg.ARInteger;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
@ -27,78 +28,30 @@ public class CmdFactionsList extends FCommand
|
|||||||
@Override
|
@Override
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
|
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1);
|
||||||
|
if (pageHumanBased == null) return;
|
||||||
|
|
||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(ConfServer.econCostList, "to list the factions", "for listing the factions")) return;
|
if ( ! payForCommand(ConfServer.econCostList, "to list the factions", "for listing the factions")) return;
|
||||||
|
|
||||||
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColl.get().getAll());
|
// Create Messages
|
||||||
|
List<String> lines = new ArrayList<String>();
|
||||||
|
|
||||||
factionList.remove(FactionColl.get().getNone());
|
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColl.get().getAll(null, FactionListComparator.get()));
|
||||||
// TODO: Add flag SECRET To factions instead.
|
|
||||||
//factionList.remove(Factions.i.getSafeZone());
|
|
||||||
//factionList.remove(Factions.i.getWarZone());
|
|
||||||
|
|
||||||
// Sort by total followers first
|
|
||||||
Collections.sort(factionList, new Comparator<Faction>(){
|
|
||||||
@Override
|
|
||||||
public int compare(Faction f1, Faction f2) {
|
|
||||||
int f1Size = f1.getFPlayers().size();
|
|
||||||
int f2Size = f2.getFPlayers().size();
|
|
||||||
if (f1Size < f2Size)
|
|
||||||
return 1;
|
|
||||||
else if (f1Size > f2Size)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Then sort by how many members are online now
|
|
||||||
Collections.sort(factionList, new Comparator<Faction>(){
|
|
||||||
@Override
|
|
||||||
public int compare(Faction f1, Faction f2) {
|
|
||||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
|
||||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
|
||||||
if (f1Size < f2Size)
|
|
||||||
return 1;
|
|
||||||
else if (f1Size > f2Size)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ArrayList<String> lines = new ArrayList<String>();
|
|
||||||
|
|
||||||
/* // this code was really slow on large servers, getting full info for every faction and then only showing 9 of them; rewritten below
|
|
||||||
lines.add(Txt.parse("<i>Factionless<i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
|
|
||||||
for (Faction faction : factionList)
|
|
||||||
{
|
|
||||||
lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
|
||||||
faction.getTag(fme),
|
|
||||||
faction.getFPlayersWhereOnline(true).size(),
|
|
||||||
faction.getFPlayers().size(),
|
|
||||||
faction.getLandRounded(),
|
|
||||||
faction.getPowerRounded(),
|
|
||||||
faction.getPowerMaxRounded())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage(Txt.getPage(lines, this.argAsInt(0, 1), "Faction List"));
|
|
||||||
*/
|
|
||||||
|
|
||||||
factionList.add(0, FactionColl.get().getNone());
|
|
||||||
|
|
||||||
final int pageheight = 9;
|
final int pageheight = 9;
|
||||||
int pagenumber = this.argAsInt(0, 1);
|
|
||||||
int pagecount = (factionList.size() / pageheight) + 1;
|
int pagecount = (factionList.size() / pageheight) + 1;
|
||||||
if (pagenumber > pagecount)
|
if (pageHumanBased > pagecount)
|
||||||
pagenumber = pagecount;
|
pageHumanBased = pagecount;
|
||||||
else if (pagenumber < 1)
|
else if (pageHumanBased < 1)
|
||||||
pagenumber = 1;
|
pageHumanBased = 1;
|
||||||
int start = (pagenumber - 1) * pageheight;
|
int start = (pageHumanBased - 1) * pageheight;
|
||||||
int end = start + pageheight;
|
int end = start + pageheight;
|
||||||
if (end > factionList.size())
|
if (end > factionList.size())
|
||||||
end = factionList.size();
|
end = factionList.size();
|
||||||
|
|
||||||
lines.add(Txt.titleize("Faction List "+pagenumber+"/"+pagecount));
|
lines.add(Txt.titleize("Faction List "+pageHumanBased+"/"+pagecount));
|
||||||
|
|
||||||
for (Faction faction : factionList.subList(start, end))
|
for (Faction faction : factionList.subList(start, end))
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.mcore.cmd.HelpCommand;
|
import com.massivecraft.mcore.cmd.HelpCommand;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsMoney extends FCommand
|
public class CmdFactionsMoney extends FCommand
|
||||||
{
|
{
|
||||||
@ -17,15 +16,10 @@ public class CmdFactionsMoney extends FCommand
|
|||||||
{
|
{
|
||||||
this.addAliases("money");
|
this.addAliases("money");
|
||||||
|
|
||||||
this.isMoneyCommand = true;
|
this.setDesc("faction money commands");
|
||||||
|
this.setHelp("The faction money commands.");
|
||||||
|
|
||||||
senderMustBePlayer = false;
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeOfficer = false;
|
|
||||||
senderMustBeLeader = false;
|
|
||||||
|
|
||||||
this.setHelpShort("faction money commands");
|
|
||||||
this.helpLong.add(Txt.parse("<i>The faction money commands."));
|
|
||||||
|
|
||||||
this.addSubCommand(this.cmdMoneyBalance);
|
this.addSubCommand(this.cmdMoneyBalance);
|
||||||
this.addSubCommand(this.cmdMoneyDeposit);
|
this.addSubCommand(this.cmdMoneyDeposit);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
@ -15,8 +16,7 @@ public class CmdFactionsMoneyBalance extends FCommand
|
|||||||
this.addOptionalArg("faction", "you");
|
this.addOptionalArg("faction", "you");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
|
this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
|
||||||
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
this.setHelpShort("show faction balance");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,7 +5,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
@ -25,8 +25,7 @@ public class CmdFactionsMoneyDeposit extends FCommand
|
|||||||
this.addOptionalArg("faction", "you");
|
this.addOptionalArg("faction", "you");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
|
this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
|
||||||
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
this.setHelpShort("deposit money");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,7 @@ import com.massivecraft.factions.ConfServer;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
||||||
@ -25,8 +25,7 @@ public class CmdFactionsMoneyTransferFf extends FCommand
|
|||||||
this.addRequiredArg("faction");
|
this.addRequiredArg("faction");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
|
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
|
||||||
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
this.setHelpShort("transfer f -> f");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,7 +6,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
||||||
@ -27,8 +27,7 @@ public class CmdFactionsMoneyTransferFp extends FCommand
|
|||||||
this.addRequiredArg("player");
|
this.addRequiredArg("player");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
|
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
|
||||||
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
this.setHelpShort("transfer f -> p");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,7 +6,7 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
||||||
@ -27,8 +27,7 @@ public class CmdFactionsMoneyTransferPf extends FCommand
|
|||||||
this.addRequiredArg("faction");
|
this.addRequiredArg("faction");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
|
this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
|
||||||
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
this.setHelpShort("transfer p -> f");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,7 @@ import com.massivecraft.factions.ConfServer;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
import com.massivecraft.mcore.cmd.arg.ARDouble;
|
||||||
@ -24,8 +24,7 @@ public class CmdFactionsMoneyWithdraw extends FCommand
|
|||||||
this.addOptionalArg("faction", "you");
|
this.addOptionalArg("faction", "you");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
|
this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
|
||||||
|
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||||
this.setHelpShort("withdraw money");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,8 @@ import com.massivecraft.factions.ConfServer;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionColl;
|
import com.massivecraft.factions.FactionColl;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARBoolean;
|
import com.massivecraft.mcore.cmd.arg.ARBoolean;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
@ -16,8 +18,7 @@ public class CmdFactionsOpen extends FCommand
|
|||||||
this.addOptionalArg("yes/no", "toggle");
|
this.addOptionalArg("yes/no", "toggle");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.OPEN.node));
|
this.addRequirements(ReqHasPerm.get(Perm.OPEN.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,10 +8,10 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.event.FactionRelationEvent;
|
import com.massivecraft.factions.event.FactionRelationEvent;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
|
||||||
|
|
||||||
public abstract class CmdFactionsRelationAbstract extends FCommand
|
public abstract class CmdFactionsRelationAbstract extends FCommand
|
||||||
{
|
{
|
||||||
@ -22,8 +22,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
|
|||||||
this.addAliases("faction");
|
this.addAliases("faction");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
|
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,6 +8,8 @@ import com.massivecraft.factions.ConfServer;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FactionColl;
|
import com.massivecraft.factions.FactionColl;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.event.FactionRenameEvent;
|
import com.massivecraft.factions.event.FactionRenameEvent;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
@ -23,8 +25,7 @@ public class CmdFactionsTag extends FCommand
|
|||||||
this.addRequiredArg("new tag");
|
this.addRequiredArg("new tag");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.TAG.node));
|
this.addRequirements(ReqHasPerm.get(Perm.TAG.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,11 +3,12 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
import com.massivecraft.factions.cmd.arg.ARFPlayer;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.mcore.cmd.arg.ARString;
|
import com.massivecraft.mcore.cmd.arg.ARString;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
|
||||||
|
|
||||||
public class CmdFactionsTitle extends FCommand
|
public class CmdFactionsTitle extends FCommand
|
||||||
{
|
{
|
||||||
@ -19,8 +20,7 @@ public class CmdFactionsTitle extends FCommand
|
|||||||
this.addOptionalArg("title", "");
|
this.addOptionalArg("title", "");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
|
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,8 @@ import com.massivecraft.factions.BoardColl;
|
|||||||
import com.massivecraft.factions.ConfServer;
|
import com.massivecraft.factions.ConfServer;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
|
import com.massivecraft.factions.Rel;
|
||||||
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
@ -18,8 +20,7 @@ public class CmdFactionsUnclaimall extends FCommand
|
|||||||
this.addAliases("unclaimall", "declaimall");
|
this.addAliases("unclaimall", "declaimall");
|
||||||
|
|
||||||
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
|
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
|
||||||
|
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
|
||||||
senderMustBeOfficer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,383 +0,0 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
|
||||||
import com.massivecraft.factions.integration.Econ;
|
|
||||||
import com.massivecraft.factions.FFlag;
|
|
||||||
import com.massivecraft.factions.FPerm;
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
|
||||||
import com.massivecraft.factions.FPlayerColl;
|
|
||||||
import com.massivecraft.factions.Faction;
|
|
||||||
import com.massivecraft.factions.FactionColl;
|
|
||||||
import com.massivecraft.factions.Factions;
|
|
||||||
import com.massivecraft.factions.Rel;
|
|
||||||
import com.massivecraft.factions.zcore.MCommand;
|
|
||||||
import com.massivecraft.mcore.util.Txt;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class FCommandOld extends MCommand<Factions>
|
|
||||||
{
|
|
||||||
public FPlayer fme;
|
|
||||||
public Faction myFaction;
|
|
||||||
|
|
||||||
// TODO: All these are "command reqs"
|
|
||||||
public boolean senderMustBeMember;
|
|
||||||
public boolean senderMustBeOfficer;
|
|
||||||
public boolean senderMustBeLeader;
|
|
||||||
|
|
||||||
public boolean isMoneyCommand;
|
|
||||||
|
|
||||||
public FCommandOld()
|
|
||||||
{
|
|
||||||
super(Factions.get());
|
|
||||||
|
|
||||||
// The money commands must be disabled if money should not be used.
|
|
||||||
isMoneyCommand = false;
|
|
||||||
|
|
||||||
senderMustBeMember = false;
|
|
||||||
senderMustBeOfficer = false;
|
|
||||||
senderMustBeLeader = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain)
|
|
||||||
{
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
this.fme = FPlayerColl.get().get(sender);
|
|
||||||
this.myFaction = this.fme.getFaction();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fme = null;
|
|
||||||
this.myFaction = null;
|
|
||||||
}
|
|
||||||
super.execute(sender, args, commandChain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
if (this.isMoneyCommand && ! ConfServer.econEnabled)
|
|
||||||
{
|
|
||||||
msg("<b>Faction economy features are disabled on this server.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isMoneyCommand && ! ConfServer.bankEnabled)
|
|
||||||
{
|
|
||||||
msg("<b>The faction bank system is disabled on this server.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot)
|
|
||||||
{
|
|
||||||
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
|
||||||
if ( ! superValid) return false;
|
|
||||||
|
|
||||||
if ( ! (this.senderMustBeMember || this.senderMustBeOfficer || this.senderMustBeLeader)) return true;
|
|
||||||
|
|
||||||
if ( ! (sender instanceof Player)) return false;
|
|
||||||
|
|
||||||
FPlayer fplayer = FPlayerColl.get().get((Player)sender);
|
|
||||||
|
|
||||||
if ( ! fplayer.hasFaction())
|
|
||||||
{
|
|
||||||
sender.sendMessage(Txt.parse("<b>You are not member of any faction."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.senderMustBeOfficer && ! fplayer.getRole().isAtLeast(Rel.OFFICER))
|
|
||||||
{
|
|
||||||
sender.sendMessage(Txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.senderMustBeLeader && ! fplayer.getRole().isAtLeast(Rel.LEADER))
|
|
||||||
{
|
|
||||||
sender.sendMessage(Txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// Assertions
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// These are not used. Remove in the future if no need for them arises.
|
|
||||||
|
|
||||||
/*
|
|
||||||
public boolean assertHasFaction()
|
|
||||||
{
|
|
||||||
if (me == null) return true;
|
|
||||||
|
|
||||||
if ( ! fme.hasFaction())
|
|
||||||
{
|
|
||||||
sendMessage("You are not member of any faction.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean assertMinRole(Rel role)
|
|
||||||
{
|
|
||||||
if (me == null) return true;
|
|
||||||
|
|
||||||
if (fme.getRole().isLessThan(role))
|
|
||||||
{
|
|
||||||
msg("<b>You <h>must be "+role+"<b> to "+this.getHelpShort()+".");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// Argument Readers
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
// TODO: Convert these arg-readers to MCore ArgReaders.
|
|
||||||
|
|
||||||
// FPLAYER ======================
|
|
||||||
public FPlayer strAsFPlayer(String name, FPlayer def, boolean msg)
|
|
||||||
{
|
|
||||||
FPlayer ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
|
||||||
{
|
|
||||||
FPlayer fplayer = FPlayerColl.get().get(name);
|
|
||||||
if (fplayer != null)
|
|
||||||
{
|
|
||||||
ret = fplayer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
|
||||||
{
|
|
||||||
this.msg("<b>No player \"<p>%s<b>\" could be found.", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public FPlayer argAsFPlayer(int idx, FPlayer def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsFPlayer(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public FPlayer argAsFPlayer(int idx, FPlayer def)
|
|
||||||
{
|
|
||||||
return this.argAsFPlayer(idx, def, true);
|
|
||||||
}
|
|
||||||
public FPlayer argAsFPlayer(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsFPlayer(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// BEST FPLAYER MATCH ======================
|
|
||||||
public FPlayer strAsBestFPlayerMatch(String name, FPlayer def, boolean msg)
|
|
||||||
{
|
|
||||||
FPlayer ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
|
||||||
{
|
|
||||||
// TODO: Easy fix for now
|
|
||||||
//FPlayer fplayer = FPlayerColl.get().getBestIdMatch(name);
|
|
||||||
FPlayer fplayer = FPlayerColl.get().getId2entity().get(name);
|
|
||||||
if (fplayer != null)
|
|
||||||
{
|
|
||||||
ret = fplayer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
|
||||||
{
|
|
||||||
this.msg("<b>No player match found for \"<p>%s<b>\".", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsBestFPlayerMatch(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx, FPlayer def)
|
|
||||||
{
|
|
||||||
return this.argAsBestFPlayerMatch(idx, def, true);
|
|
||||||
}
|
|
||||||
public FPlayer argAsBestFPlayerMatch(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsBestFPlayerMatch(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FACTION ======================
|
|
||||||
public Faction strAsFaction(String name, Faction def, boolean msg)
|
|
||||||
{
|
|
||||||
Faction ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
|
||||||
{
|
|
||||||
Faction faction = null;
|
|
||||||
|
|
||||||
// First we try an exact match
|
|
||||||
if (faction == null)
|
|
||||||
{
|
|
||||||
faction = FactionColl.get().getByTag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next we match faction tags
|
|
||||||
if (faction == null)
|
|
||||||
{
|
|
||||||
faction = FactionColl.get().getBestTagMatch(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next we match player names
|
|
||||||
if (faction == null)
|
|
||||||
{
|
|
||||||
// TODO: Easy fix for now
|
|
||||||
//FPlayer fplayer = FPlayerColl.get().getBestIdMatch(name);
|
|
||||||
FPlayer fplayer = FPlayerColl.get().getId2entity().get(name);
|
|
||||||
|
|
||||||
if (fplayer != null)
|
|
||||||
{
|
|
||||||
faction = fplayer.getFaction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faction != null)
|
|
||||||
{
|
|
||||||
ret = faction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
|
||||||
{
|
|
||||||
this.msg("<b>The faction or player \"<p>%s<b>\" could not be found.", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public Faction argAsFaction(int idx, Faction def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsFaction(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public Faction argAsFaction(int idx, Faction def)
|
|
||||||
{
|
|
||||||
return this.argAsFaction(idx, def, true);
|
|
||||||
}
|
|
||||||
public Faction argAsFaction(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsFaction(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FACTION FLAG ======================
|
|
||||||
public FFlag strAsFactionFlag(String name, FFlag def, boolean msg)
|
|
||||||
{
|
|
||||||
FFlag ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
|
||||||
{
|
|
||||||
FFlag flag = FFlag.parse(name);
|
|
||||||
if (flag != null)
|
|
||||||
{
|
|
||||||
ret = flag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
|
||||||
{
|
|
||||||
this.msg("<b>The faction-flag \"<p>%s<b>\" could not be found.", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public FFlag argAsFactionFlag(int idx, FFlag def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsFactionFlag(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public FFlag argAsFactionFlag(int idx, FFlag def)
|
|
||||||
{
|
|
||||||
return this.argAsFactionFlag(idx, def, true);
|
|
||||||
}
|
|
||||||
public FFlag argAsFactionFlag(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsFactionFlag(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FACTION PERM ======================
|
|
||||||
public FPerm strAsFactionPerm(String name, FPerm def, boolean msg)
|
|
||||||
{
|
|
||||||
FPerm ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
|
||||||
{
|
|
||||||
FPerm perm = FPerm.parse(name);
|
|
||||||
if (perm != null)
|
|
||||||
{
|
|
||||||
ret = perm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
|
||||||
{
|
|
||||||
this.msg("<b>The faction-perm \"<p>%s<b>\" could not be found.", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public FPerm argAsFactionPerm(int idx, FPerm def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsFactionPerm(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public FPerm argAsFactionPerm(int idx, FPerm def)
|
|
||||||
{
|
|
||||||
return this.argAsFactionPerm(idx, def, true);
|
|
||||||
}
|
|
||||||
public FPerm argAsFactionPerm(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsFactionPerm(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FACTION REL ======================
|
|
||||||
public Rel strAsRel(String name, Rel def, boolean msg)
|
|
||||||
{
|
|
||||||
Rel ret = def;
|
|
||||||
|
|
||||||
if (name != null)
|
|
||||||
{
|
|
||||||
Rel perm = Rel.parse(name);
|
|
||||||
if (perm != null)
|
|
||||||
{
|
|
||||||
ret = perm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg && ret == null)
|
|
||||||
{
|
|
||||||
this.msg("<b>The role \"<p>%s<b>\" could not be found.", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public Rel argAsRel(int idx, Rel def, boolean msg)
|
|
||||||
{
|
|
||||||
return this.strAsRel(this.argAsString(idx), def, msg);
|
|
||||||
}
|
|
||||||
public Rel argAsRel(int idx, Rel def)
|
|
||||||
{
|
|
||||||
return this.argAsRel(idx, def, true);
|
|
||||||
}
|
|
||||||
public Rel argAsRel(int idx)
|
|
||||||
{
|
|
||||||
return this.argAsRel(idx, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.massivecraft.factions.cmd.req;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.ConfServer;
|
||||||
|
import com.massivecraft.mcore.cmd.MCommand;
|
||||||
|
import com.massivecraft.mcore.cmd.req.ReqAbstract;
|
||||||
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
|
public class ReqBankCommandsEnabled extends ReqAbstract
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
private static ReqBankCommandsEnabled i = new ReqBankCommandsEnabled();
|
||||||
|
public static ReqBankCommandsEnabled get() { return i; }
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(CommandSender sender, MCommand command)
|
||||||
|
{
|
||||||
|
return ConfServer.econEnabled && ConfServer.bankEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createErrorMessage(CommandSender sender, MCommand command)
|
||||||
|
{
|
||||||
|
if (!ConfServer.bankEnabled)
|
||||||
|
{
|
||||||
|
return Txt.parse("<b>The Factions bank system is disabled on this server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Txt.parse("<b>The Factions economy features are disabled on this server.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -40,7 +40,7 @@ public class ReqRoleIsAtLeast extends ReqAbstract
|
|||||||
@Override
|
@Override
|
||||||
public String createErrorMessage(CommandSender sender, MCommand command)
|
public String createErrorMessage(CommandSender sender, MCommand command)
|
||||||
{
|
{
|
||||||
return Txt.parse("<b>You must be <h>%s <b>or higher to do this.", Txt.getNicedEnum(this.rel));
|
return Txt.parse("<b>You must be <h>%s <b>or higher to "+(command == null ? "do that" : command.getDesc())+".", Txt.getNicedEnum(this.rel));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user