Make holograms view range configurable

This commit is contained in:
filoghost 2022-11-13 16:29:25 +01:00
parent 0e98b2f89a
commit 39f0a02412
6 changed files with 15 additions and 0 deletions

View File

@ -8,5 +8,6 @@ package me.filoghost.holographicdisplays.core;
public class CoreGlobalConfig {
public static double spaceBetweenLines;
public static int maxViewRange;
}

View File

@ -89,6 +89,10 @@ public class HolographicDisplaysCore {
}
}
public void setMaxViewRange(int maxViewRange) {
CoreGlobalConfig.maxViewRange = maxViewRange;
}
public void disable() {
if (lineTrackerManager != null) {
lineTrackerManager.resetViewersAndSendDestroyPackets();

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.core.tick;
import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.core.CoreGlobalConfig;
import me.filoghost.holographicdisplays.core.listener.LineClickListener;
import me.filoghost.holographicdisplays.core.placeholder.tracking.ActivePlaceholderTracker;
import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager;
@ -75,6 +76,9 @@ public class TickingTask implements Runnable {
// Holograms need to disappear before chunks (code taken from Bukkit)
int maxViewRange = (Bukkit.getViewDistance() - 1) * 16;
if (maxViewRange > CoreGlobalConfig.maxViewRange) {
maxViewRange = CoreGlobalConfig.maxViewRange;
}
try {
lineTrackerManager.update(onlinePlayers, movedPlayers, maxViewRange);

View File

@ -128,6 +128,7 @@ public class HolographicDisplays extends FCommonsPlugin {
configManager.reloadMainSettings(errorCollector);
core.setSpaceBetweenHologramLines(Settings.spaceBetweenLines);
core.setMaxViewRange(Settings.viewRange);
AnimationPlaceholderFactory animationPlaceholderFactory = configManager.loadAnimations(errorCollector);
DefaultPlaceholders.resetAndRegister(api, animationPlaceholderFactory, bungeeServerTracker);

View File

@ -20,6 +20,7 @@ import java.util.Map;
public class Settings {
public static double spaceBetweenLines;
public static int viewRange;
public static boolean quickEditCommands;
public static DateTimeFormatter timeFormat;
public static boolean updateNotification;
@ -42,6 +43,7 @@ public class Settings {
public static void load(SettingsModel config, ErrorCollector errorCollector) {
spaceBetweenLines = config.spaceBetweenLines;
viewRange = config.viewRange;
quickEditCommands = config.quickEditCommands;
timeFormat = parseTimeFormatter(config.timeFormat, config.timeZone, errorCollector);
updateNotification = config.updateNotification;

View File

@ -18,6 +18,9 @@ public class SettingsModel implements MappedConfig {
@Path("space-between-lines")
double spaceBetweenLines = 0.02;
@Path("holograms-view-range")
int viewRange = 48;
@Path("quick-edit-commands")
boolean quickEditCommands = true;