From 6d18c16a4e4ce16fa042d02a359c7dc901f903d9 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Sun, 2 Jun 2019 21:42:30 +0800 Subject: [PATCH] Install errors uploader Former-commit-id: 2ff2bd7188e5ad396543f0b018ee5a1d3f3d73bd [formerly 01ea781323812dd1401408a5beca2d27ffa2544f] Former-commit-id: fe21f080d6c12061b76cd9ea58e9efa1204d5919 --- .../org/maxgamer/quickshop/QuickShop.java | 16 +++++++++++++++- .../maxgamer/quickshop/Shop/ShopManager.java | 14 +++++++------- .../quickshop/Util/SentryErrorReporter.java | 3 ++- .../org/maxgamer/quickshop/Util/Util.java | 19 ++++++++++++++++++- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index b835b2bb3..9929ecf80 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -76,6 +76,7 @@ public class QuickShop extends JavaPlugin { /** The plugin OpenInv (null if not present) */ private Plugin openInvPlugin; + /** The shop limites. **/ private HashMap limits = new HashMap<>(); /** Use SpoutPlugin to get item / block names */ private boolean useSpout = false; @@ -85,20 +86,33 @@ public class QuickShop extends JavaPlugin { private int displayItemCheckTicks; private boolean noopDisable; private boolean setupDBonEnableding = false; + /** Default database prefix, can overwrite by config **/ private String dbPrefix = ""; private Tab commandTabCompleter; + /** bStats, good helper for metrics. **/ private Metrics metrics; + /** Language manager, to select which language will loaded. **/ private Language language; + /** The BootError, if it not NULL, plugin will stop loading and show setted errors when use /qs **/ private BootError bootError; private CustomInventoryListener customInventoryListener; + /** WIP **/ private Compatibility compatibilityTool = new Compatibility(this); + /** Queued shop manager **/ private QueuedShopManager queuedShopManager; + /** Rewrited shoploader, more faster. **/ private ShopLoader shopLoader; + /** Contains all SQL tasks **/ private DatabaseHelper databaseHelper; + /** Queued database manager **/ private DatabaseManager databaseManager; + /** A util to call to check some actions permission **/ private PermissionChecker permissionChecker; - private SentryErrorReporter sentryErrorReporter; + /** The server UniqueID, use to the ErrorReporter **/ private static UUID serverUniqueID; + /** The error reporter to help devs report errors to Sentry.io **/ + private SentryErrorReporter sentryErrorReporter; + //private LWCPlugin lwcPlugin; /** diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 2f7360fd4..643e7858d 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -647,11 +647,11 @@ public class ShopManager { } } - double tax = plugin.getConfig().getDouble("shop.cost"); + double createCost = plugin.getConfig().getDouble("shop.cost"); // Tax refers to the cost to create a shop. Not actual // tax, that would be silly - if (tax != 0 && plugin.getEcon().getBalance(p.getUniqueId()) < tax) { - p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(tax))); + if (createCost != 0 && plugin.getEcon().getBalance(p.getUniqueId()) < createCost) { + p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(createCost))); return; } // Create the sample shop. @@ -667,15 +667,15 @@ public class ShopManager { // This must be called after the event has been called. // Else, if the event is cancelled, they won't get their // money back. - if (tax != 0) { - if (!plugin.getEcon().withdraw(p.getUniqueId(), tax)) { - p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(tax))); + if (createCost != 0) { + if (!plugin.getEcon().withdraw(p.getUniqueId(), createCost)) { + p.sendMessage(MsgUtil.getMessage("you-cant-afford-a-new-shop", format(createCost))); shop.onUnload(); return; } try { plugin.getEcon().deposit( - Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account")).getUniqueId(), tax); + Bukkit.getOfflinePlayer(plugin.getConfig().getString("tax-account")).getUniqueId(), createCost); } catch (Exception e2) { e2.printStackTrace(); plugin.getLogger().log(Level.WARNING, diff --git a/src/main/java/org/maxgamer/quickshop/Util/SentryErrorReporter.java b/src/main/java/org/maxgamer/quickshop/Util/SentryErrorReporter.java index 3111d4cf1..1db08ced1 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/SentryErrorReporter.java +++ b/src/main/java/org/maxgamer/quickshop/Util/SentryErrorReporter.java @@ -172,7 +172,8 @@ public class SentryErrorReporter { if (Util.isDevMode()) { return true; } - return false; + sendError(record.getThrown(), record.getMessage()); + return false; //Hide errors } } diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index a4605b1c6..0995973a6 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -125,6 +125,7 @@ public class Util { } public static boolean isShoppables(Material material) { + Util.debugLog("" + shoppables.contains(material)); return shoppables.contains(material); } @@ -177,18 +178,21 @@ public class Util { return false; } if ((bs instanceof InventoryHolder == false) && b.getType() != Material.ENDER_CHEST) { + Util.debugLog("Not InventoryHolder"); return false; } if (b.getType() == Material.ENDER_CHEST) { if (plugin.getOpenInvPlugin() == null) { + Util.debugLog("OpenInv not loaded."); return false; } } - return (isShoppables(b.getType()) && isBlacklistWorld(b.getWorld())); + return ((isShoppables(b.getType()) && isBlacklistWorld(b.getWorld()))); } public static boolean isBlacklistWorld(World world) { + Util.debugLog("" + worldBlacklist.contains(world.getName())); return worldBlacklist.contains(world.getName()); } @@ -441,6 +445,13 @@ public class Util { } } + /** + * Remapping the INT to ROMAIN + * 10=X 9=IX 5=V 4=IV 1=I + * + * @param value + * @return + */ public static String toRomain(Integer value) { return toRoman(value.intValue()); } @@ -484,6 +495,7 @@ public class Util { /** * Compares two items to each other. Returns true if they match. + * Rewrite it to use more faster hashCode. * * @param stack1 The first item stack * @param stack2 The second item stack @@ -555,6 +567,11 @@ public class Util { return true; } + /** + * Sort the HashMap + * @param map + * @return Sorted HashMap + */ public static Map sortHashMap(Map map) { List> list = new ArrayList>(map.entrySet()); Collections.sort(list, new Comparator>() {