Reformat
This commit is contained in:
@@ -32,30 +32,38 @@ public abstract class FCommand extends MCommand<P> {
|
||||
// The money commands must be disabled if money should not be used.
|
||||
isMoneyCommand = false;
|
||||
|
||||
senderMustBeMember = false; senderMustBeModerator = false; senderMustBeAdmin = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, List<String> args, List<MCommand<?>> commandChain) {
|
||||
if (sender instanceof Player) {
|
||||
this.fme = FPlayers.i.get((Player) sender); this.myFaction = this.fme.getFaction();
|
||||
this.fme = FPlayers.i.get((Player) sender);
|
||||
this.myFaction = this.fme.getFaction();
|
||||
} else {
|
||||
this.fme = null; this.myFaction = null;
|
||||
} super.execute(sender, args, commandChain);
|
||||
this.fme = null;
|
||||
this.myFaction = null;
|
||||
}
|
||||
super.execute(sender, args, commandChain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (p.getLocked() && this.disableOnLock) {
|
||||
msg("<b>Factions was locked by an admin. Please try again later."); return false;
|
||||
msg("<b>Factions was locked by an admin. Please try again later.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isMoneyCommand && !Conf.econEnabled) {
|
||||
msg("<b>Faction economy features are disabled on this server."); return false;
|
||||
msg("<b>Faction economy features are disabled on this server.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isMoneyCommand && !Conf.bankEnabled) {
|
||||
msg("<b>The faction bank system is disabled on this server."); return false;
|
||||
msg("<b>The faction bank system is disabled on this server.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -63,24 +71,34 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
@Override
|
||||
public boolean validSenderType(CommandSender sender, boolean informSenderIfNot) {
|
||||
boolean superValid = super.validSenderType(sender, informSenderIfNot); if (!superValid) { return false; }
|
||||
boolean superValid = super.validSenderType(sender, informSenderIfNot);
|
||||
if (!superValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) { return true; }
|
||||
if (!(this.senderMustBeMember || this.senderMustBeModerator || this.senderMustBeAdmin)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) { return false; }
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FPlayer fplayer = FPlayers.i.get((Player) sender);
|
||||
|
||||
if (!fplayer.hasFaction()) {
|
||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction.")); return false;
|
||||
sender.sendMessage(p.txt.parse("<b>You are not member of any faction."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.senderMustBeModerator && !fplayer.getRole().isAtLeast(Role.MODERATOR)) {
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort())); return false;
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.senderMustBeAdmin && !fplayer.getRole().isAtLeast(Role.ADMIN)) {
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort())); return false;
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -91,19 +109,27 @@ public abstract class FCommand extends MCommand<P> {
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean assertHasFaction() {
|
||||
if (me == null) { return true; }
|
||||
if (me == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!fme.hasFaction()) {
|
||||
sendMessage("You are not member of any faction."); return false;
|
||||
} return true;
|
||||
sendMessage("You are not member of any faction.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean assertMinRole(Role role) {
|
||||
if (me == null) { return true; }
|
||||
if (me == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fme.getRole().value < role.value) {
|
||||
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + "."); return false;
|
||||
} return true;
|
||||
msg("<b>You <h>must be " + role + "<b> to " + this.getHelpShort() + ".");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@@ -115,7 +141,8 @@ public abstract class FCommand extends MCommand<P> {
|
||||
FPlayer ret = def;
|
||||
|
||||
if (name != null) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name); FPlayer fplayer = FPlayers.i.get(player);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
if (fplayer != null) {
|
||||
ret = fplayer;
|
||||
}
|
||||
@@ -176,7 +203,8 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
// Next we match player names
|
||||
if (faction == null) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name); FPlayer fplayer = FPlayers.i.get(player);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
if (fplayer != null) {
|
||||
faction = fplayer.getFaction();
|
||||
}
|
||||
@@ -237,19 +265,27 @@ public abstract class FCommand extends MCommand<P> {
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
||||
public boolean payForCommand(double cost, String toDoThis, String forDoingThis) {
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; }
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||
return Econ.modifyMoney(myFaction, -cost, toDoThis, forDoingThis);
|
||||
} else { return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis); }
|
||||
} else {
|
||||
return Econ.modifyMoney(fme, -cost, toDoThis, forDoingThis);
|
||||
}
|
||||
}
|
||||
|
||||
// like above, but just make sure they can pay; returns true unless person can't afford the cost
|
||||
public boolean canAffordCommand(double cost, String toDoThis) {
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) { return true; }
|
||||
if (!Econ.shouldBeUsed() || this.fme == null || cost == 0.0 || fme.isAdminBypassing()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && fme.hasFaction()) {
|
||||
return Econ.hasAtLeast(myFaction, cost, toDoThis);
|
||||
} else { return Econ.hasAtLeast(fme, cost, toDoThis); }
|
||||
} else {
|
||||
return Econ.hasAtLeast(fme, cost, toDoThis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user