Merge pull request #1 from JosTheDude/master

General Changes: Messages & Console Error Fix
This commit is contained in:
Pyr 2023-04-20 12:11:41 +01:00 committed by GitHub
commit d0c37eb3cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 18 deletions

@ -4,9 +4,7 @@ import java.lang.reflect.Method;
public class CommandInvoker { public class CommandInvoker {
private final Command command; private final Command command;
private final Method commandMethod; private final Method commandMethod;
private final String permission; private final String permission;
public CommandInvoker(Command command, Method commandMethod, String permission) { public CommandInvoker(Command command, Method commandMethod, String permission) {
@ -16,8 +14,12 @@ public class CommandInvoker {
} }
public void execute(CommandSender sender, Object command) throws CommandPermissionException, CommandExecuteException { public void execute(CommandSender sender, Object command) throws CommandPermissionException, CommandExecuteException {
if (this.permission.length() > 0 && !sender.getCommandSender().hasPermission(this.permission)) if (!(sender instanceof Player) && this.permission.length() == 0) {
throw new CommandPermissionException("Only players may execute this command.");
}
if (this.permission.length() > 0 && !sender.getCommandSender().hasPermission(this.permission)) {
throw new CommandPermissionException("Insufficient permission."); throw new CommandPermissionException("Insufficient permission.");
}
try { try {
this.commandMethod.invoke(this.command, sender, command); this.commandMethod.invoke(this.command, sender, command);
} catch (IllegalAccessException | java.lang.reflect.InvocationTargetException e) { } catch (IllegalAccessException | java.lang.reflect.InvocationTargetException e) {

@ -22,34 +22,34 @@ public enum ConfigurationValue {
LINE_SPACING("config", 0.3D, Double.class), LINE_SPACING("config", 0.3D, Double.class),
ANIMATION_RGB("config", Boolean.FALSE, Boolean.class), ANIMATION_RGB("config", Boolean.FALSE, Boolean.class),
NO_PERMISSION("messages", "&cYou do not have permission to execute this command.", String.class), NO_PERMISSION("messages", "&cYou do not have permission to execute this command.", String.class),
SUCCESS("messages", "&aDone...", String.class), SUCCESS("messages", "&aDone!", String.class),
INCORRECT_USAGE("messages", "&cIncorrect use of command.", String.class), INCORRECT_USAGE("messages", "&cThe arguements you specified are not valid, do &f/znpcs help&c for assistance and examples.", String.class),
COMMAND_NOT_FOUND("messages", "&cThis command was not found.", String.class), COMMAND_NOT_FOUND("messages", "&cThe command you specified does not exist!", String.class),
COMMAND_ERROR("messages", "&cThere was an error executing the command, see the console for more information.", String.class), COMMAND_ERROR("messages", "&cThere was an error executing the command, see the console for more information.", String.class),
INVALID_NUMBER("messages", "&cHey!, The inserted number/id does not look like a number..", String.class), INVALID_NUMBER("messages", "&cHey!, The inserted number/id does not look like a number, please use integer values only!", String.class),
NPC_NOT_FOUND("messages", "&cHey!, I couldnt find a npc with this id.", String.class), NPC_NOT_FOUND("messages", "&cHey!, I couldn't find a npc with this id!", String.class),
TOO_FEW_ARGUMENTS("messages", "&cToo few arguments.", String.class), TOO_FEW_ARGUMENTS("messages", "&cThis command does not have enough arguements, do &f/znpcs help&c for assistance and examples.", String.class),
PATH_START("messages", "&aDone, now walk where you want the npc to, when u finish type /znpcs path exit.", String.class), PATH_START("messages", "&aDone, now walk where you want the npc to walk towards, when finished type &f/znpcs path exit", String.class),
EXIT_PATH("messages", "&cYou have exited the waypoint creation.", String.class), EXIT_PATH("messages", "&cYou have exited the waypoint creation.", String.class),
PATH_FOUND("messages", "&cThere is already a path with this name.", String.class), PATH_FOUND("messages", "&cThere is already a path with this name.", String.class),
NPC_FOUND("messages", "&cThere is already a npc with this id.", String.class), NPC_FOUND("messages", "&cThere is already an NPC with this id.", String.class),
NO_PATH_FOUND("messages", "&cNo path found.", String.class), NO_PATH_FOUND("messages", "&cNo path found.", String.class),
NO_SKIN_FOUND("messages", "&cSkin not found.", String.class), NO_SKIN_FOUND("messages", "&cSkin not found.", String.class),
NO_NPC_FOUND("messages", "&cNo npc found.", String.class), NO_NPC_FOUND("messages", "&cNo npc found.", String.class),
NO_ACTION_FOUND("messages", "&cNo action found.", String.class), NO_ACTION_FOUND("messages", "&cThis action was not valid! Check the wiki for valid action types.", String.class),
METHOD_NOT_FOUND("messages", "&cNo method found.", String.class), METHOD_NOT_FOUND("messages", "&cThis method was not found! Check the wiki for valid action types.", String.class),
INVALID_NAME_LENGTH("messages", "&cThe name is too short or long, it must be in the range of (3 to 16) characters.", String.class), INVALID_NAME_LENGTH("messages", "&cThe name you specified is too short or long, it must be in the range of (3 to 16) characters.", String.class),
UNSUPPORTED_ENTITY("messages", "&cEntity type not available for your current version.", String.class), UNSUPPORTED_ENTITY("messages", "&cThis entity type not available for your current version.", String.class),
PATH_SET_INCORRECT_USAGE("messages", "&eUsage: &aset <npc_id> <path_name>", String.class), PATH_SET_INCORRECT_USAGE("messages", "&eUsage: &aset <npc_id> <path_name>", String.class),
ACTION_ADD_INCORRECT_USAGE("messages", "&eUsage: &a<SERVER:CMD:MESSAGE:CONSOLE> <actionValue>", String.class), ACTION_ADD_INCORRECT_USAGE("messages", "&eUsage: &a<SERVER:CMD:MESSAGE:CONSOLE> <actionValue>", String.class),
ACTION_DELAY_INCORRECT_USAGE("messages", "&eUsage: &a<action_id> <delay>", String.class), ACTION_DELAY_INCORRECT_USAGE("messages", "&eUsage: &a<action_id> <delay>", String.class),
CONVERSATION_SET_INCORRECT_USAGE("messages", "&cUsage: <npc_id> <conversation_name> <RADIUS:CLICK>", String.class), CONVERSATION_SET_INCORRECT_USAGE("messages", "&cUsage: <npc_id> <conversation_name> <RADIUS:CLICK>", String.class),
NO_CONVERSATION_FOUND("messages", "&cNo conversation found.", String.class), NO_CONVERSATION_FOUND("messages", "&cThis conversation was not found.", String.class),
CONVERSATION_FOUND("messages", "&cThere is already a conversation with this name.", String.class), CONVERSATION_FOUND("messages", "&cThere is already a conversation with this name.", String.class),
INVALID_SIZE("messages", "&cThe position cannot exceed the limit.", String.class), INVALID_SIZE("messages", "&cThe position cannot exceed the limit.", String.class),
FETCHING_SKIN("messages", "&aFetching skin for name: &f%s&a, wait...", String.class), FETCHING_SKIN("messages", "&aFetching skin for name: &f%s&a, wait...", String.class),
CANT_GET_SKIN("messages", "&ccan't fetch skin with name: %s.", String.class), CANT_GET_SKIN("messages", "&cCould not fetch skin for name: %s.", String.class),
GET_SKIN("messages", "&aSkin fetched.", String.class), GET_SKIN("messages", "&aSkin fetched!", String.class),
CONVERSATION_LIST("conversations", new ArrayList<>(), Conversation.class); CONVERSATION_LIST("conversations", new ArrayList<>(), Conversation.class);
public static final Map<String, ImmutableSet<ConfigurationValue>> VALUES_BY_NAME; public static final Map<String, ImmutableSet<ConfigurationValue>> VALUES_BY_NAME;