mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-26 04:05:56 +01:00
* added command to disband a faction (/f disband <tag>)
This commit is contained in:
parent
bffa9df8f7
commit
516a98c970
@ -26,6 +26,7 @@ import org.mcteam.factions.commands.FCommandClaim;
|
||||
import org.mcteam.factions.commands.FCommandCreate;
|
||||
import org.mcteam.factions.commands.FCommandDeinvite;
|
||||
import org.mcteam.factions.commands.FCommandDescription;
|
||||
import org.mcteam.factions.commands.FCommandDisband;
|
||||
import org.mcteam.factions.commands.FCommandHelp;
|
||||
import org.mcteam.factions.commands.FCommandHome;
|
||||
import org.mcteam.factions.commands.FCommandInvite;
|
||||
@ -109,6 +110,7 @@ public class Factions extends JavaPlugin {
|
||||
commands.add(new FCommandCreate());
|
||||
commands.add(new FCommandDeinvite());
|
||||
commands.add(new FCommandDescription());
|
||||
commands.add(new FCommandDisband());
|
||||
commands.add(new FCommandHome());
|
||||
commands.add(new FCommandInvite());
|
||||
commands.add(new FCommandJoin());
|
||||
@ -232,6 +234,10 @@ public class Factions extends JavaPlugin {
|
||||
return hasPerm(sender, "factions.lock", true);
|
||||
}
|
||||
|
||||
public static boolean hasPermDisband(CommandSender sender) {
|
||||
return hasPerm(sender, "factions.disband", true);
|
||||
}
|
||||
|
||||
private static boolean hasPerm(CommandSender sender, String permNode, boolean fallbackOnlyOp) {
|
||||
if (Factions.Permissions == null || ! (sender instanceof Player)) {
|
||||
return fallbackOnlyOp == false || sender.isOp();
|
||||
|
35
src/org/mcteam/factions/commands/FCommandDisband.java
Normal file
35
src/org/mcteam/factions/commands/FCommandDisband.java
Normal file
@ -0,0 +1,35 @@
|
||||
package org.mcteam.factions.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.mcteam.factions.Faction;
|
||||
import org.mcteam.factions.Factions;
|
||||
|
||||
public class FCommandDisband extends FBaseCommand {
|
||||
|
||||
public FCommandDisband() {
|
||||
aliases.add("disband");
|
||||
|
||||
requiredParameters.add("faction tag");
|
||||
|
||||
helpDescription = "Disband a faction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return Factions.hasPermDisband(sender);
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
if( parameters.size() > 0) {
|
||||
Faction faction = Faction.findByTag(parameters.get(0));
|
||||
|
||||
if( faction.getId() > 0 ) {
|
||||
me.sendMessage("Faction " + faction.getTag() + " got disbanded");
|
||||
Faction.delete( faction.getId() );
|
||||
} else {
|
||||
me.sendMessage("Faction " + parameters.get(0) + "not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user