Small refactoring

This commit is contained in:
filoghost 2021-03-15 21:41:03 +01:00
parent f474684693
commit 6cc28cc957
10 changed files with 21 additions and 35 deletions

View File

@ -77,11 +77,11 @@ public class APIHologram extends BaseHologram<APIHologramLine> implements Hologr
} }
private APITextLine createTextLine(String text) { private APITextLine createTextLine(String text) {
return new APITextLine(this, getNMSManager(), text); return new APITextLine(this, text);
} }
private APIItemLine createItemLine(ItemStack itemStack) { private APIItemLine createItemLine(ItemStack itemStack) {
return new APIItemLine(this, getNMSManager(), itemStack); return new APIItemLine(this, itemStack);
} }
@Override @Override

View File

@ -1,7 +1,6 @@
package me.filoghost.holographicdisplays.object.api; package me.filoghost.holographicdisplays.object.api;
import me.filoghost.holographicdisplays.api.line.ItemLine; import me.filoghost.holographicdisplays.api.line.ItemLine;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.object.base.BaseItemLine; import me.filoghost.holographicdisplays.object.base.BaseItemLine;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -9,8 +8,8 @@ public class APIItemLine extends BaseItemLine implements ItemLine, APIHologramLi
private final APIHologram parent; private final APIHologram parent;
public APIItemLine(APIHologram parent, NMSManager nmsManager, ItemStack itemStack) { public APIItemLine(APIHologram parent, ItemStack itemStack) {
super(parent, nmsManager, itemStack); super(parent, itemStack);
this.parent = parent; this.parent = parent;
} }

View File

