Saber-Factions/src/com/massivecraft/factions/commands/FCommandDisband.java

87 lines
2.5 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
2011-09-24 03:22:53 +02:00
import com.massivecraft.factions.Econ;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.SpoutFeatures;
import com.massivecraft.factions.struct.Role;
public class FCommandDisband extends FBaseCommand {
public FCommandDisband() {
aliases.add("disband");
senderMustBePlayer = false;
optionalParameters.add("faction tag");
helpDescription = "Disband a faction";
}
@Override
public void perform() {
Faction faction = null;
if( parameters.size() > 0) {
faction = Faction.findByTag(parameters.get(0));
if( faction == null || !faction.isNormal()) {
sendMessage("Faction \"" + parameters.get(0) + "\" not found");
return;
}
if ( ! Factions.hasPermDisband(sender)) {
if (me.getFaction() == faction) {
parameters.clear();
}
else {
sendMessage("You do not have sufficient permission to disband other factions.");
return;
}
}
}
if (parameters.isEmpty()) {
if ( ! assertHasFaction()) {
return;
}
if ( ! assertMinRole(Role.ADMIN)) {
return;
}
faction = me.getFaction();
if (faction.isPermanent() && !Factions.hasPermDisband(sender)) {
sendMessage("Your faction is designated as permanent, so you cannot disband it.");
return;
}
}
// Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) {
fplayer.sendMessage((senderIsConsole ? "A server admin" : me.getNameAndRelevant(fplayer))+Conf.colorSystem+" disbanded your faction.");
} else {
fplayer.sendMessage((senderIsConsole ? "A server admin" : me.getNameAndRelevant(fplayer))+Conf.colorSystem+" disbanded the faction "+faction.getTag(fplayer)+".");
}
}
2011-09-24 03:22:53 +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();
Econ.addMoney(me.getName(), amount ); //Give all the faction's money to the disbander
if (amount > 0.0) {
String amountString = Econ.moneyString(amount);
sendMessage("You have been given the disbanded faction's bank, totaling "+amountString+".");
Factions.log(player.getName() + " has been given bank holdings of "+amountString+" from disbanding "+faction.getTag()+".");
}
2011-09-24 03:22:53 +02:00
}
Faction.delete( faction.getId() );
SpoutFeatures.updateAppearances();
}
}