feat: Add config for papi hook

This commit is contained in:
Ben Woo 2023-03-24 15:47:12 +08:00
parent 2edf955332
commit d126b3d31a
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
4 changed files with 34 additions and 1 deletions

View File

@ -258,8 +258,9 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
}
private void setupPlaceholderAPI() {
if(getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
if(config.isRegisterPapiHook() && getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
new MultiverseCorePlaceholders(this).register();
Logging.config("Registered PlaceholderAPI hook.");
}
}

View File

@ -1,5 +1,7 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders;
public interface MVConfig {
/**
@ -156,6 +158,18 @@ public interface MVConfig {
*/
String getPrefixChatFormat();
/**
* Sets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
* @param registerPapiHook The new value.
*/
void setRegisterPapiHook(boolean registerPapiHook);
/**
* Gets whether to register the {@link MultiverseCorePlaceholders} class with PlaceholderAPI plugin.
* @return registerPapiHook.
*/
boolean isRegisterPapiHook();
/**
* Sets globalDebug.
* @param globalDebug The new value.

View File

@ -201,6 +201,16 @@ public class DefaultMVConfig implements MVConfig {
return settings.get(MVConfigNodes.CHAT_PREFIX_FORMAT);
}
@Override
public void setRegisterPapiHook(boolean registerPapiHook) {
settings.set(MVConfigNodes.REGISTER_PAPI_HOOK, registerPapiHook);
}
@Override
public boolean isRegisterPapiHook() {
return settings.get(MVConfigNodes.REGISTER_PAPI_HOOK);
}
@Override
public void setGlobalDebug(int globalDebug) {
settings.set(MVConfigNodes.GLOBAL_DEBUG, globalDebug);

View File

@ -140,6 +140,14 @@ public class MVConfigNodes {
.name("chat-prefix-format")
.build());
public static final MVValueNode<Boolean> REGISTER_PAPI_HOOK = node(MVValueNode.builder("messaging.register-papi-hook", Boolean.class)
.comment("")
.comment("This config option defines whether or not Multiverse should register the PlaceholderAPI hook.")
.comment("This only applies if PlaceholderAPI is installed.")
.defaultValue(true)
.name("register-papi-hook")
.build());
private static final MVCommentedNode MISC_HEADER = node(MVCommentedNode.builder("misc")
.comment("")
.comment("")