Various grammar fixes and enhanced readability

This commit is contained in:
R00tB33rMan 2023-04-20 14:34:31 +00:00
parent f171af7ef2
commit fbe04e97ed
6 changed files with 21 additions and 21 deletions

@ -19,7 +19,7 @@ public class Command extends BukkitCommand {
try { try {
COMMAND_MAP = (CommandMap) CacheRegistry.BUKKIT_COMMAND_MAP.load().get(Bukkit.getServer()); COMMAND_MAP = (CommandMap) CacheRegistry.BUKKIT_COMMAND_MAP.load().get(Bukkit.getServer());
} catch (IllegalAccessException exception) { } catch (IllegalAccessException exception) {
throw new IllegalStateException("can't access bukkit command map."); throw new IllegalStateException("Unable to register Bukkit command map.");
} }
} }
@ -69,17 +69,17 @@ public class Command extends BukkitCommand {
public boolean execute(CommandSender sender, String commandLabel, String[] args) { 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(); 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()) { 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; return false;
} }
try { try {
Map.Entry<CommandInformation, CommandInvoker> subCommand = subCommandOptional.get(); Map.Entry<CommandInformation, CommandInvoker> subCommand = subCommandOptional.get();
subCommand.getValue().execute(new io.github.znetworkw.znpcservers.commands.CommandSender(sender), loadArgs(subCommand.getKey(), Arrays.asList(args))); subCommand.getValue().execute(new io.github.znetworkw.znpcservers.commands.CommandSender(sender), loadArgs(subCommand.getKey(), Arrays.asList(args)));
} catch (CommandExecuteException e) { } 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(); e.printStackTrace();
} catch (CommandPermissionException e) { } 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; return true;
} }

@ -18,7 +18,7 @@ public class CommandInvoker {
throw new CommandPermissionException("Only players may execute this command."); throw new CommandPermissionException("Only players may execute this command.");
} }
if (this.permission.length() > 0 && !sender.getCommandSender().hasPermission(this.permission)) { if (this.permission.length() > 0 && !sender.getCommandSender().hasPermission(this.permission)) {
throw new CommandPermissionException("Insufficient permission."); throw new CommandPermissionException("You cannot execute this command.");
} }
try { try {
this.commandMethod.invoke(this.command, sender, command); this.commandMethod.invoke(this.command, sender, command);

@ -51,7 +51,7 @@ public class CommandSender {
public Player getPlayer() { public Player getPlayer() {
if (this.type != SenderType.PLAYER) 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(); return (Player) getCommandSender();
} }

@ -47,15 +47,15 @@ public class DefaultCommand extends Command {
@CommandInformation(arguments = {}, name = "", permission = "") @CommandInformation(arguments = {}, name = "", permission = "")
public void defaultCommand(CommandSender sender, Map<String, String> args) { public void defaultCommand(CommandSender sender, Map<String, String> args) {
sender.sendMessage("&6&m------------------------------------------"); sender.sendMessage("&6&m------------------------------------------");
sender.sendMessage("&b&lZNPCS &8\u00BB &7ZNetwork"); sender.sendMessage("&b&lZNPCS &8\u00BB &7ZNetwork & Pyr");
sender.sendMessage("&6https://www.spigotmc.org/resources/znpcs.80940"); sender.sendMessage("&6https://www.spigotmc.org/resources/znpcsplus.109380/");
Objects.requireNonNull(sender); Objects.requireNonNull(sender);
getCommands().forEach(sender::sendMessage); 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------------------------------------------"); 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) { public void createNPC(CommandSender sender, Map<String, String> args) {
if (args.size() < 3) { if (args.size() < 3) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE); Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
@ -116,7 +116,7 @@ public class DefaultCommand extends Command {
TextComponent textComponent2 = new TextComponent("[TELEPORT]"); TextComponent textComponent2 = new TextComponent("[TELEPORT]");
textComponent2.setBold(true); textComponent2.setBold(true);
textComponent2.setColor(ChatColor.DARK_GREEN); 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())); .color(ChatColor.GREEN).create()));
textComponent2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/znpcs teleport " + npcModel textComponent2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/znpcs teleport " + npcModel
@ -126,7 +126,7 @@ public class DefaultCommand extends Command {
TextComponent textComponent3 = new TextComponent("[DELETE]"); TextComponent textComponent3 = new TextComponent("[DELETE]");
textComponent3.setBold(true); textComponent3.setBold(true);
textComponent3.setColor(ChatColor.DARK_RED); 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())); .color(ChatColor.RED).create()));
textComponent3.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/znpcs delete " + npcModel textComponent3.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/znpcs delete " + npcModel
@ -158,7 +158,7 @@ public class DefaultCommand extends Command {
DO_APPLY_SKIN.apply(sender.getPlayer(), foundNPC, args.get("skin")); 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) { public void equip(CommandSender sender, Map<String, String> args) {
if (args.size() < 2) { if (args.size() < 2) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE); Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
@ -251,7 +251,7 @@ public class DefaultCommand extends Command {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS); 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) { public void action(CommandSender sender, Map<String, String> args) {
if (args.size() < 1) { if (args.size() < 1) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE); Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
@ -445,7 +445,7 @@ public class DefaultCommand extends Command {
return; return;
} }
if (znpcUser.isHasPath()) { 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; return;
} }
NPCPath.AbstractTypeWriter.forCreation(pathName, znpcUser, NPCPath.AbstractTypeWriter.TypeWriter.MOVEMENT); NPCPath.AbstractTypeWriter.forCreation(pathName, znpcUser, NPCPath.AbstractTypeWriter.TypeWriter.MOVEMENT);
@ -481,7 +481,7 @@ public class DefaultCommand extends Command {
sender.getPlayer().teleport(foundNPC.getLocation()); 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) { public void changeHologramHeight(CommandSender sender, Map<String, String> args) {
if (args.size() < 2) { if (args.size() < 2) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE); Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);
@ -507,7 +507,7 @@ public class DefaultCommand extends Command {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS); 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) { public void conversations(CommandSender sender, Map<String, String> args) {
if (args.size() < 1) { if (args.size() < 1) {
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE); Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.INCORRECT_USAGE);

@ -119,7 +119,7 @@ public class ConversationGUI extends ZInventory {
}); });
} }
this.addItem(ItemStackBuilder.forMaterial(Material.EMERALD).setName(ChatColor.AQUA + "ADD A NEW ACTION").setLore("&7click here...").build(), this.getRows() - 5, clickEvent -> { 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 -> { EventService.addService(ZUser.find(this.getPlayer()), AsyncPlayerChatEvent.class).addConsumer(event -> {
if (ConfigurationConstants.NPC_CONVERSATIONS.contains(this.conversation) && this.conversation.getTexts().contains(this.conversationKey)) { if (ConfigurationConstants.NPC_CONVERSATIONS.contains(this.conversation) && this.conversation.getTexts().contains(this.conversationKey)) {
List<String> stringList = SPACE_SPLITTER.splitToList(event.getMessage()); List<String> stringList = SPACE_SPLITTER.splitToList(event.getMessage());

@ -34,7 +34,7 @@ public class Configuration {
} }
private Configuration(String name, Path path) { 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.name = name;
this.path = path; this.path = path;
this.configurationValues = ConfigurationValue.VALUES_BY_NAME.get(name).stream().collect(Collectors.toMap((c) -> c, ConfigurationValue::getValue)); this.configurationValues = ConfigurationValue.VALUES_BY_NAME.get(name).stream().collect(Collectors.toMap((c) -> c, ConfigurationValue::getValue));
@ -54,7 +54,7 @@ public class Configuration {
} }
} catch (NoSuchFileException ignored) { } catch (NoSuchFileException ignored) {
} catch (IOException ex) { } catch (IOException ex) {
throw new IllegalStateException("Failed to read config: " + this.name); throw new IllegalStateException("Failed to read configuration: " + this.name);
} }
} }
@ -62,7 +62,7 @@ public class Configuration {
try (Writer writer = Files.newBufferedWriter(this.path, CHARSET)) { try (Writer writer = Files.newBufferedWriter(this.path, CHARSET)) {
ZNPCsPlus.GSON.toJson(this.configurationValues.size() == 1 ? this.configurationValues.values().iterator().next() : this.configurationValues, writer); ZNPCsPlus.GSON.toJson(this.configurationValues.size() == 1 ? this.configurationValues.values().iterator().next() : this.configurationValues, writer);
} catch (IOException ex) { } catch (IOException ex) {
throw new IllegalStateException("Failed to save config: " + this.name); throw new IllegalStateException("Failed to save configuration: " + this.name);
} }
} }