use of com.sk89q.minecraft.util.commands.CommandPermissions in project WorldGuard by EngineHub.
the class ToggleCommands method stopLag.
@Command(aliases = { "halt-activity", "stoplag", "haltactivity" }, usage = "[confirm]", desc = "Attempts to cease as much activity in order to stop lag", flags = "cis", max = 1)
@CommandPermissions({ "worldguard.halt-activity" })
public void stopLag(CommandContext args, Actor sender) throws CommandException {
ConfigurationManager configManager = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
if (args.hasFlag('i')) {
if (configManager.activityHaltToggle) {
sender.print("ALL intensive server activity is not allowed.");
} else {
sender.print("ALL intensive server activity is allowed.");
}
} else {
boolean activityHaltToggle = !args.hasFlag('c');
if (activityHaltToggle && (args.argsLength() == 0 || !args.getString(0).equalsIgnoreCase("confirm"))) {
String confirmCommand = "/" + args.getCommand() + " confirm";
TextComponent message = TextComponent.builder("").append(ErrorFormat.wrap("This command will ")).append(ErrorFormat.wrap("PERMANENTLY").decoration(TextDecoration.BOLD, TextDecoration.State.TRUE)).append(ErrorFormat.wrap(" erase ALL animals in ALL loaded chunks in ALL loaded worlds. ")).append(TextComponent.newline()).append(TextComponent.of("[Click]", TextColor.GREEN).clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, confirmCommand)).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to confirm /" + args.getCommand())))).append(ErrorFormat.wrap(" or type ")).append(CodeFormat.wrap(confirmCommand).clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, confirmCommand))).append(ErrorFormat.wrap(" to confirm.")).build();
sender.print(message);
return;
}
configManager.activityHaltToggle = activityHaltToggle;
if (activityHaltToggle) {
if (!(sender instanceof LocalPlayer)) {
sender.print("ALL intensive server activity halted.");
}
if (!args.hasFlag('s')) {
worldGuard.getPlatform().broadcastNotification(LabelFormat.wrap("ALL intensive server activity halted by " + sender.getDisplayName() + "."));
} else {
sender.print("(Silent) ALL intensive server activity halted by " + sender.getDisplayName() + ".");
}
for (World world : WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWorlds()) {
int removed = 0;
for (Entity entity : world.getEntities()) {
if (Entities.isIntensiveEntity(entity)) {
entity.remove();
removed++;
}
}
if (removed > 10) {
sender.printRaw("" + removed + " entities (>10) auto-removed from " + world.getName());
}
}
} else {
if (!args.hasFlag('s')) {
worldGuard.getPlatform().broadcastNotification(LabelFormat.wrap("ALL intensive server activity is now allowed."));
if (!(sender instanceof LocalPlayer)) {
sender.print("ALL intensive server activity is now allowed.");
}
} else {
sender.print("(Silent) ALL intensive server activity is now allowed.");
}
}
}
}
use of com.sk89q.minecraft.util.commands.CommandPermissions 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.CommandPermissions 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.CommandPermissions 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.CommandPermissions 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'));
}
Aggregations