use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.
the class ToggleCommands method stopFire.
@Command(aliases = { "stopfire" }, usage = "[<world>]", desc = "Disables all fire spread temporarily", max = 1)
@CommandPermissions({ "worldguard.fire-toggle.stop" })
public void stopFire(CommandContext args, Actor sender) throws CommandException {
World world;
if (args.argsLength() == 0) {
world = worldGuard.checkPlayer(sender).getWorld();
} else {
world = worldGuard.getPlatform().getMatcher().matchWorld(sender, args.getString(0));
}
WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
if (!wcfg.fireSpreadDisableToggle) {
worldGuard.getPlatform().broadcastNotification(LabelFormat.wrap("Fire spread has been globally disabled for '" + world.getName() + "' by " + sender.getDisplayName() + "."));
} else {
sender.print("Fire spread was already globally disabled.");
}
wcfg.fireSpreadDisableToggle = true;
}
use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.
the class WorldGuardCommands method flushStates.
@Command(aliases = { "flushstates", "clearstates" }, usage = "[player]", desc = "Flush the state manager", max = 1)
@CommandPermissions("worldguard.flushstates")
public void flushStates(CommandContext args, Actor sender) throws CommandException {
if (args.argsLength() == 0) {
WorldGuard.getInstance().getPlatform().getSessionManager().resetAllStates();
sender.print("Cleared all states.");
} else {
LocalPlayer player = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
if (player != null) {
WorldGuard.getInstance().getPlatform().getSessionManager().resetState(player);
sender.print("Cleared states for player \"" + player.getName() + "\".");
}
}
}
use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.
the class WorldGuardCommands method reload.
@Command(aliases = { "reload" }, desc = "Reload WorldGuard configuration", max = 0)
@CommandPermissions({ "worldguard.reload" })
public void reload(CommandContext args, Actor sender) throws CommandException {
// TODO: This is subject to a race condition, but at least other commands are not being processed concurrently
List<Task<?>> tasks = WorldGuard.getInstance().getSupervisor().getTasks();
if (!tasks.isEmpty()) {
throw new CommandException("There are currently pending tasks. Use /wg running to monitor these tasks first.");
}
LoggerToChatHandler handler = null;
Logger minecraftLogger = null;
if (sender instanceof LocalPlayer) {
handler = new LoggerToChatHandler(sender);
handler.setLevel(Level.ALL);
minecraftLogger = Logger.getLogger("com.sk89q.worldguard");
minecraftLogger.addHandler(handler);
}
try {
ConfigurationManager config = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
config.unload();
config.load();
for (World world : WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWorlds()) {
config.get(world);
}
WorldGuard.getInstance().getPlatform().getRegionContainer().reload();
// WGBukkit.cleanCache();
sender.print("WorldGuard configuration reloaded.");
} catch (Throwable t) {
sender.printError("Error while reloading: " + t.getMessage());
} finally {
if (minecraftLogger != null) {
minecraftLogger.removeHandler(handler);
}
}
}
use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.
the class DebuggingCommands method fireBreakEvent.
@Command(aliases = { "testbreak" }, usage = "[player]", desc = "Simulate a block break", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void fireBreakEvent(CommandContext args, final Actor sender) throws CommandException {
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
worldGuard.getPlatform().getDebugHandler().testBreak(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}
use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.
the class GeneralCommands method ungod.
@Command(aliases = { "ungod" }, usage = "[player]", desc = "Disable godmode on a player", flags = "s", max = 1)
public void ungod(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
Iterable<? extends LocalPlayer> targets;
boolean included = false;
// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
// Check permissions!
sender.checkPermission("worldguard.god");
} else {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));
// Check permissions!
sender.checkPermission("worldguard.god.other");
}
for (LocalPlayer player : targets) {
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
if (GodMode.set(player, session, false)) {
// Tell the user
if (player.equals(sender)) {
player.print("God mode disabled!");
// Keep track of this
included = true;
} else {
player.print("God disabled by " + sender.getDisplayName() + ".");
}
}
}
// user a message so s/he know that something is indeed working
if (!included && args.hasFlag('s')) {
sender.print("Players no longer have god mode.");
}
}
Aggregations