@ -1,15 +1,14 @@
package me.filoghost.holographicdisplays.object.api; package me.filoghost.holographicdisplays.object.api;
import me.filoghost.holographicdisplays.api.line.TextLine; import me.filoghost.holographicdisplays.api.line.TextLine;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.object.base.BaseTextLine; import me.filoghost.holographicdisplays.object.base.BaseTextLine;
public class APITextLine extends BaseTextLine implements TextLine, APIHologramLine { public class APITextLine extends BaseTextLine implements TextLine, APIHologramLine {
private final APIHologram parent; private final APIHologram parent;
public APITextLine(APIHologram parent, NMSManager nmsManager, String text) { public APITextLine(APIHologram parent, String text) {
super(parent, nmsManager, text); super(parent, text);
this.parent = parent; this.parent = parent;
} }

View File

@ -15,15 +15,13 @@ import org.bukkit.World;
public abstract class BaseHologramLine extends BaseHologramComponent implements StandardHologramLine { public abstract class BaseHologramLine extends BaseHologramComponent implements StandardHologramLine {
private final StandardHologram hologram; private final BaseHologram<?> hologram;
private final NMSManager nmsManager;
private boolean isSpawned; private boolean isSpawned;
protected BaseHologramLine(StandardHologram hologram, NMSManager nmsManager) { protected BaseHologramLine(BaseHologram<?> hologram) {
Preconditions.notNull(hologram, "parent hologram"); Preconditions.notNull(hologram, "parent hologram");
this.hologram = hologram; this.hologram = hologram;
this.nmsManager = nmsManager;
} }
@Override @Override
@ -32,7 +30,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
} }
protected final NMSManager getNMSManager() { protected final NMSManager getNMSManager() {
return nmsManager; return hologram.getNMSManager();
} }
@Override @Override

View File

@ -8,9 +8,7 @@ package me.filoghost.holographicdisplays.object.base;
import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.Preconditions;
import me.filoghost.fcommons.logging.Log; import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.api.handler.PickupHandler; import me.filoghost.holographicdisplays.api.handler.PickupHandler;
import me.filoghost.holographicdisplays.core.hologram.StandardHologram;
import me.filoghost.holographicdisplays.core.hologram.StandardItemLine; import me.filoghost.holographicdisplays.core.hologram.StandardItemLine;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.core.nms.SpawnFailedException; import me.filoghost.holographicdisplays.core.nms.SpawnFailedException;
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
import me.filoghost.holographicdisplays.core.nms.entity.NMSItem; import me.filoghost.holographicdisplays.core.nms.entity.NMSItem;
@ -28,8 +26,8 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard
private NMSArmorStand itemVehicleEntity; private NMSArmorStand itemVehicleEntity;
private PickupHandler pickupHandler; private PickupHandler pickupHandler;
public BaseItemLine(StandardHologram hologram, NMSManager nmsManager, ItemStack itemStack) { public BaseItemLine(BaseHologram<?> hologram, ItemStack itemStack) {
super(hologram, nmsManager); super(hologram);
setItemStack(itemStack); setItemStack(itemStack);
} }

View File

@ -5,9 +5,7 @@
*/ */
package me.filoghost.holographicdisplays.object.base; package me.filoghost.holographicdisplays.object.base;
import me.filoghost.holographicdisplays.core.hologram.StandardHologram;
import me.filoghost.holographicdisplays.core.hologram.StandardTextLine; import me.filoghost.holographicdisplays.core.hologram.StandardTextLine;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.core.nms.SpawnFailedException; import me.filoghost.holographicdisplays.core.nms.SpawnFailedException;
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
import me.filoghost.holographicdisplays.core.placeholder.RelativePlaceholder; import me.filoghost.holographicdisplays.core.placeholder.RelativePlaceholder;
@ -23,8 +21,8 @@ public abstract class BaseTextLine extends BaseTouchableLine implements Standard
private String text; private String text;
private NMSArmorStand textEntity; private NMSArmorStand textEntity;
public BaseTextLine(StandardHologram hologram, NMSManager nmsManager, String text) { public BaseTextLine(BaseHologram<?> hologram, String text) {
super(hologram, nmsManager); super(hologram);
this.relativePlaceholders = new ArrayList<>(); this.relativePlaceholders = new ArrayList<>();
setText(text); setText(text);
} }

View File

@ -8,9 +8,7 @@ package me.filoghost.holographicdisplays.object.base;
import me.filoghost.fcommons.logging.Log; import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.api.handler.TouchHandler; import me.filoghost.holographicdisplays.api.handler.TouchHandler;
import me.filoghost.holographicdisplays.core.DebugLogger; import me.filoghost.holographicdisplays.core.DebugLogger;
import me.filoghost.holographicdisplays.core.hologram.StandardHologram;
import me.filoghost.holographicdisplays.core.hologram.StandardTouchableLine; import me.filoghost.holographicdisplays.core.hologram.StandardTouchableLine;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.core.nms.SpawnFailedException; import me.filoghost.holographicdisplays.core.nms.SpawnFailedException;
import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand; import me.filoghost.holographicdisplays.core.nms.entity.NMSArmorStand;
import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime; import me.filoghost.holographicdisplays.core.nms.entity.NMSSlime;
@ -37,8 +35,8 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
private NMSArmorStand slimeVehicleEntity; private NMSArmorStand slimeVehicleEntity;
protected BaseTouchableLine(StandardHologram hologram, NMSManager nmsManager) { protected BaseTouchableLine(BaseHologram<?> hologram) {
super(hologram, nmsManager); super(hologram);
} }
@Override @Override

View File

@ -23,11 +23,11 @@ public class InternalHologram extends BaseHologram<InternalHologramLine> {
} }
public InternalTextLine createTextLine(String text, String serializedConfigValue) { public InternalTextLine createTextLine(String text, String serializedConfigValue) {
return new InternalTextLine(this, getNMSManager(), text, serializedConfigValue); return new InternalTextLine(this, text, serializedConfigValue);
} }
public InternalItemLine createItemLine(ItemStack icon, String serializedConfigValue) { public InternalItemLine createItemLine(ItemStack icon, String serializedConfigValue) {
return new InternalItemLine(this, getNMSManager(), icon, serializedConfigValue); return new InternalItemLine(this, icon, serializedConfigValue);
} }
public String getName() { public String getName() {

View File

@ -5,8 +5,6 @@
*/ */
package me.filoghost.holographicdisplays.object.internal; package me.filoghost.holographicdisplays.object.internal;
import me.filoghost.holographicdisplays.core.hologram.StandardHologram;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.object.base.BaseItemLine; import me.filoghost.holographicdisplays.object.base.BaseItemLine;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -14,8 +12,8 @@ public class InternalItemLine extends BaseItemLine implements InternalHologramLi
private final String serializedConfigValue; private final String serializedConfigValue;
protected InternalItemLine(StandardHologram hologram, NMSManager nmsManager, ItemStack itemStack, String serializedConfigValue) { protected InternalItemLine(InternalHologram hologram, ItemStack itemStack, String serializedConfigValue) {
super(hologram, nmsManager, itemStack); super(hologram, itemStack);
this.serializedConfigValue = serializedConfigValue; this.serializedConfigValue = serializedConfigValue;
} }

View File

@ -5,16 +5,14 @@
*/ */
package me.filoghost.holographicdisplays.object.internal; package me.filoghost.holographicdisplays.object.internal;
import me.filoghost.holographicdisplays.core.hologram.StandardHologram;
import me.filoghost.holographicdisplays.core.nms.NMSManager;
import me.filoghost.holographicdisplays.object.base.BaseTextLine; import me.filoghost.holographicdisplays.object.base.BaseTextLine;
public class InternalTextLine extends BaseTextLine implements InternalHologramLine { public class InternalTextLine extends BaseTextLine implements InternalHologramLine {
private final String serializedConfigValue; private final String serializedConfigValue;
protected InternalTextLine(StandardHologram hologram, NMSManager nmsManager, String text, String serializedConfigValue) { protected InternalTextLine(InternalHologram hologram, String text, String serializedConfigValue) {
super(hologram, nmsManager, text); super(hologram, text);
this.serializedConfigValue = serializedConfigValue; this.serializedConfigValue = serializedConfigValue;
} }