2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2011-08-20 03:36:23 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-10-05 12:13:54 +02:00
|
|
|
import com.massivecraft.factions.integration.Econ;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.FPlayers;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-08-20 03:36:23 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2011-10-05 12:13:54 +02:00
|
|
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2011-09-13 05:23:44 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
|
|
|
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2011-10-09 20:10:19 +02:00
|
|
|
public class CmdDisband extends FCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-10-09 20:10:19 +02:00
|
|
|
public CmdDisband()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("disband");
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("faction tag", "yours");
|
2011-06-30 12:56:02 +02:00
|
|
|
|
2011-10-09 21:57:43 +02:00
|
|
|
this.permission = Permission.DISBAND.node;
|
|
|
|
this.disableOnLock = true;
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
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);
|
2011-10-09 14:53:38 +02:00
|
|
|
if (faction == null) return;
|
|
|
|
|
2011-10-09 18:35:39 +02:00
|
|
|
boolean isMyFaction = fme == null ? false : faction == myFaction;
|
2011-10-09 14:53:38 +02:00
|
|
|
|
|
|
|
if (isMyFaction)
|
|
|
|
{
|
|
|
|
if ( ! assertMinRole(Role.ADMIN)) return;
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
2011-10-09 14:53:38 +02:00
|
|
|
else
|
|
|
|
{
|
2011-10-09 21:57:43 +02:00
|
|
|
if ( ! Permission.DISBAND_ANY.has(me, true))
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-09-13 05:23:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-10-09 14:53:38 +02:00
|
|
|
}
|
2011-09-13 05:23:44 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if (faction.isPermanent())
|
|
|
|
{
|
2011-10-10 13:40:24 +02:00
|
|
|
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
2011-10-09 14:53:38 +02:00
|
|
|
return;
|
2011-09-13 05:23:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Inform all players
|
2011-10-09 14:53:38 +02:00
|
|
|
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);
|
2011-10-09 14:53:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-10 13:40:24 +02:00
|
|
|
fplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getTag(fplayer));
|
2011-09-13 05:23:44 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-24 03:22:53 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if (Conf.bankEnabled)
|
|
|
|
{
|
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
|
|
|
double amount = faction.getMoney();
|
2011-10-09 14:53:38 +02:00
|
|
|
Econ.addMoney(fme.getId(), amount); //Give all the faction's money to the disbander
|
|
|
|
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);
|
2011-10-09 14:53:38 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
faction.detach();
|
|
|
|
|
2011-09-13 05:23:44 +02:00
|
|
|
SpoutFeatures.updateAppearances();
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
|
|
|
}
|