Faction admins can now disband their own faction using /f disband; note that use of /f disband with another faction specified (/f disband <faction tag>) still requires the factions.disband permission, but the permission is not required for faction admins disbanding their own faction

This commit is contained in:
Brettflan 2011-09-12 22:23:44 -05:00
parent 120039b07f
commit 632e2b2d1c

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.commands; package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.SpoutFeatures; import com.massivecraft.factions.SpoutFeatures;
import com.massivecraft.factions.struct.Role;
public class FCommandDisband extends FBaseCommand { public class FCommandDisband extends FBaseCommand {
@ -15,26 +15,45 @@ public class FCommandDisband extends FBaseCommand {
senderMustBePlayer = false; senderMustBePlayer = false;
requiredParameters.add("faction tag"); optionalParameters.add("faction tag");
helpDescription = "Disband a faction"; helpDescription = "Disband a faction";
} }
@Override
public boolean hasPermission(CommandSender sender) {
return Factions.hasPermDisband(sender);
}
@Override @Override
public void perform() { public void perform() {
Faction faction = null;
if( parameters.size() > 0) { if( parameters.size() > 0) {
Faction faction = Faction.findByTag(parameters.get(0)); faction = Faction.findByTag(parameters.get(0));
if( faction == null || !faction.isNormal()) { if( faction == null || !faction.isNormal()) {
sendMessage("Faction " + parameters.get(0) + "not found"); sendMessage("Faction \"" + parameters.get(0) + "\" not found");
return; 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();
}
// Inform all players // Inform all players
for (FPlayer fplayer : FPlayer.getAllOnline()) { for (FPlayer fplayer : FPlayer.getAllOnline()) {
if (fplayer.getFaction() == faction) { if (fplayer.getFaction() == faction) {
@ -45,7 +64,6 @@ public class FCommandDisband extends FBaseCommand {
} }
Faction.delete( faction.getId() ); Faction.delete( faction.getId() );
SpoutFeatures.updateAppearances(); SpoutFeatures.updateAppearances();
}
}
}
} }