mirror of
https://github.com/filoghost/ChestCommands.git
synced 2024-11-23 10:35:16 +01:00
Fix NPE and tell the user what menu was not found.
This commit is contained in:
parent
1df75f8da2
commit
7ea65934d6
@ -94,8 +94,9 @@ public class CommandHandler extends CommandFramework {
|
|||||||
|
|
||||||
CommandValidate.notNull(target, "That player is not online.");
|
CommandValidate.notNull(target, "That player is not online.");
|
||||||
|
|
||||||
ExtendedIconMenu menu = ChestCommands.getFileNameToMenuMap().get(args[1].toLowerCase().endsWith(".yml") ? args[1] : args[1] + ".yml");
|
String menuName = args[1].toLowerCase().endsWith(".yml") ? args[1] : args[1] + ".yml";
|
||||||
CommandValidate.notNull(target, "That menu was not found.");
|
ExtendedIconMenu menu = ChestCommands.getFileNameToMenuMap().get(menuName);
|
||||||
|
CommandValidate.notNull(menu, "The menu \"" + menuName + "\" was not found.");
|
||||||
|
|
||||||
if (!sender.hasPermission(menu.getPermission())) {
|
if (!sender.hasPermission(menu.getPermission())) {
|
||||||
menu.sendNoPermissionMessage(sender);
|
menu.sendNoPermissionMessage(sender);
|
||||||
@ -103,9 +104,9 @@ public class CommandHandler extends CommandFramework {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender.getName().equalsIgnoreCase(target.getName())) {
|
if (sender.getName().equalsIgnoreCase(target.getName())) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Opening the menu \"" + args[1] + "\".");
|
sender.sendMessage(ChatColor.GREEN + "Opening the menu \"" + menuName + "\".");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Opening the menu \"" + args[1] + "\" to " + target.getName() + ".");
|
sender.sendMessage(ChatColor.GREEN + "Opening the menu \"" + menuName + "\" to " + target.getName() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.open(target);
|
menu.open(target);
|
||||||
|
Loading…
Reference in New Issue
Block a user