Remove obscure old code for disguise construction using commands for 1.13

This commit is contained in:
libraryaddict 2018-12-13 11:57:54 +13:00
parent 9e7f332788
commit 40cc5a7a84

View File

@ -236,81 +236,30 @@ public class DisguiseParser {
// Its a misc, we are going to use the MiscDisguise constructor.
ItemStack itemStack = new ItemStack(Material.STONE);
int miscId = -1;
int miscData = -1;
String secondArg = null;
if (args.length > 1) {
// They have defined more arguments!
// If the first arg is a number
if (args[1].contains(":")) {
String[] split = args[1].split(":");
if (isInteger(split[1])) {
secondArg = split[1];
}
args[1] = split[0];
}
if (isInteger(args[1])) {
miscId = Integer.parseInt(args[1]);
} else {
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK ||
disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
for (Material mat : Material.values()) {
if (mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) {
itemStack = new ItemStack(mat);
miscId = mat.getId();
break;
}
}
}
}
if (miscId != -1) {
switch (disguisePerm.getType()) {
case PAINTING:
case FALLING_BLOCK:
case SPLASH_POTION:
case DROPPED_ITEM:
case FISHING_HOOK:
case ARROW:
case TIPPED_ARROW:
case SPECTRAL_ARROW:
case SMALL_FIREBALL:
case FIREBALL:
case WITHER_SKULL:
case TRIDENT:
Material material = null;
for (Material mat : Material.values()) {
if (!mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) {
continue;
}
material = mat;
break;
default:
throw new DisguiseParseException(LibsMsg.PARSE_TOO_MANY_ARGS,
disguisePerm.toReadable(), args[1]);
}
toSkip++;
// If they also defined a data value
if (args.length > 2 && secondArg == null && isInteger(args[2])) {
secondArg = args[2];
toSkip++;
}
if (secondArg != null) {
if (disguisePerm.getType() != DisguiseType.FALLING_BLOCK &&
disguisePerm.getType() != DisguiseType.DROPPED_ITEM) {
throw new DisguiseParseException(LibsMsg.PARSE_USE_SECOND_NUM,
DisguiseType.FALLING_BLOCK.toReadable(),
DisguiseType.DROPPED_ITEM.toReadable());
}
miscData = Integer.parseInt(secondArg);
}
}
}
if (!disguiseOptions.isEmpty() && miscId != -1) {
String toCheck = "" + miscId;
if (material == null) {
break;
}
if (miscData == 0 || miscData == -1) {
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
toCheck += ":0";
}
} else {
toCheck += ":" + miscData;
}
itemStack = new ItemStack(material);
if (!disguiseOptions.isEmpty()) {
String toCheck = "" + itemStack.getType().name();
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, toCheck,
@ -318,19 +267,44 @@ public class DisguiseParser {
}
}
if (miscId != -1) {
toSkip++;
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
usedOptions.add("setblock");
} else {
usedOptions.add("setitemstack");
}
doCheck(sender, permissions, disguisePerm, usedOptions);
} else if (disguisePerm.getType() == DisguiseType.PAINTING) {
break;
case PAINTING:
case SPLASH_POTION:
if (!isInteger(args[1])) {
break;
}
miscId = Integer.parseInt(args[1]);
toSkip++;
if (!disguiseOptions.isEmpty()) {
String toCheck = "" + miscId;
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, toCheck,
disguisePerm.toReadable());
}
}
if (disguisePerm.getType() == DisguiseType.PAINTING) {
usedOptions.add("setpainting");
doCheck(sender, permissions, disguisePerm, usedOptions);
} else if (disguisePerm.getType() == DisguiseType.SPLASH_POTION) {
} else {
usedOptions.add("setpotionid");
}
doCheck(sender, permissions, disguisePerm, usedOptions);
break;
default:
break;
}
}
@ -339,7 +313,7 @@ public class DisguiseParser {
disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
disguise = new MiscDisguise(disguisePerm.getType(), itemStack);
} else {
disguise = new MiscDisguise(disguisePerm.getType(), miscId, miscData);
disguise = new MiscDisguise(disguisePerm.getType(), miscId);
}
}
}