2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
2011-05-08 17:44:00 +02:00
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
2011-07-18 22:06:02 +02:00
|
|
|
|
2011-08-20 03:36:23 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
|
|
|
import com.massivecraft.factions.Factions;
|
2011-08-20 03:36:23 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.SpoutFeatures;
|
2011-05-08 17:44:00 +02:00
|
|
|
|
|
|
|
public class FCommandDisband extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandDisband() {
|
|
|
|
aliases.add("disband");
|
|
|
|
|
2011-06-30 12:56:02 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
|
2011-05-08 17:44:00 +02:00
|
|
|
requiredParameters.add("faction tag");
|
|
|
|
|
|
|
|
helpDescription = "Disband a faction";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasPermission(CommandSender sender) {
|
|
|
|
return Factions.hasPermDisband(sender);
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-05-08 17:44:00 +02:00
|
|
|
public void perform() {
|
|
|
|
if( parameters.size() > 0) {
|
|
|
|
Faction faction = Faction.findByTag(parameters.get(0));
|
|
|
|
|
2011-08-20 03:36:23 +02:00
|
|
|
if( faction == null || !faction.isNormal()) {
|
2011-06-30 12:56:02 +02:00
|
|
|
sendMessage("Faction " + parameters.get(0) + "not found");
|
2011-08-20 03:36:23 +02:00
|
|
|
return;
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
2011-08-20 03:36:23 +02:00
|
|
|
|
|
|
|
// Inform all players
|
|
|
|
for (FPlayer fplayer : FPlayer.getAllOnline()) {
|
|
|
|
if (fplayer.getFaction() == faction) {
|
|
|
|
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" disbanded your faction.");
|
|
|
|
} else {
|
|
|
|
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" disbanded the faction "+faction.getTag(fplayer)+".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Faction.delete( faction.getId() );
|
|
|
|
SpoutFeatures.updateAppearances();
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|