From deb09992f10f18477f69cf6369c19cfbf08392b1 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 24 Jun 2023 13:45:07 -0700 Subject: [PATCH 1/4] Update Github Build script --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c771fd5..ee925e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,21 +11,21 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 17 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 17 - name: Cache SonarCloud packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache Maven packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} From 1b02f112207aad911fdc89678f9d05f623c62eca Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 24 Jun 2023 13:56:20 -0700 Subject: [PATCH 2/4] Added distribution required for Github Action --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee925e9..825b18d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,7 @@ jobs: - name: Set up JDK 17 uses: actions/setup-java@v3 with: + distribution: 'adopt' java-version: 17 - name: Cache SonarCloud packages uses: actions/cache@v3 From 2b0a6d82ef161bb88537b471bec4627cea8f65bb Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 10 Jul 2023 21:44:22 -0700 Subject: [PATCH 3/4] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d204ec7..5dab9e6 100644 --- a/pom.xml +++ b/pom.xml @@ -403,7 +403,7 @@ org.jacoco jacoco-maven-plugin - 0.8.7 + 0.8.10 true From 913eed9c77a4d439fc85f18cd0bc35755231391a Mon Sep 17 00:00:00 2001 From: PapiCapi <49530141+PapiCapi@users.noreply.github.com> Date: Sat, 7 Oct 2023 01:14:45 +0200 Subject: [PATCH 4/4] Add config option to disable plugin hooks (#291) * Update UltimateStacker dependency * Add config option to disable plugin hooks --- pom.xml | 2 +- src/main/java/world/bentobox/level/Level.java | 50 +++++++++++-------- .../bentobox/level/config/ConfigSettings.java | 15 ++++++ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index 5dab9e6..d511296 100644 --- a/pom.xml +++ b/pom.xml @@ -237,7 +237,7 @@ com.songoda UltimateStacker - 2.3.3 + 2.4.0 provided diff --git a/src/main/java/world/bentobox/level/Level.java b/src/main/java/world/bentobox/level/Level.java index 0d02802..1639b05 100644 --- a/src/main/java/world/bentobox/level/Level.java +++ b/src/main/java/world/bentobox/level/Level.java @@ -126,32 +126,42 @@ public class Level extends Addon { // Check if WildStackers is enabled on the server // I only added support for counting blocks into the island level // Someone else can PR if they want spawners added to the Leveling system :) - stackersEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker"); - if (stackersEnabled) { - log("Hooked into WildStackers."); - } - // Check if AdvancedChests is enabled on the server - Plugin advChest = Bukkit.getPluginManager().getPlugin("AdvancedChests"); - advChestEnabled = advChest != null; - if (advChestEnabled) { - // Check version - if (compareVersions(advChest.getDescription().getVersion(), "23.0") > 0) { - log("Hooked into AdvancedChests."); - } else { - logError("Could not hook into AdvancedChests " + advChest.getDescription().getVersion() + " - requires version 23.0 or later"); - advChestEnabled = false; + if ( !settings.getDisabledPluginHooks().contains("WildStacker") ) { + stackersEnabled = Bukkit.getPluginManager().isPluginEnabled("WildStacker"); + if (stackersEnabled) { + log("Hooked into WildStackers."); } } + + // Check if AdvancedChests is enabled on the server + if ( !settings.getDisabledPluginHooks().contains("AdvancedChests") ) { + Plugin advChest = Bukkit.getPluginManager().getPlugin("AdvancedChests"); + advChestEnabled = advChest != null; + if (advChestEnabled) { + // Check version + if (compareVersions(advChest.getDescription().getVersion(), "23.0") > 0) { + log("Hooked into AdvancedChests."); + } else { + logError("Could not hook into AdvancedChests " + advChest.getDescription().getVersion() + " - requires version 23.0 or later"); + advChestEnabled = false; + } + } + } + // Check if RoseStackers is enabled - roseStackersEnabled = Bukkit.getPluginManager().isPluginEnabled("RoseStacker"); - if (roseStackersEnabled) { - log("Hooked into RoseStackers."); + if ( !settings.getDisabledPluginHooks().contains("RoseStacker") ) { + roseStackersEnabled = Bukkit.getPluginManager().isPluginEnabled("RoseStacker"); + if (roseStackersEnabled) { + log("Hooked into RoseStackers."); + } } // Check if UltimateStacker is enabled - ultimateStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker"); - if (ultimateStackerEnabled) { - log("Hooked into UltimateStacker."); + if ( !settings.getDisabledPluginHooks().contains("UltimateStacker") ) { + ultimateStackerEnabled = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker"); + if (ultimateStackerEnabled) { + log("Hooked into UltimateStacker."); + } } } diff --git a/src/main/java/world/bentobox/level/config/ConfigSettings.java b/src/main/java/world/bentobox/level/config/ConfigSettings.java index 7be3364..c287d2a 100644 --- a/src/main/java/world/bentobox/level/config/ConfigSettings.java +++ b/src/main/java/world/bentobox/level/config/ConfigSettings.java @@ -1,5 +1,6 @@ package world.bentobox.level.config; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -126,6 +127,12 @@ public class ConfigSettings implements ConfigObject { @ConfigEntry(path = "include-shulkers-in-chest") private boolean includeShulkersInChest = false; + @ConfigComment("") + @ConfigComment("Disables hooking with other plugins.") + @ConfigComment("Example: disabled-plugin-hooks: [UltimateStacker, RoseStacker]") + @ConfigEntry(path = "disabled-plugin-hooks") + private List disabledPluginHooks = new ArrayList<>(); + /** * @return the gameModes @@ -404,4 +411,12 @@ public class ConfigSettings implements ConfigObject { public void setIncludeShulkersInChest(boolean includeShulkersInChest) { this.includeShulkersInChest = includeShulkersInChest; } + + public List getDisabledPluginHooks() { + return disabledPluginHooks; + } + + public void setDisabledPluginHooks(List disabledPluginHooks) { + this.disabledPluginHooks = disabledPluginHooks; + } }