Search in sources :

Example 36 with Command

use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.

the class DebuggingCommands method firePlaceEvent.

@Command(aliases = { "testplace" }, usage = "[player]", desc = "Simulate a block place", min = 1, max = 1, flags = "ts")
@CommandPermissions("worldguard.debug.event")
public void firePlaceEvent(CommandContext args, final Actor sender) throws CommandException {
    LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
    worldGuard.getPlatform().getDebugHandler().testPlace(sender, target, args.hasFlag('t'), args.hasFlag('s'));
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Command(com.sk89q.minecraft.util.commands.Command) CommandPermissions(com.sk89q.minecraft.util.commands.CommandPermissions)

Example 37 with Command

use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.

the class GeneralCommands method heal.

@Command(aliases = { "heal" }, usage = "[player]", desc = "Heal a player", flags = "s", max = 1)
public void heal(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
    Iterable<? extends LocalPlayer> targets = null;
    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.heal");
    } else if (args.argsLength() == 1) {
        targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));
        // Check permissions!
        sender.checkPermission("worldguard.heal.other");
    }
    for (LocalPlayer player : targets) {
        player.setHealth(player.getMaxHealth());
        player.setFoodLevel(20);
        player.setSaturation(20);
        player.setExhaustion(0);
        // Tell the user
        if (player.equals(sender)) {
            player.print("Healed!");
            // Keep track of this
            included = true;
        } else {
            player.print("Healed by " + sender.getDisplayName() + ".");
        }
    }
    // user a message so s/he know that something is indeed working
    if (!included && args.hasFlag('s')) {
        sender.print("Players healed.");
    }
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Command(com.sk89q.minecraft.util.commands.Command)

Example 38 with Command

use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.

the class GeneralCommands method stack.

@Command(aliases = { "stack", ";" }, usage = "", desc = "Stack items", max = 0)
@CommandPermissions({ "worldguard.stack" })
public void stack(CommandContext args, Actor sender) throws CommandException {
    LocalPlayer player = worldGuard.checkPlayer(sender);
    WorldGuard.getInstance().getPlatform().stackPlayerInventory(player);
    player.print("Items compacted into stacks!");
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Command(com.sk89q.minecraft.util.commands.Command) CommandPermissions(com.sk89q.minecraft.util.commands.CommandPermissions)

Example 39 with Command

use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.

the class GeneralCommands method god.

@Command(aliases = { "god" }, usage = "[player]", desc = "Enable godmode on a player", flags = "s", max = 1)
public void god(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
    Iterable<? extends LocalPlayer> targets = null;
    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, true)) {
            player.setFireTicks(0);
            // Tell the user
            if (player.equals(sender)) {
                player.print("God mode enabled! Use /ungod to disable.");
                // Keep track of this
                included = true;
            } else {
                player.print("God enabled by " + sender.getDisplayName() + ".");
            }
        }
    }
    // user a message so s/he know that something is indeed working
    if (!included && args.hasFlag('s')) {
        sender.print("Players now have god mode.");
    }
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Session(com.sk89q.worldguard.session.Session) Command(com.sk89q.minecraft.util.commands.Command)

Example 40 with Command

use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.

the class GeneralCommands method locate.

@Command(aliases = { "locate" }, usage = "[player]", desc = "Locate a player", max = 1)
@CommandPermissions({ "worldguard.locate" })
public void locate(CommandContext args, Actor sender) throws CommandException {
    LocalPlayer player = worldGuard.checkPlayer(sender);
    if (args.argsLength() == 0) {
        player.setCompassTarget(new Location(player.getWorld(), player.getWorld().getSpawnPosition().toVector3()));
        sender.print("Compass reset to spawn.");
    } else {
        LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
        player.setCompassTarget(target.getLocation());
        sender.print("Compass repointed.");
    }
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Location(com.sk89q.worldedit.util.Location) Command(com.sk89q.minecraft.util.commands.Command) CommandPermissions(com.sk89q.minecraft.util.commands.CommandPermissions)

Aggregations

Command (com.sk89q.minecraft.util.commands.Command)41 LocalPlayer (com.sk89q.worldguard.LocalPlayer)24 World (com.sk89q.worldedit.world.World)23 CommandPermissionsException (com.sk89q.minecraft.util.commands.CommandPermissionsException)22 CommandException (com.sk89q.minecraft.util.commands.CommandException)18 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)18 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)16 CommandPermissions (com.sk89q.minecraft.util.commands.CommandPermissions)15 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)12 NestedCommand (com.sk89q.minecraft.util.commands.NestedCommand)5 ConfigurationManager (com.sk89q.worldguard.config.ConfigurationManager)5 LoggerToChatHandler (com.sk89q.worldguard.util.logging.LoggerToChatHandler)5 Logger (java.util.logging.Logger)5 RegionPermissionModel (com.sk89q.worldguard.internal.permission.RegionPermissionModel)4 TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)3 FutureForwardingTask (com.sk89q.worldedit.util.task.FutureForwardingTask)3 Task (com.sk89q.worldedit.util.task.Task)3 RegionAdder (com.sk89q.worldguard.commands.task.RegionAdder)3 WorldConfiguration (com.sk89q.worldguard.config.WorldConfiguration)3 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)3