From c0a75026b1a19c648fd4db4598bd4ff201f7294c Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Thu, 12 Sep 2019 19:30:28 +0800 Subject: [PATCH] Add option to turn off permission checking event manager and default turn off Former-commit-id: df299754b23d6aa717c28ebffc70aa3f60669c3d [formerly 82b3bb0a9f1a4826278c1437edb7179538f9be9d] Former-commit-id: dbf8d44b9bd6d8808505e4fada203e0f7b07babb --- src/main/java/org/maxgamer/quickshop/QuickShop.java | 6 +++++- .../org/maxgamer/quickshop/Util/PermissionChecker.java | 9 ++++++--- .../java/org/maxgamer/quickshop/Util/QSEventManager.java | 1 + src/main/resources/config.yml | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index 9f3893186..3555cee29 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -902,7 +902,11 @@ public class QuickShop extends JavaPlugin { getConfig().set("config-version", 46); selectedVersion = 46; } - + if (selectedVersion == 46) { + getConfig().set("shop.use-protection-checking-filter", false); + getConfig().set("config-version", 47); + selectedVersion = 47; + } saveConfig(); reloadConfig(); File file = new File(getDataFolder(), "example.config.yml"); diff --git a/src/main/java/org/maxgamer/quickshop/Util/PermissionChecker.java b/src/main/java/org/maxgamer/quickshop/Util/PermissionChecker.java index 4cedc3fc3..ffaf9c96f 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/PermissionChecker.java +++ b/src/main/java/org/maxgamer/quickshop/Util/PermissionChecker.java @@ -55,7 +55,12 @@ public class PermissionChecker { //Bukkit.getPluginManager().callEvent(beMainHand); beMainHand.setDropItems(false); beMainHand.setExpToDrop(-1); - Plugin cancelPlugin = plugin.getQsEventManager().fireEvent(beMainHand); + Plugin cancelPlugin = null; + if(plugin.getConfig().getBoolean("shop.use-protection-checking-filter")){ + cancelPlugin = plugin.getQsEventManager().fireEvent(beMainHand); + }else{ + Bukkit.getPluginManager().callEvent(beMainHand); + } //Use our custom event caller. ListenerHelper.enableEvent(beMainHand.getClass()); //Call for event for protection check end @@ -69,8 +74,6 @@ public class PermissionChecker { // } if(cancelPlugin != null) { Util.debugLog("Plugin " + cancelPlugin.getName() + " cancelled this build create action."); - }else{ - Util.debugLog("Internal server error."); } } diff --git a/src/main/java/org/maxgamer/quickshop/Util/QSEventManager.java b/src/main/java/org/maxgamer/quickshop/Util/QSEventManager.java index ba96872fc..2944fc4f7 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/QSEventManager.java +++ b/src/main/java/org/maxgamer/quickshop/Util/QSEventManager.java @@ -76,6 +76,7 @@ public class QSEventManager { } Set containers = containerSet.get(registration.getPlugin().getName()); if (containers == null) { + Util.debugLog("Container is null, skipping..."); continue; } for (PluginEventFilterContainer container : containers) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cf42aca4b..ce3ffd3a1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,7 +1,7 @@ #This is example config, don't direct modify this file, all changes will revert when you reload the plugin. #Do not touch if you not clear know about this -config-version: 46 +config-version: 47 #Select the language you want to use, (e.g de), use only supported language codes from the list below. #If you use a not exist/not support language, plugin will move to use en_US to keep everything working. @@ -231,6 +231,7 @@ shop: #Protection advanced event calling filter #Advance users only. + use-protection-checking-filter: false protection-checking-filter: [] # - PLUGIN##LISTENER##EVENT #Example: - QuickShop##org.maxgamer.Listeners.BlockListener##org.bukkit.event.block.BlockPlaceEvent