Don't silently fail when a disguisetype has a null entitytype
This commit is contained in:
parent
dea2dc856a
commit
bd317b4cce
@ -138,9 +138,6 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
|||||||
}
|
}
|
||||||
DisguiseType type = null;
|
DisguiseType type = null;
|
||||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||||
if (disguiseType.getEntityType() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase(disguiseType.name())
|
if (args[0].equalsIgnoreCase(disguiseType.name())
|
||||||
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
||||||
type = disguiseType;
|
type = disguiseType;
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Monster;
|
import org.bukkit.entity.Monster;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
@ -66,8 +67,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
String disguiseType = perm.split("\\.")[0];
|
String disguiseType = perm.split("\\.")[0];
|
||||||
try {
|
try {
|
||||||
DisguiseType type = DisguiseType.valueOf(disguiseType.toUpperCase());
|
DisguiseType type = DisguiseType.valueOf(disguiseType.toUpperCase());
|
||||||
if (type.getEntityType() == null)
|
|
||||||
continue;
|
|
||||||
HashMap<ArrayList<String>, Boolean> list;
|
HashMap<ArrayList<String>, Boolean> list;
|
||||||
if (singleDisguises.containsKey(type)) {
|
if (singleDisguises.containsKey(type)) {
|
||||||
list = singleDisguises.get(type);
|
list = singleDisguises.get(type);
|
||||||
@ -79,11 +78,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
list.put(map1.keySet().iterator().next(), map1.values().iterator().next());
|
list.put(map1.keySet().iterator().next(), map1.values().iterator().next());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
for (DisguiseType type : DisguiseType.values()) {
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
if (type.getEntityType() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
HashMap<ArrayList<String>, Boolean> options = null;
|
HashMap<ArrayList<String>, Boolean> options = null;
|
||||||
Class entityClass = type.getEntityType().getEntityClass();
|
Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();
|
||||||
if (disguiseType.equals("mob")) {
|
if (disguiseType.equals("mob")) {
|
||||||
if (type.isMob()) {
|
if (type.isMob()) {
|
||||||
options = getOptions(perm);
|
options = getOptions(perm);
|
||||||
@ -131,11 +127,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
singleDisguises.remove(type);
|
singleDisguises.remove(type);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
for (DisguiseType type : DisguiseType.values()) {
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
if (type.getEntityType() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
boolean foundHim = false;
|
boolean foundHim = false;
|
||||||
Class entityClass = type.getEntityType().getEntityClass();
|
Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();
|
||||||
if (disguiseType.equals("mob")) {
|
if (disguiseType.equals("mob")) {
|
||||||
if (type.isMob()) {
|
if (type.isMob()) {
|
||||||
foundHim = true;
|
foundHim = true;
|
||||||
@ -258,9 +251,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
disguiseType = DisguiseType.PLAYER;
|
disguiseType = DisguiseType.PLAYER;
|
||||||
} else {
|
} else {
|
||||||
for (DisguiseType type : DisguiseType.values()) {
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
if (type.getEntityType() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase(type.name()) || args[0].equalsIgnoreCase(type.name().replace("_", ""))) {
|
if (args[0].equalsIgnoreCase(type.name()) || args[0].equalsIgnoreCase(type.name().replace("_", ""))) {
|
||||||
disguiseType = type;
|
disguiseType = type;
|
||||||
break;
|
break;
|
||||||
@ -271,6 +261,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
throw new Exception(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0] + ChatColor.RED
|
throw new Exception(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0] + ChatColor.RED
|
||||||
+ " doesn't exist!");
|
+ " doesn't exist!");
|
||||||
}
|
}
|
||||||
|
if (disguiseType.getEntityType() == null) {
|
||||||
|
throw new Exception(ChatColor.RED + "Error! This version of minecraft does not have that disguise!");
|
||||||
|
}
|
||||||
if (!map.containsKey(disguiseType)) {
|
if (!map.containsKey(disguiseType)) {
|
||||||
throw new Exception(ChatColor.RED + "You are forbidden to use this disguise.");
|
throw new Exception(ChatColor.RED + "You are forbidden to use this disguise.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user