mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 10:37:41 +01:00
Updated for new commands format
This commit is contained in:
parent
f904c91443
commit
8b4332e842
@ -24,6 +24,7 @@
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -51,6 +52,7 @@
|
|||||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||||
import com.sk89q.minecraft.util.commands.MissingNestedCommandException;
|
import com.sk89q.minecraft.util.commands.MissingNestedCommandException;
|
||||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||||
|
import com.sk89q.minecraft.util.commands.Injector;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
|
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
|
||||||
@ -116,6 +118,16 @@ public boolean hasPermission(CommandSender player, String perm) {
|
|||||||
return plugin.hasPermission(player, perm);
|
return plugin.hasPermission(player, perm);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
commands.setInjector(new Injector() {
|
||||||
|
public Object getInstance(Class<?> cls) throws InvocationTargetException, IllegalAccessException, InstantiationException {
|
||||||
|
try {
|
||||||
|
return cls.getConstructor(WorldGuardPlugin.class).newInstance(this);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Register command classes
|
// Register command classes
|
||||||
commands.register(ToggleCommands.class);
|
commands.register(ToggleCommands.class);
|
||||||
@ -203,7 +215,7 @@ public void onDisable() {
|
|||||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
String[] args) {
|
String[] args) {
|
||||||
try {
|
try {
|
||||||
commands.execute(cmd.getName(), args, sender, this, sender);
|
commands.execute(cmd.getName(), args, sender, sender);
|
||||||
} catch (CommandPermissionsException e) {
|
} catch (CommandPermissionsException e) {
|
||||||
sender.sendMessage(ChatColor.RED + "You don't have permission.");
|
sender.sendMessage(ChatColor.RED + "You don't have permission.");
|
||||||
} catch (MissingNestedCommandException e) {
|
} catch (MissingNestedCommandException e) {
|
||||||
|
@ -33,13 +33,15 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
public class GeneralCommands {
|
public class GeneralCommands {
|
||||||
|
private final WorldGuardPlugin plugin;
|
||||||
|
|
||||||
|
public GeneralCommands(WorldGuardPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Command(aliases = {"god"},
|
@Command(aliases = {"god"}, usage = "[player]",
|
||||||
usage = "[player]",
|
desc = "Enable godmode on a player", flags = "s", max = 1)
|
||||||
desc = "Enable godmode on a player",
|
public void god(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "s", min = 0, max = 1)
|
|
||||||
public static void god(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
ConfigurationManager config = plugin.getGlobalStateManager();
|
ConfigurationManager config = plugin.getGlobalStateManager();
|
||||||
|
|
||||||
Iterable<Player> targets = null;
|
Iterable<Player> targets = null;
|
||||||
@ -82,12 +84,9 @@ public static void god(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"ungod"},
|
@Command(aliases = {"ungod"}, usage = "[player]",
|
||||||
usage = "[player]",
|
desc = "Disable godmode on a player", flags = "s", max = 1)
|
||||||
desc = "Disable godmode on a player",
|
public void ungod(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "s", min = 0, max = 1)
|
|
||||||
public static void ungod(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
ConfigurationManager config = plugin.getGlobalStateManager();
|
ConfigurationManager config = plugin.getGlobalStateManager();
|
||||||
|
|
||||||
Iterable<Player> targets = null;
|
Iterable<Player> targets = null;
|
||||||
@ -129,12 +128,8 @@ public static void ungod(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"heal"},
|
@Command(aliases = {"heal"}, usage = "[player]", desc = "Heal a player", flags = "s", max = 1)
|
||||||
usage = "[player]",
|
public void heal(CommandContext args,CommandSender sender) throws CommandException {
|
||||||
desc = "Heal a player",
|
|
||||||
flags = "s", min = 0, max = 1)
|
|
||||||
public static void heal(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Iterable<Player> targets = null;
|
Iterable<Player> targets = null;
|
||||||
boolean included = false;
|
boolean included = false;
|
||||||
@ -176,10 +171,7 @@ public static void heal(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"slay"},
|
@Command(aliases = {"slay"}, usage = "[player]", desc = "Slay a player", flags = "s", max = 1)
|
||||||
usage = "[player]",
|
|
||||||
desc = "Slay a player",
|
|
||||||
flags = "s", min = 0, max = 1)
|
|
||||||
public static void slay(CommandContext args, WorldGuardPlugin plugin,
|
public static void slay(CommandContext args, WorldGuardPlugin plugin,
|
||||||
CommandSender sender) throws CommandException {
|
CommandSender sender) throws CommandException {
|
||||||
|
|
||||||
@ -222,13 +214,9 @@ public static void slay(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"locate"},
|
@Command(aliases = {"locate"}, usage = "[player]", desc = "Locate a player", max = 1)
|
||||||
usage = "[player]",
|
|
||||||
desc = "Locate a player",
|
|
||||||
flags = "", min = 0, max = 1)
|
|
||||||
@CommandPermissions({"worldguard.locate"})
|
@CommandPermissions({"worldguard.locate"})
|
||||||
public static void locate(CommandContext args, WorldGuardPlugin plugin,
|
public void locate(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
|
|
||||||
@ -244,13 +232,9 @@ public static void locate(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"stack", ";"},
|
@Command(aliases = {"stack", ";"}, usage = "", desc = "Stack items", max = 0)
|
||||||
usage = "",
|
|
||||||
desc = "Stack items",
|
|
||||||
flags = "", min = 0, max = 0)
|
|
||||||
@CommandPermissions({"worldguard.stack"})
|
@CommandPermissions({"worldguard.stack"})
|
||||||
public static void stack(CommandContext args, WorldGuardPlugin plugin,
|
public void stack(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
boolean ignoreMax = plugin.hasPermission(player, "worldguard.stack.illegitimate");
|
boolean ignoreMax = plugin.hasPermission(player, "worldguard.stack.illegitimate");
|
||||||
@ -288,7 +272,8 @@ public static void stack(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
// Blocks store their color in the damage value
|
// Blocks store their color in the damage value
|
||||||
if (item2.getTypeId() == item.getTypeId() &&
|
if (item2.getTypeId() == item.getTypeId() &&
|
||||||
(!ItemType.usesDamageValue(item.getTypeId())
|
(!ItemType.usesDamageValue(item.getTypeId())
|
||||||
|| item.getDurability() == item2.getDurability())) {
|
|| item.getDurability() == item2.getDurability()) &&
|
||||||
|
item.getEnchantments().equals(item2.getEnchantments())) {
|
||||||
// This stack won't fit in the parent stack
|
// This stack won't fit in the parent stack
|
||||||
if (item2.getAmount() > needed) {
|
if (item2.getAmount() > needed) {
|
||||||
item.setAmount(64);
|
item.setAmount(64);
|
||||||
|
@ -23,22 +23,21 @@
|
|||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
public class ProtectionCommands {
|
public class ProtectionCommands {
|
||||||
@Command(aliases = {"region"},
|
private final WorldGuardPlugin plugin;
|
||||||
desc = "Region management commands")
|
|
||||||
@NestedCommand({RegionCommands.class, RegionMemberCommands.class})
|
public ProtectionCommands(WorldGuardPlugin plugin) {
|
||||||
public static void region(CommandContext args, WorldGuardPlugin plugin,
|
this.plugin = plugin;
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"worldguard"},
|
@Command(aliases = {"region"}, desc = "Region management commands")
|
||||||
desc = "WorldGuard commands")
|
@NestedCommand({RegionCommands.class, RegionMemberCommands.class})
|
||||||
|
public void region(CommandContext args, CommandSender sender) {}
|
||||||
|
|
||||||
|
@Command(aliases = {"worldguard"}, desc = "WorldGuard commands")
|
||||||
@NestedCommand({WorldGuardCommands.class})
|
@NestedCommand({WorldGuardCommands.class})
|
||||||
public static void worldGuard(CommandContext args, WorldGuardPlugin plugin,
|
public void worldGuard(CommandContext args, CommandSender sender) {}
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -56,14 +56,16 @@
|
|||||||
import com.sk89q.worldguard.util.RegionUtil;
|
import com.sk89q.worldguard.util.RegionUtil;
|
||||||
|
|
||||||
public class RegionCommands {
|
public class RegionCommands {
|
||||||
|
private final WorldGuardPlugin plugin;
|
||||||
|
|
||||||
|
public RegionCommands(WorldGuardPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Command(aliases = {"define", "def", "d"},
|
@Command(aliases = {"define", "def", "d"}, usage = "<id> [<owner1> [<owner2> [<owners...>]]]",
|
||||||
usage = "<id> [<owner1> [<owner2> [<owners...>]]]",
|
desc = "Defines a region", min = 1)
|
||||||
desc = "Defines a region",
|
|
||||||
flags = "", min = 1, max = -1)
|
|
||||||
@CommandPermissions({"worldguard.region.define"})
|
@CommandPermissions({"worldguard.region.define"})
|
||||||
public static void define(CommandContext args, WorldGuardPlugin plugin,
|
public void define(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
WorldEditPlugin worldEdit = plugin.getWorldEdit();
|
WorldEditPlugin worldEdit = plugin.getWorldEdit();
|
||||||
@ -122,12 +124,9 @@ public static void define(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"redefine", "update", "move"},
|
@Command(aliases = {"redefine", "update", "move"}, usage = "<id>",
|
||||||
usage = "<id>",
|
desc = "Re-defines the shape of a region", min = 1, max = 1)
|
||||||
desc = "Re-defines the shape of a region",
|
public void redefine(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 1, max = 1)
|
|
||||||
public static void redefine(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -199,13 +198,10 @@ public static void redefine(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"claim"},
|
@Command(aliases = {"claim"}, usage = "<id> [<owner1> [<owner2> [<owners...>]]]",
|
||||||
usage = "<id> [<owner1> [<owner2> [<owners...>]]]",
|
desc = "Claim a region", min = 1)
|
||||||
desc = "Claim a region",
|
|
||||||
flags = "", min = 1, max = -1)
|
|
||||||
@CommandPermissions({"worldguard.region.claim"})
|
@CommandPermissions({"worldguard.region.claim"})
|
||||||
public static void claim(CommandContext args, WorldGuardPlugin plugin,
|
public void claim(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
@ -332,12 +328,9 @@ public static void claim(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"select", "sel", "s"},
|
@Command(aliases = {"select", "sel", "s"}, usage = "<id>",
|
||||||
usage = "<id>",
|
desc = "Load a region as a WorldEdit selection", min = 1, max = 1)
|
||||||
desc = "Load a region as a WorldEdit selection",
|
public void select(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 1, max = 1)
|
|
||||||
public static void select(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -381,12 +374,9 @@ public static void select(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"info", "i"},
|
@Command(aliases = {"info", "i"}, usage = "[world] <id>",
|
||||||
usage = "[world] <id>",
|
desc = "Get information about a region", min = 1, max = 2)
|
||||||
desc = "Get information about a region",
|
public void info(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 1, max = 2)
|
|
||||||
public static void info(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = null;
|
Player player = null;
|
||||||
LocalPlayer localPlayer = null;
|
LocalPlayer localPlayer = null;
|
||||||
@ -468,13 +458,10 @@ public static void info(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Bounds: " + c);
|
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Bounds: " + c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"list"},
|
@Command(aliases = {"list"}, usage = "[.player] [page] [world]",
|
||||||
usage = "[.player] [page] [world]",
|
desc = "Get a list of regions", max = 3)
|
||||||
desc = "Get a list of regions",
|
|
||||||
flags = "", min = 0, max = 3)
|
|
||||||
// @CommandPermissions({"worldguard.region.list"})
|
// @CommandPermissions({"worldguard.region.list"})
|
||||||
public static void list(CommandContext args, WorldGuardPlugin plugin,
|
public void list(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
World world;
|
World world;
|
||||||
int page = 0;
|
int page = 0;
|
||||||
@ -559,7 +546,7 @@ else if (regions.get(id).isMember(localPlayer)) {
|
|||||||
int pages = (int) Math.ceil(size / (float) listSize);
|
int pages = (int) Math.ceil(size / (float) listSize);
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.RED
|
sender.sendMessage(ChatColor.RED
|
||||||
+ (name == "" ? "Regions (page " : "Regions for " + name + " (page ")
|
+ (name.equals("") ? "Regions (page " : "Regions for " + name + " (page ")
|
||||||
+ (page + 1) + " of " + pages + "):");
|
+ (page + 1) + " of " + pages + "):");
|
||||||
|
|
||||||
if (page < pages) {
|
if (page < pages) {
|
||||||
@ -573,12 +560,9 @@ else if (regions.get(id).isMember(localPlayer)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"flag", "f"},
|
@Command(aliases = {"flag", "f"}, usage = "<id> <flag> [value]",
|
||||||
usage = "<id> <flag> [value]",
|
desc = "Set flags", min = 2)
|
||||||
desc = "Set flags",
|
public void flag(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 2, max = -1)
|
|
||||||
public static void flag(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -679,7 +663,7 @@ public static void flag(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
setFlag(region, foundFlag, plugin, sender, value);
|
setFlag(region, foundFlag, sender, value);
|
||||||
} catch (InvalidFlagFormat e) {
|
} catch (InvalidFlagFormat e) {
|
||||||
throw new CommandException(e.getMessage());
|
throw new CommandException(e.getMessage());
|
||||||
}
|
}
|
||||||
@ -702,18 +686,15 @@ public static void flag(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <V> void setFlag(ProtectedRegion region,
|
public <V> void setFlag(ProtectedRegion region,
|
||||||
Flag<V> flag, WorldGuardPlugin plugin, CommandSender sender, String value)
|
Flag<V> flag, CommandSender sender, String value)
|
||||||
throws InvalidFlagFormat {
|
throws InvalidFlagFormat {
|
||||||
region.setFlag(flag, flag.parseInput(plugin, sender, value));
|
region.setFlag(flag, flag.parseInput(plugin, sender, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"setpriority", "priority", "pri"},
|
@Command(aliases = {"setpriority", "priority", "pri"}, usage = "<id> <priority>",
|
||||||
usage = "<id> <priority>",
|
desc = "Set the priority of a region", min = 2, max = 2)
|
||||||
desc = "Set the priority of a region",
|
public void setPriority(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 2, max = 2)
|
|
||||||
public static void setPriority(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
@ -754,12 +735,9 @@ public static void setPriority(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"setparent", "parent", "par"},
|
@Command(aliases = {"setparent", "parent", "par"}, usage = "<id> [parent-id]",
|
||||||
usage = "<id> [parent-id]",
|
desc = "Set the parent of a region", min = 1, max = 2)
|
||||||
desc = "Set the parent of a region",
|
public void setParent(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 1, max = 2)
|
|
||||||
public static void setParent(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
@ -828,12 +806,9 @@ public static void setParent(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"remove", "delete", "del", "rem"},
|
@Command(aliases = {"remove", "delete", "del", "rem"}, usage = "<id>",
|
||||||
usage = "<id>",
|
desc = "Remove a region", min = 1, max = 1)
|
||||||
desc = "Remove a region",
|
public void remove(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 1, max = 1)
|
|
||||||
public static void remove(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -869,12 +844,9 @@ public static void remove(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"load", "reload"},
|
@Command(aliases = {"load", "reload"}, usage = "[world]",
|
||||||
usage = "[world]",
|
desc = "Reload regions from file", max = 1)
|
||||||
desc = "Reload regions from file",
|
public void load(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 0, max = 1)
|
|
||||||
public static void load(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
World world = null;
|
World world = null;
|
||||||
|
|
||||||
@ -910,12 +882,9 @@ public static void load(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"save", "write"},
|
@Command(aliases = {"save", "write"}, usage = "[world]",
|
||||||
usage = "[world]",
|
desc = "Re-save regions to file", max = 1)
|
||||||
desc = "Re-save regions to file",
|
public void save(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 0, max = 1)
|
|
||||||
public static void save(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
World world = null;
|
World world = null;
|
||||||
|
|
||||||
|
@ -40,13 +40,15 @@
|
|||||||
// @TODO: A lot of code duplication here! Need to fix.
|
// @TODO: A lot of code duplication here! Need to fix.
|
||||||
|
|
||||||
public class RegionMemberCommands {
|
public class RegionMemberCommands {
|
||||||
|
private final WorldGuardPlugin plugin;
|
||||||
|
|
||||||
|
public RegionMemberCommands(WorldGuardPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Command(aliases = {"addmember", "addmember"},
|
@Command(aliases = {"addmember", "addmember"}, usage = "<id> <members...>",
|
||||||
usage = "<id> <members...>",
|
desc = "Add a member to a region", min = 2)
|
||||||
desc = "Add a member to a region",
|
public void addMember(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 2, max = -1)
|
|
||||||
public static void addMember(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -82,12 +84,9 @@ public static void addMember(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"addowner", "addowner"},
|
@Command(aliases = {"addowner", "addowner"}, usage = "<id> <owners...>",
|
||||||
usage = "<id> <owners...>",
|
desc = "Add an owner to a region", min = 2)
|
||||||
desc = "Add an owner to a region",
|
public void addOwner(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 2, max = -1)
|
|
||||||
public static void addOwner(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -133,12 +132,9 @@ public static void addOwner(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"removemember", "remmember", "removemem", "remmem"},
|
@Command(aliases = {"removemember", "remmember", "removemem", "remmem"}, usage = "<id> <owners...>",
|
||||||
usage = "<id> <owners...>",
|
desc = "Remove an owner to a region", min = 2)
|
||||||
desc = "Remove an owner to a region",
|
public void removeMember(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
flags = "", min = 2, max = -1)
|
|
||||||
public static void removeMember(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@ -174,11 +170,9 @@ public static void removeMember(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"removeowner", "remowner"},
|
@Command(aliases = {"removeowner", "remowner"}, usage = "<id> <owners...>",
|
||||||
usage = "<id> <owners...>",
|
desc = "Remove an owner to a region", min = 2)
|
||||||
desc = "Remove an owner to a region",
|
public void removeOwner(CommandContext args,
|
||||||
flags = "", min = 2, max = -1)
|
|
||||||
public static void removeOwner(CommandContext args, WorldGuardPlugin plugin,
|
|
||||||
CommandSender sender) throws CommandException {
|
CommandSender sender) throws CommandException {
|
||||||
|
|
||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
|
@ -35,13 +35,16 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
public class ToggleCommands {
|
public class ToggleCommands {
|
||||||
|
private final WorldGuardPlugin plugin;
|
||||||
|
|
||||||
@Command(aliases = {"stopfire"},
|
public ToggleCommands(WorldGuardPlugin plugin) {
|
||||||
usage = "[<world>]", desc = "Disables all fire spread temporarily",
|
this.plugin = plugin;
|
||||||
flags = "", min = 0, max = 1)
|
}
|
||||||
|
|
||||||
|
@Command(aliases = {"stopfire"}, usage = "[<world>]",
|
||||||
|
desc = "Disables all fire spread temporarily", max = 1)
|
||||||
@CommandPermissions({"worldguard.fire-toggle.stop"})
|
@CommandPermissions({"worldguard.fire-toggle.stop"})
|
||||||
public static void stopFire(CommandContext args, WorldGuardPlugin plugin,
|
public void stopFire(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
@ -67,12 +70,10 @@ public static void stopFire(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
wcfg.fireSpreadDisableToggle = true;
|
wcfg.fireSpreadDisableToggle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"allowfire"},
|
@Command(aliases = {"allowfire"}, usage = "[<world>]",
|
||||||
usage = "[<world>]", desc = "Allows all fire spread temporarily",
|
desc = "Allows all fire spread temporarily", max = 1)
|
||||||
flags = "", min = 0, max = 1)
|
|
||||||
@CommandPermissions({"worldguard.fire-toggle.stop"})
|
@CommandPermissions({"worldguard.fire-toggle.stop"})
|
||||||
public static void allowFire(CommandContext args, WorldGuardPlugin plugin,
|
public void allowFire(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
World world;
|
World world;
|
||||||
|
|
||||||
@ -97,8 +98,7 @@ public static void allowFire(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"halt-activity"},
|
@Command(aliases = {"halt-activity"},
|
||||||
usage = "", desc = "Attempts to cease as much activity in order to stop lag",
|
desc = "Attempts to cease as much activity in order to stop lag", flags = "c", max = 0)
|
||||||
flags = "c", min = 0, max = 0)
|
|
||||||
@CommandPermissions({"worldguard.halt-activity"})
|
@CommandPermissions({"worldguard.halt-activity"})
|
||||||
public static void stopLag(CommandContext args, WorldGuardPlugin plugin,
|
public static void stopLag(CommandContext args, WorldGuardPlugin plugin,
|
||||||
CommandSender sender) throws CommandException {
|
CommandSender sender) throws CommandException {
|
||||||
|
@ -39,26 +39,23 @@
|
|||||||
import com.sk89q.worldguard.util.PastebinPoster.PasteCallback;
|
import com.sk89q.worldguard.util.PastebinPoster.PasteCallback;
|
||||||
|
|
||||||
public class WorldGuardCommands {
|
public class WorldGuardCommands {
|
||||||
|
private final WorldGuardPlugin plugin;
|
||||||
|
|
||||||
@Command(aliases = {"version"},
|
public WorldGuardCommands(WorldGuardPlugin plugin) {
|
||||||
usage = "",
|
this.plugin = plugin;
|
||||||
desc = "Get the WorldGuard version",
|
}
|
||||||
flags = "", min = 0, max = 0)
|
|
||||||
public static void version(CommandContext args, WorldGuardPlugin plugin,
|
@Command(aliases = {"version"}, desc = "Get the WorldGuard version", max = 0)
|
||||||
CommandSender sender) throws CommandException {
|
public void version(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
sender.sendMessage(ChatColor.YELLOW
|
sender.sendMessage(ChatColor.YELLOW
|
||||||
+ "WorldGuard " + plugin.getDescription().getVersion());
|
+ "WorldGuard " + plugin.getDescription().getVersion());
|
||||||
sender.sendMessage(ChatColor.YELLOW
|
sender.sendMessage(ChatColor.YELLOW
|
||||||
+ "http://www.sk89q.com");
|
+ "http://www.sk89q.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"reload"},
|
@Command(aliases = {"reload"}, desc = "Reload WorldGuard configuration", max = 0)
|
||||||
usage = "",
|
|
||||||
desc = "Reload WorldGuard configuration",
|
|
||||||
flags = "", min = 0, max = 0)
|
|
||||||
@CommandPermissions({"worldguard.reload"})
|
@CommandPermissions({"worldguard.reload"})
|
||||||
public static void relload(CommandContext args, WorldGuardPlugin plugin,
|
public void reload(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
|
|
||||||
LoggerToChatHandler handler = null;
|
LoggerToChatHandler handler = null;
|
||||||
Logger minecraftLogger = null;
|
Logger minecraftLogger = null;
|
||||||
@ -86,10 +83,7 @@ public static void relload(CommandContext args, WorldGuardPlugin plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"report"},
|
@Command(aliases = {"report"}, desc = "Writes a report on WorldGuard", flags = "p", max = 0)
|
||||||
usage = "",
|
|
||||||
desc = "Writes a report on WorldGuard",
|
|
||||||
flags = "p", min = 0, max = 0)
|
|
||||||
@CommandPermissions({"worldguard.report"})
|
@CommandPermissions({"worldguard.report"})
|
||||||
public static void report(CommandContext args, WorldGuardPlugin plugin,
|
public static void report(CommandContext args, WorldGuardPlugin plugin,
|
||||||
final CommandSender sender) throws CommandException {
|
final CommandSender sender) throws CommandException {
|
||||||
@ -126,12 +120,9 @@ public void handleError(String err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"flushstates", "clearstates"},
|
@Command(aliases = {"flushstates", "clearstates"},
|
||||||
usage = "[player]",
|
usage = "[player]", desc = "Flush the state manager", max = 1)
|
||||||
desc = "Flush the state manager",
|
|
||||||
flags = "", min = 0, max = 1)
|
|
||||||
@CommandPermissions("worldguard.flushstates")
|
@CommandPermissions("worldguard.flushstates")
|
||||||
public static void flushStates(CommandContext args, WorldGuardPlugin plugin,
|
public void flushStates(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
CommandSender sender) throws CommandException {
|
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
plugin.getFlagStateManager().forgetAll();
|
plugin.getFlagStateManager().forgetAll();
|
||||||
sender.sendMessage("Cleared all states.");
|
sender.sendMessage("Cleared all states.");
|
||||||
|
Loading…
Reference in New Issue
Block a user