mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-27 14:22:44 +02:00
Added arguments to /rg toggle-bypass: on, off
This commit is contained in:
parent
b1674e5cb7
commit
e04c654cde
@ -25,7 +25,6 @@
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
@ -1124,6 +1123,7 @@ public void teleport(CommandContext args, Actor sender) throws CommandException
|
||||
}
|
||||
|
||||
@Command(aliases = {"toggle-bypass", "bypass"},
|
||||
usage = "[on|off]",
|
||||
desc = "Toggle region bypassing, effectively ignoring bypass permissions.")
|
||||
public void toggleBypass(CommandContext args, Actor sender) throws CommandException {
|
||||
LocalPlayer player = worldGuard.checkPlayer(sender);
|
||||
@ -1131,7 +1131,17 @@ public void toggleBypass(CommandContext args, Actor sender) throws CommandExcept
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
if (session.hasBypassDisabled()) {
|
||||
boolean shouldEnableBypass;
|
||||
if (args.argsLength() > 0) {
|
||||
String arg1 = args.getString(0);
|
||||
if (!arg1.equalsIgnoreCase("on") && !arg1.equalsIgnoreCase("off")) {
|
||||
throw new CommandException("Allowed optional arguments are: on, off");
|
||||
}
|
||||
shouldEnableBypass = arg1.equalsIgnoreCase("on");
|
||||
} else {
|
||||
shouldEnableBypass = session.hasBypassDisabled();
|
||||
}
|
||||
if (shouldEnableBypass) {
|
||||
session.setBypassDisabled(false);
|
||||
player.print("You are now bypassing region protection (as long as you have permission).");
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user