Skip to content

Commit

Permalink
Merge pull request #1 from JosTheDude/master
Browse files Browse the repository at this point in the history
General Changes: Messages & Console Error Fix
  • Loading branch information
Pyrbu authored Apr 20, 2023
2 parents 269a248 + e30d4a4 commit d0c37eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

public class CommandInvoker {
private final Command command;

private final Method commandMethod;

private final String permission;

public CommandInvoker(Command command, Method commandMethod, String permission) {
Expand All @@ -16,8 +14,12 @@ public CommandInvoker(Command command, Method commandMethod, String permission)
}

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.");
}
try {
this.commandMethod.invoke(this.command, sender, command);
} catch (IllegalAccessException | java.lang.reflect.InvocationTargetException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,34 @@ public enum ConfigurationValue {
LINE_SPACING("config", 0.3D, Double.class),
ANIMATION_RGB("config", Boolean.FALSE, Boolean.class),
NO_PERMISSION("messages", "&cYou do not have permission to execute this command.", String.class),
SUCCESS("messages", "&aDone...", String.class),
INCORRECT_USAGE("messages", "&cIncorrect use of command.", String.class),
COMMAND_NOT_FOUND("messages", "&cThis command was not found.", String.class),
SUCCESS("messages", "&aDone!", 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", "&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),
INVALID_NUMBER("messages", "&cHey!, The inserted number/id does not look like a number..", String.class),
NPC_NOT_FOUND("messages", "&cHey!, I couldnt find a npc with this id.", String.class),
TOO_FEW_ARGUMENTS("messages", "&cToo few arguments.", String.class),
PATH_START("messages", "&aDone, now walk where you want the npc to, when u finish type /znpcs path exit.", 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 couldn't find a npc with this id!", 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 walk towards, when finished type &f/znpcs path exit", 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),
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_SKIN_FOUND("messages", "&cSkin not found.", String.class),
NO_NPC_FOUND("messages", "&cNo npc found.", String.class),
NO_ACTION_FOUND("messages", "&cNo action found.", String.class),
METHOD_NOT_FOUND("messages", "&cNo method found.", 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),
UNSUPPORTED_ENTITY("messages", "&cEntity type not available for your current version.", String.class),
NO_ACTION_FOUND("messages", "&cThis action was not valid! Check the wiki for valid action types.", 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 you specified is too short or long, it must be in the range of (3 to 16) characters.", 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),
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),
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),
INVALID_SIZE("messages", "&cThe position cannot exceed the limit.", 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),
GET_SKIN("messages", "&aSkin fetched.", String.class),
CANT_GET_SKIN("messages", "&cCould not fetch skin for name: %s.", String.class),
GET_SKIN("messages", "&aSkin fetched!", String.class),
CONVERSATION_LIST("conversations", new ArrayList<>(), Conversation.class);

public static final Map<String, ImmutableSet<ConfigurationValue>> VALUES_BY_NAME;
Expand Down

0 comments on commit d0c37eb

Please sign in to comment.