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. // Its a misc, we are going to use the MiscDisguise constructor.
ItemStack itemStack = new ItemStack(Material.STONE); ItemStack itemStack = new ItemStack(Material.STONE);
int miscId = -1; int miscId = -1;
int miscData = -1;
String secondArg = null;
if (args.length > 1) { 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()) { switch (disguisePerm.getType()) {
case PAINTING:
case FALLING_BLOCK: case FALLING_BLOCK:
case SPLASH_POTION:
case DROPPED_ITEM: case DROPPED_ITEM:
case FISHING_HOOK: Material material = null;
case ARROW:
case TIPPED_ARROW: for (Material mat : Material.values()) {
case SPECTRAL_ARROW: if (!mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) {
case SMALL_FIREBALL: continue;
case FIREBALL: }
case WITHER_SKULL:
case TRIDENT: material = mat;
break; 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) { if (material == null) {
String toCheck = "" + miscId; break;
}
if (miscData == 0 || miscData == -1) { itemStack = new ItemStack(material);
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
toCheck += ":0"; if (!disguiseOptions.isEmpty()) {
} String toCheck = "" + itemStack.getType().name();
} else {
toCheck += ":" + miscData;
}
if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) { if (!disguiseOptions.containsKey(toCheck) || !disguiseOptions.get(toCheck)) {
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, 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) { if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
usedOptions.add("setblock"); usedOptions.add("setblock");
} else {
usedOptions.add("setitemstack");
}
doCheck(sender, permissions, disguisePerm, usedOptions); 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"); usedOptions.add("setpainting");
} else {
doCheck(sender, permissions, disguisePerm, usedOptions);
} else if (disguisePerm.getType() == DisguiseType.SPLASH_POTION) {
usedOptions.add("setpotionid"); usedOptions.add("setpotionid");
}
doCheck(sender, permissions, disguisePerm, usedOptions); doCheck(sender, permissions, disguisePerm, usedOptions);
break;
default:
break;
} }
} }
@ -339,7 +313,7 @@ public class DisguiseParser {
disguisePerm.getType() == DisguiseType.FALLING_BLOCK) { disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
disguise = new MiscDisguise(disguisePerm.getType(), itemStack); disguise = new MiscDisguise(disguisePerm.getType(), itemStack);
} else { } else {
disguise = new MiscDisguise(disguisePerm.getType(), miscId, miscData); disguise = new MiscDisguise(disguisePerm.getType(), miscId);
} }
} }
} }