Add config option to disable plugin hooks (#291)

* Update UltimateStacker dependency

* Add config option to disable plugin hooks
This commit is contained in:
PapiCapi 2023-10-07 01:14:45 +02:00 committed by GitHub
parent 2b0a6d82ef
commit 913eed9c77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 21 deletions

View File

@ -237,7 +237,7 @@
<dependency>
<groupId>com.songoda</groupId>
<artifactId>UltimateStacker</artifactId>
<version>2.3.3</version>
<version>2.4.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -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.");
}
}
}

View File

@ -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<String> 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<String> getDisabledPluginHooks() {
return disabledPluginHooks;
}
public void setDisabledPluginHooks(List<String> disabledPluginHooks) {
this.disabledPluginHooks = disabledPluginHooks;
}
}