Refactoring

This commit is contained in:
filoghost 2021-07-28 21:00:14 +02:00
parent 438dcfb1dc
commit 55643651c9
8 changed files with 23 additions and 9 deletions

View File

@ -6,15 +6,16 @@
package me.filoghost.holographicdisplays.common.hologram;
import org.bukkit.World;
import org.bukkit.entity.Player;
public interface StandardHologramLine extends StandardHologramComponent {
StandardHologram getHologram();
void setLocation(World world, double x, double y, double z);
double getHeight();
void setChanged();
boolean isVisibleTo(Player player);
}

View File

@ -107,6 +107,14 @@ public abstract class BaseHologram<T extends StandardHologramLine> extends BaseH
// No need to refresh, since there are no lines
}
@Override
public final void setDeleted() {
super.setDeleted();
for (T line : lines) {
line.setDeleted();
}
}
@Override
public int getLineCount() {
return lines.size();

View File

@ -78,8 +78,9 @@ public abstract class BaseHologramComponent implements StandardHologramComponent
return deleted;
}
@MustBeInvokedByOverriders
@Override
public final void setDeleted() {
public void setDeleted() {
deleted = true;
}

View File

@ -26,8 +26,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
protected abstract LineTracker<?> createTracker(LineTrackerManager trackerManager);
@Override
public final StandardHologram getHologram() {
protected final StandardHologram getHologram() {
return hologram;
}
@ -46,4 +45,9 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
setChanged();
}
@Override
public boolean isVisibleTo(Player player) {
return hologram.isVisibleTo(player);
}
}

View File

@ -33,7 +33,7 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard
@Override
public void onPickup(Player player) {
if (pickupHandler == null || !getHologram().isVisibleTo(player)) {
if (pickupHandler == null || !isVisibleTo(player)) {
return;
}

View File

@ -37,7 +37,7 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
|| !isTrackedPlayer(player)
|| player.getGameMode() == GameMode.SPECTATOR
|| touchHandler == null
|| !getHologram().isVisibleTo(player)) {
|| !isVisibleTo(player)) {
return;
}

View File

@ -103,7 +103,7 @@ public abstract class LineTracker<T extends StandardHologramLine> {
}
final boolean shouldBeRemoved() {
return line.isDeleted() || line.getHologram().isDeleted();
return line.isDeleted();
}
@MustBeInvokedByOverriders

View File

@ -76,7 +76,7 @@ abstract class LocationBasedLineTracker<T extends StandardHologramLine> extends
return playerLocation.getWorld() == world
&& diffX <= (double) ENTITY_VIEW_RANGE
&& diffZ <= (double) ENTITY_VIEW_RANGE
&& line.getHologram().isVisibleTo(player);
&& line.isVisibleTo(player);
}
@MustBeInvokedByOverriders