2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
2011-05-08 17:44:00 +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-09-13 05:23:44 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
|
|
|
|
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-09-13 05:23:44 +02:00
|
|
|
optionalParameters.add("faction tag");
|
2011-05-08 17:44:00 +02:00
|
|
|
|
|
|
|
helpDescription = "Disband a faction";
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-05-08 17:44:00 +02:00
|
|
|
public void perform() {
|
2011-09-13 05:23:44 +02:00
|
|
|
|
|
|
|
Faction faction = null;
|
|
|
|
|
|
|
|
if( parameters.size() > 0) {
|
|
|
|
faction = Faction.findByTag(parameters.get(0));
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2011-08-20 03:36:23 +02:00
|
|
|
if( faction == null || !faction.isNormal()) {
|
2011-09-13 05:23:44 +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
|
|
|
|
2011-09-13 05:23:44 +02:00
|
|
|
if ( ! Factions.hasPermDisband(sender)) {
|
|
|
|
if (me.getFaction() == faction) {
|
|
|
|
parameters.clear();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sendMessage("You do not have sufficient permission to disband other factions.");
|
|
|
|
return;
|
2011-08-20 03:36:23 +02:00
|
|
|
}
|
|
|
|
}
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|
2011-09-13 05:23:44 +02:00
|
|
|
if (parameters.isEmpty()) {
|
|
|
|
if ( ! assertHasFaction()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ! assertMinRole(Role.ADMIN)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faction = me.getFaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|