diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index 6d12dfd..f2918ee 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -6,6 +6,7 @@ + @@ -13,12 +14,187 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index c578f08..50ef1d4 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -4,5 +4,5 @@ "https://checkstyle.org/dtds/suppressions_1_2.dtd"> - + \ No newline at end of file diff --git a/plugin/src/main/java/me/filoghost/chestcommands/action/DragonBarAction.java b/plugin/src/main/java/me/filoghost/chestcommands/action/DragonBarAction.java index 764cb28..80176ff 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/action/DragonBarAction.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/action/DragonBarAction.java @@ -25,7 +25,7 @@ public class DragonBarAction implements Action { String[] split = Strings.trimmedSplit(serialiazedAction, "\\|", 2); // Max of 2 pieces if (split.length > 1) { try { - seconds = NumberParser.getStrictlyPositiveInteger(split[0]); + seconds = NumberParser.getStrictlyPositiveInteger(split[0]); message = split[1]; } catch (ParseException e) { throw new ParseException(Errors.Parsing.invalidBossBarTime(split[0]), e); diff --git a/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java b/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java index 72c5b3c..e22ca2c 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java @@ -58,7 +58,8 @@ public class CommandHandler extends CommandFramework { if (errorCollector.hasErrors()) { errorCollector.logToConsole(); - sender.sendMessage(ChestCommands.CHAT_PREFIX + ChatColor.RED + "Last time the plugin loaded, " + errorCollector.getErrorsCount() + " error(s) were found."); + sender.sendMessage(ChestCommands.CHAT_PREFIX + ChatColor.RED + "Last time the plugin loaded, " + + errorCollector.getErrorsCount() + " error(s) were found."); if (!(sender instanceof ConsoleCommandSender)) { sender.sendMessage(ChestCommands.CHAT_PREFIX + ChatColor.RED + "Errors were printed on the console."); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/hook/VaultEconomyHook.java b/plugin/src/main/java/me/filoghost/chestcommands/hook/VaultEconomyHook.java index b9bc36a..38c9d41 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/hook/VaultEconomyHook.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/hook/VaultEconomyHook.java @@ -52,8 +52,8 @@ public enum VaultEconomyHook implements PluginHook { return balance >= minimum; } - /** - * @return true if the operation was successful. + /* + * Returns true if the operation was successful. */ public static boolean takeMoney(Player player, double amount) { INSTANCE.checkEnabledState(); diff --git a/plugin/src/main/java/me/filoghost/chestcommands/icon/BaseConfigurableIcon.java b/plugin/src/main/java/me/filoghost/chestcommands/icon/BaseConfigurableIcon.java index f72b74f..a3f7a5e 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/icon/BaseConfigurableIcon.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/icon/BaseConfigurableIcon.java @@ -5,11 +5,6 @@ */ package me.filoghost.chestcommands.icon; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import me.filoghost.chestcommands.api.Icon; import me.filoghost.chestcommands.placeholder.PlaceholderString; import me.filoghost.chestcommands.placeholder.PlaceholderStringList; @@ -17,7 +12,6 @@ import me.filoghost.chestcommands.util.nbt.parser.MojangsonParseException; import me.filoghost.chestcommands.util.nbt.parser.MojangsonParser; import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.collection.CollectionUtils; -import me.filoghost.fcommons.logging.Log; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -33,6 +27,12 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public abstract class BaseConfigurableIcon implements Icon { private Material material; @@ -49,7 +49,7 @@ public abstract class BaseConfigurableIcon implements Icon { private List bannerPatterns; private boolean placeholdersEnabled; - protected ItemStack cachedRendering; // Cache the rendered item when possible and if state hasn't changed + private ItemStack cachedRendering; // Cache the rendered item when possible and if state hasn't changed public BaseConfigurableIcon(Material material) { this.material = material; @@ -266,13 +266,7 @@ public abstract class BaseConfigurableIcon implements Icon { // 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 - Bukkit.getUnsafe().modifyItemStack(itemStack, nbtData); - } catch (Throwable t) { - this.nbtData = null; - Log.warning("Could not apply NBT data to an item.", t); - } + Bukkit.getUnsafe().modifyItemStack(itemStack, nbtData); } // Then apply data from config nodes, overwriting NBT data if there are conflicting values diff --git a/plugin/src/main/java/me/filoghost/chestcommands/inventory/Grid.java b/plugin/src/main/java/me/filoghost/chestcommands/inventory/Grid.java index 3ac0df2..b49a8d3 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/inventory/Grid.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/inventory/Grid.java @@ -12,14 +12,14 @@ import me.filoghost.fcommons.Preconditions; * There 3 rows and 9 columns. The number inside the cells is the index. * * <--- Column ---> - * + * * 0 1 2 3 4 5 6 7 8 * ^ +--------------------------------------------+ * | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | * |----+----+----+----+----+----+----+----+----| * Row 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | * |----+----+----+----+----+----+----+----+----| - * | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | + * | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | * v +--------------------------------------------+ * */ diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradeList.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradeList.java index 5c3fb48..902be11 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradeList.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradeList.java @@ -6,24 +6,26 @@ package me.filoghost.chestcommands.legacy; import com.google.common.collect.ImmutableList; +import me.filoghost.chestcommands.config.ConfigManager; +import me.filoghost.chestcommands.legacy.upgrade.Upgrade; +import me.filoghost.chestcommands.legacy.upgrade.UpgradeTask; +import me.filoghost.chestcommands.legacy.upgrade.UpgradeTaskException; +import me.filoghost.chestcommands.legacy.v4_0.V4_0_LangUpgradeTask; +import me.filoghost.chestcommands.legacy.v4_0.V4_0_MenuNodeRenameUpgradeTask; +import me.filoghost.chestcommands.legacy.v4_0.V4_0_MenuReformatUpgradeTask; +import me.filoghost.chestcommands.legacy.v4_0.V4_0_PlaceholdersUpgradeTask; +import me.filoghost.chestcommands.legacy.v4_0.V4_0_SettingsUpgradeTask; +import me.filoghost.chestcommands.logging.Errors; +import me.filoghost.fcommons.collection.CollectionUtils; +import me.filoghost.fcommons.config.ConfigLoader; +import me.filoghost.fcommons.config.exception.ConfigException; +import me.filoghost.fcommons.logging.Log; + import java.io.IOException; import java.nio.file.Path; import java.util.Collections; import java.util.List; import java.util.function.Function; -import me.filoghost.chestcommands.config.ConfigManager; -import me.filoghost.chestcommands.legacy.upgrade.Upgrade; -import me.filoghost.chestcommands.legacy.upgrade.UpgradeTask; -import me.filoghost.chestcommands.legacy.upgrade.UpgradeTaskException; -import me.filoghost.chestcommands.legacy.v4_0.v4_0_LangUpgradeTask; -import me.filoghost.chestcommands.legacy.v4_0.v4_0_MenuNodeRenameUpgradeTask; -import me.filoghost.chestcommands.legacy.v4_0.v4_0_MenuReformatUpgradeTask; -import me.filoghost.chestcommands.legacy.v4_0.v4_0_PlaceholdersUpgradeTask; -import me.filoghost.chestcommands.legacy.v4_0.v4_0_SettingsUpgradeTask; -import me.filoghost.chestcommands.logging.Errors; -import me.filoghost.fcommons.collection.CollectionUtils; -import me.filoghost.fcommons.config.ConfigLoader; -import me.filoghost.fcommons.logging.Log; public class UpgradeList { @@ -32,20 +34,20 @@ public class UpgradeList { */ private static final ImmutableList orderedUpgrades = ImmutableList.of( multiTaskUpgrade("v4.0-menus-rename", (configManager) -> { - return createMenuTasks(configManager, v4_0_MenuNodeRenameUpgradeTask::new); + return createMenuTasks(configManager, V4_0_MenuNodeRenameUpgradeTask::new); }), // Reformat after nodes have already been renamed multiTaskUpgrade("v4.0-menus-reformat", (configManager) -> { String legacyCommandSeparator = readLegacyCommandSeparator(configManager); return createMenuTasks(configManager, - file -> new v4_0_MenuReformatUpgradeTask(configManager, file, legacyCommandSeparator)); + file -> new V4_0_MenuReformatUpgradeTask(configManager, file, legacyCommandSeparator)); }), // Upgrade config after reading the command separator for menus - singleTaskUpgrade("v4.0-config", v4_0_SettingsUpgradeTask::new), - singleTaskUpgrade("v4.0-placeholders", v4_0_PlaceholdersUpgradeTask::new), - singleTaskUpgrade("v4.0-lang", v4_0_LangUpgradeTask::new) + singleTaskUpgrade("v4.0-config", V4_0_SettingsUpgradeTask::new), + singleTaskUpgrade("v4.0-placeholders", V4_0_PlaceholdersUpgradeTask::new), + singleTaskUpgrade("v4.0-lang", V4_0_LangUpgradeTask::new) ); private static Upgrade singleTaskUpgrade(String id, Upgrade.SingleTaskSupplier upgradeTaskSupplier) { @@ -80,7 +82,7 @@ public class UpgradeList { try { return settingsConfigLoader.load().getString("multiple-commands-separator"); - } catch (Throwable t) { + } catch (ConfigException e) { Log.warning("Failed to load \"" + settingsConfigLoader.getFile() + "\", assuming default command separator \";\"."); return null; } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradesDoneRegistry.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradesDoneRegistry.java index 31e8876..4e4aae1 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradesDoneRegistry.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/UpgradesDoneRegistry.java @@ -5,6 +5,8 @@ */ package me.filoghost.chestcommands.legacy; +import me.filoghost.chestcommands.legacy.upgrade.Upgrade; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -13,7 +15,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Stream; -import me.filoghost.chestcommands.legacy.upgrade.Upgrade; public class UpgradesDoneRegistry { @@ -21,7 +22,7 @@ public class UpgradesDoneRegistry { private final Set upgradesDone; private boolean needSave; - public UpgradesDoneRegistry(Path saveFile) throws IOException { + public UpgradesDoneRegistry(Path saveFile) throws IOException { this.saveFile = saveFile; this.upgradesDone = new HashSet<>(); diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_LangUpgradeTask.java similarity index 84% rename from plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java rename to plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_LangUpgradeTask.java index cf1a5ab..a6bc963 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_LangUpgradeTask.java @@ -9,9 +9,9 @@ import me.filoghost.chestcommands.config.ConfigManager; import me.filoghost.chestcommands.legacy.upgrade.YamlUpgradeTask; import me.filoghost.fcommons.config.Config; -public class v4_0_LangUpgradeTask extends YamlUpgradeTask { +public class V4_0_LangUpgradeTask extends YamlUpgradeTask { - public v4_0_LangUpgradeTask(ConfigManager configManager) { + public V4_0_LangUpgradeTask(ConfigManager configManager) { super(configManager.getConfigLoader("lang.yml")); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_MenuNodeRenameUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_MenuNodeRenameUpgradeTask.java similarity index 89% rename from plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_MenuNodeRenameUpgradeTask.java rename to plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_MenuNodeRenameUpgradeTask.java index e1952a1..d50d476 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_MenuNodeRenameUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_MenuNodeRenameUpgradeTask.java @@ -5,15 +5,17 @@ */ package me.filoghost.chestcommands.legacy.v4_0; -import java.nio.file.Path; import me.filoghost.chestcommands.legacy.upgrade.RegexUpgradeTask; import me.filoghost.chestcommands.parsing.icon.AttributeType; -public class v4_0_MenuNodeRenameUpgradeTask extends RegexUpgradeTask { +import java.nio.file.Path; - public v4_0_MenuNodeRenameUpgradeTask(Path menuFile) { +public class V4_0_MenuNodeRenameUpgradeTask extends RegexUpgradeTask { + + public V4_0_MenuNodeRenameUpgradeTask(Path menuFile) { super(menuFile); } + @Override protected void computeRegexChanges() { replaceSubNode("command", "commands"); diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_MenuReformatUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_MenuReformatUpgradeTask.java similarity index 97% rename from plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_MenuReformatUpgradeTask.java rename to plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_MenuReformatUpgradeTask.java index a6ac8dc..3cd28a2 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_MenuReformatUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_MenuReformatUpgradeTask.java @@ -5,11 +5,6 @@ */ package me.filoghost.chestcommands.legacy.v4_0; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.regex.Pattern; import me.filoghost.chestcommands.config.ConfigManager; import me.filoghost.chestcommands.legacy.upgrade.YamlUpgradeTask; import me.filoghost.chestcommands.parsing.icon.AttributeType; @@ -19,11 +14,17 @@ import me.filoghost.fcommons.config.Config; import me.filoghost.fcommons.config.ConfigSection; import me.filoghost.fcommons.config.ConfigValueType; -public class v4_0_MenuReformatUpgradeTask extends YamlUpgradeTask { +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.regex.Pattern; + +public class V4_0_MenuReformatUpgradeTask extends YamlUpgradeTask { private final String legacyCommandSeparator; - public v4_0_MenuReformatUpgradeTask(ConfigManager configManager, Path menuFile, String legacyCommandSeparator) { + public V4_0_MenuReformatUpgradeTask(ConfigManager configManager, Path menuFile, String legacyCommandSeparator) { super(configManager.getConfigLoader(menuFile)); this.legacyCommandSeparator = legacyCommandSeparator; } @@ -78,7 +79,7 @@ public class v4_0_MenuReformatUpgradeTask extends YamlUpgradeTask { setSaveRequired(); actions.set(i, newAction); } - } + } config.setStringList(node, actions); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_PlaceholdersUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_PlaceholdersUpgradeTask.java similarity index 96% rename from plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_PlaceholdersUpgradeTask.java rename to plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_PlaceholdersUpgradeTask.java index c806a04..0960f76 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_PlaceholdersUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_PlaceholdersUpgradeTask.java @@ -5,10 +5,6 @@ */ package me.filoghost.chestcommands.legacy.v4_0; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; import me.filoghost.chestcommands.config.ConfigManager; import me.filoghost.chestcommands.legacy.upgrade.UpgradeTask; import me.filoghost.fcommons.Strings; @@ -19,13 +15,18 @@ import me.filoghost.fcommons.config.exception.ConfigLoadException; import me.filoghost.fcommons.config.exception.ConfigSaveException; import org.apache.commons.lang.StringEscapeUtils; -public class v4_0_PlaceholdersUpgradeTask extends UpgradeTask { +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +public class V4_0_PlaceholdersUpgradeTask extends UpgradeTask { private final Path oldPlaceholdersFile; private final ConfigLoader newPlaceholdersConfigLoader; private Config updatedConfig; - public v4_0_PlaceholdersUpgradeTask(ConfigManager configManager) { + public V4_0_PlaceholdersUpgradeTask(ConfigManager configManager) { this.oldPlaceholdersFile = configManager.getRootDataFolder().resolve("placeholders.yml"); this.newPlaceholdersConfigLoader = configManager.getConfigLoader("custom-placeholders.yml"); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_SettingsUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_SettingsUpgradeTask.java similarity index 83% rename from plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_SettingsUpgradeTask.java rename to plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_SettingsUpgradeTask.java index bc2eb0f..37f4b89 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_SettingsUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/V4_0_SettingsUpgradeTask.java @@ -9,9 +9,9 @@ import me.filoghost.chestcommands.config.ConfigManager; import me.filoghost.chestcommands.legacy.upgrade.YamlUpgradeTask; import me.filoghost.fcommons.config.Config; -public class v4_0_SettingsUpgradeTask extends YamlUpgradeTask { +public class V4_0_SettingsUpgradeTask extends YamlUpgradeTask { - public v4_0_SettingsUpgradeTask(ConfigManager configManager) { + public V4_0_SettingsUpgradeTask(ConfigManager configManager) { super(configManager.getConfigLoader("config.yml")); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/logging/ErrorPrintInfo.java b/plugin/src/main/java/me/filoghost/chestcommands/logging/ErrorPrintInfo.java index f7b25d5..38ae3d3 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/logging/ErrorPrintInfo.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/logging/ErrorPrintInfo.java @@ -14,7 +14,7 @@ class ErrorPrintInfo { private final String details; private final Throwable cause; - public ErrorPrintInfo(int index, List message, String details, Throwable cause) { + protected ErrorPrintInfo(int index, List message, String details, Throwable cause) { this.index = index; this.message = message; this.details = details; diff --git a/plugin/src/main/java/me/filoghost/chestcommands/logging/Errors.java b/plugin/src/main/java/me/filoghost/chestcommands/logging/Errors.java index b2aedde..246a528 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/logging/Errors.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/logging/Errors.java @@ -5,13 +5,14 @@ */ package me.filoghost.chestcommands.logging; -import java.nio.file.Path; import me.filoghost.chestcommands.ChestCommands; import me.filoghost.chestcommands.parsing.icon.AttributeType; import me.filoghost.chestcommands.parsing.icon.IconSettings; import me.filoghost.fcommons.config.ConfigErrors; import org.bukkit.ChatColor; +import java.nio.file.Path; + public class Errors { public static class Config { @@ -41,7 +42,9 @@ public class Errors { public static final String genericExecutorError = "error while running automatic configuration upgrades"; public static final String menuListIOException = "couldn't obtain a list of menu files"; - public static final String failedSomeUpgrades = "note: one or more automatic upgrades may have not been applied, configuration files or menus may require manual changes"; + public static final String failedSomeUpgrades = + "note: one or more automatic upgrades may have not been applied, " + + "configuration files or menus may require manual changes"; public static final String failedToPrepareUpgradeTasks = "error while trying to prepare an automatic configuration upgrade"; public static String metadataReadError(Path metadataFile) { diff --git a/plugin/src/main/java/me/filoghost/chestcommands/menu/BaseMenu.java b/plugin/src/main/java/me/filoghost/chestcommands/menu/BaseMenu.java index b70480b..9a5f101 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/menu/BaseMenu.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/menu/BaseMenu.java @@ -18,8 +18,8 @@ import org.bukkit.entity.Player; public abstract class BaseMenu implements Menu { - protected final String title; - protected final Grid icons; + private final String title; + private final Grid icons; public BaseMenu(String title, int rows) { diff --git a/plugin/src/main/java/me/filoghost/chestcommands/parsing/ItemStackParser.java b/plugin/src/main/java/me/filoghost/chestcommands/parsing/ItemStackParser.java index 9467092..009577d 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/parsing/ItemStackParser.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/parsing/ItemStackParser.java @@ -19,7 +19,7 @@ public class ItemStackParser { private short durability = 0; private boolean hasExplicitDurability = false; - /** + /* * Reads item in the format "material:durability, amount". */ public ItemStackParser(String input, boolean parseAmount) throws ParseException { diff --git a/plugin/src/main/java/me/filoghost/chestcommands/placeholder/scanner/PlaceholderMatch.java b/plugin/src/main/java/me/filoghost/chestcommands/placeholder/scanner/PlaceholderMatch.java index b0ecb49..29d73c0 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/placeholder/scanner/PlaceholderMatch.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/placeholder/scanner/PlaceholderMatch.java @@ -5,9 +5,10 @@ */ package me.filoghost.chestcommands.placeholder.scanner; -import java.util.Objects; import me.filoghost.fcommons.Strings; +import java.util.Objects; + public class PlaceholderMatch { private final String pluginNamespace; @@ -32,7 +33,7 @@ public class PlaceholderMatch { return argument; } - /** + /* * Valid formats: * {pluginName/placeholder: argument} * {placeholder: argument} @@ -70,9 +71,9 @@ public class PlaceholderMatch { } PlaceholderMatch other = (PlaceholderMatch) obj; - return Objects.equals(this.pluginNamespace, other.pluginNamespace) && - Objects.equals(this.identifier, other.identifier) && - Objects.equals(this.argument, other.argument); + return Objects.equals(this.pluginNamespace, other.pluginNamespace) + && Objects.equals(this.identifier, other.identifier) + && Objects.equals(this.argument, other.argument); } @Override diff --git a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTByteArray.java b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTByteArray.java index 1b4175e..836614d 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTByteArray.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTByteArray.java @@ -20,8 +20,9 @@ public final class NBTByteArray extends NBTTag { public NBTByteArray(Number[] numbers) { this.value = new byte[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { value[i] = numbers[i].byteValue(); + } } /** diff --git a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTCompound.java b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTCompound.java index bf8a0e5..5ccea47 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTCompound.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTCompound.java @@ -61,7 +61,9 @@ public final class NBTCompound extends NBTTag { * @throws NoSuchElementException if there is no tag with given name */ public NBTTag getTag(String key) { - if (!hasKey(key)) throw new NoSuchElementException(key); + if (!hasKey(key)) { + throw new NoSuchElementException(key); + } return value.get(key); } @@ -74,7 +76,9 @@ public final class NBTCompound extends NBTTag { */ public byte getByte(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTByte)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTByte)) { + throw new NoSuchElementException(key); + } return ((NBTByte) tag).getValue(); } @@ -87,7 +91,9 @@ public final class NBTCompound extends NBTTag { */ public short getShort(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTShort)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTShort)) { + throw new NoSuchElementException(key); + } return ((NBTShort) tag).getValue(); } @@ -100,7 +106,9 @@ public final class NBTCompound extends NBTTag { */ public int getInt(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTInt)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTInt)) { + throw new NoSuchElementException(key); + } return ((NBTInt) tag).getValue(); } @@ -113,7 +121,9 @@ public final class NBTCompound extends NBTTag { */ public long getLong(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTLong)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTLong)) { + throw new NoSuchElementException(key); + } return ((NBTLong) tag).getValue(); } @@ -126,7 +136,9 @@ public final class NBTCompound extends NBTTag { */ public float getFloat(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTFloat)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTFloat)) { + throw new NoSuchElementException(key); + } return ((NBTFloat) tag).getValue(); } @@ -139,7 +151,9 @@ public final class NBTCompound extends NBTTag { */ public double getDouble(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTDouble)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTDouble)) { + throw new NoSuchElementException(key); + } return ((NBTDouble) tag).getValue(); } @@ -152,7 +166,9 @@ public final class NBTCompound extends NBTTag { */ public byte[] getByteArray(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTByteArray)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTByteArray)) { + throw new NoSuchElementException(key); + } return ((NBTByteArray) tag).getValue(); } @@ -165,7 +181,9 @@ public final class NBTCompound extends NBTTag { */ public String getString(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTString)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTString)) { + throw new NoSuchElementException(key); + } return ((NBTString) tag).getValue(); } @@ -189,7 +207,9 @@ public final class NBTCompound extends NBTTag { */ public NBTList getTagList(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTList)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTList)) { + throw new NoSuchElementException(key); + } return (NBTList) tag; } @@ -213,7 +233,9 @@ public final class NBTCompound extends NBTTag { */ public NBTCompound getCompoundTag(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTCompound)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTCompound)) { + throw new NoSuchElementException(key); + } return (NBTCompound) tag; } @@ -226,7 +248,9 @@ public final class NBTCompound extends NBTTag { */ public int[] getIntArray(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTIntArray)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTIntArray)) { + throw new NoSuchElementException(key); + } return ((NBTIntArray) tag).getValue(); } @@ -239,7 +263,9 @@ public final class NBTCompound extends NBTTag { */ public long[] getLongArray(String key) { NBTTag tag = value.get(key); - if (!(tag instanceof NBTLongArray)) throw new NoSuchElementException(key); + if (!(tag instanceof NBTLongArray)) { + throw new NoSuchElementException(key); + } return ((NBTLongArray) tag).getValue(); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTIntArray.java b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTIntArray.java index 0d75a64..3c3f5d3 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTIntArray.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTIntArray.java @@ -26,8 +26,9 @@ public final class NBTIntArray extends NBTTag implements Cloneable { public NBTIntArray(Number[] numbers) { this.value = new int[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { value[i] = numbers[i].intValue(); + } } /** diff --git a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTList.java b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTList.java index c702bd4..028e3d0 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTList.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTList.java @@ -120,25 +120,29 @@ public final class NBTList extends NBTTag implements Iterable, Cloneable * @param value the tag */ public void add(NBTTag value) { - if (this.type == null) + if (this.type == null) { this.type = value.getType(); - else if (this.type != value.getType()) + } else if (this.type != value.getType()) { throw new IllegalArgumentException(value.getType() + " is not of expected type " + type); + } list.add(value); } /** * Add the given tag at the given index in the list. * + * @param index the index in the list * @param value the tag */ public void add(int index, NBTTag value) { - if (index < 0 || index >= list.size()) + if (index < 0 || index >= list.size()) { throw new IndexOutOfBoundsException(Integer.toString(index)); - if (this.type == null) + } + if (this.type == null) { this.type = value.getType(); - else if (this.type != value.getType()) + } else if (this.type != value.getType()) { throw new IllegalArgumentException(value.getType() + " is not of expected type " + type); + } list.add(index, value); } @@ -177,8 +181,11 @@ public final class NBTList extends NBTTag implements Iterable, Cloneable boolean first = true; while (iter.hasNext()) { - if (first) first = false; - else builder.append(','); + if (first) { + first = false; + } else { + builder.append(','); + } builder.append(iter.next().toMSONString()); } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTLongArray.java b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTLongArray.java index 6540759..5e81f88 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTLongArray.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/NBTLongArray.java @@ -25,8 +25,9 @@ public final class NBTLongArray extends NBTTag { public NBTLongArray(Number[] numbers) { this.value = new long[numbers.length]; - for (int i = 0; i < numbers.length; i++) + for (int i = 0; i < numbers.length; i++) { value[i] = numbers[i].longValue(); + } } /** diff --git a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/parser/MojangsonParser.java b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/parser/MojangsonParser.java index 8550081..a5d6e81 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/parser/MojangsonParser.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/util/nbt/parser/MojangsonParser.java @@ -5,9 +5,6 @@ */ package me.filoghost.chestcommands.util.nbt.parser; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; import me.filoghost.chestcommands.util.nbt.NBTByte; import me.filoghost.chestcommands.util.nbt.NBTByteArray; import me.filoghost.chestcommands.util.nbt.NBTCompound; @@ -23,6 +20,10 @@ import me.filoghost.chestcommands.util.nbt.NBTString; import me.filoghost.chestcommands.util.nbt.NBTTag; import me.filoghost.chestcommands.util.nbt.NBTType; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + public final class MojangsonParser { private static final Pattern @@ -65,11 +66,13 @@ public final class MojangsonParser { private NBTTag parseStringOrLiteral() throws MojangsonParseException { skipWhitespace(); - if (currentChar() == '"') + if (currentChar() == '"') { return new NBTString(parseQuotedString()); + } String str = parseSimpleString(); - if (str.isEmpty()) + if (str.isEmpty()) { throw parseException("Expected value"); + } return parseLiteral(str); } @@ -150,16 +153,18 @@ public final class MojangsonParser { private NBTTag parseAnything() throws MojangsonParseException { skipWhitespace(); - if (!hasNext()) + if (!hasNext()) { throw parseException("Expected value"); + } int c = currentChar(); - if (c == '{') + if (c == '{') { return parseCompound(); - else if (c == '[') + } else if (c == '[') { return parseDetectedArray(); - else + } else { return parseStringOrLiteral(); + } } private NBTTag parseDetectedArray() throws MojangsonParseException { @@ -237,12 +242,13 @@ public final class MojangsonParser { if (!hasNext()) { throw parseException("Expected value"); } - if (arrayType == 'B') + if (arrayType == 'B') { return new NBTByteArray(parseNumArray(NBTType.BYTE_ARRAY, NBTType.BYTE)); - else if (arrayType == 'L') + } else if (arrayType == 'L') { return new NBTLongArray(parseNumArray(NBTType.LONG_ARRAY, NBTType.LONG)); - else if (arrayType == 'I') + } else if (arrayType == 'I') { return new NBTIntArray(parseNumArray(NBTType.INT_ARRAY, NBTType.INT)); + } throw parseException("Invalid array type '" + arrayType + "' found"); } @@ -346,7 +352,10 @@ public final class MojangsonParser { this.index += 1; return; } - throw new MojangsonParseException("Expected '" + c + "' but got '" + (hasNext ? Character.valueOf(currentChar()) : "") + "'", this.str, this.index + 1); + throw new MojangsonParseException( + "Expected '" + c + "' but got '" + (hasNext ? Character.valueOf(currentChar()) : "") + "'", + this.str, + this.index + 1); } /**