Factions/src/com/massivecraft/factions/cmd/CmdDisband.java

94 lines
2.5 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPlayers;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
2011-10-09 20:10:19 +02:00
public class CmdDisband extends FCommand
{
2011-10-09 20:10:19 +02:00
public CmdDisband()
{
super();
this.aliases.add("disband");
//this.requiredArgs.add("");
this.optionalArgs.put("faction tag", "yours");
2011-10-09 21:57:43 +02:00
this.permission = Permission.DISBAND.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform()
{
// The faction, default to your own.. but null if console sender.
2011-10-09 18:35:39 +02:00
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
if (faction == null) return;
2011-10-09 18:35:39 +02:00
boolean isMyFaction = fme == null ? false : faction == myFaction;
if (isMyFaction)
{
if ( ! assertMinRole(Role.ADMIN)) return;
}
else
{
if ( ! Permission.DISBAND_ANY.has(sender, true))
{
return;
}
}
if (faction.isPermanent())
{
2011-10-10 13:40:24 +02:00
msg("<i>This faction is designated as permanent, so you cannot disband it.");
return;
}
// Inform all players
for (FPlayer fplayer : FPlayers.i.getOnline())
{
String who = senderIsConsole ? "A server admin" : fme.getNameAndRelevant(fplayer);
if (fplayer.getFaction() == faction)
{
2011-10-10 13:40:24 +02:00
fplayer.msg("<h>%s<i> disbanded your faction.", who);
}
else
{
2011-10-10 13:40:24 +02:00
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
}
}
P.p.log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
2011-10-12 17:25:01 +02:00
if (Econ.shouldBeUsed())
{
2011-10-12 17:25:01 +02:00
//Give all the faction's money to the disbander
double amount = faction.getAccount().balance();
fme.getAccount().add(amount);
faction.getAccount().remove();
if (amount > 0.0)
{
Some tweaking of the faction bank code... The new help page with bank related commands will now only be shown if banks are enabled and the Economy is enabled and hooked in. Shortened a couple of command descriptions to fit on one line. Made Deposit, Pay, and Withdraw commands additionally log to the server console/log. When bank is given to person disbanding a faction, it now lets them know and logs it to the server log. Added commands to commandDisable list in plugin.yml, along with "permanent" command which I'd missed adding before Added new permission node factions.viewAnyFactionBalance (granted by default if using superperms), which is required to view the bank balance of other factions For reference, about the faction bank addition as a whole... New conf.json settings: "bankEnabled": true, - enable faction banks "bankMembersCanWithdraw": false, - have to be at least moderator to withdraw or pay money to another faction, unless this is set to true "bankFactionPaysCosts": true, - if true, payments for faction command costs are charged to faction bank "bankFactionPaysLandCosts": true, - if true, payments for land claims are charged to faction bank New commands: /f balance *<faction tag> - Shows the bank balance of a specified faction (if permission checks out), or the player's faction if none is specified /f deposit <amount> - Deposit money into your faction's bank /f pay <faction tag> <amount> - Pay money from your faction bank to another faction (requires moderator or admin status) /f withdraw <amount> - Withdraw money from your faction's bank (requires moderator or admin status, unless "bankMembersCanWithdraw" is set to true) New permission node: factions.viewAnyFactionBalance - Allows the player to view the faction bank balance of all factions (default)
2011-10-01 12:59:09 +02:00
String amountString = Econ.moneyString(amount);
2011-10-10 13:40:24 +02:00
msg("<i>You have been given the disbanded faction's bank, totaling %s.", amountString);
P.p.log(fme.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
Some tweaking of the faction bank code... The new help page with bank related commands will now only be shown if banks are enabled and the Economy is enabled and hooked in. Shortened a couple of command descriptions to fit on one line. Made Deposit, Pay, and Withdraw commands additionally log to the server console/log. When bank is given to person disbanding a faction, it now lets them know and logs it to the server log. Added commands to commandDisable list in plugin.yml, along with "permanent" command which I'd missed adding before Added new permission node factions.viewAnyFactionBalance (granted by default if using superperms), which is required to view the bank balance of other factions For reference, about the faction bank addition as a whole... New conf.json settings: "bankEnabled": true, - enable faction banks "bankMembersCanWithdraw": false, - have to be at least moderator to withdraw or pay money to another faction, unless this is set to true "bankFactionPaysCosts": true, - if true, payments for faction command costs are charged to faction bank "bankFactionPaysLandCosts": true, - if true, payments for land claims are charged to faction bank New commands: /f balance *<faction tag> - Shows the bank balance of a specified faction (if permission checks out), or the player's faction if none is specified /f deposit <amount> - Deposit money into your faction's bank /f pay <faction tag> <amount> - Pay money from your faction bank to another faction (requires moderator or admin status) /f withdraw <amount> - Withdraw money from your faction's bank (requires moderator or admin status, unless "bankMembersCanWithdraw" is set to true) New permission node: factions.viewAnyFactionBalance - Allows the player to view the faction bank balance of all factions (default)
2011-10-01 12:59:09 +02:00
}
2011-09-24 03:22:53 +02:00
}
faction.detach();
SpoutFeatures.updateAppearances();
}
}