From 97af919551a31743ef58e9fcb80481234712ed57 Mon Sep 17 00:00:00 2001 From: filoghost Date: Wed, 28 Nov 2018 16:51:56 +0100 Subject: [PATCH] Improve comment formatting --- .../chestcommands/ChestCommands.java | 6 +++--- .../chestcommands/SimpleUpdater.java | 10 +++++----- .../filoghost/chestcommands/api/Icon.java | 20 +++++++++---------- .../bridge/bungee/BungeeCordUtils.java | 2 +- .../command/CommandFramework.java | 2 +- .../chestcommands/command/CommandHandler.java | 2 +- .../config/AsciiPlaceholders.java | 4 ++-- .../filoghost/chestcommands/config/Lang.java | 2 +- .../config/yaml/PluginConfig.java | 2 +- .../config/yaml/SpecialConfig.java | 12 +++++------ .../chestcommands/internal/BoundItem.java | 8 ++++---- .../internal/CommandsClickHandler.java | 2 +- .../internal/ExtendedIconMenu.java | 2 +- .../chestcommands/internal/MenuData.java | 6 +++--- .../internal/MenuInventoryHolder.java | 10 ++++++---- .../internal/icon/ExtendedIcon.java | 6 +++--- .../icon/command/DragonBarIconCommand.java | 2 +- .../icon/command/OpenIconCommand.java | 6 ++++-- .../listener/CommandListener.java | 2 +- .../listener/InventoryListener.java | 4 ++-- .../chestcommands/listener/SignListener.java | 2 +- .../chestcommands/nms/AttributeRemover.java | 10 ++++++---- .../serializer/CommandSerializer.java | 10 +++++----- .../serializer/EnchantmentSerializer.java | 2 +- .../serializer/IconSerializer.java | 4 ++-- .../serializer/MenuSerializer.java | 2 +- .../chestcommands/util/ItemStackReader.java | 12 +++++------ .../chestcommands/util/MaterialsRegistry.java | 18 ++++++++--------- .../chestcommands/util/StringUtils.java | 2 +- .../filoghost/chestcommands/util/Utils.java | 2 +- 30 files changed, 90 insertions(+), 84 deletions(-) diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/ChestCommands.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/ChestCommands.java index 89abd0d..79aa22e 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/ChestCommands.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/ChestCommands.java @@ -193,11 +193,11 @@ public class ChestCommands extends JavaPlugin { getLogger().warning("Unhandled error while reading the placeholders! Please inform the developer."); } - // Load the menus. + // Load the menus File menusFolder = new File(getDataFolder(), "menu"); if (!menusFolder.isDirectory()) { - // Create the directory with the default menu. + // Create the directory with the default menu menusFolder.mkdirs(); Utils.saveResourceSafe(this, "menu" + File.separator + "example.yml"); } @@ -250,7 +250,7 @@ public class ChestCommands extends JavaPlugin { } } - // Register the BungeeCord plugin channel. + // Register the BungeeCord plugin channel if (!Bukkit.getMessenger().isOutgoingChannelRegistered(this, "BungeeCord")) { Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/SimpleUpdater.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/SimpleUpdater.java index 4f485e8..0d684ed 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/SimpleUpdater.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/SimpleUpdater.java @@ -68,7 +68,7 @@ public final class SimpleUpdater { JSONArray filesArray = (JSONArray) readJson("https://api.curseforge.com/servermods/files?projectIds=" + projectId); if (filesArray.size() == 0) { - // The array cannot be empty, there must be at least one file. The project ID is not valid. + // The array cannot be empty, there must be at least one file. The project ID is not valid plugin.getLogger().warning("The project ID (" + projectId + ") provided for updating is invalid or curse had a problem."); plugin.getLogger().warning("If the error persists, please inform the author."); return; @@ -127,16 +127,16 @@ public final class SimpleUpdater { String pluginVersion = plugin.getDescription().getVersion(); if (pluginVersion == null) { - // Do not throw exceptions, just consider it as v0. + // Do not throw exceptions, just consider it as v0 pluginVersion = "0"; } if (!remoteVersion.matches("v?[0-9\\.]+")) { - // Should always be checked before by this class. + // Should always be checked before by this class throw new IllegalArgumentException("fetched version's format is incorrect"); } - // Remove all the "v" from the versions, replace multiple full stops with a single full stop, and split them. + // Remove all the "v" from the versions, replace multiple full stops with a single full stop, and split them String[] pluginVersionSplit = pluginVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\."); String[] remoteVersionSplit = remoteVersion.replace("v", "").replaceAll("[\\.]{2,}", ".").split("\\."); @@ -161,7 +161,7 @@ public final class SimpleUpdater { return false; } - // Continue the loop. + // Continue the loop } return false; diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/api/Icon.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/api/Icon.java index db16829..82cb453 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/api/Icon.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/api/Icon.java @@ -56,7 +56,7 @@ public class Icon { private Set nameVariables; private Map> loreVariables; - private ItemStack cachedItem; // When there are no variables, we don't recreate the item. + private ItemStack cachedItem; // When there are no variables, we don't recreate the item public Icon() { enchantments = new HashMap(); @@ -236,7 +236,7 @@ public class Icon { } if (name.isEmpty()) { - // Add a color to display the name empty. + // Add a color to display the name empty return ChatColor.WHITE.toString(); } else { return name; @@ -269,7 +269,7 @@ public class Icon { output.add(line); } } else { - // Otherwise just copy the lines. + // Otherwise just copy the lines output.addAll(lore); } } @@ -280,7 +280,7 @@ public class Icon { output = Utils.newArrayList(); } - // Add an error message. + // Add an error message output.add(ChatColor.RED + "(Invalid material)"); } @@ -291,17 +291,17 @@ public class Icon { public ItemStack createItemstack(Player pov) { if (!this.hasVariables() && cachedItem != null) { - // Performance. + // Performance return cachedItem; } - // If the material is not set, display BEDROCK. + // If the material is not set, display BEDROCK ItemStack itemStack = (material != null) ? new ItemStack(material, amount, dataValue) : new ItemStack(Material.BEDROCK, amount); - // First try to apply NBT data. + // First try to apply NBT data if (nbtData != null) { try { - // Note: this method should not throw any exception. It should log directly to the console. + // Note: this method should not throw any exception. It should log directly to the console Bukkit.getUnsafe().modifyItemStack(itemStack, nbtData); } catch (Throwable t) { this.nbtData = null; @@ -309,7 +309,7 @@ public class Icon { } } - // Then apply data from config nodes, overwriting NBT data if there are confliting values. + // Then apply data from config nodes, overwriting NBT data if there are confliting values ItemMeta itemMeta = itemStack.getItemMeta(); if (hasName()) { @@ -336,7 +336,7 @@ public class Icon { } if (!this.hasVariables()) { - // If there are no variables, cache the item. + // If there are no variables, cache the item cachedItem = itemStack; } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/bridge/bungee/BungeeCordUtils.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/bridge/bungee/BungeeCordUtils.java index d5bae68..3ffed6a 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/bridge/bungee/BungeeCordUtils.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/bridge/bungee/BungeeCordUtils.java @@ -36,7 +36,7 @@ public class BungeeCordUtils { DataOutputStream out = new DataOutputStream(byteArray); out.writeUTF("Connect"); - out.writeUTF(server); // Target Server. + out.writeUTF(server); // Target Server player.sendPluginMessage(ChestCommands.getInstance(), "BungeeCord", byteArray.toByteArray()); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandFramework.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandFramework.java index 83018b8..f133969 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandFramework.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandFramework.java @@ -62,7 +62,7 @@ public abstract class CommandFramework implements CommandExecutor { } catch (CommandException ex) { if (ex.getMessage() != null && !ex.getMessage().isEmpty()) { - // Use RED by default. + // Use RED by default sender.sendMessage(ChatColor.RED + ex.getMessage()); } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandHandler.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandHandler.java index 23dcb59..564ab05 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandHandler.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/command/CommandHandler.java @@ -35,7 +35,7 @@ public class CommandHandler extends CommandFramework { @Override public void execute(CommandSender sender, String label, String[] args) { if (args.length == 0) { - // This info is accessible to anyone. Please don't remove it, remember that Chest Commands is developed for FREE. + // This info is accessible to anyone. Please don't remove it, remember that Chest Commands is developed for free sender.sendMessage(ChestCommands.CHAT_PREFIX); sender.sendMessage(ChatColor.GREEN + "Version: " + ChatColor.GRAY + ChestCommands.getInstance().getDescription().getVersion()); sender.sendMessage(ChatColor.GREEN + "Developer: " + ChatColor.GRAY + "filoghost"); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/AsciiPlaceholders.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/AsciiPlaceholders.java index 7731e52..e24454b 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/AsciiPlaceholders.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/AsciiPlaceholders.java @@ -46,7 +46,7 @@ public class AsciiPlaceholders { List lines = Utils.readLines(file); for (String line : lines) { - // Comment or empty line. + // Comment or empty line if (line.isEmpty() || line.startsWith("#")) { continue; } @@ -100,7 +100,7 @@ public class AsciiPlaceholders { private static String unquote(String input) { if (input.length() < 2) { - // Cannot be quoted. + // Cannot be quoted return input; } if (input.startsWith("'") && input.endsWith("'")) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/Lang.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/Lang.java index ec2a79c..ac07f66 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/Lang.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/Lang.java @@ -27,7 +27,7 @@ public class Lang extends SpecialConfig { public String menu_not_found = "&cMenu not found! Please inform the staff."; public String open_menu = "&aOpening the menu \"{menu}\"."; public String open_menu_others = "&aOpening the menu \"{menu}\" to {player}."; - public String any = "any"; // Used in no_required_item when data value is not restrictive. + public String any = "any"; // Used in no_required_item when data value is not restrictive public Lang(PluginConfig config) { super(config); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/PluginConfig.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/PluginConfig.java index 6e1e2e1..56e31a6 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/PluginConfig.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/PluginConfig.java @@ -52,7 +52,7 @@ public class PluginConfig extends YamlConfiguration { } } - // To reset all the values when loading. + // To reset all the values when loading for (String section : this.getKeys(false)) { set(section, null); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/SpecialConfig.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/SpecialConfig.java index 869392f..79a3a8a 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/SpecialConfig.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/config/yaml/SpecialConfig.java @@ -45,11 +45,11 @@ public class SpecialConfig { public void load() throws IOException, InvalidConfigurationException, Exception { - // Check if the configuration was initialized. + // Check if the configuration was initialized if (defaultValuesMap == null) { defaultValuesMap = new HashMap(); - // Put the values in the default values map. + // Put the values in the default values map for (Field field : getClass().getDeclaredFields()) { if (!isValidField(field)) continue; @@ -70,10 +70,10 @@ public class SpecialConfig { } } - // First of all, try to load the yaml file. + // First of all, try to load the yaml file config.load(); - // Save default values not set. + // Save default values not set boolean needsSave = false; for (Entry entry : defaultValuesMap.entrySet()) { if (!config.isSet(entry.getKey())) { @@ -87,7 +87,7 @@ public class SpecialConfig { config.save(); } - // Now read change the fields. + // Now read change the fields for (Field field : getClass().getDeclaredFields()) { if (!isValidField(field)) continue; @@ -110,7 +110,7 @@ public class SpecialConfig { field.set(this, config.getDouble(configKey)); } else if (type == String.class) { - field.set(this, Utils.addColors(config.getString(configKey))); // Always add colors. + field.set(this, Utils.addColors(config.getString(configKey))); // Always add colors } else { config.getPlugin().getLogger().warning("Unknown field type: " + field.getType().getName() + " (" + field.getName() + "). Please inform the developer."); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/BoundItem.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/BoundItem.java index 481ce06..cdaed7d 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/BoundItem.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/BoundItem.java @@ -36,7 +36,7 @@ public class BoundItem { this.menu = menu; this.material = material; this.clickType = clickType; - data = -1; // -1 = any. + data = -1; // -1 = any } public void setRestrictiveData(short data) { @@ -52,16 +52,16 @@ public class BoundItem { return false; } - // First, they must have the same material. + // First, they must have the same material if (this.material != item.getType()) { return false; } - // Check if the data value is valid (-1 = any data value). + // Check if the data value is valid (-1 = any data value) if (this.data != -1 && this.data != item.getDurability()) { return false; } - // Finally checks the action. + // Finally checks the action return clickType.isValidInteract(action); } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/CommandsClickHandler.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/CommandsClickHandler.java index 4f9cf68..31de4a2 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/CommandsClickHandler.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/CommandsClickHandler.java @@ -34,7 +34,7 @@ public class CommandsClickHandler implements ClickHandler { if (commands != null && commands.size() > 0) { for (IconCommand command : commands) { if (command instanceof OpenIconCommand) { - // Fix GUI closing if KEEP-OPEN is not set, and a command should open another GUI. + // Fix GUI closing if KEEP-OPEN is not set, and a command should open another GUI this.closeOnClick = false; } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java index 3f669dd..04798ff 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java @@ -112,7 +112,7 @@ public class ExtendedIconMenu extends IconMenu { ItemStack newItem = AttributeRemover.hideAttributes(extIcon.createItemstack(player)); inventory.setItem(i, newItem); } else { - // Performance, only update name and lore. + // Performance, only update name and lore ItemStack oldItem = AttributeRemover.hideAttributes(inventory.getItem(i)); ItemMeta meta = oldItem.getItemMeta(); meta.setDisplayName(extIcon.calculateName(player)); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuData.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuData.java index c883cfe..13918b5 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuData.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuData.java @@ -23,11 +23,11 @@ import com.gmail.filoghost.chestcommands.util.ClickType; public class MenuData { - // Required data. + // Required data private String title; private int rows; - // Optional data. + // Optional data private String[] commands; private Material boundMaterial; private short boundDataValue; @@ -38,7 +38,7 @@ public class MenuData { public MenuData(String title, int rows) { this.title = title; this.rows = rows; - boundDataValue = -1; // -1 = any. + boundDataValue = -1; // -1 = any } public String getTitle() { diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuInventoryHolder.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuInventoryHolder.java index 1f42725..d39ea37 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuInventoryHolder.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/MenuInventoryHolder.java @@ -34,10 +34,12 @@ public class MenuInventoryHolder implements InventoryHolder { @Override public Inventory getInventory() { - // This inventory will not do anything. - // I'm 90% sure that it doesn't break any other plugin, - // because the only way you can get here is using InventoryClickEvent, - // that is cancelled by ChestCommands, or using InventoryOpenEvent. + /* + * This inventory will not do anything. + * I'm 90% sure that it doesn't break any other plugin, + * because the only way you can get here is using InventoryClickEvent, + * that is cancelled by ChestCommands, or using InventoryOpenEvent. + */ return Bukkit.createInventory(null, iconMenu.getSize()); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/ExtendedIcon.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/ExtendedIcon.java index 910fadb..2d7c061 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/ExtendedIcon.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/ExtendedIcon.java @@ -147,7 +147,7 @@ public class ExtendedIcon extends Icon { @Override public boolean onClick(Player player) { - // Check all the requirements. + // Check all the requirements if (!canClickIcon(player)) { if (permissionMessage != null) { @@ -190,9 +190,9 @@ public class ExtendedIcon extends Icon { } } - // Take the money and the required item. + // Take the money and the required item - boolean changedVariables = false; // To update the placeholders. + boolean changedVariables = false; // To update the placeholders if (moneyPrice > 0) { if (!EconomyBridge.takeMoney(player, moneyPrice)) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/DragonBarIconCommand.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/DragonBarIconCommand.java index 1579e0d..24a4619 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/DragonBarIconCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/DragonBarIconCommand.java @@ -31,7 +31,7 @@ public class DragonBarIconCommand extends IconCommand { seconds = 1; message = command; - String[] split = command.split("\\|", 2); // Max of 2 pieces. + String[] split = command.split("\\|", 2); // Max of 2 pieces if (split.length > 1 && Utils.isValidPositiveInteger(split[0].trim())) { seconds = Integer.parseInt(split[0].trim()); message = split[1].trim(); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/OpenIconCommand.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/OpenIconCommand.java index 7d4789e..53ebb31 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/OpenIconCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/internal/icon/command/OpenIconCommand.java @@ -33,8 +33,10 @@ public class OpenIconCommand extends IconCommand { final ExtendedIconMenu menu = ChestCommands.getFileNameToMenuMap().get(command.toLowerCase()); if (menu != null) { - // Delay the task, since this command is executed in ClickInventoryEvent - // and opening another inventory in the same moment is not a good idea. + /* + * Delay the task, since this command is executed in ClickInventoryEvent + * and opening another inventory in the same moment is not a good idea. + */ Bukkit.getScheduler().scheduleSyncDelayedTask(ChestCommands.getInstance(), new Runnable() { public void run() { if (player.hasPermission(menu.getPermission())) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/CommandListener.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/CommandListener.java index 4121d61..b7ff6b6 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/CommandListener.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/CommandListener.java @@ -32,7 +32,7 @@ public class CommandListener implements Listener { return; } - // Very fast method compared to split & substring. + // Very fast method compared to split & substring String command = StringUtils.getCleanCommand(event.getMessage()); if (command.isEmpty()) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/InventoryListener.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/InventoryListener.java index 3fcc006..ba907bf 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/InventoryListener.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/InventoryListener.java @@ -57,7 +57,7 @@ public class InventoryListener implements Listener { public void onInventoryClick(InventoryClickEvent event) { if (event.getInventory().getHolder() instanceof MenuInventoryHolder) { - event.setCancelled(true); // First thing to do, if an exception is thrown at least the player doesn't take the item. + event.setCancelled(true); // First thing to do, if an exception is thrown at least the player doesn't take the item IconMenu menu = ((MenuInventoryHolder) event.getInventory().getHolder()).getIconMenu(); int slot = event.getRawSlot(); @@ -81,7 +81,7 @@ public class InventoryListener implements Listener { } } - // Closes the inventory and executes commands AFTER the event. + // Closes the inventory and executes commands AFTER the event Bukkit.getScheduler().scheduleSyncDelayedTask(ChestCommands.getInstance(), new ExecuteCommandsTask(clicker, icon)); } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/SignListener.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/SignListener.java index de9d553..f354781 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/SignListener.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/listener/SignListener.java @@ -82,7 +82,7 @@ public class SignListener implements Listener { @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) public void onSignChangeMonitor(SignChangeEvent event) { - // Prevent players with permissions for creating colored signs from creating menu signs. + // Prevent players with permissions for creating colored signs from creating menu signs if (event.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[menu]") && !event.getPlayer().hasPermission(Permissions.SIGN_CREATE)) { event.setLine(0, ChatColor.stripColor(event.getLine(0))); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/nms/AttributeRemover.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/nms/AttributeRemover.java index f20b07c..433fe7e 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/nms/AttributeRemover.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/nms/AttributeRemover.java @@ -32,8 +32,8 @@ public class AttributeRemover { private static Class nbtTagCompoundClass; private static Class nbtTagListClass; private static Class nmsItemstackClass; - private static Method asNmsCopyMethod; // static - private static Method asCraftMirrorMethod; // static + private static Method asNmsCopyMethod; + private static Method asCraftMirrorMethod; private static Method hasTagMethod; private static Method getTagMethod; private static Method setTagMethod; @@ -111,10 +111,12 @@ public class AttributeRemover { nbtSetMethod.invoke(nbtCompound, "AttributeModifiers", nbtList); return (ItemStack) asCraftMirrorMethod.invoke(null, nmsItemstack); - } catch (Exception e) { } + } catch (Throwable t) { + // Ignore + } } - // On failure + // On failure just return the item return item; } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/CommandSerializer.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/CommandSerializer.java index f1b86d6..54aa8ea 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/CommandSerializer.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/CommandSerializer.java @@ -43,7 +43,7 @@ public class CommandSerializer { commandTypesMap.put(commandPattern("console:"), ConsoleIconCommand.class); commandTypesMap.put(commandPattern("op:"), OpIconCommand.class); commandTypesMap.put(commandPattern("(open|menu):"), OpenIconCommand.class); - commandTypesMap.put(commandPattern("server:?"), ServerIconCommand.class); // The colon is optional. + commandTypesMap.put(commandPattern("server:?"), ServerIconCommand.class); // The colon is optional commandTypesMap.put(commandPattern("tell:"), TellIconCommand.class); commandTypesMap.put(commandPattern("broadcast:"), BroadcastIconCommand.class); commandTypesMap.put(commandPattern("give:"), GiveIconCommand.class); @@ -53,7 +53,7 @@ public class CommandSerializer { } private static Pattern commandPattern(String regex) { - return Pattern.compile("^(?i)" + regex); // Case insensitive and only at the beginning. + return Pattern.compile("^(?i)" + regex); // Case insensitive and only at the beginning } public static void checkClassConstructors(ErrorLogger errorLogger) { @@ -93,18 +93,18 @@ public class CommandSerializer { for (Entry> entry : commandTypesMap.entrySet()) { Matcher matcher = entry.getKey().matcher(input); if (matcher.find()) { - // Remove the command prefix and trim the spaces. + // Remove the command prefix and trim the spaces String cleanCommand = matcher.replaceFirst("").trim(); try { return entry.getValue().getDeclaredConstructor(String.class).newInstance(cleanCommand); } catch (Exception e) { - // Checked at startup. + // Checked at startup } } } - return new PlayerIconCommand(input); // Normal command, no match found. + return new PlayerIconCommand(input); // Normal command, no match found } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/EnchantmentSerializer.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/EnchantmentSerializer.java index d6de9c7..47cce08 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/EnchantmentSerializer.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/EnchantmentSerializer.java @@ -53,7 +53,7 @@ public class EnchantmentSerializer { for (Enchantment enchant : Enchantment.values()) { if (enchant != null) { - // Accepts the ugly default names too. + // Accepts the ugly default names too enchantmentsMap.put(formatLowercase(enchant.getName()), enchant); } } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/IconSerializer.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/IconSerializer.java index b3f3024..1530fc9 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/IconSerializer.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/IconSerializer.java @@ -89,7 +89,7 @@ public class IconSerializer { public static Icon loadIconFromSection(ConfigurationSection section, String iconName, String menuFileName, ErrorLogger errorLogger) { Validate.notNull(section, "ConfigurationSection cannot be null"); - // The icon is valid even without a Material. + // The icon is valid even without a Material ExtendedIcon icon = new ExtendedIcon(); if (section.isSet(Nodes.ID)) { @@ -116,7 +116,7 @@ public class IconSerializer { if (section.isSet(Nodes.NBT_DATA)) { String nbtData = section.getString(Nodes.NBT_DATA); try { - // Check that NBT has valid syntax before applying it to the icon. + // Check that NBT has valid syntax before applying it to the icon MojangsonParser.parse(nbtData); icon.setNBTData(nbtData); } catch (MojangsonParseException e) { diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/MenuSerializer.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/MenuSerializer.java index 0fdf2f4..8b3b209 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/MenuSerializer.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/serializer/MenuSerializer.java @@ -99,7 +99,7 @@ public class MenuSerializer { } } else { - rows = 6; // Defaults to 6 rows. + rows = 6; // Defaults to 6 rows errorLogger.addError("The menu \"" + config.getFileName() + "\" doesn't have a the number of rows set, it will have 6 rows by default."); } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/ItemStackReader.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/ItemStackReader.java index 01ced92..4713f4e 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/ItemStackReader.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/ItemStackReader.java @@ -21,7 +21,7 @@ import com.gmail.filoghost.chestcommands.exception.FormatException; public class ItemStackReader { - private Material material = Material.STONE; // In the worst case (bad exception handling) we just get stone. + private Material material = Material.STONE; // In the worst case (bad exception handling) we just get stone private int amount = 1; private short dataValue = 0; private boolean explicitDataValue = false; @@ -34,11 +34,11 @@ public class ItemStackReader { public ItemStackReader(String input, boolean parseAmount) throws FormatException { Validate.notNull(input, "input cannot be null"); - // Remove spaces, they're not needed. + // Remove spaces, they're not needed input = StringUtils.stripChars(input, " _-"); if (parseAmount) { - // Read the optional amount. + // Read the optional amount String[] splitAmount = input.split(","); if (splitAmount.length > 1) { @@ -51,13 +51,13 @@ public class ItemStackReader { if (amount <= 0) throw new FormatException("invalid amount \"" + splitAmount[1] + "\""); this.amount = amount; - // Only keep the first part as input. + // Only keep the first part as input input = splitAmount[0]; } } - // Read the optional data value. + // Read the optional data value String[] splitByColons = input.split(":"); if (splitByColons.length > 1) { @@ -74,7 +74,7 @@ public class ItemStackReader { this.explicitDataValue = true; this.dataValue = dataValue; - // Only keep the first part as input. + // Only keep the first part as input input = splitByColons[0]; } diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/MaterialsRegistry.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/MaterialsRegistry.java index 64e1ae5..4a6e760 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/MaterialsRegistry.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/MaterialsRegistry.java @@ -24,19 +24,19 @@ import org.bukkit.Material; @SuppressWarnings("deprecation") public class MaterialsRegistry { - // Material names have been changed in 1.13, when dolphins were added. + // Material names have been changed in 1.13, when dolphins were added private static final boolean USE_NEW_MATERIAL_NAMES = Utils.isClassLoaded("org.bukkit.entity.Dolphin"); - // Characters to ignore when searching materials by name. + // Characters to ignore when searching materials by name private static final char[] IGNORE_CHARS = {'-', '_', ' '}; - // Default material names are ugly. + // Default material names are ugly private static final Map MATERIALS_BY_ALIAS = new HashMap(); - // Materials that are considered air (with 1.13+ compatibility). + // Materials that are considered air (with 1.13+ compatibility) private static final Collection AIR_MATERIALS = getExistingMaterials("AIR", "CAVE_AIR", "VOID_AIR"); - // Materials that have a "Sign" block state (with 1.13+ compatibility). + // Materials that have a "Sign" block state (with 1.13+ compatibility) private static final Collection SIGN_MATERIALS = getExistingMaterials("SIGN", "SIGN_POST", "WALL_SIGN"); @@ -48,7 +48,7 @@ public class MaterialsRegistry { try { addMaterialAlias(name, Material.valueOf(materialEnumName)); } catch (IllegalArgumentException e) { - // Ignore, do not add a new alias. + // Ignore, do not add a new alias } } @@ -71,7 +71,7 @@ public class MaterialsRegistry { try { existingMaterials.add(Material.valueOf(materialEnumName)); } catch (IllegalArgumentException e) { - // Ignore, not existing. + // Ignore, not existing } } @@ -95,12 +95,12 @@ public class MaterialsRegistry { addMaterialAlias(material.toString(), material); if (!useNewMaterialNames()) { - // Add numerical IDs in versions before 1.13. + // Add numerical IDs in versions before 1.13 addMaterialAlias(String.valueOf(material.getId()), material); } } - // Add some default useful aliases (when present). + // Add some default useful aliases (when present) tryAddMaterialAlias("iron bar", "IRON_FENCE"); tryAddMaterialAlias("iron bars", "IRON_FENCE"); tryAddMaterialAlias("glass pane", "THIN_GLASS"); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/StringUtils.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/StringUtils.java index 4c895d8..e459e65 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/StringUtils.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/StringUtils.java @@ -24,7 +24,7 @@ public class StringUtils { return stripChars(input, removed.toCharArray()); } - // Removes the first slash, and returns the all the chars until a space is encontered. + // Removes the first slash, and returns the all the chars until a space is encontered public static String getCleanCommand(String message) { char[] chars = message.toCharArray(); diff --git a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/Utils.java b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/Utils.java index 9e97954..e14ffab 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/Utils.java +++ b/Plugin/src/main/java/com/gmail/filoghost/chestcommands/util/Utils.java @@ -228,7 +228,7 @@ public class Utils { try { plugin.saveResource(name, false); } catch (Exception ex) { - // Shhh... + // Ignore } }