Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrbu committed Apr 20, 2023
2 parents 6a0ea31 + 7737cba commit 61593b0
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Command extends BukkitCommand {
try {
COMMAND_MAP = (CommandMap) CacheRegistry.BUKKIT_COMMAND_MAP.load().get(Bukkit.getServer());
} catch (IllegalAccessException exception) {
throw new IllegalStateException("can't access bukkit command map.");
throw new IllegalStateException("Unable to register Bukkit command map.");
}
}

Expand Down Expand Up @@ -69,17 +69,17 @@ public Set<CommandInformation> getCommands() {
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
Optional<Map.Entry<CommandInformation, CommandInvoker>> subCommandOptional = this.subCommands.entrySet().stream().filter(command -> command.getKey().name().contentEquals((args.length > 0) ? args[0] : "")).findFirst();
if (subCommandOptional.isEmpty()) {
sender.sendMessage(ChatColor.RED + "can't find command: " + commandLabel + ".");
sender.sendMessage(ChatColor.RED + "Unable to locate the following command: " + commandLabel + ".");
return false;
}
try {
Map.Entry<CommandInformation, CommandInvoker> subCommand = subCommandOptional.get();
subCommand.getValue().execute(new io.github.znetworkw.znpcservers.commands.CommandSender(sender), loadArgs(subCommand.getKey(), Arrays.asList(args)));
} catch (CommandExecuteException e) {
sender.sendMessage(ChatColor.RED + "can't execute command.");
sender.sendMessage(ChatColor.RED + "Cannot execute this command or this command execution has failed.");
e.printStackTrace();
} catch (CommandPermissionException e) {
sender.sendMessage(ChatColor.RED + "no permission for run this command.");
sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command.");
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void execute(CommandSender sender, Object command) throws CommandPermissi
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("You cannot execute this command.");
}
try {
this.commandMethod.invoke(this.command, sender, command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void sendMessage(String message, Iterable<String> hover) {

public Player getPlayer() {
if (this.type != SenderType.PLAYER)
throw new IllegalStateException("sender is not a player.");
throw new IllegalStateException("The following sender is not a player.");
return (Player) getCommandSender();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public DefaultCommand() {
@CommandInformation(arguments = {}, name = "", permission = "")
public void defaultCommand(CommandSender sender, Map<String, String> args) {
sender.sendMessage("&6&m------------------------------------------");
sender.sendMessage("&b&lZNPCS &8\u00BB &7ZNetwork");
sender.sendMessage("&6https://www.spigotmc.org/resources/znpcs.80940");
sender.sendMessage("&b&lZNPCS &8\u00BB &7ZNetwork & Pyr");
sender.sendMessage("&6https://www.spigotmc.org/resources/znpcsplus.109380/");
Objects.requireNonNull(sender);
getCommands().forEach(sender::sendMessage);
sender.sendMessage(ChatColor.DARK_GRAY + "Hover over the commands to see help for the command.");
sender.sendMessage(ChatColor.DARK_GRAY + "Hover over the commands to view command arguments.");
sender.sendMessage("&6&m------------------------------------------");
}

@CommandInformation(arguments = {"id", "type", "name"}, name = "create", permission = "znpcs.cmd.create", help = {" &f&l* &e/znpcs create <npc_id> PLAYER Qentin"})
@CommandInformation(arguments = {"id", "type", "name"}, name = "create", permission = "znpcs.cmd.create", help = {" &f&l* &e/znpcs create <npc_id> PLAYER Steve"})
public void createNPC(CommandSender sender, Map<String, String> args) {
if (args.size() < 3) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
Expand Down Expand Up @@ -116,7 +116,7 @@ public void list(CommandSender sender, Map<String, String> args) {
TextComponent textComponent2 = new TextComponent("[TELEPORT]");
textComponent2.setBold(true);
textComponent2.setColor(ChatColor.DARK_GREEN);
textComponent2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ComponentBuilder("Click to teleport this npc!"))
textComponent2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ComponentBuilder("Click to teleport this NPC!"))

.color(ChatColor.GREEN).create()));
textComponent2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/znpcs teleport " + npcModel
Expand All @@ -126,7 +126,7 @@ public void list(CommandSender sender, Map<String, String> args) {
TextComponent textComponent3 = new TextComponent("[DELETE]");
textComponent3.setBold(true);
textComponent3.setColor(ChatColor.DARK_RED);
textComponent3.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ComponentBuilder("Click to delete this npc!"))
textComponent3.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, (new ComponentBuilder("Click to delete this NPC!"))

.color(ChatColor.RED).create()));
textComponent3.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/znpcs delete " + npcModel
Expand Down Expand Up @@ -158,7 +158,7 @@ public void setSkin(CommandSender sender, Map<String, String> args) {
DO_APPLY_SKIN.apply(sender.getPlayer(), foundNPC, args.get("skin"));
}

@CommandInformation(arguments = {"id", "slot"}, name = "equip", permission = "znpcs.cmd.equip", help = {" &f&l* &e/znpcs equip <npc_id> [HAND,OFFHAND,HELMET,CHESTPLATE,LEGGINGS,BOOTS]", "&8(You need to have the item in your hand.)"})
@CommandInformation(arguments = {"id", "slot"}, name = "equip", permission = "znpcs.cmd.equip", help = {" &f&l* &e/znpcs equip <npc_id> [HAND/OFFHAND/HELMET/CHESTPLATE/LEGGINGS/BOOTS]", "&8(You need to have the item in your hand)."})
public void equip(CommandSender sender, Map<String, String> args) {
if (args.size() < 2) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
Expand Down Expand Up @@ -251,7 +251,7 @@ public void changeType(CommandSender sender, Map<String, String> args) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS);
}

@CommandInformation(arguments = {"add", "remove", "cooldown", "list"}, name = "action", isMultiple = true, permission = "znpcs.cmd.action", help = {" &f&l* &e/znpcs action add <npc_id> SERVER skywars", " &f&l* &e/znpcs action add <npc_id> CMD spawn", " &f&l* &e/znpcs action remove <npc_id> <action_id>", " &f&l* &e/znpcs action cooldown <npc_id> <action_id> <delay_in_seconds>", " &f&l* &e/znpcs action list <npc_id>"})
@CommandInformation(arguments = {"add", "remove", "cooldown", "list"}, name = "action", isMultiple = true, permission = "znpcs.cmd.action", help = {" &f&l* &e/znpcs action add <npc_id> SERVER survival", " &f&l* &e/znpcs action add <npc_id> CMD spawn", " &f&l* &e/znpcs action remove <npc_id> <action_id>", " &f&l* &e/znpcs action cooldown <npc_id> <action_id> <delay_in_seconds>", " &f&l* &e/znpcs action list <npc_id>"})
public void action(CommandSender sender, Map<String, String> args) {
if (args.size() < 1) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
Expand Down Expand Up @@ -445,7 +445,7 @@ public void path(CommandSender sender, Map<String, String> args) {
return;
}
if (znpcUser.isHasPath()) {
sender.getPlayer().sendMessage(ChatColor.RED + "You already have a path creator active, to remove it use /znpcs path exit.");
sender.getPlayer().sendMessage(ChatColor.RED + "You already have a path creator active! To remove it, type " + ChatColor.WHITE + "/znpcs path exit" + ChatColor.RED + ".");
return;
}
NPCPath.AbstractTypeWriter.forCreation(pathName, znpcUser, NPCPath.AbstractTypeWriter.TypeWriter.MOVEMENT);
Expand Down Expand Up @@ -481,7 +481,7 @@ public void teleport(CommandSender sender, Map<String, String> args) {
sender.getPlayer().teleport(foundNPC.getLocation());
}

@CommandInformation(arguments = {"id", "height"}, name = "height", permission = "znpcs.cmd.height", help = {" &f&l* &e/znpcs height <npc_id> 2", "&8Add more height to the hologram of the npc"})
@CommandInformation(arguments = {"id", "height"}, name = "height", permission = "znpcs.cmd.height", help = {" &f&l* &e/znpcs height <npc_id> 2", "&8Set a greater or lesser distance of a hologram from the NPC."})
public void changeHologramHeight(CommandSender sender, Map<String, String> args) {
if (args.size() < 2) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
Expand All @@ -507,7 +507,7 @@ public void changeHologramHeight(CommandSender sender, Map<String, String> args)
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS);
}

@CommandInformation(arguments = {"create", "remove", "gui", "set"}, name = "conversation", isMultiple = true, permission = "znpcs.cmd.conversation", help = {" &f&l* &e/znpcs conversation create first", " &f&l* &e/znpcs conversation remove first", " &f&l* &e/znpcs conversation set <npc_id> first [CLICK:RADIUS]", " &f&l* &e/znpcs conversation gui &8(&7Open a gui to manage the conversations&8)", "&8RADIUS: &7it is activated when the player is near the npc", "&8CLICK: &7it is activated when the player interacts with the npc"})
@CommandInformation(arguments = {"create", "remove", "gui", "set"}, name = "conversation", isMultiple = true, permission = "znpcs.cmd.conversation", help = {" &f&l* &e/znpcs conversation create first", " &f&l* &e/znpcs conversation remove first", " &f&l* &e/znpcs conversation set <npc_id> first [CLICK/RADIUS]", " &f&l* &e/znpcs conversation gui &8(&7Opens a GUI to manage conversations&8)", "&8RADIUS: &7Activates when the player is near the NPC", "&8CLICK: &7Activates when the player interacts with the NPC"})
public void conversations(CommandSender sender, Map<String, String> args) {
if (args.size() < 1) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void update() {
});
}
this.addItem(ItemStackBuilder.forMaterial(Material.EMERALD).setName(ChatColor.AQUA + "ADD A NEW ACTION").setLore("&7click here...").build(), this.getRows() - 5, clickEvent -> {
Utils.sendTitle(this.getPlayer(), "&d&lADD ACTION", "&7Type the action...");
Utils.sendTitle(this.getPlayer(), "&d&lADD ACTION", "&7Type the new action...");
EventService.addService(ZUser.find(this.getPlayer()), AsyncPlayerChatEvent.class).addConsumer(event -> {
if (ConfigurationConstants.NPC_CONVERSATIONS.contains(this.conversation) && this.conversation.getTexts().contains(this.conversationKey)) {
List<String> stringList = SPACE_SPLITTER.splitToList(event.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected Configuration(String name) {
}

private Configuration(String name, Path path) {
if (!path.getFileName().toString().endsWith(".json")) throw new IllegalStateException("invalid configuration format for: " + path.getFileName());
if (!path.getFileName().toString().endsWith(".json")) throw new IllegalStateException("Invalid configuration format for: " + path.getFileName());
this.name = name;
this.path = path;
this.configurationValues = ConfigurationValue.VALUES_BY_NAME.get(name).stream().collect(Collectors.toMap((c) -> c, ConfigurationValue::getValue));
Expand All @@ -54,15 +54,15 @@ protected void onLoad() {
}
} catch (NoSuchFileException ignored) {
} catch (IOException ex) {
throw new IllegalStateException("Failed to read config: " + this.name);
throw new IllegalStateException("Failed to read configuration: " + this.name);
}
}

public void save() {
try (Writer writer = Files.newBufferedWriter(this.path, CHARSET)) {
ZNPCsPlus.GSON.toJson(this.configurationValues.size() == 1 ? this.configurationValues.values().iterator().next() : this.configurationValues, writer);
} catch (IOException ex) {
throw new IllegalStateException("Failed to save config: " + this.name);
throw new IllegalStateException("Failed to save configuration: " + this.name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@ 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", "&cThe arguements you specified are not valid, do &f/znpcs help&c for assistance and examples.", String.class),
SUCCESS("messages", "&aSuccess!", String.class),
INCORRECT_USAGE("messages", "&cThe arguments you specified are invalid. Type &f/znpcs help&c for 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, 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),
COMMAND_ERROR("messages", "&cAn error occurred when executing this command. See console for more information.", String.class),
INVALID_NUMBER("messages", "&cThe ID you have specified is invalid. Please use positive integers only!", String.class),
NPC_NOT_FOUND("messages", "&cNo NPCs could be found with this ID!", String.class),
TOO_FEW_ARGUMENTS("messages", "&cThis command does not contain enough arguments. Type &f/znpcs help&c or view our documentation for a list/examples of existing arguments.", String.class),
PATH_START("messages", "&aSuccess! Move to create a path for your NPC. When finished, type &f/znpcs path exit&c to exit path creation.", String.class),
EXIT_PATH("messages", "&cYou have exited path creation.", String.class),
PATH_FOUND("messages", "&cThere is already a path with this name.", 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", "&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),
NPC_FOUND("messages", "&cThere is already an NPC with this ID.", String.class),
NO_PATH_FOUND("messages", "&cThe path you have specified does not exist.", String.class),
NO_SKIN_FOUND("messages", "&cThe skin username/URL you have specified does not exist or is invalid.", String.class),
NO_NPC_FOUND("messages", "&cThe NPC you have specified does not exist.", String.class),
NO_ACTION_FOUND("messages", "&cThis action does not exist! Type &f/znpcs help&c or view our documentation for a list/examples of existing action types.", String.class),
METHOD_NOT_FOUND("messages", "&cThis method does not exist! Type &f/znpcs help&c or view our documentation for a list/examples of existing methods.", String.class),
INVALID_NAME_LENGTH("messages", "&cThe name you specified either too short or long. Please enter a positive integer of (3 to 16) characters.", String.class),
UNSUPPORTED_ENTITY("messages", "&cThis entity type not available in your current server 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_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", "&cThis conversation was not found.", String.class),
CONVERSATION_SET_INCORRECT_USAGE("messages", "&cUsage: <npc_id> <conversation_name> <RADIUS/CLICK>", String.class),
NO_CONVERSATION_FOUND("messages", "&cThe conversation you have specified does not exist!", 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),
INVALID_SIZE("messages", "&cThe position you have specified cannot exceed the limit.", String.class),
FETCHING_SKIN("messages", "&aFetching skin for name: &f%s&a. Please wait...", 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);
GET_SKIN("messages", "&aSkin successfully 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 61593b0

Please sign in to comment.