diff --git a/src/main/java/me/kodysimpson/simpapi/colors/ColorTranslator.java b/src/main/java/me/kodysimpson/simpapi/colors/ColorTranslator.java index 5594a82..aa3f9d9 100644 --- a/src/main/java/me/kodysimpson/simpapi/colors/ColorTranslator.java +++ b/src/main/java/me/kodysimpson/simpapi/colors/ColorTranslator.java @@ -2,7 +2,6 @@ import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.TextComponent; import org.jetbrains.annotations.NotNull; @@ -11,16 +10,15 @@ public class ColorTranslator { - private static final Pattern HEX_PATTERN = Pattern.compile("(&#[0-9a-fA-F]{6})"); - @Deprecated public static final String WITH_DELIMITER = "((?<=%1$s)|(?=%1$s))"; + private static final Pattern HEX_PATTERN = Pattern.compile("(&#[0-9a-fA-F]{6})"); /** * @param text The string of text to apply color/effects to * @return Returns a string of text with color/effects applied */ - public static String translateColorCodes(@NotNull String text){ + public static String translateColorCodes(@NotNull String text) { //good thing we're stuck on java 8, which means we can't use this (: // String hexColored = HEX_PATTERN.matcher(text) // .replaceAll(match -> "" + ChatColor.of(match.group(1))); @@ -41,7 +39,7 @@ public static String translateColorCodes(@NotNull String text){ * @param text The text with color codes that you want to turn into a TextComponent * @return the TextComponent with hex colors and regular colors */ - public static TextComponent translateColorCodesToTextComponent(@NotNull String text){ + public static TextComponent translateColorCodesToTextComponent(@NotNull String text) { //This is done solely to ensure hex color codes are in the format //fromLegacyText expects: //&#FF0000 -> &x&f&f&0&0&0&0 @@ -50,7 +48,7 @@ public static TextComponent translateColorCodesToTextComponent(@NotNull String t TextComponent base = new TextComponent(); BaseComponent[] converted = TextComponent.fromLegacyText(colored); - for(BaseComponent comp : converted) { + for (BaseComponent comp : converted) { base.addExtra(comp); } diff --git a/src/main/java/me/kodysimpson/simpapi/command/CommandList.java b/src/main/java/me/kodysimpson/simpapi/command/CommandList.java index fd4725f..870f7b9 100644 --- a/src/main/java/me/kodysimpson/simpapi/command/CommandList.java +++ b/src/main/java/me/kodysimpson/simpapi/command/CommandList.java @@ -11,7 +11,7 @@ public interface CommandList { /** - * @param sender The thing that ran the command + * @param sender The thing that ran the command * @param subCommandList A list of all the subcommands you can display */ void displayCommandList(CommandSender sender, List subCommandList); diff --git a/src/main/java/me/kodysimpson/simpapi/command/CommandManager.java b/src/main/java/me/kodysimpson/simpapi/command/CommandManager.java index c600446..00bea8d 100644 --- a/src/main/java/me/kodysimpson/simpapi/command/CommandManager.java +++ b/src/main/java/me/kodysimpson/simpapi/command/CommandManager.java @@ -18,12 +18,12 @@ public class CommandManager { /** - * @param plugin An instance of your plugin that is using this API. If called within plugin main class, provide this keyword - * @param commandName The name of the command + * @param plugin An instance of your plugin that is using this API. If called within plugin main class, provide this keyword + * @param commandName The name of the command * @param commandDescription Description of command as would put it in plugin.yml - * @param commandUsage Usage of command as would put it in plugin.yml - * @param aliases A String list of aliases(or nothing for overloaded method) - * @param subcommands Class reference to each SubCommand you create for this core command + * @param commandUsage Usage of command as would put it in plugin.yml + * @param aliases A String list of aliases(or nothing for overloaded method) + * @param subcommands Class reference to each SubCommand you create for this core command */ @SafeVarargs public static void createCoreCommand(JavaPlugin plugin, String commandName, @@ -36,7 +36,7 @@ public static void createCoreCommand(JavaPlugin plugin, String commandName, ArrayList commands = new ArrayList<>(); Arrays.stream(subcommands).map(subcommand -> { - try{ + try { Constructor constructor = subcommand.getConstructor(); return constructor.newInstance(); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { @@ -54,11 +54,11 @@ public static void createCoreCommand(JavaPlugin plugin, String commandName, /** - * @param plugin An instance of your plugin that is using this API. If called within plugin main class, provide this keyword - * @param commandName The name of the command + * @param plugin An instance of your plugin that is using this API. If called within plugin main class, provide this keyword + * @param commandName The name of the command * @param commandDescription Description of command as would put it in plugin.yml - * @param commandUsage Usage of command as would put it in plugin.yml - * @param subcommands Class reference to each SubCommand you create for this core command + * @param commandUsage Usage of command as would put it in plugin.yml + * @param subcommands Class reference to each SubCommand you create for this core command */ @SafeVarargs public static void createCoreCommand(JavaPlugin plugin, String commandName, diff --git a/src/main/java/me/kodysimpson/simpapi/command/CoreCommand.java b/src/main/java/me/kodysimpson/simpapi/command/CoreCommand.java index 9746f9d..948d966 100644 --- a/src/main/java/me/kodysimpson/simpapi/command/CoreCommand.java +++ b/src/main/java/me/kodysimpson/simpapi/command/CoreCommand.java @@ -1,6 +1,5 @@ package me.kodysimpson.simpapi.command; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -18,34 +17,34 @@ class CoreCommand extends Command { private final ArrayList subcommands; private final CommandList commandList; - public CoreCommand(String name, String description, String usageMessage, CommandList commandList, List aliases, ArrayList subCommands){ + public CoreCommand(String name, String description, String usageMessage, CommandList commandList, List aliases, ArrayList subCommands) { super(name, description, usageMessage, aliases); //Get the subcommands so we can access them in the command manager class(here) this.subcommands = subCommands; this.commandList = commandList; } - public ArrayList getSubCommands(){ + public ArrayList getSubCommands() { return subcommands; } @Override public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args) { - if (args.length > 0){ - for (int i = 0; i < getSubCommands().size(); i++){ - if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName()) || (getSubCommands().get(i).getAliases() != null && getSubCommands().get(i).getAliases().contains(args[0]))){ + if (args.length > 0) { + for (int i = 0; i < getSubCommands().size(); i++) { + if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName()) || (getSubCommands().get(i).getAliases() != null && getSubCommands().get(i).getAliases().contains(args[0]))) { getSubCommands().get(i).perform(sender, args); } } - }else { - if (commandList == null){ + } else { + if (commandList == null) { sender.sendMessage("--------------------------------"); for (SubCommand subcommand : subcommands) { sender.sendMessage(subcommand.getSyntax() + " - " + subcommand.getDescription()); } sender.sendMessage("--------------------------------"); - }else{ + } else { commandList.displayCommandList(sender, subcommands); } } @@ -55,23 +54,23 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab @Override public @NotNull List tabComplete(@NotNull CommandSender sender, @NotNull String alias, String[] args) throws IllegalArgumentException { - if (args.length == 1){ //prank + if (args.length == 1) { //prank ArrayList subcommandsArguments = new ArrayList<>(); //Does the subcommand autocomplete - for (int i = 0; i < getSubCommands().size(); i++){ + for (int i = 0; i < getSubCommands().size(); i++) { subcommandsArguments.add(getSubCommands().get(i).getName()); } return subcommandsArguments; - }else if(args.length >= 2){ - for (int i = 0; i < getSubCommands().size(); i++){ - if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName())){ + } else if (args.length >= 2) { + for (int i = 0; i < getSubCommands().size(); i++) { + if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName())) { List subCommandArgs = getSubCommands().get(i).getSubcommandArguments( (Player) sender, args ); //getSubcommandArguments will have returned null if no implementation was provided. - if(subCommandArgs != null) + if (subCommandArgs != null) return subCommandArgs; return Collections.emptyList(); diff --git a/src/main/java/me/kodysimpson/simpapi/command/SubCommand.java b/src/main/java/me/kodysimpson/simpapi/command/SubCommand.java index 12e4005..42b1fac 100644 --- a/src/main/java/me/kodysimpson/simpapi/command/SubCommand.java +++ b/src/main/java/me/kodysimpson/simpapi/command/SubCommand.java @@ -33,13 +33,13 @@ public abstract class SubCommand { /** * @param sender The thing that ran the command - * @param args The args passed into the command when run + * @param args The args passed into the command when run */ public abstract void perform(CommandSender sender, String[] args); /** * @param player The player who ran the command - * @param args The args passed into the command when run + * @param args The args passed into the command when run * @return A list of arguments to be suggested for autocomplete */ public abstract List getSubcommandArguments(Player player, String[] args); diff --git a/src/main/java/me/kodysimpson/simpapi/config/Config.java b/src/main/java/me/kodysimpson/simpapi/config/Config.java index 11e2c71..95f4077 100644 --- a/src/main/java/me/kodysimpson/simpapi/config/Config.java +++ b/src/main/java/me/kodysimpson/simpapi/config/Config.java @@ -9,5 +9,6 @@ @Target(ElementType.TYPE) public @interface Config { String fileName(); + ConfigManager.FileType fileType(); } diff --git a/src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java b/src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java index a330ea1..7be0e14 100644 --- a/src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java +++ b/src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java @@ -16,16 +16,12 @@ public class ConfigManager { - private PrettyPrinter prettyPrinter = null; - - public enum FileType{ - JSON, YAML - } + private final PrettyPrinter prettyPrinter = null; /** - * @param plugin An instance of your plugin + * @param plugin An instance of your plugin * @param configClass A class reference to a Java class annotated with @Config containing your config values - * @param The generic type of the Config class + * @param The generic type of the Config class * @return A new instance of the Config class to be used throughout your plugin */ public static T loadConfig(JavaPlugin plugin, Class configClass) { @@ -37,7 +33,7 @@ public static T loadConfig(JavaPlugin plugin, Class configClass) { if (configAnnotation == null) { plugin.getLogger().severe("The provided Configuration Java class was not annotated properly with @Config from SimpAPI. Therefore the config could not be loaded."); plugin.getPluginLoader().disablePlugin(plugin); - }else{ + } else { String fileName = configAnnotation.fileName(); FileType fileType = configAnnotation.fileType(); @@ -45,7 +41,7 @@ public static T loadConfig(JavaPlugin plugin, Class configClass) { File messagesConfigFile = getConfigFile(plugin, fileName, fileType); ObjectMapper mapper = getObjectMapper(fileType); - if (!messagesConfigFile.exists()){ + if (!messagesConfigFile.exists()) { try { config = configClass.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { @@ -57,7 +53,7 @@ public static T loadConfig(JavaPlugin plugin, Class configClass) { } catch (IOException e) { e.printStackTrace(); } - }else{ + } else { //since it exists already, load the values into the object try { plugin.getLogger().info("Attempting to read " + fileName + " config file."); @@ -75,16 +71,16 @@ public static T loadConfig(JavaPlugin plugin, Class configClass) { } /** - * @param plugin Your plugin class + * @param plugin Your plugin class * @param configObject An instance of your Config class to use to save the contents of it to file */ public static void saveConfig(JavaPlugin plugin, Object configObject) { Config configAnnotation = configObject.getClass().getAnnotation(Config.class); - if (configAnnotation == null){ + if (configAnnotation == null) { plugin.getLogger().severe("The provided Configuration Java class was not annotated properly with @Config from SimpAPI. Therefore the config could not be saved."); plugin.getPluginLoader().disablePlugin(plugin); - }else{ + } else { String fileName = configAnnotation.fileName(); FileType fileType = configAnnotation.fileType(); @@ -103,7 +99,7 @@ public static void saveConfig(JavaPlugin plugin, Object configObject) { } - private static File getConfigFile(JavaPlugin plugin, String fileName, FileType fileType){ + private static File getConfigFile(JavaPlugin plugin, String fileName, FileType fileType) { switch (fileType) { case YAML: return new File(plugin.getDataFolder(), fileName + ".yml"); @@ -115,11 +111,15 @@ private static File getConfigFile(JavaPlugin plugin, String fileName, FileType f } private static ObjectMapper getObjectMapper(FileType fileType) { - if (fileType == FileType.YAML){ + if (fileType == FileType.YAML) { return new ObjectMapper(new YAMLFactory()).configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true).configure(JsonParser.Feature.IGNORE_UNDEFINED, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - }else{ + } else { return new ObjectMapper(new JsonFactory()).configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true).configure(JsonParser.Feature.IGNORE_UNDEFINED, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setDefaultPrettyPrinter(new DefaultPrettyPrinter()); } } + public enum FileType { + JSON, YAML + } + } diff --git a/src/main/java/me/kodysimpson/simpapi/conversations/ConversationStarter.java b/src/main/java/me/kodysimpson/simpapi/conversations/ConversationStarter.java index 1bcf7ee..c8ebd39 100644 --- a/src/main/java/me/kodysimpson/simpapi/conversations/ConversationStarter.java +++ b/src/main/java/me/kodysimpson/simpapi/conversations/ConversationStarter.java @@ -16,8 +16,8 @@ * Wraps {@link ConversationFactory} to make building conversations with players * significantly less tedious and boiler-plate prone. * - * @see ConversationOptions * @author muunitnocQ + * @see ConversationOptions */ public final class ConversationStarter { @@ -83,12 +83,12 @@ public final static class ConversationOptions { * @see ColorTranslator#translateColorCodes(String) */ public final ConversationPrefix prefix; - private final String rawPrefix; public final boolean localEcho; public final boolean modal; public final int timeOut; public final boolean escapeWordsCaseSensitive; public final String[] escapeWords; + private final String rawPrefix; /** * Describes all options a conversation can have. diff --git a/src/main/java/me/kodysimpson/simpapi/conversations/PrefixedAbandonedListener.java b/src/main/java/me/kodysimpson/simpapi/conversations/PrefixedAbandonedListener.java index 9b5a339..784bef4 100644 --- a/src/main/java/me/kodysimpson/simpapi/conversations/PrefixedAbandonedListener.java +++ b/src/main/java/me/kodysimpson/simpapi/conversations/PrefixedAbandonedListener.java @@ -23,6 +23,10 @@ final class PrefixedAbandonedListener implements ConversationAbandonedListener { this.prefix = prefix; } + private static String tl(String msg) { + return ColorTranslator.translateColorCodes(msg); + } + @Override public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) { if (abandonedEvent.gracefulExit()) return; @@ -54,8 +58,4 @@ public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) { player.sendMessage(tl(prefix + "&9Conversation cancelled by &#FF00FFcosmic energy&9.")); } - private static String tl(String msg) { - return ColorTranslator.translateColorCodes(msg); - } - } diff --git a/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerException.java b/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerException.java index 8e46265..d971b66 100644 --- a/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerException.java +++ b/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerException.java @@ -1,8 +1,7 @@ package me.kodysimpson.simpapi.exceptions; -public class MenuManagerException extends Exception{ - +public class MenuManagerException extends Exception { } diff --git a/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerNotSetupException.java b/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerNotSetupException.java index 566a48f..2ee5ac2 100644 --- a/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerNotSetupException.java +++ b/src/main/java/me/kodysimpson/simpapi/exceptions/MenuManagerNotSetupException.java @@ -1,4 +1,4 @@ package me.kodysimpson.simpapi.exceptions; -public class MenuManagerNotSetupException extends Exception{ +public class MenuManagerNotSetupException extends Exception { } diff --git a/src/main/java/me/kodysimpson/simpapi/heads/SkullCreator.java b/src/main/java/me/kodysimpson/simpapi/heads/SkullCreator.java index 2bf6117..a473ed8 100644 --- a/src/main/java/me/kodysimpson/simpapi/heads/SkullCreator.java +++ b/src/main/java/me/kodysimpson/simpapi/heads/SkullCreator.java @@ -16,7 +16,7 @@ /** * A library for the Bukkit API to create player skulls * from names, base64 strings, and texture URLs. - * + *

* Does not use any NMS code, and should work across all versions. * * @author Dean B on 12/28/2016. @@ -28,7 +28,6 @@ public class SkullCreator { * * @param name The Player's name * @return The head of the Player - * * @deprecated names don't make for good identifiers */ @Deprecated @@ -44,7 +43,6 @@ public static ItemStack itemFromName(String name) { * @param item The item to apply the name to * @param name The Player's name * @return The head of the Player - * * @deprecated names don't make for good identifiers */ @Deprecated @@ -73,7 +71,7 @@ public static ItemStack itemFromUuid(UUID id) { * Creates a player skull based on a UUID. 1.13 only. * * @param item The item to apply the name to - * @param id The Player's UUID + * @param id The Player's UUID * @return The head of the Player */ public static ItemStack itemWithUuid(ItemStack item, UUID id) { @@ -104,7 +102,7 @@ public static ItemStack itemFromUrl(String url) { * Creates a player skull based on a Mojang server URL. * * @param item The item to apply the skin to - * @param url The URL of the Mojang skin + * @param url The URL of the Mojang skin * @return The head associated with the URL */ public static ItemStack itemWithUrl(ItemStack item, String url) { @@ -128,7 +126,7 @@ public static ItemStack itemFromBase64(String base64) { /** * Applies the base64 string to the ItemStack. * - * @param item The ItemStack to put the base64 onto + * @param item The ItemStack to put the base64 onto * @param base64 The base64 string containing the texture * @return The head with a custom texture */ @@ -146,8 +144,7 @@ public static ItemStack itemWithBase64(ItemStack item, String base64) { * Sets the block to a skull with the given name. * * @param block The block to set - * @param name The player to set it to - * + * @param name The player to set it to * @deprecated names don't make for good identifiers */ @Deprecated @@ -163,7 +160,7 @@ public static void blockWithName(Block block, String name) { * Sets the block to a skull with the given UUID. * * @param block The block to set - * @param id The player to set it to + * @param id The player to set it to */ public static void blockWithUuid(Block block, UUID id) { notNull(block, "block"); @@ -177,7 +174,7 @@ public static void blockWithUuid(Block block, UUID id) { * Sets the block to a skull with the given UUID. * * @param block The block to set - * @param url The mojang URL to set it to use + * @param url The mojang URL to set it to use */ public static void blockWithUrl(Block block, String url) { notNull(block, "block"); @@ -189,7 +186,7 @@ public static void blockWithUrl(Block block, String url) { /** * Sets the block to a skull with the given UUID. * - * @param block The block to set + * @param block The block to set * @param base64 The base64 to set it to use */ public static void blockWithBase64(Block block, String base64) { @@ -209,7 +206,7 @@ public static void blockWithBase64(Block block, String base64) { if (newerApi()) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "data merge block " + args); } else { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"blockdata " + args); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "blockdata " + args); } } @@ -254,7 +251,7 @@ private static String urlToBase64(String url) { } catch (URISyntaxException e) { throw new RuntimeException(e); } - String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl.toString() + "\"}}}"; + String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl + "\"}}}"; return Base64.getEncoder().encodeToString(toEncode.getBytes()); } } diff --git a/src/main/java/me/kodysimpson/simpapi/menu/Menu.java b/src/main/java/me/kodysimpson/simpapi/menu/Menu.java index 4be0aa9..fc85a16 100644 --- a/src/main/java/me/kodysimpson/simpapi/menu/Menu.java +++ b/src/main/java/me/kodysimpson/simpapi/menu/Menu.java @@ -69,7 +69,7 @@ public void back() throws MenuManagerException, MenuManagerNotSetupException { } protected void reloadItems() { - for (int i = 0; i < inventory.getSize(); i++){ + for (int i = 0; i < inventory.getSize(); i++) { inventory.setItem(i, null); } setMenuItems(); @@ -90,9 +90,9 @@ protected void reload() throws MenuManagerException, MenuManagerNotSetupExceptio * This will fill all of the empty slots with "filler glass" */ //Helpful utility method to fill all remaining slots with "filler glass" - public void setFillerGlass(){ + public void setFillerGlass() { for (int i = 0; i < getSlots(); i++) { - if (inventory.getItem(i) == null){ + if (inventory.getItem(i) == null) { inventory.setItem(i, FILLER_GLASS); } } @@ -103,16 +103,16 @@ public void setFillerGlass(){ */ public void setFillerGlass(ItemStack itemStack) { for (int i = 0; i < getSlots(); i++) { - if (inventory.getItem(i) == null){ + if (inventory.getItem(i) == null) { inventory.setItem(i, itemStack); } } } /** - * @param material The material to base the ItemStack on + * @param material The material to base the ItemStack on * @param displayName The display name of the ItemStack - * @param lore The lore of the ItemStack, with the Strings being automatically color coded with ColorTranslator + * @param lore The lore of the ItemStack, with the Strings being automatically color coded with ColorTranslator * @return The constructed ItemStack object */ public ItemStack makeItem(Material material, String displayName, String... lore) { diff --git a/src/main/java/me/kodysimpson/simpapi/menu/MenuListener.java b/src/main/java/me/kodysimpson/simpapi/menu/MenuListener.java index ed7259f..d73c5de 100644 --- a/src/main/java/me/kodysimpson/simpapi/menu/MenuListener.java +++ b/src/main/java/me/kodysimpson/simpapi/menu/MenuListener.java @@ -12,7 +12,7 @@ public class MenuListener implements Listener { @EventHandler - public void onMenuClick(InventoryClickEvent e){ + public void onMenuClick(InventoryClickEvent e) { InventoryHolder holder = e.getInventory().getHolder(); //If the inventoryholder of the inventory clicked on @@ -27,12 +27,12 @@ public void onMenuClick(InventoryClickEvent e){ // the menu we clicked on Menu menu = (Menu) holder; - if (menu.cancelAllClicks()){ + if (menu.cancelAllClicks()) { e.setCancelled(true); //prevent them from fucking with the inventory } //Call the handleMenu object which takes the event and processes it - try{ + try { menu.handleMenu(e); } catch (MenuManagerNotSetupException menuManagerNotSetupException) { System.out.println(ChatColor.RED + "THE MENU MANAGER HAS NOT BEEN CONFIGURED. CALL MENUMANAGER.SETUP()"); diff --git a/src/main/java/me/kodysimpson/simpapi/menu/MenuManager.java b/src/main/java/me/kodysimpson/simpapi/menu/MenuManager.java index 88671bd..6252416 100644 --- a/src/main/java/me/kodysimpson/simpapi/menu/MenuManager.java +++ b/src/main/java/me/kodysimpson/simpapi/menu/MenuManager.java @@ -27,7 +27,7 @@ private static void registerMenuListener(Server server, Plugin plugin) { boolean isAlreadyRegistered = false; for (RegisteredListener rl : InventoryClickEvent.getHandlerList().getRegisteredListeners()) { System.out.println(rl.getListener().getClass().getSimpleName()); - if (rl.getListener() instanceof MenuListener){ + if (rl.getListener() instanceof MenuListener) { isAlreadyRegistered = true; break; } @@ -44,7 +44,7 @@ private static void registerMenuListener(Server server, Plugin plugin) { // }); //System.out.println("erwiwjriwer: " + isAlreadyRegistered); - if (!isAlreadyRegistered){ + if (!isAlreadyRegistered) { server.getPluginManager().registerEvents(new MenuListener(), plugin); } @@ -72,7 +72,7 @@ public static void setup(Server server, Plugin plugin) { /** * @param menuClass The class reference of the Menu you want to open for a player - * @param player The player to open the menu for + * @param player The player to open the menu for * @throws MenuManagerNotSetupException Thrown if the setup() method has not been called and used properly */ public static void openMenu(Class menuClass, Player player) throws MenuManagerException, MenuManagerNotSetupException { @@ -100,7 +100,7 @@ public static void openMenu(Class menuClass, Player player) thro public static PlayerMenuUtility getPlayerMenuUtility(Player p) throws MenuManagerException, MenuManagerNotSetupException { - if (!isSetup){ + if (!isSetup) { throw new MenuManagerNotSetupException(); } diff --git a/src/main/java/me/kodysimpson/simpapi/menu/PaginatedMenu.java b/src/main/java/me/kodysimpson/simpapi/menu/PaginatedMenu.java index fae636f..45a885f 100644 --- a/src/main/java/me/kodysimpson/simpapi/menu/PaginatedMenu.java +++ b/src/main/java/me/kodysimpson/simpapi/menu/PaginatedMenu.java @@ -45,7 +45,7 @@ public PaginatedMenu(PlayerMenuUtility playerMenuUtility) { /** * Set the border and menu buttons for the menu. Override this method to provide a custom menu border or specify custom items in customMenuBorderItems() */ - protected void addMenuBorder(){ + protected void addMenuBorder() { inventory.setItem(48, makeItem(Material.DARK_OAK_BUTTON, ChatColor.GREEN + "Left")); inventory.setItem(49, makeItem(Material.BARRIER, ChatColor.DARK_RED + "Close")); @@ -71,7 +71,7 @@ protected void addMenuBorder(){ } //place the custom items if they exist - if (getCustomMenuBorderItems() != null){ + if (getCustomMenuBorderItems() != null) { getCustomMenuBorderItems().forEach((integer, itemStack) -> inventory.setItem(integer, itemStack)); } @@ -104,10 +104,10 @@ public void setMenuItems() { /** * @return true if successful, false if already on the first page */ - public boolean prevPage(){ - if (page == 0){ + public boolean prevPage() { + if (page == 0) { return false; - }else{ + } else { page = page - 1; reloadItems(); return true; @@ -117,7 +117,7 @@ public boolean prevPage(){ /** * @return true if successful, false if already on the last page */ - public boolean nextPage(){ + public boolean nextPage() { if (!((index + 1) >= getData().size())) { page = page + 1; reloadItems(); diff --git a/src/main/java/me/kodysimpson/simpapi/menu/PlayerMenuUtility.java b/src/main/java/me/kodysimpson/simpapi/menu/PlayerMenuUtility.java index 8bfe4c1..9d78e24 100644 --- a/src/main/java/me/kodysimpson/simpapi/menu/PlayerMenuUtility.java +++ b/src/main/java/me/kodysimpson/simpapi/menu/PlayerMenuUtility.java @@ -28,13 +28,13 @@ public Player getOwner() { /** * @param identifier A key to store the data by - * @param data The data itself to be stored + * @param data The data itself to be stored */ - public void setData(String identifier, Object data){ + public void setData(String identifier, Object data) { this.dataMap.put(identifier, data); } - public void setData(Enum identifier, Object data){ + public void setData(Enum identifier, Object data) { this.dataMap.put(identifier.toString(), data); } @@ -42,32 +42,32 @@ public void setData(Enum identifier, Object data){ * @param identifier The key for the data stored in the PMC * @return The retrieved value or null if not found */ - public Object getData(String identifier){ + public Object getData(String identifier) { return this.dataMap.get(identifier); } - public Object getData(Enum identifier){ + public Object getData(Enum identifier) { return this.dataMap.get(identifier.toString()); } - public T getData(String identifier, Class classRef){ + public T getData(String identifier, Class classRef) { Object obj = this.dataMap.get(identifier); - if (obj == null){ + if (obj == null) { return null; - }else{ + } else { return classRef.cast(obj); } } - public T getData(Enum identifier, Class classRef){ + public T getData(Enum identifier, Class classRef) { Object obj = this.dataMap.get(identifier.toString()); - if (obj == null){ + if (obj == null) { return null; - }else{ + } else { return classRef.cast(obj); } } @@ -75,12 +75,12 @@ public T getData(Enum identifier, Class classRef){ /** * @return Get the previous menu that was opened for the player */ - public Menu lastMenu(){ + public Menu lastMenu() { this.history.pop(); //Makes back() work for some reason return this.history.pop(); } - public void pushMenu(Menu menu){ + public void pushMenu(Menu menu) { this.history.push(menu); }