mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-28 05:25:20 +01:00
added aliases /rd, /rc, /rf, /ri, /rl, /rp for region commands
This commit is contained in:
parent
a258400443
commit
0669bab563
@ -24,7 +24,7 @@ commands:
|
||||
region:
|
||||
description: Adjust protected regions
|
||||
usage: /<command> <define|claim|setparent|flag|delete|info|addowner|removeowner|addmember|removemember|list|save|load|priority> ...
|
||||
aliases: rg, regions
|
||||
aliases: rg, regions, rd, rc, rsp, rf, rdel, ri, rao, rro, rl, rp
|
||||
locate:
|
||||
description: Set your compass towards a person
|
||||
usage: /<command> <target>
|
||||
|
@ -255,13 +255,12 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
player.getWorld().getName()).getApplicableRegions(
|
||||
BukkitUtil.toVector(location));
|
||||
|
||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
|
||||
String spawnconfig = regions.getAreaFlag("spawn", "settings", true, null);
|
||||
Location spawn = regions.getLocationAreaFlag("spawn", player.getServer(), true, null);
|
||||
|
||||
if (spawn != null) {
|
||||
String spawnconfig = regions.getAreaFlag("spawn", "settings", true, null);
|
||||
if (spawnconfig != null) {
|
||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||
if (spawnconfig.equals("owner")) {
|
||||
if (regions.isOwner(localPlayer)) {
|
||||
player.teleportTo(spawn);
|
||||
|
@ -44,11 +44,19 @@ public CommandHandler(WorldGuardPlugin wg)
|
||||
this.wg = wg;
|
||||
this.commandMap = new HashMap<String, WgCommand>();
|
||||
|
||||
WgCommand regionHandler = new RegionCommandHandler();
|
||||
|
||||
// commands that DO support console as sender
|
||||
this.commandMap.put("allowfire", new CommandAllowFire());
|
||||
this.commandMap.put("god", new CommandGod());
|
||||
this.commandMap.put("heal", new CommandHeal());
|
||||
this.commandMap.put("region", new RegionCommandHandler());
|
||||
this.commandMap.put("region", regionHandler);
|
||||
this.commandMap.put("rd", regionHandler);
|
||||
this.commandMap.put("rc", regionHandler);
|
||||
this.commandMap.put("rf", regionHandler);
|
||||
this.commandMap.put("ri", regionHandler);
|
||||
this.commandMap.put("rl", regionHandler);
|
||||
this.commandMap.put("rp", regionHandler);
|
||||
this.commandMap.put("reloadwg", new CommandReloadWG());
|
||||
this.commandMap.put("slay", new CommandSlay());
|
||||
this.commandMap.put("stopfire", new CommandStopFire());
|
||||
|
@ -35,9 +35,11 @@
|
||||
public class RegionCommandHandler extends WgCommand {
|
||||
|
||||
private Map<String, WgRegionCommand> commandMap;
|
||||
private Map<String, String> aliasMap;
|
||||
|
||||
public RegionCommandHandler() {
|
||||
this.commandMap = new HashMap<String, WgRegionCommand>();
|
||||
this.aliasMap = new HashMap<String, String>();
|
||||
|
||||
WgRegionCommand addmember = new CommandRegionAddMember();
|
||||
WgRegionCommand removemember = new CommandRegionRemoveMember();
|
||||
@ -60,21 +62,46 @@ public RegionCommandHandler() {
|
||||
this.commandMap.put("define", new CommandRegionDefine());
|
||||
this.commandMap.put("claim", new CommandRegionClaim());
|
||||
|
||||
|
||||
this.aliasMap.put("rd", "define");
|
||||
this.aliasMap.put("rc", "claim");
|
||||
this.aliasMap.put("rf", "flag");
|
||||
this.aliasMap.put("ri", "info");
|
||||
this.aliasMap.put("rl", "list");
|
||||
this.aliasMap.put("rp", "priority");
|
||||
}
|
||||
|
||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||
|
||||
String worldName;
|
||||
String subCommand;
|
||||
int argsStartAt;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
CommandHandler.checkArgs(args, 1, -1);
|
||||
worldName = ((Player) sender).getWorld().getName();
|
||||
subCommand = args[0].toLowerCase();
|
||||
if (!command.equals("region")) {
|
||||
subCommand = this.aliasMap.get(command);
|
||||
if (subCommand == null) {
|
||||
return false;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
worldName = ((Player) sender).getWorld().getName();
|
||||
argsStartAt = 0;
|
||||
} else {
|
||||
CommandHandler.checkArgs(args, 1, -1);
|
||||
worldName = args[0];
|
||||
argsStartAt = 1;
|
||||
}
|
||||
} else {
|
||||
CommandHandler.checkArgs(args, 2, -1);
|
||||
worldName = args[0];
|
||||
subCommand = args[1].toLowerCase();
|
||||
if (sender instanceof Player) {
|
||||
CommandHandler.checkArgs(args, 1, -1);
|
||||
worldName = ((Player) sender).getWorld().getName();
|
||||
subCommand = args[0].toLowerCase();
|
||||
argsStartAt = 1;
|
||||
} else {
|
||||
CommandHandler.checkArgs(args, 2, -1);
|
||||
worldName = args[0];
|
||||
subCommand = args[1].toLowerCase();
|
||||
argsStartAt = 2;
|
||||
}
|
||||
}
|
||||
|
||||
Server server = cfg.getWorldGuardPlugin().getServer();
|
||||
@ -96,16 +123,23 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
}
|
||||
|
||||
String[] subArgs;
|
||||
if (sender instanceof Player) {
|
||||
subArgs = new String[args.length - 1];
|
||||
System.arraycopy(args, 1, subArgs, 0, args.length - 1);
|
||||
if (argsStartAt > 0) {
|
||||
subArgs = new String[args.length - argsStartAt];
|
||||
System.arraycopy(args, argsStartAt, subArgs, 0, args.length - argsStartAt);
|
||||
} else {
|
||||
subArgs = new String[args.length - 2];
|
||||
System.arraycopy(args, 2, subArgs, 0, args.length - 2);
|
||||
subArgs = args;
|
||||
}
|
||||
|
||||
wgcmd.handle(sender, senderName, subCommand, subArgs, cfg, wcfg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getCommandFromAlias(String alias) {
|
||||
if (alias.equals("rf")) {
|
||||
return "flag";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user