Move spaceBetweenLines to separate class

This commit is contained in:
filoghost 2022-11-13 15:57:40 +01:00
parent 0449fe65ca
commit 0e98b2f89a
4 changed files with 18 additions and 8 deletions

View File

@ -0,0 +1,12 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.core;
public class CoreGlobalConfig {
public static double spaceBetweenLines;
}

View File

@ -16,7 +16,6 @@ import me.filoghost.holographicdisplays.core.api.current.DefaultHolographicDispl
import me.filoghost.holographicdisplays.core.api.v2.V2HologramManager;
import me.filoghost.holographicdisplays.core.api.v2.V2HologramsAPIProvider;
import me.filoghost.holographicdisplays.core.base.BaseHologram;
import me.filoghost.holographicdisplays.core.base.BaseHologramLines;
import me.filoghost.holographicdisplays.core.listener.ChunkListener;
import me.filoghost.holographicdisplays.core.listener.LineClickListener;
import me.filoghost.holographicdisplays.core.listener.PlayerListener;
@ -81,7 +80,7 @@ public class HolographicDisplaysCore {
}
public void setSpaceBetweenHologramLines(double spaceBetweenLines) {
BaseHologramLines.spaceBetweenLines = spaceBetweenLines;
CoreGlobalConfig.spaceBetweenLines = spaceBetweenLines;
for (BaseHologram hologram : apiHologramManager.getHolograms()) {
hologram.getLines().updatePositions();
}

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.core.base;
import me.filoghost.holographicdisplays.api.Position;
import me.filoghost.holographicdisplays.core.CoreGlobalConfig;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@ -15,8 +16,6 @@ import java.util.List;
public class BaseHologramLines<T extends EditableHologramLine> implements Iterable<T> {
public static double spaceBetweenLines;
private final BaseHologram hologram;
private final List<T> lines;
private final List<T> unmodifiableLinesView;
@ -98,7 +97,7 @@ public class BaseHologramLines<T extends EditableHologramLine> implements Iterab
currentLineY -= line.getHeight();
if (i > 0) {
currentLineY -= spaceBetweenLines;
currentLineY -= CoreGlobalConfig.spaceBetweenLines;
}
line.setCoordinates(hologramPosition.getX(), currentLineY, hologramPosition.getZ());
@ -116,7 +115,7 @@ public class BaseHologramLines<T extends EditableHologramLine> implements Iterab
height += line.getHeight();
}
height += spaceBetweenLines * (lines.size() - 1);
height += CoreGlobalConfig.spaceBetweenLines * (lines.size() - 1);
return height;
}

View File

@ -127,6 +127,8 @@ public class HolographicDisplays extends FCommonsPlugin {
configManager.reloadStaticReplacements(errorCollector);
configManager.reloadMainSettings(errorCollector);
core.setSpaceBetweenHologramLines(Settings.spaceBetweenLines);
AnimationPlaceholderFactory animationPlaceholderFactory = configManager.loadAnimations(errorCollector);
DefaultPlaceholders.resetAndRegister(api, animationPlaceholderFactory, bungeeServerTracker);
@ -144,8 +146,6 @@ public class HolographicDisplays extends FCommonsPlugin {
errorCollector.add(e, "error while loading hologram \"" + hologramConfig.getName() + "\"");
}
}
core.setSpaceBetweenHologramLines(Settings.spaceBetweenLines);
}
@Override