Made a Factions.disband() method into the api.
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.event.FactionDisbandEvent;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.scoreboards.FTeamWrapper;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class CmdDisband extends FCommand {
|
||||
@@ -59,46 +54,8 @@ public class CmdDisband extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
String who = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(fplayer);
|
||||
if (fplayer.getFaction() == faction) {
|
||||
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, who);
|
||||
} else {
|
||||
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, who, faction.getTag(fplayer));
|
||||
}
|
||||
}
|
||||
if (Conf.logFactionDisband) {
|
||||
//TODO: Format this correctly and translate.
|
||||
P.p.log("The faction " + faction.getTag() + " (" + faction.getId() + ") was disbanded by " + (senderIsConsole ? "console command" : fme.getName()) + ".");
|
||||
}
|
||||
|
||||
if (Econ.shouldBeUsed() && !senderIsConsole) {
|
||||
//Give all the faction's money to the disbander
|
||||
double amount = Econ.getBalance(faction.getAccountId());
|
||||
Econ.transferMoney(fme, faction, fme, amount, false);
|
||||
|
||||
if (amount > 0.0) {
|
||||
String amountString = Econ.moneyString(amount);
|
||||
msg(TL.COMMAND_DISBAND_HOLDINGS, amountString);
|
||||
//TODO: Format this correctly and translate
|
||||
P.p.log(fme.getName() + " has been given bank holdings of " + amountString + " from disbanding " + faction.getTag() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
Factions.getInstance().removeFaction(faction.getId());
|
||||
FTeamWrapper.applyUpdates(faction);
|
||||
//Success
|
||||
faction.disband(me);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user