Add BlockFace aka direction to disguise options
This commit is contained in:
parent
9f72a3940e
commit
babe5554ab
@ -2,6 +2,7 @@ package me.libraryaddict.disguise.commands;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -13,6 +14,7 @@ import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -112,6 +114,8 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
"org.bukkit.entity.Villager$Profession").getEnumConstants()));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
|
||||
+ "- View the four directions usable on player setsleeping disguise", Arrays.copyOf(BlockFace.values(), 4)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -206,6 +210,8 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
valueType = "Potion effect";
|
||||
} else if (c == int[].class) {
|
||||
valueType = "number,number,number...";
|
||||
} else if (c == BlockFace.class) {
|
||||
valueType = "direction";
|
||||
}
|
||||
if (valueType != null) {
|
||||
ChatColor methodColor = ChatColor.YELLOW;
|
||||
|
@ -16,6 +16,7 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Ageable;
|
||||
@ -467,7 +468,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
methodName = methodToUse.getName();
|
||||
Class<?>[] types = methodToUse.getParameterTypes();
|
||||
if (types.length == 1) {
|
||||
Class param = types[0];
|
||||
if (boolean.class == param) {
|
||||
// Parse to boolean
|
||||
@ -574,6 +574,14 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
value = values;
|
||||
} else if (param == BlockFace.class) {
|
||||
try {
|
||||
BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
|
||||
if (face.ordinal() > 3)
|
||||
throw new Exception();
|
||||
value = face;
|
||||
} catch (Exception ex) {
|
||||
throw parseToException("a direction (north, east, south, west)", valueString, methodName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user