From 8d9ba7324770913fd92546fb4048a8254d5d6bbe Mon Sep 17 00:00:00 2001 From: BadBones Date: Thu, 7 Apr 2022 22:05:32 -0400 Subject: [PATCH] Grammer changes --- .../me/badbones69/crazyauctions/Main.java | 9 +- .../me/badbones69/crazyauctions/Methods.java | 6 +- .../crazyauctions/api/Category.java | 26 +-- .../crazyauctions/api/FileManager.java | 16 +- .../crazyauctions/api/Messages.java | 4 +- .../crazyauctions/api/ShopType.java | 4 +- .../badbones69/crazyauctions/api/Version.java | 6 +- .../api/events/AuctionBuyEvent.java | 6 +- .../api/events/AuctionCancelledEvent.java | 4 +- .../api/events/AuctionExpireEvent.java | 4 +- .../api/events/AuctionListEvent.java | 8 +- .../api/events/AuctionNewBidEvent.java | 6 +- .../api/events/AuctionWinBidEvent.java | 6 +- .../crazyauctions/controllers/Metrics.java | 196 +++++++++--------- .../currency/CurrencyManager.java | 3 +- src/main/resources/config1.12.2-Down.yml | 14 +- src/main/resources/config1.13-Up.yml | 14 +- 17 files changed, 168 insertions(+), 164 deletions(-) diff --git a/src/main/java/me/badbones69/crazyauctions/Main.java b/src/main/java/me/badbones69/crazyauctions/Main.java index faf9543..a85394e 100644 --- a/src/main/java/me/badbones69/crazyauctions/Main.java +++ b/src/main/java/me/badbones69/crazyauctions/Main.java @@ -18,7 +18,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; import org.yaml.snakeyaml.error.YAMLException; import java.util.ArrayList; @@ -373,16 +372,12 @@ public class Main extends JavaPlugin implements Listener { public void onJoin(PlayerJoinEvent e) { final Player player = e.getPlayer(); if (player.getName().equalsIgnoreCase("BadBones69")) { - Bukkit.getScheduler().runTaskLater(this, () -> { - player.sendMessage(Methods.getPrefix() + Methods.color("&7This server is running your Crazy Auctions Plugin. " + "&7It is running version &av" + Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions").getDescription().getVersion() + "&7.")); - }, 40); + Bukkit.getScheduler().runTaskLater(this, () -> player.sendMessage(Methods.getPrefix() + Methods.color("&7This server is running your Crazy Auctions Plugin. " + "&7It is running version &av" + Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions").getDescription().getVersion() + "&7.")), 40); } } private void startCheck() { - Bukkit.getScheduler().runTaskTimer(this, () -> { - Methods.updateAuction(); - }, 20, 5 * 20); + Bukkit.getScheduler().runTaskTimer(this, Methods :: updateAuction, 20, 5 * 20); } private ArrayList getDamageableItems() { diff --git a/src/main/java/me/badbones69/crazyauctions/Methods.java b/src/main/java/me/badbones69/crazyauctions/Methods.java index a562a6f..2424fde 100644 --- a/src/main/java/me/badbones69/crazyauctions/Methods.java +++ b/src/main/java/me/badbones69/crazyauctions/Methods.java @@ -63,7 +63,7 @@ public class Methods { try { item = new ItemStack(m, amount, (short) ty); } catch (Exception e) { - if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) { + if (Version.isNewer(Version.v1_12_R1)) { item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1); } else { @@ -85,7 +85,7 @@ public class Methods { try { item = new ItemStack(m, amount, (short) ty); } catch (Exception e) { - if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) { + if (Version.isNewer(Version.v1_12_R1)) { item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1); } else { @@ -111,7 +111,7 @@ public class Methods { try { item = new ItemStack(m, amount, (short) ty); } catch (Exception e) { - if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) { + if (Version.isNewer(Version.v1_12_R1)) { item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1); } else { diff --git a/src/main/java/me/badbones69/crazyauctions/api/Category.java b/src/main/java/me/badbones69/crazyauctions/api/Category.java index 3e8db53..ee38ab1 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/Category.java +++ b/src/main/java/me/badbones69/crazyauctions/api/Category.java @@ -15,20 +15,20 @@ public enum Category { POTIONS("Potions", getPotions()), BLOCKS("Blocks", getBlocks()); - private String Name; - private ArrayList Items; + private final String name; + private final ArrayList items; /** * @param name Name of the Shop Type. */ private Category(String name, ArrayList items) { - this.Name = name; - this.Items = items; + this.name = name; + this.items = items; } /** * @param name Name of the Type you want. - * @return Returns the Type as a Enum. + * @return Returns the Type as an Enum. */ public static Category getFromName(String name) { for (Category type : Category.values()) { @@ -41,7 +41,7 @@ public enum Category { private static ArrayList getArmor() { ArrayList ma = new ArrayList<>(); - if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) { + if (Version.isNewer(Version.v1_12_R1)) { ma.add(Material.matchMaterial("GOLDEN_HELMET")); ma.add(Material.matchMaterial("GOLDEN_CHESTPLATE")); ma.add(Material.matchMaterial("GOLDEN_LEGGINGS")); @@ -68,7 +68,7 @@ public enum Category { ma.add(Material.DIAMOND_CHESTPLATE); ma.add(Material.DIAMOND_LEGGINGS); ma.add(Material.DIAMOND_BOOTS); - if (Version.getCurrentVersion().isNewer(Version.v1_15_R1)) { + if (Version.isNewer(Version.v1_15_R1)) { ma.add(Material.NETHERITE_HELMET); ma.add(Material.NETHERITE_CHESTPLATE); ma.add(Material.NETHERITE_LEGGINGS); @@ -79,7 +79,7 @@ public enum Category { private static ArrayList getTools() { ArrayList ma = new ArrayList<>(); - if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) { + if (Version.isNewer(Version.v1_12_R1)) { ma.add(Material.matchMaterial("WOODEN_PICKAXE")); ma.add(Material.matchMaterial("WOODEN_AXE")); ma.add(Material.matchMaterial("WOODEN_SHOVEL")); @@ -113,7 +113,7 @@ public enum Category { ma.add(Material.STONE_HOE); ma.add(Material.IRON_HOE); ma.add(Material.DIAMOND_HOE); - if (Version.getCurrentVersion().isNewer(Version.v1_15_R1)) { + if (Version.isNewer(Version.v1_15_R1)) { ma.add(Material.NETHERITE_PICKAXE); ma.add(Material.NETHERITE_AXE); ma.add(Material.NETHERITE_HOE); @@ -124,7 +124,7 @@ public enum Category { private static ArrayList getWeapons() { ArrayList ma = new ArrayList<>(); - if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) { + if (Version.isNewer(Version.v1_12_R1)) { ma.add(Material.matchMaterial("WOODEN_SWORD")); ma.add(Material.matchMaterial("WOODEN_AXE")); ma.add(Material.matchMaterial("GOLDEN_SWORD")); @@ -142,7 +142,7 @@ public enum Category { ma.add(Material.IRON_AXE); ma.add(Material.DIAMOND_AXE); ma.add(Material.BOW); - if (Version.getCurrentVersion().isNewer(Version.v1_15_R1)) { + if (Version.isNewer(Version.v1_15_R1)) { ma.add(Material.NETHERITE_SWORD); ma.add(Material.NETHERITE_AXE); } @@ -195,11 +195,11 @@ public enum Category { * @return Returns the type name as a string. */ public String getName() { - return Name; + return name; } public ArrayList getItems() { - return Items; + return items; } } \ No newline at end of file diff --git a/src/main/java/me/badbones69/crazyauctions/api/FileManager.java b/src/main/java/me/badbones69/crazyauctions/api/FileManager.java index 4aed16f..903ac97 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/FileManager.java +++ b/src/main/java/me/badbones69/crazyauctions/api/FileManager.java @@ -190,7 +190,7 @@ public class FileManager { */ public CustomFile getFile(String name) { for (CustomFile file : customFiles) { - if (file.getName().toLowerCase().equalsIgnoreCase(name.toLowerCase())) { + if (file.getName().equalsIgnoreCase(name)) { return file; } } @@ -204,10 +204,10 @@ public class FileManager { try { File targetFile = files.get(file); FileConfiguration configuration = configurations.get(file); - + YamlConfiguration copy = new YamlConfiguration(); - configuration.getValues(false).forEach(copy::set); - + configuration.getValues(false).forEach(copy :: set); + BukkitRunnable runnable = new BukkitRunnable() { @Override public void run() { @@ -317,8 +317,8 @@ public class FileManager { MESSAGES("Messages.yml", "Messages.yml"), TEST_FILE("Test-File.yml", "Test-File.yml"); - private String fileName; - private String fileLocation; + private final String fileName; + private final String fileLocation; /** * The files that the server will try and load. @@ -360,11 +360,11 @@ public class FileManager { public void saveFile(boolean sync) { getInstance().saveFile(this, sync); } - + public void saveFile() { getInstance().saveFile(this, false); } - + /** * Overrides the loaded state file and loads the file systems file. */ diff --git a/src/main/java/me/badbones69/crazyauctions/api/Messages.java b/src/main/java/me/badbones69/crazyauctions/api/Messages.java index 203a7db..a5ce55b 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/Messages.java +++ b/src/main/java/me/badbones69/crazyauctions/api/Messages.java @@ -55,8 +55,8 @@ public enum Messages { "&9/Ah Listed - &eView and manage the items you are selling.", "&9/Ah Help - &eView this help menu.")); - private static FileManager fileManager = FileManager.getInstance(); - private String path; + private static final FileManager fileManager = FileManager.getInstance(); + private final String path; private String defaultMessage; private List defaultListMessage; diff --git a/src/main/java/me/badbones69/crazyauctions/api/ShopType.java b/src/main/java/me/badbones69/crazyauctions/api/ShopType.java index 320975f..83f6e52 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/ShopType.java +++ b/src/main/java/me/badbones69/crazyauctions/api/ShopType.java @@ -4,7 +4,7 @@ public enum ShopType { SELL("Sell"), BID("Bid"); - private String name; + private final String name; /** * @param name name of the Shop Type. @@ -15,7 +15,7 @@ public enum ShopType { /** * @param name name of the Type you want. - * @return Returns the Type as a Enum. + * @return Returns the Type as an Enum. */ public static ShopType getFromName(String name) { for (ShopType type : ShopType.values()) { diff --git a/src/main/java/me/badbones69/crazyauctions/api/Version.java b/src/main/java/me/badbones69/crazyauctions/api/Version.java index a4c3229..abaca7e 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/Version.java +++ b/src/main/java/me/badbones69/crazyauctions/api/Version.java @@ -19,7 +19,7 @@ public enum Version { private static Version currentVersion; private static Version latest; - private int versionInteger; + private final int versionInteger; private Version(int versionInteger) { this.versionInteger = versionInteger; @@ -116,9 +116,9 @@ public enum Version { } /** - * Checks to see if the current version is older then the checked version. + * Checks to see if the current version is older than the checked version. * @param version The version you are checking. - * @return True if older then the checked version and false if the same or newer. + * @return True if older than the checked version and false if the same or newer. */ public static boolean isOlder(Version version) { if (currentVersion == null) getCurrentVersion(); diff --git a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionBuyEvent.java b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionBuyEvent.java index b70c012..8adefab 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionBuyEvent.java +++ b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionBuyEvent.java @@ -21,9 +21,9 @@ public class AuctionBuyEvent extends Event { /** * - * @param player - * @param item - * @param price + * @param player The player who bought the item. + * @param item The item that was bought. + * @param price The price of the item. */ public AuctionBuyEvent(Player player, ItemStack item, long price) { this.player = player; diff --git a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionCancelledEvent.java b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionCancelledEvent.java index a7b7159..cc94364 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionCancelledEvent.java +++ b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionCancelledEvent.java @@ -25,7 +25,7 @@ public class AuctionCancelledEvent extends Event { /** * - * @param offlinePlayer The player who's item is cancelled. + * @param offlinePlayer The player whose item is cancelled. * @param item The item that is cancelled. */ public AuctionCancelledEvent(OfflinePlayer offlinePlayer, ItemStack item, CancelledReason reason) { @@ -37,7 +37,7 @@ public class AuctionCancelledEvent extends Event { /** * - * @param onlinePlayer The player who's item is cancelled. + * @param onlinePlayer The player whose item is cancelled. * @param item The item that is cancelled. */ public AuctionCancelledEvent(Player onlinePlayer, ItemStack item, CancelledReason reason) { diff --git a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionExpireEvent.java b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionExpireEvent.java index b50877a..c61cf11 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionExpireEvent.java +++ b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionExpireEvent.java @@ -23,7 +23,7 @@ public class AuctionExpireEvent extends Event { /** * - * @param offlinePlayer The player who's item is expiring. + * @param offlinePlayer The player whose item is expiring. * @param item The item that is expiring. */ public AuctionExpireEvent(OfflinePlayer offlinePlayer, ItemStack item) { @@ -34,7 +34,7 @@ public class AuctionExpireEvent extends Event { /** * - * @param onlinePlayer The player who's item is expiring. + * @param onlinePlayer The player whose item is expiring. * @param item The item that is expiring. */ public AuctionExpireEvent(Player onlinePlayer, ItemStack item) { diff --git a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionListEvent.java b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionListEvent.java index e7e191c..db69c93 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionListEvent.java +++ b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionListEvent.java @@ -23,10 +23,10 @@ public class AuctionListEvent extends Event { /** * - * @param player - * @param shop - * @param item - * @param price + * @param player The player who is listing the item. + * @param shop The shop type the item is being listed to. + * @param item The item being listed. + * @param price The price the item is being listed for. */ public AuctionListEvent(Player player, ShopType shop, ItemStack item, long price) { this.player = player; diff --git a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionNewBidEvent.java b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionNewBidEvent.java index 3685ace..0ea2c0a 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionNewBidEvent.java +++ b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionNewBidEvent.java @@ -18,9 +18,9 @@ public class AuctionNewBidEvent extends Event { /** * - * @param player - * @param item - * @param bid + * @param player The player who placed the bid. + * @param item The item that was bid on. + * @param bid The amount of money that was bid. */ public AuctionNewBidEvent(Player player, ItemStack item, long bid) { this.player = player; diff --git a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionWinBidEvent.java b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionWinBidEvent.java index ceaba59..e0c6dda 100644 --- a/src/main/java/me/badbones69/crazyauctions/api/events/AuctionWinBidEvent.java +++ b/src/main/java/me/badbones69/crazyauctions/api/events/AuctionWinBidEvent.java @@ -21,9 +21,9 @@ public class AuctionWinBidEvent extends Event { /** * - * @param player - * @param item - * @param bid + * @param player The player who won the item. + * @param item The item that was won. + * @param bid The bid that was placed on the item. */ public AuctionWinBidEvent(Player player, ItemStack item, long bid) { this.player = player; diff --git a/src/main/java/me/badbones69/crazyauctions/controllers/Metrics.java b/src/main/java/me/badbones69/crazyauctions/controllers/Metrics.java index c2fd3e9..6309015 100644 --- a/src/main/java/me/badbones69/crazyauctions/controllers/Metrics.java +++ b/src/main/java/me/badbones69/crazyauctions/controllers/Metrics.java @@ -28,51 +28,51 @@ import java.util.zip.GZIPOutputStream; * Check out https://bStats.org/ to learn more about bStats! */ public class Metrics { - + static { // You can use the property to disable the check in your test environment if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) { // Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D final String defaultPackage = new String( - new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); - final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); + new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); + final String examplePackage = new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); // We want to make sure nobody just copy & pastes the example and use the wrong package names if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); } } } - + // The version of this bStats class public static final int B_STATS_VERSION = 1; - + // The url to which the data is sent private static final String URL = "https://bStats.org/submitData/bukkit"; - + // Is bStats enabled on this server? private boolean enabled; - + // Should failed requests be logged? private static boolean logFailedRequests; - + // Should the sent data be logged? private static boolean logSentData; - + // Should the response text be logged? private static boolean logResponseStatusText; - + // The uuid of the server private static String serverUUID; - + // The plugin private final Plugin plugin; - + // The plugin id private final int pluginId; - + // A list with all custom charts private final List charts = new ArrayList<>(); - + /** * Class constructor. * @@ -86,15 +86,15 @@ public class Metrics { } this.plugin = plugin; this.pluginId = pluginId; - + // Get the config file File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); File configFile = new File(bStatsFolder, "config.yml"); YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); - + // Check if the config file exists if (!config.isSet("serverUuid")) { - + // Add default values config.addDefault("enabled", true); // Every server gets it's unique random id. @@ -105,26 +105,27 @@ public class Metrics { config.addDefault("logSentData", false); // Should the response text be logged? config.addDefault("logResponseStatusText", false); - + // Inform the server owners about bStats config.options().header( - "bStats collects some data for plugin authors like how many servers are using their plugins.\n" + - "To honor their work, you should not disable it.\n" + - "This has nearly no effect on the server performance!\n" + - "Check out https://bStats.org/ to learn more :)" + "bStats collects some data for plugin authors like how many servers are using their plugins.\n" + + "To honor their work, you should not disable it.\n" + + "This has nearly no effect on the server performance!\n" + + "Check out https://bStats.org/ to learn more :)" ).copyDefaults(true); try { config.save(configFile); - } catch (IOException ignored) { } + } catch (IOException ignored) { + } } - + // Load the data enabled = config.getBoolean("enabled", true); serverUUID = config.getString("serverUuid"); logFailedRequests = config.getBoolean("logFailedRequests", false); logSentData = config.getBoolean("logSentData", false); logResponseStatusText = config.getBoolean("logResponseStatusText", false); - + if (enabled) { boolean found = false; // Search for all other bStats Metrics classes to see if we are the first one @@ -133,7 +134,8 @@ public class Metrics { service.getField("B_STATS_VERSION"); // Our identifier :) found = true; // We aren't the first break; - } catch (NoSuchFieldException ignored) { } + } catch (NoSuchFieldException ignored) { + } } // Register our service Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal); @@ -143,7 +145,7 @@ public class Metrics { } } } - + /** * Checks if bStats is enabled. * @@ -152,7 +154,7 @@ public class Metrics { public boolean isEnabled() { return enabled; } - + /** * Adds a custom chart. * @@ -164,7 +166,7 @@ public class Metrics { } charts.add(chart); } - + /** * Starts the Scheduler which submits our data every 30 minutes. */ @@ -186,7 +188,7 @@ public class Metrics { // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted! // WARNING: Just don't do it! } - + /** * Gets the plugin specific data. * This method is called using Reflection. @@ -195,10 +197,10 @@ public class Metrics { */ public JsonObject getPluginData() { JsonObject data = new JsonObject(); - + String pluginName = plugin.getDescription().getName(); String pluginVersion = plugin.getDescription().getVersion(); - + data.addProperty("pluginName", pluginName); // Append the name of the plugin data.addProperty("id", pluginId); // Append the id of the plugin data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin @@ -212,10 +214,10 @@ public class Metrics { customCharts.add(chart); } data.add("customCharts", customCharts); - + return data; } - + /** * Gets the server specific data. * @@ -229,52 +231,52 @@ public class Metrics { // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) - ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() - : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; + ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() + : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; } catch (Exception e) { playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed } int onlineMode = Bukkit.getOnlineMode() ? 1 : 0; String bukkitVersion = Bukkit.getVersion(); String bukkitName = Bukkit.getName(); - + // OS/Java specific data String javaVersion = System.getProperty("java.version"); String osName = System.getProperty("os.name"); String osArch = System.getProperty("os.arch"); String osVersion = System.getProperty("os.version"); int coreCount = Runtime.getRuntime().availableProcessors(); - + JsonObject data = new JsonObject(); - + data.addProperty("serverUUID", serverUUID); - + data.addProperty("playerAmount", playerAmount); data.addProperty("onlineMode", onlineMode); data.addProperty("bukkitVersion", bukkitVersion); data.addProperty("bukkitName", bukkitName); - + data.addProperty("javaVersion", javaVersion); data.addProperty("osName", osName); data.addProperty("osArch", osArch); data.addProperty("osVersion", osVersion); data.addProperty("coreCount", coreCount); - + return data; } - + /** * Collects the data and sends it afterwards. */ private void submitData() { final JsonObject data = getServerData(); - + JsonArray pluginData = new JsonArray(); // Search for all other bStats Metrics classes to get their plugin data for (Class service : Bukkit.getServicesManager().getKnownServices()) { try { service.getField("B_STATS_VERSION"); // Our identifier :) - + for (RegisteredServiceProvider provider : Bukkit.getServicesManager().getRegistrations(service)) { try { Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider()); @@ -297,13 +299,15 @@ public class Metrics { } } } - } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { } + } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { + } } - } catch (NoSuchFieldException ignored) { } + } catch (NoSuchFieldException ignored) { + } } - + data.add("plugins", pluginData); - + // Create a new thread for the connection to the bStats server new Thread(() -> { try { @@ -317,7 +321,7 @@ public class Metrics { } }).start(); } - + /** * Sends the data to the bStats server. * @@ -336,10 +340,10 @@ public class Metrics { plugin.getLogger().info("Sending data to bStats: " + data); } HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection(); - + // Compress the data to save bandwidth byte[] compressedData = compress(data.toString()); - + // Add headers connection.setRequestMethod("POST"); connection.addRequestProperty("Accept", "application/json"); @@ -348,13 +352,13 @@ public class Metrics { connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length)); connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION); - + // Send data connection.setDoOutput(true); try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { outputStream.write(compressedData); } - + StringBuilder builder = new StringBuilder(); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { String line; @@ -362,12 +366,12 @@ public class Metrics { builder.append(line); } } - + if (logResponseStatusText) { plugin.getLogger().info("Sent data to bStats and received response: " + builder); } } - + /** * Gzips the given String. * @@ -385,15 +389,15 @@ public class Metrics { } return outputStream.toByteArray(); } - + /** * Represents a custom chart. */ public static abstract class CustomChart { - + // The id of the chart final String chartId; - + /** * Class constructor. * @@ -405,7 +409,7 @@ public class Metrics { } this.chartId = chartId; } - + private JsonObject getRequestJsonObject() { JsonObject chart = new JsonObject(); chart.addProperty("chartId", chartId); @@ -424,18 +428,18 @@ public class Metrics { } return chart; } - + protected abstract JsonObject getChartData() throws Exception; - + } - + /** * Represents a custom simple pie. */ public static class SimplePie extends CustomChart { - + private final Callable callable; - + /** * Class constructor. * @@ -446,7 +450,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -458,15 +462,16 @@ public class Metrics { data.addProperty("value", value); return data; } + } - + /** * Represents a custom advanced pie. */ public static class AdvancedPie extends CustomChart { - + private final Callable> callable; - + /** * Class constructor. * @@ -477,7 +482,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -502,15 +507,16 @@ public class Metrics { data.add("values", values); return data; } + } - + /** * Represents a custom drilldown pie. */ public static class DrilldownPie extends CustomChart { - + private final Callable>> callable; - + /** * Class constructor. * @@ -521,7 +527,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override public JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -551,15 +557,16 @@ public class Metrics { data.add("values", values); return data; } + } - + /** * Represents a custom single line chart. */ public static class SingleLineChart extends CustomChart { - + private final Callable callable; - + /** * Class constructor. * @@ -570,7 +577,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -582,16 +589,16 @@ public class Metrics { data.addProperty("value", value); return data; } - + } - + /** * Represents a custom multi line chart. */ public static class MultiLineChart extends CustomChart { - + private final Callable> callable; - + /** * Class constructor. * @@ -602,7 +609,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -627,16 +634,16 @@ public class Metrics { data.add("values", values); return data; } - + } - + /** * Represents a custom simple bar chart. */ public static class SimpleBarChart extends CustomChart { - + private final Callable> callable; - + /** * Class constructor. * @@ -647,7 +654,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -665,16 +672,16 @@ public class Metrics { data.add("values", values); return data; } - + } - + /** * Represents a custom advanced bar chart. */ public static class AdvancedBarChart extends CustomChart { - + private final Callable> callable; - + /** * Class constructor. * @@ -685,7 +692,7 @@ public class Metrics { super(chartId); this.callable = callable; } - + @Override protected JsonObject getChartData() throws Exception { JsonObject data = new JsonObject(); @@ -714,6 +721,7 @@ public class Metrics { data.add("values", values); return data; } + } - + } \ No newline at end of file diff --git a/src/main/java/me/badbones69/crazyauctions/currency/CurrencyManager.java b/src/main/java/me/badbones69/crazyauctions/currency/CurrencyManager.java index a16f5ed..34d7c6c 100644 --- a/src/main/java/me/badbones69/crazyauctions/currency/CurrencyManager.java +++ b/src/main/java/me/badbones69/crazyauctions/currency/CurrencyManager.java @@ -9,7 +9,8 @@ public enum CurrencyManager { // Currency Manager VAULT("Vault", "Money"); - private String pluginName, name; + private final String pluginName; + private final String name; /** * @param pluginname diff --git a/src/main/resources/config1.12.2-Down.yml b/src/main/resources/config1.12.2-Down.yml index cf8cb37..b945326 100644 --- a/src/main/resources/config1.12.2-Down.yml +++ b/src/main/resources/config1.12.2-Down.yml @@ -10,12 +10,12 @@ Settings: Bid-Time: 2m 30s #Time for each item that is biddable. Full-Expire-Time: 10d #The full time the item is in the crazy auctions. Bid-Winner-Time: 20d #The time the winner of a bid has to claim their prize. - Minimum-Sell-Price: 10 #Minimum amount you can sell a item for. - Max-Beginning-Sell-Price: 1000000 #Max amount you can sell a item for. + Minimum-Sell-Price: 10 #Minimum amount you can sell an item for. + Max-Beginning-Sell-Price: 1000000 #Max amount you can sell an item for. Minimum-Bid-Price: 100 #Minimum starting bid. Max-Beginning-Bid-Price: 1000000 #Maximum starting bid. Allow-Damaged-Items: False #Allow items that have been damaged. - Category-Page-Opens-First: False #If set to true the categories page will open when they do /CA. + Category-Page-Opens-First: False #If set to true the categories' page will open when they do /CA. Feature-Toggle: #Toggle if a feature is on or off. Selling: true #Able to use the selling part of the auction house. Bidding: true #Able to use the bidding part of the auction house. @@ -141,19 +141,19 @@ Settings: Toggle: true Slot: 49 Name: '&6Previous Page' - Lore: {} + Lore: { } Refesh: #The button for Refresh Page. Item: '175' Toggle: true Slot: 50 Name: '&6Refresh Page' - Lore: {} + Lore: { } NextPage: #The button for Next Page. Item: '339' Toggle: true Slot: 51 Name: '&6Next Page' - Lore: {} + Lore: { } Category1: #The button for Next Page. Item: '54' Toggle: true @@ -281,7 +281,7 @@ Settings: Your-Item: #The item that shows when you try to buy/bid on your item. Item: '166' Name: '&cYou Can''t Purchase Your Own Item.' - Cant-Afford: #The item that shows when you cant afford this item. + Cant-Afford: #The item that shows when you can't afford this item. Item: '166' Name: '&cYou Can''t Afford This Item.' Top-Bidder: #The item for when a player is already the top bidder. diff --git a/src/main/resources/config1.13-Up.yml b/src/main/resources/config1.13-Up.yml index d68ffde..ebaf756 100644 --- a/src/main/resources/config1.13-Up.yml +++ b/src/main/resources/config1.13-Up.yml @@ -10,12 +10,12 @@ Settings: Bid-Time: 2m 30s #Time for each item that is biddable. Full-Expire-Time: 10d #The full time the item is in the crazy auctions. Bid-Winner-Time: 20d #The time the winner of a bid has to claim their prize. - Minimum-Sell-Price: 10 #Minimum amount you can sell a item for. - Max-Beginning-Sell-Price: 1000000 #Max amount you can sell a item for. + Minimum-Sell-Price: 10 #Minimum amount you can sell an item for. + Max-Beginning-Sell-Price: 1000000 #Max amount you can sell an item for. Minimum-Bid-Price: 100 #Minimum starting bid. Max-Beginning-Bid-Price: 1000000 #Maximum starting bid. Allow-Damaged-Items: false #Allow items that have been damaged. - Category-Page-Opens-First: false #If set to true the categories page will open when they do /CA. + Category-Page-Opens-First: false #If set to true the categories' page will open when they do /CA. Feature-Toggle: #Toggle if a feature is on or off. Selling: true #Able to use the selling part of the auction house. Bidding: true #Able to use the bidding part of the auction house. @@ -140,19 +140,19 @@ Settings: Toggle: true Slot: 49 Name: '&6Previous Page' - Lore: {} + Lore: { } Refesh: #The button for Refresh Page. Item: 'SUNFLOWER' Toggle: true Slot: 50 Name: '&6Refresh Page' - Lore: {} + Lore: { } NextPage: #The button for Next Page. Item: 'PAPER' Toggle: true Slot: 51 Name: '&6Next Page' - Lore: {} + Lore: { } Category1: #The button for Next Page. Item: 'CHEST' Toggle: true @@ -280,7 +280,7 @@ Settings: Your-Item: #The item that shows when you try to buy/bid on your item. Item: 'BARRIER' Name: '&cYou Can''t Purchase Your Own Item.' - Cant-Afford: #The item that shows when you cant afford this item. + Cant-Afford: #The item that shows when you can't afford this item. Item: 'BARRIER' Name: '&cYou Can''t Afford This Item.' Top-Bidder: #The item for when a player is already the top bidder.