Add options to disable PlaceholderAPI and to change the refresh interval
This commit is contained in:
parent
459abdc2f8
commit
c7e0f64469
|
@ -24,6 +24,9 @@ public class Settings {
|
|||
public static DateTimeFormatter timeFormat;
|
||||
public static boolean updateNotification;
|
||||
|
||||
public static boolean placeholderAPIEnabled;
|
||||
public static int placeholderAPIDefaultRefreshInternalTicks;
|
||||
|
||||
public static String imageSymbol;
|
||||
public static String transparencySymbol;
|
||||
|
||||
|
@ -43,6 +46,9 @@ public class Settings {
|
|||
timeFormat = parseTimeFormatter(config.timeFormat, config.timeZone, errorCollector);
|
||||
updateNotification = config.updateNotification;
|
||||
|
||||
placeholderAPIEnabled = config.placeholderAPIEnabled;
|
||||
placeholderAPIDefaultRefreshInternalTicks = config.placeholderAPIDefaultRefreshIntervalTicks;
|
||||
|
||||
imageSymbol = DisplayFormat.apply(config.imageRenderingSolidPixel);
|
||||
transparencySymbol = DisplayFormat.apply(config.imageRenderingTransparentPixel);
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ public class SettingsModel implements MappedConfig {
|
|||
@Path("quick-edit-commands")
|
||||
boolean quickEditCommands = true;
|
||||
|
||||
@Path("placeholders.PlaceholderAPI.enabled")
|
||||
boolean placeholderAPIEnabled = true;
|
||||
|
||||
@Path("placeholders.PlaceholderAPI.default-refresh-interval-ticks")
|
||||
int placeholderAPIDefaultRefreshIntervalTicks = 200;
|
||||
|
||||
@Path("image-rendering.solid-pixel")
|
||||
String imageRenderingSolidPixel = "\\u2588";
|
||||
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
package me.filoghost.holographicdisplays.plugin.internal.placeholder;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.placeholder.GlobalPlaceholder;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholder;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ImmutablePlaceholder implements GlobalPlaceholder {
|
||||
public class ImmutablePlaceholder implements GlobalPlaceholder, IndividualPlaceholder {
|
||||
|
||||
private final String text;
|
||||
|
||||
|
@ -21,7 +25,12 @@ public class ImmutablePlaceholder implements GlobalPlaceholder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getReplacement(String argument) {
|
||||
public String getReplacement(@Nullable String argument) {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReplacement(@NotNull Player player, @Nullable String argument) {
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.plugin.internal.placeholder;
|
|||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholder;
|
||||
import me.filoghost.holographicdisplays.api.placeholder.IndividualPlaceholderFactory;
|
||||
import me.filoghost.holographicdisplays.plugin.bridge.placeholderapi.PlaceholderAPIHook;
|
||||
import me.filoghost.holographicdisplays.plugin.config.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -16,9 +17,14 @@ public class PlaceholderAPIPlaceholderFactory implements IndividualPlaceholderFa
|
|||
|
||||
@Override
|
||||
public @Nullable IndividualPlaceholder getPlaceholder(@Nullable String argument) {
|
||||
if (!Settings.placeholderAPIEnabled) {
|
||||
return new ImmutablePlaceholder("[PlaceholderAPI not enabled in configuration]");
|
||||
}
|
||||
|
||||
if (argument == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new PlaceholderAPIPlaceholder("%" + argument + "%");
|
||||
}
|
||||
|
||||
|
@ -33,7 +39,7 @@ public class PlaceholderAPIPlaceholderFactory implements IndividualPlaceholderFa
|
|||
|
||||
@Override
|
||||
public int getRefreshIntervalTicks() {
|
||||
return 1;
|
||||
return Settings.placeholderAPIDefaultRefreshInternalTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +47,7 @@ public class PlaceholderAPIPlaceholderFactory implements IndividualPlaceholderFa
|
|||
if (!PlaceholderAPIHook.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return PlaceholderAPIHook.replacePlaceholders(player, content);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue