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) {
return new APITextLine(this, getNMSManager(), text);
return new APITextLine(this, text);
}
private APIItemLine createItemLine(ItemStack itemStack) {
return new APIItemLine(this, getNMSManager(), itemStack);
return new APIItemLine(this, itemStack);
}
@Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,11 +23,11 @@ public class InternalHologram extends BaseHologram<InternalHologramLine> {
}
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) {
return new InternalItemLine(this, getNMSManager(), icon, serializedConfigValue);
return new InternalItemLine(this, icon, serializedConfigValue);
}
public String getName() {

View File

@ -5,8 +5,6 @@
*/
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 org.bukkit.inventory.ItemStack;
@ -14,8 +12,8 @@ public class InternalItemLine extends BaseItemLine implements InternalHologramLi
private final String serializedConfigValue;
protected InternalItemLine(StandardHologram hologram, NMSManager nmsManager, ItemStack itemStack, String serializedConfigValue) {
super(hologram, nmsManager, itemStack);
protected InternalItemLine(InternalHologram hologram, ItemStack itemStack, String serializedConfigValue) {
super(hologram, itemStack);
this.serializedConfigValue = serializedConfigValue;
}

View File

@ -5,16 +5,14 @@
*/
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;
public class InternalTextLine extends BaseTextLine implements InternalHologramLine {
private final String serializedConfigValue;
protected InternalTextLine(StandardHologram hologram, NMSManager nmsManager, String text, String serializedConfigValue) {
super(hologram, nmsManager, text);
protected InternalTextLine(InternalHologram hologram, String text, String serializedConfigValue) {
super(hologram, text);
this.serializedConfigValue = serializedConfigValue;
}