2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2012-03-13 13:58:51 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
Additional logging, with new conf.json settings to enable/disable logging of specific events:
"logFactionCreate": true, - log faction creation
"logFactionDisband": true, - log factions being disbanded, by command or by circumstance
"logFactionJoin": true, - log player joining a faction
"logFactionKick": true, - log player being kicked from a faction
"logFactionLeave": true, - log player leaving a faction
"logLandClaims": true, - log land being claimed (including safe zone and war zone)
"logLandUnclaims": true, - log land being unclaimed (including safe zone and war zone)
"logMoneyTransactions": true, - log money being deposited, withdrawn, and otherwise transferred in relation to faction banks
Also a fix for a potential NPE from players logging out and Spout appearance handler referencing them afterwards
2011-10-23 19:50:02 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2012-03-13 13:58:51 +01:00
|
|
|
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
|
|
|
import com.massivecraft.factions.event.FactionDisbandEvent;
|
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-13 11:10:29 +02:00
|
|
|
if ( ! Permission.DISBAND_ANY.has(sender, 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-12-16 07:22:36 +01:00
|
|
|
if (! faction.isNormal())
|
|
|
|
{
|
|
|
|
msg("<i>You cannot disband the Wilderness, SafeZone, or WarZone.");
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2012-03-13 13:58:51 +01:00
|
|
|
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(me, faction.getId());
|
|
|
|
Bukkit.getServer().getPluginManager().callEvent(disbandEvent);
|
|
|
|
if(disbandEvent.isCancelled()) return;
|
|
|
|
|
|
|
|
// Send FPlayerLeaveEvent for each player in the faction
|
|
|
|
for ( FPlayer fplayer : faction.getFPlayers() )
|
|
|
|
{
|
|
|
|
Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, faction, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND));
|
|
|
|
}
|
|
|
|
|
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())
|
|
|
|
{
|
2011-10-21 19:20:33 +02:00
|
|
|
String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer);
|
2011-10-09 14:53:38 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
Additional logging, with new conf.json settings to enable/disable logging of specific events:
"logFactionCreate": true, - log faction creation
"logFactionDisband": true, - log factions being disbanded, by command or by circumstance
"logFactionJoin": true, - log player joining a faction
"logFactionKick": true, - log player being kicked from a faction
"logFactionLeave": true, - log player leaving a faction
"logLandClaims": true, - log land being claimed (including safe zone and war zone)
"logLandUnclaims": true, - log land being unclaimed (including safe zone and war zone)
"logMoneyTransactions": true, - log money being deposited, withdrawn, and otherwise transferred in relation to faction banks
Also a fix for a potential NPE from players logging out and Spout appearance handler referencing them afterwards
2011-10-23 19:50:02 +02:00
|
|
|
if (Conf.logFactionDisband)
|
|
|
|
P.p.log("The faction "+faction.getTag()+" ("+faction.getId()+") was disbanded by "+(senderIsConsole ? "console command" : fme.getName())+".");
|
2011-10-13 11:10:29 +02:00
|
|
|
|
2012-02-07 21:57:03 +01:00
|
|
|
if (Econ.shouldBeUsed() && ! senderIsConsole)
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-10-12 17:25:01 +02:00
|
|
|
//Give all the faction's money to the disbander
|
2012-01-17 02:36:32 +01:00
|
|
|
double amount = Econ.getBalance(faction.getAccountId());
|
|
|
|
Econ.transferMoney(fme, faction, fme, amount, false);
|
2011-10-12 17:25:01 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
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();
|
Additional logging, with new conf.json settings to enable/disable logging of specific events:
"logFactionCreate": true, - log faction creation
"logFactionDisband": true, - log factions being disbanded, by command or by circumstance
"logFactionJoin": true, - log player joining a faction
"logFactionKick": true, - log player being kicked from a faction
"logFactionLeave": true, - log player leaving a faction
"logLandClaims": true, - log land being claimed (including safe zone and war zone)
"logLandUnclaims": true, - log land being unclaimed (including safe zone and war zone)
"logMoneyTransactions": true, - log money being deposited, withdrawn, and otherwise transferred in relation to faction banks
Also a fix for a potential NPE from players logging out and Spout appearance handler referencing them afterwards
2011-10-23 19:50:02 +02:00
|
|
|
|
2011-09-13 05:23:44 +02:00
|
|
|
SpoutFeatures.updateAppearances();
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
|
|
|
}
|