mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-01-30 03:31:32 +01:00
Use Position instead of ImmutablePosition where possible
This commit is contained in:
parent
525622b59a
commit
d35648b4e4
@ -10,8 +10,8 @@ import me.filoghost.fcommons.FeatureSupport;
|
||||
import me.filoghost.fcommons.logging.ErrorCollector;
|
||||
import me.filoghost.fcommons.logging.Log;
|
||||
import me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.core.HolographicDisplaysCore;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.bridge.bungeecord.BungeeServerTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.bridge.placeholderapi.PlaceholderAPIHook;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.HologramCommandManager;
|
||||
@ -137,7 +137,7 @@ public class HolographicDisplays extends FCommonsPlugin {
|
||||
for (InternalHologramConfig hologramConfig : hologramConfigs) {
|
||||
try {
|
||||
List<InternalHologramLine> lines = hologramConfig.deserializeLines();
|
||||
ImmutablePosition position = hologramConfig.deserializePosition();
|
||||
Position position = hologramConfig.deserializePosition();
|
||||
InternalHologram hologram = internalHologramManager.createHologram(hologramConfig.getName(), position);
|
||||
hologram.addLines(lines);
|
||||
} catch (InternalHologramLoadException e) {
|
||||
|
@ -8,11 +8,11 @@ package me.filoghost.holographicdisplays.plugin.commands;
|
||||
import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.command.validation.CommandException;
|
||||
import me.filoghost.fcommons.command.validation.CommandValidate;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.plugin.config.ConfigManager;
|
||||
import me.filoghost.holographicdisplays.plugin.config.InternalHologramLineParser;
|
||||
import me.filoghost.holographicdisplays.plugin.config.InternalHologramLoadException;
|
||||
import me.filoghost.holographicdisplays.plugin.event.InternalHologramChangeEvent.ChangeType;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologramLine;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologramManager;
|
||||
@ -71,7 +71,7 @@ public class InternalHologramEditor {
|
||||
return internalHologramManager.getHolograms();
|
||||
}
|
||||
|
||||
public InternalHologram create(String hologramName, ImmutablePosition spawnPosition) {
|
||||
public InternalHologram create(String hologramName, Position spawnPosition) {
|
||||
return internalHologramManager.createHologram(hologramName, spawnPosition);
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,11 @@ package me.filoghost.holographicdisplays.plugin.commands.subs;
|
||||
import me.filoghost.fcommons.command.sub.SubCommandContext;
|
||||
import me.filoghost.fcommons.command.validation.CommandException;
|
||||
import me.filoghost.fcommons.command.validation.CommandValidate;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor;
|
||||
import me.filoghost.holographicdisplays.plugin.event.InternalHologramChangeEvent.ChangeType;
|
||||
import me.filoghost.holographicdisplays.plugin.format.ColorScheme;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -36,19 +36,19 @@ public class AlignCommand extends HologramSubCommand {
|
||||
|
||||
CommandValidate.check(hologram != referenceHologram, "The holograms must not be the same.");
|
||||
|
||||
ImmutablePosition referencePosition = referenceHologram.getPosition();
|
||||
ImmutablePosition newPosition = hologram.getPosition();
|
||||
Position referencePosition = referenceHologram.getPosition();
|
||||
Position oldPosition = hologram.getPosition();
|
||||
Position newPosition;
|
||||
|
||||
String axis = args[0];
|
||||
if (axis.equalsIgnoreCase("x")) {
|
||||
newPosition = newPosition.withX(referencePosition.getX());
|
||||
newPosition = Position.of(oldPosition.getWorldName(), referencePosition.getX(), oldPosition.getY(), oldPosition.getZ());
|
||||
} else if (axis.equalsIgnoreCase("y")) {
|
||||
newPosition = newPosition.withY(referencePosition.getY());
|
||||
newPosition = Position.of(oldPosition.getWorldName(), oldPosition.getX(), referencePosition.getY(), oldPosition.getZ());
|
||||
} else if (axis.equalsIgnoreCase("z")) {
|
||||
newPosition = newPosition.withZ(referencePosition.getZ());
|
||||
newPosition = Position.of(oldPosition.getWorldName(), oldPosition.getX(), oldPosition.getY(), referencePosition.getZ());
|
||||
} else if (axis.equalsIgnoreCase("xz")) {
|
||||
newPosition = newPosition.withX(referencePosition.getX());
|
||||
newPosition = newPosition.withZ(referencePosition.getZ());
|
||||
newPosition = Position.of(oldPosition.getWorldName(), referencePosition.getX(), oldPosition.getY(), referencePosition.getZ());
|
||||
} else {
|
||||
throw new CommandException("You must specify either X, Y, Z or XZ, " + axis + " is not a valid axis.");
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import me.filoghost.fcommons.Strings;
|
||||
import me.filoghost.fcommons.command.sub.SubCommandContext;
|
||||
import me.filoghost.fcommons.command.validation.CommandException;
|
||||
import me.filoghost.fcommons.command.validation.CommandValidate;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologramLine;
|
||||
import me.filoghost.holographicdisplays.plugin.event.InternalHologramChangeEvent.ChangeType;
|
||||
import me.filoghost.holographicdisplays.plugin.format.ColorScheme;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologramLine;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -46,7 +46,7 @@ public class CreateCommand extends HologramSubCommand {
|
||||
"The name must contain only alphanumeric characters, underscores and hyphens.");
|
||||
CommandValidate.check(!hologramEditor.hologramExists(hologramName), "A hologram with that name already exists.");
|
||||
|
||||
ImmutablePosition spawnPosition = ImmutablePosition.of(player.getLocation());
|
||||
Position spawnPosition = Position.of(player);
|
||||
boolean moveUp = player.isOnGround();
|
||||
|
||||
if (moveUp) {
|
||||
|
@ -8,11 +8,11 @@ package me.filoghost.holographicdisplays.plugin.commands.subs;
|
||||
import me.filoghost.fcommons.command.sub.SubCommandContext;
|
||||
import me.filoghost.fcommons.command.validation.CommandException;
|
||||
import me.filoghost.fcommons.command.validation.CommandValidate;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor;
|
||||
import me.filoghost.holographicdisplays.plugin.event.InternalHologramChangeEvent.ChangeType;
|
||||
import me.filoghost.holographicdisplays.plugin.format.ColorScheme;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -35,7 +35,7 @@ public class MoveHereCommand extends HologramSubCommand {
|
||||
Player player = CommandValidate.getPlayerSender(sender);
|
||||
InternalHologram hologram = hologramEditor.getExistingHologram(args[0]);
|
||||
|
||||
hologram.setPosition(ImmutablePosition.of(player.getLocation()));
|
||||
hologram.setPosition(Position.of(player));
|
||||
hologramEditor.saveChanges(hologram, ChangeType.EDIT_POSITION);
|
||||
|
||||
hologramEditor.teleportLookingDown(player, player.getLocation());
|
||||
|
@ -8,10 +8,10 @@ package me.filoghost.holographicdisplays.plugin.commands.subs;
|
||||
import me.filoghost.fcommons.command.sub.SubCommandContext;
|
||||
import me.filoghost.fcommons.command.validation.CommandException;
|
||||
import me.filoghost.fcommons.command.validation.CommandValidate;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.HologramSubCommand;
|
||||
import me.filoghost.holographicdisplays.plugin.commands.InternalHologramEditor;
|
||||
import me.filoghost.holographicdisplays.plugin.format.DisplayFormat;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -41,7 +41,7 @@ public class NearCommand extends HologramSubCommand {
|
||||
List<InternalHologram> nearHolograms = new ArrayList<>();
|
||||
|
||||
for (InternalHologram hologram : hologramEditor.getHolograms()) {
|
||||
ImmutablePosition position = hologram.getPosition();
|
||||
Position position = hologram.getPosition();
|
||||
if (position.isInSameWorld(player) && position.distance(player) <= radius) {
|
||||
nearHolograms.add(hologram);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import me.filoghost.fcommons.collection.CollectionUtils;
|
||||
import me.filoghost.fcommons.config.ConfigSection;
|
||||
import me.filoghost.fcommons.config.exception.ConfigValueException;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologramLine;
|
||||
|
||||
@ -77,7 +76,7 @@ public class InternalHologramConfig {
|
||||
return positionConfigSection;
|
||||
}
|
||||
|
||||
public ImmutablePosition deserializePosition() throws InternalHologramLoadException {
|
||||
public Position deserializePosition() throws InternalHologramLoadException {
|
||||
ConfigSection positionConfigSection = configSection.getConfigSection("position");
|
||||
|
||||
if (positionConfigSection == null) {
|
||||
@ -89,7 +88,7 @@ public class InternalHologramConfig {
|
||||
double x = positionConfigSection.getRequiredDouble("x");
|
||||
double y = positionConfigSection.getRequiredDouble("y");
|
||||
double z = positionConfigSection.getRequiredDouble("z");
|
||||
return new ImmutablePosition(worldName, x, y, z);
|
||||
return Position.of(worldName, x, y, z);
|
||||
} catch (ConfigValueException e) {
|
||||
throw new InternalHologramLoadException("invalid position attribute \"" + e.getConfigPath() + "\"", e);
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
package me.filoghost.holographicdisplays.plugin.format;
|
||||
|
||||
import me.filoghost.fcommons.Colors;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.plugin.config.StaticReplacements;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.plugin.internal.hologram.InternalHologram;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -93,7 +93,7 @@ public class DisplayFormat {
|
||||
}
|
||||
|
||||
public static void sendHologramSummary(CommandSender sender, InternalHologram hologram, boolean showWorld) {
|
||||
ImmutablePosition position = hologram.getPosition();
|
||||
Position position = hologram.getPosition();
|
||||
sender.sendMessage(ColorScheme.SECONDARY_DARK + "- " + ColorScheme.SECONDARY_BOLD + hologram.getName()
|
||||
+ ColorScheme.SECONDARY_DARK + " (" + hologram.getLines().size() + " lines) at "
|
||||
+ (showWorld ? "world: \"" + position.getWorldName() + "\", " : "")
|
||||
|
@ -6,11 +6,11 @@
|
||||
package me.filoghost.holographicdisplays.plugin.internal.hologram;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import me.filoghost.holographicdisplays.api.beta.hologram.Hologram;
|
||||
import me.filoghost.holographicdisplays.api.beta.hologram.PlaceholderSetting;
|
||||
import me.filoghost.holographicdisplays.plugin.event.InternalHologramChangeEvent;
|
||||
import me.filoghost.holographicdisplays.plugin.event.InternalHologramChangeEvent.ChangeType;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -21,12 +21,12 @@ public class InternalHologram {
|
||||
|
||||
private final Hologram renderedHologram;
|
||||
private final String name;
|
||||
private ImmutablePosition position;
|
||||
private Position position;
|
||||
private final List<InternalHologramLine> lines;
|
||||
private final List<InternalHologramLine> unmodifiableLinesView;
|
||||
private boolean deleted;
|
||||
|
||||
public InternalHologram(HolographicDisplaysAPI api, String name, ImmutablePosition position) {
|
||||
public InternalHologram(HolographicDisplaysAPI api, String name, Position position) {
|
||||
this.renderedHologram = api.createHologram(position);
|
||||
this.renderedHologram.setPlaceholderSetting(PlaceholderSetting.ENABLE_ALL);
|
||||
this.name = name;
|
||||
@ -43,11 +43,11 @@ public class InternalHologram {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ImmutablePosition getPosition() {
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(ImmutablePosition position) {
|
||||
public void setPosition(Position position) {
|
||||
checkNotDeleted();
|
||||
this.position = position;
|
||||
updateRendering();
|
||||
|
@ -6,7 +6,7 @@
|
||||
package me.filoghost.holographicdisplays.plugin.internal.hologram;
|
||||
|
||||
import me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.core.base.ImmutablePosition;
|
||||
import me.filoghost.holographicdisplays.api.beta.Position;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -32,7 +32,7 @@ public class InternalHologramManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public InternalHologram createHologram(String name, ImmutablePosition position) {
|
||||
public InternalHologram createHologram(String name, Position position) {
|
||||
if (getHologramByName(name) != null) {
|
||||
throw new IllegalStateException("hologram named \"" + name + "\" already exists");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user