Make HologramPosition immutable

This commit is contained in:
filoghost 2021-08-19 15:36:10 +02:00
parent 9e966ea185
commit 55f690cec9
17 changed files with 108 additions and 209 deletions

View File

@ -120,38 +120,6 @@ public interface Hologram {
*/ */
@NotNull HologramPosition getPosition(); @NotNull HologramPosition getPosition();
/**
* Returns the world name of the hologram position.
*
* @return the world name of the hologram position
* @since 1
*/
@NotNull String getPositionWorldName();
/**
* Returns the X coordinate of the hologram position.
*
* @return the X coordinate of the hologram position
* @since 1
*/
double getPositionX();
/**
* Returns the Y coordinate of the hologram position.
*
* @return the Y coordinate of the hologram position
* @since 1
*/
double getPositionY();
/**
* Returns the Z coordinate of the hologram position.
*
* @return the Z coordinate of the hologram position
* @since 1
*/
double getPositionZ();
/** /**
* Moves the hologram to the given position. * Moves the hologram to the given position.
* *

View File

@ -27,25 +27,15 @@ public interface HologramPosition {
@NotNull String getWorldName(); @NotNull String getWorldName();
void setWorldName(@NotNull String worldName);
@Nullable World getWorldIfLoaded(); @Nullable World getWorldIfLoaded();
void setWorld(@NotNull World world);
double getX(); double getX();
void setX(double x);
double getY(); double getY();
void setY(double y);
double getZ(); double getZ();
void setZ(double z); @NotNull HologramPosition add(double x, double y, double z);
HologramPosition add(double x, double y, double z);
int getBlockX(); int getBlockX();

View File

@ -10,7 +10,7 @@ import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
import me.filoghost.holographicdisplays.api.hologram.HologramPosition; import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider; import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
import me.filoghost.holographicdisplays.plugin.hologram.api.APIHologramManager; import me.filoghost.holographicdisplays.plugin.hologram.api.APIHologramManager;
import me.filoghost.holographicdisplays.plugin.hologram.api.APIHologramPosition; import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition;
import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry; import me.filoghost.holographicdisplays.plugin.placeholder.registry.PlaceholderRegistry;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -44,17 +44,17 @@ public class DefaultHolographicDisplaysAPIProvider extends HolographicDisplaysAP
@Override @Override
public HologramPosition createHologramPosition(World world, double x, double y, double z) { public HologramPosition createHologramPosition(World world, double x, double y, double z) {
Preconditions.notNull(world, "world"); Preconditions.notNull(world, "world");
return new APIHologramPosition(world.getName(), x, y, z); return new BaseHologramPosition(world.getName(), x, y, z);
} }
@Override @Override
public HologramPosition createHologramPosition(String worldName, double x, double y, double z) { public HologramPosition createHologramPosition(String worldName, double x, double y, double z) {
return new APIHologramPosition(worldName, x, y, z); return new BaseHologramPosition(worldName, x, y, z);
} }
@Override @Override
public HologramPosition createHologramPosition(Location location) { public HologramPosition createHologramPosition(Location location) {
return new APIHologramPosition(location); return new BaseHologramPosition(location);
} }
} }

View File

@ -81,31 +81,27 @@ public class V2HologramAdapter implements Hologram {
@Override @Override
public Location getLocation() { public Location getLocation() {
return new Location( return v3Hologram.getPosition().toLocation();
v3Hologram.getPositionWorldIfLoaded(),
v3Hologram.getPositionX(),
v3Hologram.getPositionY(),
v3Hologram.getPositionZ());
} }
@Override @Override
public double getX() { public double getX() {
return v3Hologram.getPositionX(); return v3Hologram.getPosition().getX();
} }
@Override @Override
public double getY() { public double getY() {
return v3Hologram.getPositionY(); return v3Hologram.getPosition().getY();
} }
@Override @Override
public double getZ() { public double getZ() {
return v3Hologram.getPositionZ(); return v3Hologram.getPosition().getZ();
} }
@Override @Override
public World getWorld() { public World getWorld() {
return v3Hologram.getPositionWorldIfLoaded(); return v3Hologram.getWorldIfLoaded();
} }
@Override @Override

View File

@ -36,19 +36,19 @@ public class AlignCommand extends HologramSubCommand {
CommandValidate.check(hologram != referenceHologram, "The holograms must not be the same."); CommandValidate.check(hologram != referenceHologram, "The holograms must not be the same.");
BaseHologramPosition referencePosition = referenceHologram.getBasePosition(); BaseHologramPosition referencePosition = referenceHologram.getPosition();
BaseHologramPosition newPosition = hologram.getBasePosition(); BaseHologramPosition newPosition = hologram.getPosition();
String axis = args[0]; String axis = args[0];
if (axis.equalsIgnoreCase("x")) { if (axis.equalsIgnoreCase("x")) {
newPosition.setX(referencePosition.getX()); newPosition = newPosition.withX(referencePosition.getX());
} else if (axis.equalsIgnoreCase("y")) { } else if (axis.equalsIgnoreCase("y")) {
newPosition.setY(referencePosition.getY()); newPosition = newPosition.withY(referencePosition.getY());
} else if (axis.equalsIgnoreCase("z")) { } else if (axis.equalsIgnoreCase("z")) {
newPosition.setZ(referencePosition.getZ()); newPosition = newPosition.withZ(referencePosition.getZ());
} else if (axis.equalsIgnoreCase("xz")) { } else if (axis.equalsIgnoreCase("xz")) {
newPosition.setX(referencePosition.getX()); newPosition = newPosition.withX(referencePosition.getX());
newPosition.setZ(referencePosition.getZ()); newPosition = newPosition.withZ(referencePosition.getZ());
} else { } else {
throw new CommandException("You must specify either X, Y, Z or XZ, " + axis + " is not a valid axis."); throw new CommandException("You must specify either X, Y, Z or XZ, " + axis + " is not a valid axis.");
} }

View File

@ -50,7 +50,7 @@ public class CreateCommand extends HologramSubCommand {
boolean moveUp = player.isOnGround(); boolean moveUp = player.isOnGround();
if (moveUp) { if (moveUp) {
spawnPosition.add(0, 1.2, 0); spawnPosition = spawnPosition.add(0, 1.2, 0);
} }
InternalHologram hologram = hologramEditor.create(spawnPosition, hologramName); InternalHologram hologram = hologramEditor.create(spawnPosition, hologramName);

View File

@ -43,7 +43,7 @@ public class NearCommand extends HologramSubCommand {
List<InternalHologram> nearHolograms = new ArrayList<>(); List<InternalHologram> nearHolograms = new ArrayList<>();
for (InternalHologram hologram : hologramEditor.getHolograms()) { for (InternalHologram hologram : hologramEditor.getHolograms()) {
BaseHologramPosition position = hologram.getBasePosition(); BaseHologramPosition position = hologram.getPosition();
if (position.isInWorld(world) && position.distance(player.getLocation()) <= radius) { if (position.isInWorld(world) && position.distance(player.getLocation()) <= radius) {
nearHolograms.add(hologram); nearHolograms.add(hologram);
} }

View File

@ -34,7 +34,7 @@ public class TeleportCommand extends HologramSubCommand {
Player player = CommandValidate.getPlayerSender(sender); Player player = CommandValidate.getPlayerSender(sender);
InternalHologram hologram = hologramEditor.getExistingHologram(args[0]); InternalHologram hologram = hologramEditor.getExistingHologram(args[0]);
hologramEditor.teleportLookingDown(player, hologram.getBasePosition().toLocation()); hologramEditor.teleportLookingDown(player, hologram.getPosition().toLocation());
player.sendMessage(ColorScheme.PRIMARY + "Teleported to the hologram \"" + hologram.getName() + "\"."); player.sendMessage(ColorScheme.PRIMARY + "Teleported to the hologram \"" + hologram.getName() + "\".");
} }

View File

@ -34,7 +34,7 @@ public class HologramConfig {
serializedLines.add(line.getSerializedConfigValue()); serializedLines.add(line.getSerializedConfigValue());
} }
BaseHologramPosition position = hologram.getBasePosition(); BaseHologramPosition position = hologram.getPosition();
this.positionConfigSection = new ConfigSection(); this.positionConfigSection = new ConfigSection();
positionConfigSection.setString("world", position.getWorldName()); positionConfigSection.setString("world", position.getWorldName());
positionConfigSection.setDouble("x", position.getX()); positionConfigSection.setDouble("x", position.getX());

View File

@ -87,7 +87,7 @@ public class DisplayFormat {
} }
public static void sendHologramSummary(CommandSender sender, InternalHologram hologram, boolean showWorld) { public static void sendHologramSummary(CommandSender sender, InternalHologram hologram, boolean showWorld) {
BaseHologramPosition position = hologram.getBasePosition(); BaseHologramPosition position = hologram.getPosition();
sender.sendMessage(ColorScheme.SECONDARY_DARK + "- " + ColorScheme.SECONDARY_BOLD + hologram.getName() sender.sendMessage(ColorScheme.SECONDARY_DARK + "- " + ColorScheme.SECONDARY_BOLD + hologram.getName()
+ ColorScheme.SECONDARY_DARK + " (" + hologram.getLines().size() + " lines) at " + ColorScheme.SECONDARY_DARK + " (" + hologram.getLines().size() + " lines) at "
+ (showWorld ? "world: \"" + position.getWorldName() + "\", " : "") + (showWorld ? "world: \"" + position.getWorldName() + "\", " : "")

View File

@ -8,7 +8,6 @@ package me.filoghost.holographicdisplays.plugin.hologram.api;
import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.Preconditions;
import me.filoghost.holographicdisplays.api.hologram.Hologram; import me.filoghost.holographicdisplays.api.hologram.Hologram;
import me.filoghost.holographicdisplays.api.hologram.HologramLine; import me.filoghost.holographicdisplays.api.hologram.HologramLine;
import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
import me.filoghost.holographicdisplays.plugin.api.v2.V2HologramAdapter; import me.filoghost.holographicdisplays.plugin.api.v2.V2HologramAdapter;
import me.filoghost.holographicdisplays.plugin.config.Settings; import me.filoghost.holographicdisplays.plugin.config.Settings;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologram; import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologram;
@ -170,16 +169,6 @@ public class APIHologram extends BaseHologram implements Hologram {
return height; return height;
} }
@Override
public @NotNull HologramPosition getPosition() {
return new APIHologramPosition(getPositionWorldName(), getPositionX(), getPositionY(), getPositionZ());
}
@Override
public void setPosition(@NotNull HologramPosition position) {
super.setPosition(position.getWorldName(), position.getX(), position.getY(), position.getZ());
}
@Override @Override
public long getCreationTimestamp() { public long getCreationTimestamp() {
return creationTimestamp; return creationTimestamp;

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.plugin.hologram.api;
import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramPosition;
import org.bukkit.Location;
public class APIHologramPosition extends BaseHologramPosition implements HologramPosition {
public APIHologramPosition(String worldName, double x, double y, double z) {
super(worldName, x, y, z);
}
public APIHologramPosition(Location location) {
super(location);
}
@Override
public APIHologramPosition add(double x, double y, double z) {
super.add(x, y, z);
return this;
}
}

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.plugin.hologram.base; package me.filoghost.holographicdisplays.plugin.hologram.base;
import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.Preconditions;
import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager; import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
@ -41,31 +42,15 @@ public abstract class BaseHologram extends BaseHologramComponent {
getLines().setDeleted(); getLines().setDeleted();
} }
public BaseHologramPosition getBasePosition() { public @NotNull BaseHologramPosition getPosition() {
return position.toBasePosition(); return position.getPosition();
} }
public @Nullable World getPositionWorldIfLoaded() { public @Nullable World getWorldIfLoaded() {
return position.getWorldIfLoaded(); return position.getWorldIfLoaded();
} }
public @NotNull String getPositionWorldName() { public void setPosition(@NotNull HologramPosition position) {
return position.getWorldName();
}
public double getPositionX() {
return position.getX();
}
public double getPositionY() {
return position.getY();
}
public double getPositionZ() {
return position.getZ();
}
public void setPosition(@NotNull BaseHologramPosition position) {
Preconditions.notNull(position, "position"); Preconditions.notNull(position, "position");
setPosition(position.getWorldName(), position.getX(), position.getY(), position.getZ()); setPosition(position.getWorldName(), position.getX(), position.getY(), position.getZ());
} }

View File

@ -53,7 +53,7 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
} }
public @Nullable World getWorldIfLoaded() { public @Nullable World getWorldIfLoaded() {
return hologram.getPositionWorldIfLoaded(); return hologram.getWorldIfLoaded();
} }
public boolean isInLoadedChunk() { public boolean isInLoadedChunk() {

View File

@ -5,6 +5,7 @@
*/ */
package me.filoghost.holographicdisplays.plugin.hologram.base; package me.filoghost.holographicdisplays.plugin.hologram.base;
import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
import me.filoghost.holographicdisplays.plugin.config.Settings; import me.filoghost.holographicdisplays.plugin.config.Settings;
import java.util.ArrayList; import java.util.ArrayList;
@ -114,7 +115,8 @@ public class BaseHologramLines<T extends EditableHologramLine> implements Iterab
* The second line is below the first, and so on. * The second line is below the first, and so on.
*/ */
protected void updateLinePositions() { protected void updateLinePositions() {
double currentLineY = hologram.getPositionY(); HologramPosition hologramPosition = hologram.getPosition();
double currentLineY = hologramPosition.getY();
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
T line = lines.get(i); T line = lines.get(i);
@ -124,7 +126,7 @@ public class BaseHologramLines<T extends EditableHologramLine> implements Iterab
currentLineY -= Settings.spaceBetweenLines; currentLineY -= Settings.spaceBetweenLines;
} }
line.setPosition(hologram.getPositionX(), currentLineY, hologram.getPositionZ()); line.setPosition(hologramPosition.getX(), currentLineY, hologramPosition.getZ());
} }
} }

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.plugin.hologram.base; package me.filoghost.holographicdisplays.plugin.hologram.base;
import me.filoghost.fcommons.Preconditions; import me.filoghost.fcommons.Preconditions;
import me.filoghost.holographicdisplays.api.hologram.HologramPosition;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -15,18 +16,10 @@ import org.jetbrains.annotations.Nullable;
import java.util.Locale; import java.util.Locale;
public class BaseHologramPosition { public class BaseHologramPosition implements HologramPosition {
private @NotNull String worldName; private final @NotNull String worldName;
private double x, y, z; private final double x, y, z;
public BaseHologramPosition(BaseHologramPosition position) {
Preconditions.notNull(position, "position");
this.worldName = position.worldName;
this.x = position.x;
this.y = position.y;
this.z = position.z;
}
public BaseHologramPosition(@NotNull String worldName, double x, double y, double z) { public BaseHologramPosition(@NotNull String worldName, double x, double y, double z) {
Preconditions.notNull(worldName, "worldName"); Preconditions.notNull(worldName, "worldName");
@ -36,7 +29,7 @@ public class BaseHologramPosition {
this.z = z; this.z = z;
} }
public BaseHologramPosition(Location location) { public BaseHologramPosition(@NotNull Location location) {
Preconditions.notNull(location, "location"); Preconditions.notNull(location, "location");
Preconditions.notNull(location.getWorld(), "location's world"); Preconditions.notNull(location.getWorld(), "location's world");
this.worldName = location.getWorld().getName(); this.worldName = location.getWorld().getName();
@ -45,87 +38,78 @@ public class BaseHologramPosition {
this.z = location.getZ(); this.z = location.getZ();
} }
@Override
public @NotNull String getWorldName() { public @NotNull String getWorldName() {
return worldName; return worldName;
} }
public void setWorldName(@NotNull String worldName) { public boolean isInWorld(@Nullable World world) {
Preconditions.notNull(worldName, "worldName");
this.worldName = worldName;
}
public boolean isInWorld(World world) {
return world != null && isInWorld(world.getName()); return world != null && isInWorld(world.getName());
} }
public boolean isInWorld(String worldName) { public boolean isInWorld(@Nullable String worldName) {
// Use the same comparison used by Bukkit.getWorld(...) // Use the same comparison used by Bukkit.getWorld(...)
return worldName != null && worldName.toLowerCase(Locale.ENGLISH).equals(this.worldName.toLowerCase(Locale.ENGLISH)); return worldName != null && worldName.toLowerCase(Locale.ENGLISH).equals(this.worldName.toLowerCase(Locale.ENGLISH));
} }
@Override
public @Nullable World getWorldIfLoaded() { public @Nullable World getWorldIfLoaded() {
return Bukkit.getWorld(worldName); return Bukkit.getWorld(worldName);
} }
public void setWorld(@NotNull World world) { @Override
Preconditions.notNull(world, "world");
this.worldName = world.getName();
}
public double getX() { public double getX() {
return x; return x;
} }
public void setX(double x) { @Override
this.x = x;
}
public double getY() { public double getY() {
return y; return y;
} }
public void setY(double y) { @Override
this.y = y;
}
public double getZ() { public double getZ() {
return z; return z;
} }
public void setZ(double z) { @Override
this.z = z;
}
public BaseHologramPosition add(double x, double y, double z) {
this.x += x;
this.y += y;
this.z += z;
return this;
}
public void set(String worldName, double x, double y, double z) {
this.worldName = worldName;
this.x = x;
this.y = y;
this.z = z;
}
public int getBlockX() { public int getBlockX() {
return Location.locToBlock(x); return Location.locToBlock(x);
} }
@Override
public int getBlockY() { public int getBlockY() {
return Location.locToBlock(y); return Location.locToBlock(y);
} }
@Override
public int getBlockZ() { public int getBlockZ() {
return Location.locToBlock(z); return Location.locToBlock(z);
} }
@Override
public @NotNull BaseHologramPosition add(double x, double y, double z) {
return new BaseHologramPosition(this.worldName, this.x + x, this.y + y, this.z + z);
}
public @NotNull BaseHologramPosition withX(double x) {
return new BaseHologramPosition(this.worldName, x, this.y, this.z);
}
public @NotNull BaseHologramPosition withY(double y) {
return new BaseHologramPosition(this.worldName, this.x, y, this.z);
}
public @NotNull BaseHologramPosition withZ(double z) {
return new BaseHologramPosition(this.worldName, this.x, this.y, z);
}
@Override
public double distance(@NotNull Location location) { public double distance(@NotNull Location location) {
return Math.sqrt(distanceSquared(location)); return Math.sqrt(distanceSquared(location));
} }
@Override
public double distanceSquared(@NotNull Location location) { public double distanceSquared(@NotNull Location location) {
Preconditions.notNull(location, "location"); Preconditions.notNull(location, "location");
return NumberConversions.square(this.x - location.getX()) return NumberConversions.square(this.x - location.getX())
@ -133,10 +117,37 @@ public class BaseHologramPosition {
+ NumberConversions.square(this.z - location.getZ()); + NumberConversions.square(this.z - location.getZ());
} }
@Override
public @NotNull Location toLocation() { public @NotNull Location toLocation() {
return new Location(getWorldIfLoaded(), x, y, z); return new Location(getWorldIfLoaded(), x, y, z);
} }
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
BaseHologramPosition other = (BaseHologramPosition) obj;
return this.worldName.equals(other.worldName)
&& Double.doubleToLongBits(this.x) == Double.doubleToLongBits(other.x)
&& Double.doubleToLongBits(this.y) == Double.doubleToLongBits(other.y)
&& Double.doubleToLongBits(this.z) == Double.doubleToLongBits(other.z);
}
@Override
public int hashCode() {
int result = 1;
result = 31 * result + worldName.hashCode();
result = 31 * result + Double.hashCode(x);
result = 31 * result + Double.hashCode(y);
result = 31 * result + Double.hashCode(z);
return result;
}
@Override @Override
public String toString() { public String toString() {
return "HologramPosition{" return "HologramPosition{"

View File

@ -5,6 +5,7 @@
*/ */
package me.filoghost.holographicdisplays.plugin.hologram.base; package me.filoghost.holographicdisplays.plugin.hologram.base;
import me.filoghost.fcommons.Preconditions;
import me.filoghost.holographicdisplays.plugin.util.CachedBoolean; import me.filoghost.holographicdisplays.plugin.util.CachedBoolean;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -15,25 +16,26 @@ import org.jetbrains.annotations.Nullable;
class WorldAwareHologramPosition { class WorldAwareHologramPosition {
private final BaseHologramPosition basePosition; private @NotNull BaseHologramPosition position;
private @Nullable World world; private @Nullable World world;
private int chunkX, chunkZ; private int chunkX, chunkZ;
private final CachedBoolean chunkLoaded; private final CachedBoolean chunkLoaded;
WorldAwareHologramPosition(BaseHologramPosition basePosition) { WorldAwareHologramPosition(@NotNull BaseHologramPosition position) {
this.basePosition = new BaseHologramPosition(basePosition); Preconditions.notNull(position, "position");
this.world = Bukkit.getWorld(basePosition.getWorldName()); this.position = position;
this.chunkX = getChunkCoordinate(basePosition.getX()); this.world = Bukkit.getWorld(position.getWorldName());
this.chunkZ = getChunkCoordinate(basePosition.getZ()); this.chunkX = getChunkCoordinate(position.getX());
this.chunkZ = getChunkCoordinate(position.getZ());
this.chunkLoaded = new CachedBoolean(() -> world != null && world.isChunkLoaded(chunkX, chunkZ)); this.chunkLoaded = new CachedBoolean(() -> world != null && world.isChunkLoaded(chunkX, chunkZ));
} }
final void set(String worldName, double x, double y, double z) { final void set(String worldName, double x, double y, double z) {
boolean worldChanged = !basePosition.isInWorld(worldName); boolean worldChanged = !position.isInWorld(worldName);
int chunkX = getChunkCoordinate(x); int chunkX = getChunkCoordinate(x);
int chunkZ = getChunkCoordinate(z); int chunkZ = getChunkCoordinate(z);
basePosition.set(worldName, x, y, z); position = new BaseHologramPosition(worldName, x, y, z);
if (worldChanged || this.chunkX != chunkX || this.chunkZ != chunkZ) { if (worldChanged || this.chunkX != chunkX || this.chunkZ != chunkZ) {
if (worldChanged) { if (worldChanged) {
@ -50,14 +52,14 @@ class WorldAwareHologramPosition {
} }
void onWorldLoad(World world) { void onWorldLoad(World world) {
if (basePosition.isInWorld(world)) { if (position.isInWorld(world)) {
this.world = world; this.world = world;
chunkLoaded.invalidate(); chunkLoaded.invalidate();
} }
} }
void onWorldUnload(World world) { void onWorldUnload(World world) {
if (basePosition.isInWorld(world)) { if (position.isInWorld(world)) {
this.world = null; this.world = null;
chunkLoaded.set(false); chunkLoaded.set(false);
} }
@ -83,29 +85,13 @@ class WorldAwareHologramPosition {
return world; return world;
} }
@NotNull String getWorldName() { @NotNull BaseHologramPosition getPosition() {
return basePosition.getWorldName(); return position;
}
double getX() {
return basePosition.getX();
}
double getY() {
return basePosition.getY();
}
double getZ() {
return basePosition.getZ();
}
BaseHologramPosition toBasePosition() {
return new BaseHologramPosition(basePosition);
} }
@Override @Override
public String toString() { public String toString() {
return basePosition.toString(); return position.toString();
} }
} }