mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-19 23:37:33 +01:00
Remove unnecessary classes
This commit is contained in:
parent
f470dddc40
commit
8cac729a82
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) filoghost and contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
package me.filoghost.holographicdisplays.common.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface StandardHologram extends StandardHologramComponent {
|
|
||||||
|
|
||||||
List<? extends StandardHologramLine> getLines();
|
|
||||||
|
|
||||||
int getLineCount();
|
|
||||||
|
|
||||||
Plugin getCreatorPlugin();
|
|
||||||
|
|
||||||
boolean isVisibleTo(Player player);
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) filoghost and contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
package me.filoghost.holographicdisplays.common.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
public interface StandardHologramComponent {
|
|
||||||
|
|
||||||
World getWorld();
|
|
||||||
|
|
||||||
double getX();
|
|
||||||
|
|
||||||
double getY();
|
|
||||||
|
|
||||||
double getZ();
|
|
||||||
|
|
||||||
int getChunkX();
|
|
||||||
|
|
||||||
int getChunkZ();
|
|
||||||
|
|
||||||
boolean isDeleted();
|
|
||||||
|
|
||||||
void setDeleted();
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) filoghost and contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
package me.filoghost.holographicdisplays.common.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface StandardHologramLine extends StandardHologramComponent {
|
|
||||||
|
|
||||||
void setLocation(World world, double x, double y, double z);
|
|
||||||
|
|
||||||
double getHeight();
|
|
||||||
|
|
||||||
void setChanged();
|
|
||||||
|
|
||||||
boolean isVisibleTo(Player player);
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) filoghost and contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
package me.filoghost.holographicdisplays.common.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public interface StandardItemLine extends StandardTouchableLine {
|
|
||||||
|
|
||||||
ItemStack getItemStack();
|
|
||||||
|
|
||||||
void onPickup(Player player);
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) filoghost and contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
package me.filoghost.holographicdisplays.common.hologram;
|
|
||||||
|
|
||||||
public interface StandardTextLine extends StandardTouchableLine {
|
|
||||||
|
|
||||||
String getText();
|
|
||||||
|
|
||||||
boolean isAllowPlaceholders();
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) filoghost and contributors
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
package me.filoghost.holographicdisplays.common.hologram;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface StandardTouchableLine extends StandardHologramLine {
|
|
||||||
|
|
||||||
void onTouch(Player player);
|
|
||||||
|
|
||||||
boolean hasTouchHandler();
|
|
||||||
|
|
||||||
}
|
|
@ -6,15 +6,17 @@
|
|||||||
package me.filoghost.holographicdisplays.plugin.hologram.api;
|
package me.filoghost.holographicdisplays.plugin.hologram.api;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.api.hologram.HologramLine;
|
import me.filoghost.holographicdisplays.api.hologram.HologramLine;
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
|
import me.filoghost.holographicdisplays.plugin.hologram.base.EditableHologramLine;
|
||||||
import me.filoghost.holographicdisplays.plugin.api.v2.V2HologramLineAdapter;
|
import me.filoghost.holographicdisplays.plugin.api.v2.V2HologramLineAdapter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface APIHologramLine extends HologramLine, StandardHologramLine {
|
public interface APIHologramLine extends HologramLine, EditableHologramLine {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull APIHologram getParent();
|
@NotNull APIHologram getParent();
|
||||||
|
|
||||||
|
void setChanged();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void removeLine() {
|
default void removeLine() {
|
||||||
getParent().removeLine(this);
|
getParent().removeLine(this);
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
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.common.hologram.StandardHologram;
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
|
|
||||||
import me.filoghost.holographicdisplays.plugin.disk.Settings;
|
import me.filoghost.holographicdisplays.plugin.disk.Settings;
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -19,7 +19,7 @@ import java.util.Collections;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class BaseHologram<T extends StandardHologramLine> extends BaseHologramComponent implements StandardHologram {
|
public abstract class BaseHologram<T extends EditableHologramLine> extends BaseHologramComponent {
|
||||||
|
|
||||||
private final LineTrackerManager lineTrackerManager;
|
private final LineTrackerManager lineTrackerManager;
|
||||||
private final List<T> lines;
|
private final List<T> lines;
|
||||||
@ -33,11 +33,14 @@ public abstract class BaseHologram<T extends StandardHologramLine> extends BaseH
|
|||||||
this.unmodifiableLinesView = Collections.unmodifiableList(lines);
|
this.unmodifiableLinesView = Collections.unmodifiableList(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract boolean isVisibleTo(Player player);
|
||||||
|
|
||||||
|
public abstract Plugin getCreatorPlugin();
|
||||||
|
|
||||||
protected final LineTrackerManager getTrackerManager() {
|
protected final LineTrackerManager getTrackerManager() {
|
||||||
return lineTrackerManager;
|
return lineTrackerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> getLines() {
|
public List<T> getLines() {
|
||||||
return unmodifiableLinesView;
|
return unmodifiableLinesView;
|
||||||
}
|
}
|
||||||
@ -115,7 +118,6 @@ public abstract class BaseHologram<T extends StandardHologramLine> extends BaseH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLineCount() {
|
public int getLineCount() {
|
||||||
return lines.size();
|
return lines.size();
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,12 @@
|
|||||||
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.common.hologram.StandardHologramComponent;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class BaseHologramComponent implements StandardHologramComponent {
|
public abstract class BaseHologramComponent {
|
||||||
|
|
||||||
private World world;
|
private World world;
|
||||||
private double x, y, z;
|
private double x, y, z;
|
||||||
@ -43,43 +42,35 @@ public abstract class BaseHologramComponent implements StandardHologramComponent
|
|||||||
return Location.locToBlock(locationCoord) >> 4;
|
return Location.locToBlock(locationCoord) >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final World getWorld() {
|
public final World getWorld() {
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final double getX() {
|
public final double getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final double getY() {
|
public final double getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final double getZ() {
|
public final double getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final int getChunkX() {
|
public final int getChunkX() {
|
||||||
return chunkX;
|
return chunkX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final int getChunkZ() {
|
public final int getChunkZ() {
|
||||||
return chunkZ;
|
return chunkZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final boolean isDeleted() {
|
public final boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@MustBeInvokedByOverriders
|
@MustBeInvokedByOverriders
|
||||||
@Override
|
|
||||||
public void setDeleted() {
|
public void setDeleted() {
|
||||||
deleted = true;
|
deleted = true;
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,13 @@
|
|||||||
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.common.hologram.StandardHologram;
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
|
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTracker;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTracker;
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public abstract class BaseHologramLine extends BaseHologramComponent implements StandardHologramLine {
|
public abstract class BaseHologramLine extends BaseHologramComponent implements EditableHologramLine {
|
||||||
|
|
||||||
private final BaseHologram<?> hologram;
|
private final BaseHologram<?> hologram;
|
||||||
private final LineTracker<?> tracker;
|
private final LineTracker<?> tracker;
|
||||||
@ -26,11 +25,6 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
|
|||||||
|
|
||||||
protected abstract LineTracker<?> createTracker(LineTrackerManager trackerManager);
|
protected abstract LineTracker<?> createTracker(LineTrackerManager trackerManager);
|
||||||
|
|
||||||
protected final StandardHologram getHologram() {
|
|
||||||
return hologram;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void setChanged() {
|
public final void setChanged() {
|
||||||
tracker.setLineChanged();
|
tracker.setLineChanged();
|
||||||
}
|
}
|
||||||
@ -45,9 +39,12 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
|
|||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public final boolean isVisibleTo(Player player) {
|
||||||
public boolean isVisibleTo(Player player) {
|
|
||||||
return hologram.isVisibleTo(player);
|
return hologram.isVisibleTo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Plugin getCreatorPlugin() {
|
||||||
|
return hologram.getCreatorPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,12 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.base;
|
package me.filoghost.holographicdisplays.plugin.hologram.base;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologram;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class BaseHologramManager<H extends StandardHologram> {
|
public abstract class BaseHologramManager<H extends BaseHologram<?>> {
|
||||||
|
|
||||||
private final List<H> holograms = new ArrayList<>();
|
private final List<H> holograms = new ArrayList<>();
|
||||||
private final List<H> unmodifiableHologramsView = Collections.unmodifiableList(holograms);
|
private final List<H> unmodifiableHologramsView = Collections.unmodifiableList(holograms);
|
||||||
|
@ -8,7 +8,6 @@ package me.filoghost.holographicdisplays.plugin.hologram.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.hologram.PickupHandler;
|
import me.filoghost.holographicdisplays.api.hologram.PickupHandler;
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardItemLine;
|
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.ItemLineTracker;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.ItemLineTracker;
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -17,7 +16,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public abstract class BaseItemLine extends BaseTouchableLine implements StandardItemLine {
|
public abstract class BaseItemLine extends BaseTouchableLine {
|
||||||
|
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
private PickupHandler pickupHandler;
|
private PickupHandler pickupHandler;
|
||||||
@ -32,7 +31,6 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard
|
|||||||
return trackerManager.startTracking(this);
|
return trackerManager.startTracking(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPickup(Player player) {
|
public void onPickup(Player player) {
|
||||||
if (isDeleted()
|
if (isDeleted()
|
||||||
|| !player.isOnline()
|
|| !player.isOnline()
|
||||||
@ -46,7 +44,7 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard
|
|||||||
try {
|
try {
|
||||||
pickupHandler.onPickup(player);
|
pickupHandler.onPickup(player);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.warning("The plugin " + getHologram().getCreatorPlugin().getName() + " generated an exception"
|
Log.warning("The plugin " + getCreatorPlugin().getName() + " generated an exception"
|
||||||
+ " when the player " + player.getName() + " picked up an item from a hologram.", t);
|
+ " when the player " + player.getName() + " picked up an item from a hologram.", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +58,6 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard
|
|||||||
this.pickupHandler = pickupHandler;
|
this.pickupHandler = pickupHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable ItemStack getItemStack() {
|
public @Nullable ItemStack getItemStack() {
|
||||||
return clone(itemStack);
|
return clone(itemStack);
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.base;
|
package me.filoghost.holographicdisplays.plugin.hologram.base;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardTextLine;
|
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.TextLineTracker;
|
import me.filoghost.holographicdisplays.plugin.hologram.tracking.TextLineTracker;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public abstract class BaseTextLine extends BaseTouchableLine implements StandardTextLine {
|
public abstract class BaseTextLine extends BaseTouchableLine {
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
@ -19,12 +18,13 @@ public abstract class BaseTextLine extends BaseTouchableLine implements Standard
|
|||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract boolean isAllowPlaceholders();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TextLineTracker createTracker(LineTrackerManager trackerManager) {
|
protected TextLineTracker createTracker(LineTrackerManager trackerManager) {
|
||||||
return trackerManager.startTracking(this);
|
return trackerManager.startTracking(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable String getText() {
|
public @Nullable String getText() {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ package me.filoghost.holographicdisplays.plugin.hologram.base;
|
|||||||
|
|
||||||
import me.filoghost.fcommons.logging.Log;
|
import me.filoghost.fcommons.logging.Log;
|
||||||
import me.filoghost.holographicdisplays.api.hologram.TouchHandler;
|
import me.filoghost.holographicdisplays.api.hologram.TouchHandler;
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardTouchableLine;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
@ -20,7 +19,7 @@ import java.util.WeakHashMap;
|
|||||||
* Useful class that implements StandardTouchableLine. The downside is that subclasses must extend this, and cannot extend other classes.
|
* Useful class that implements StandardTouchableLine. The downside is that subclasses must extend this, and cannot extend other classes.
|
||||||
* But all the current items are touchable.
|
* But all the current items are touchable.
|
||||||
*/
|
*/
|
||||||
public abstract class BaseTouchableLine extends BaseHologramLine implements StandardTouchableLine {
|
public abstract class BaseTouchableLine extends BaseHologramLine {
|
||||||
|
|
||||||
private static final Map<Player, Long> lastClickByPlayer = new WeakHashMap<>();
|
private static final Map<Player, Long> lastClickByPlayer = new WeakHashMap<>();
|
||||||
|
|
||||||
@ -30,7 +29,6 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
|
|||||||
super(hologram);
|
super(hologram);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTouch(Player player) {
|
public void onTouch(Player player) {
|
||||||
if (isDeleted()
|
if (isDeleted()
|
||||||
|| !player.isOnline()
|
|| !player.isOnline()
|
||||||
@ -52,14 +50,13 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
|
|||||||
try {
|
try {
|
||||||
touchHandler.onTouch(player);
|
touchHandler.onTouch(player);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.warning("The plugin " + getHologram().getCreatorPlugin().getName() + " generated an exception"
|
Log.warning("The plugin " + getCreatorPlugin().getName() + " generated an exception"
|
||||||
+ " when the player " + player.getName() + " touched a hologram.", t);
|
+ " when the player " + player.getName() + " touched a hologram.", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @Nullable TouchHandler getTouchHandler() {
|
||||||
public boolean hasTouchHandler() {
|
return touchHandler;
|
||||||
return touchHandler != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MustBeInvokedByOverriders
|
@MustBeInvokedByOverriders
|
||||||
@ -68,8 +65,4 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
|
|||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable TouchHandler getTouchHandler() {
|
|
||||||
return touchHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) filoghost and contributors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
package me.filoghost.holographicdisplays.plugin.hologram.base;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public interface EditableHologramLine {
|
||||||
|
|
||||||
|
void setLocation(World world, double x, double y, double z);
|
||||||
|
|
||||||
|
double getHeight();
|
||||||
|
|
||||||
|
void setDeleted();
|
||||||
|
|
||||||
|
}
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.internal;
|
package me.filoghost.holographicdisplays.plugin.hologram.internal;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
|
import me.filoghost.holographicdisplays.plugin.hologram.base.EditableHologramLine;
|
||||||
|
|
||||||
public interface InternalHologramLine extends StandardHologramLine {
|
public interface InternalHologramLine extends EditableHologramLine {
|
||||||
|
|
||||||
String getSerializedConfigValue();
|
String getSerializedConfigValue();
|
||||||
|
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardItemLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseItemLine;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ItemLineTracker extends TouchableLineTracker<StandardItemLine> {
|
public class ItemLineTracker extends TouchableLineTracker<BaseItemLine> {
|
||||||
|
|
||||||
private final EntityID vehicleEntityID;
|
private final EntityID vehicleEntityID;
|
||||||
private final EntityID itemEntityID;
|
private final EntityID itemEntityID;
|
||||||
@ -25,7 +25,7 @@ public class ItemLineTracker extends TouchableLineTracker<StandardItemLine> {
|
|||||||
private boolean spawnItemEntities;
|
private boolean spawnItemEntities;
|
||||||
private boolean spawnItemEntitiesChanged;
|
private boolean spawnItemEntitiesChanged;
|
||||||
|
|
||||||
public ItemLineTracker(StandardItemLine line, NMSManager nmsManager, LineTouchListener lineTouchListener) {
|
public ItemLineTracker(BaseItemLine line, NMSManager nmsManager, LineTouchListener lineTouchListener) {
|
||||||
super(line, nmsManager, lineTouchListener);
|
super(line, nmsManager, lineTouchListener);
|
||||||
this.vehicleEntityID = nmsManager.newEntityID();
|
this.vehicleEntityID = nmsManager.newEntityID();
|
||||||
this.itemEntityID = nmsManager.newEntityID();
|
this.itemEntityID = nmsManager.newEntityID();
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardTouchableLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||||
import me.filoghost.holographicdisplays.common.nms.PacketListener;
|
import me.filoghost.holographicdisplays.common.nms.PacketListener;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTouchableLine;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
public class LineTouchListener implements PacketListener {
|
public class LineTouchListener implements PacketListener {
|
||||||
|
|
||||||
private final ConcurrentMap<Integer, StandardTouchableLine> linesByEntityID;
|
private final ConcurrentMap<Integer, BaseTouchableLine> linesByEntityID;
|
||||||
|
|
||||||
// It is necessary to queue async touch events to process them from the main thread.
|
// It is necessary to queue async touch events to process them from the main thread.
|
||||||
// Use a set to avoid duplicate touch events to the same line.
|
// Use a set to avoid duplicate touch events to the same line.
|
||||||
@ -30,7 +30,7 @@ public class LineTouchListener implements PacketListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onAsyncEntityInteract(Player player, int entityID) {
|
public boolean onAsyncEntityInteract(Player player, int entityID) {
|
||||||
StandardTouchableLine line = linesByEntityID.get(entityID);
|
BaseTouchableLine line = linesByEntityID.get(entityID);
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
queuedTouchEvents.add(new TouchEvent(player, line));
|
queuedTouchEvents.add(new TouchEvent(player, line));
|
||||||
return true;
|
return true;
|
||||||
@ -46,7 +46,7 @@ public class LineTouchListener implements PacketListener {
|
|||||||
queuedTouchEvents.clear();
|
queuedTouchEvents.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerLine(EntityID touchableEntityID, StandardTouchableLine line) {
|
public void registerLine(EntityID touchableEntityID, BaseTouchableLine line) {
|
||||||
linesByEntityID.put(touchableEntityID.getNumericID(), line);
|
linesByEntityID.put(touchableEntityID.getNumericID(), line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ public class LineTouchListener implements PacketListener {
|
|||||||
private static class TouchEvent {
|
private static class TouchEvent {
|
||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final StandardTouchableLine line;
|
private final BaseTouchableLine line;
|
||||||
|
|
||||||
TouchEvent(Player player, StandardTouchableLine line) {
|
TouchEvent(Player player, BaseTouchableLine line) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.line = line;
|
this.line = line;
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramLine;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
@ -16,7 +16,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public abstract class LineTracker<T extends StandardHologramLine> {
|
public abstract class LineTracker<T extends BaseHologramLine> {
|
||||||
|
|
||||||
protected final T line;
|
protected final T line;
|
||||||
private final Set<Player> trackedPlayers;
|
private final Set<Player> trackedPlayers;
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardItemLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardTextLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseItemLine;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTextLine;
|
||||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -31,13 +31,13 @@ public class LineTrackerManager {
|
|||||||
this.lineTrackers = new LinkedList<>();
|
this.lineTrackers = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextLineTracker startTracking(StandardTextLine line) {
|
public TextLineTracker startTracking(BaseTextLine line) {
|
||||||
TextLineTracker tracker = new TextLineTracker(line, nmsManager, lineTouchListener, placeholderTracker);
|
TextLineTracker tracker = new TextLineTracker(line, nmsManager, lineTouchListener, placeholderTracker);
|
||||||
lineTrackers.add(tracker);
|
lineTrackers.add(tracker);
|
||||||
return tracker;
|
return tracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemLineTracker startTracking(StandardItemLine line) {
|
public ItemLineTracker startTracking(BaseItemLine line) {
|
||||||
ItemLineTracker tracker = new ItemLineTracker(line, nmsManager, lineTouchListener);
|
ItemLineTracker tracker = new ItemLineTracker(line, nmsManager, lineTouchListener);
|
||||||
lineTrackers.add(tracker);
|
lineTrackers.add(tracker);
|
||||||
return tracker;
|
return tracker;
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardHologramLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseHologramLine;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
|
|
||||||
abstract class LocationBasedLineTracker<T extends StandardHologramLine> extends LineTracker<T> {
|
abstract class LocationBasedLineTracker<T extends BaseHologramLine> extends LineTracker<T> {
|
||||||
|
|
||||||
private static final int ENTITY_VIEW_RANGE = 64;
|
private static final int ENTITY_VIEW_RANGE = 64;
|
||||||
|
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardTextLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTextLine;
|
||||||
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
import me.filoghost.holographicdisplays.plugin.placeholder.tracking.PlaceholderTracker;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class TextLineTracker extends TouchableLineTracker<StandardTextLine> {
|
public class TextLineTracker extends TouchableLineTracker<BaseTextLine> {
|
||||||
|
|
||||||
private final EntityID armorStandEntityID;
|
private final EntityID armorStandEntityID;
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ public class TextLineTracker extends TouchableLineTracker<StandardTextLine> {
|
|||||||
private boolean allowPlaceholders;
|
private boolean allowPlaceholders;
|
||||||
|
|
||||||
public TextLineTracker(
|
public TextLineTracker(
|
||||||
StandardTextLine line,
|
BaseTextLine line,
|
||||||
NMSManager nmsManager,
|
NMSManager nmsManager,
|
||||||
LineTouchListener lineTouchListener,
|
LineTouchListener lineTouchListener,
|
||||||
PlaceholderTracker placeholderTracker) {
|
PlaceholderTracker placeholderTracker) {
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
|
||||||
|
|
||||||
import me.filoghost.holographicdisplays.common.hologram.StandardTouchableLine;
|
|
||||||
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
import me.filoghost.holographicdisplays.common.nms.EntityID;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
import me.filoghost.holographicdisplays.common.nms.NMSManager;
|
||||||
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
import me.filoghost.holographicdisplays.common.nms.NMSPacketList;
|
||||||
|
import me.filoghost.holographicdisplays.plugin.hologram.base.BaseTouchableLine;
|
||||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||||
|
|
||||||
public abstract class TouchableLineTracker<T extends StandardTouchableLine> extends LocationBasedLineTracker<T> {
|
public abstract class TouchableLineTracker<T extends BaseTouchableLine> extends LocationBasedLineTracker<T> {
|
||||||
|
|
||||||
private static final double SLIME_HEIGHT = 0.5;
|
private static final double SLIME_HEIGHT = 0.5;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public abstract class TouchableLineTracker<T extends StandardTouchableLine> exte
|
|||||||
protected void detectChanges() {
|
protected void detectChanges() {
|
||||||
super.detectChanges();
|
super.detectChanges();
|
||||||
|
|
||||||
boolean spawnSlimeEntities = line.hasTouchHandler();
|
boolean spawnSlimeEntities = line.getTouchHandler() != null;
|
||||||
if (this.spawnSlimeEntities != spawnSlimeEntities) {
|
if (this.spawnSlimeEntities != spawnSlimeEntities) {
|
||||||
this.spawnSlimeEntities = spawnSlimeEntities;
|
this.spawnSlimeEntities = spawnSlimeEntities;
|
||||||
this.spawnSlimeEntitiesChanged = true;
|
this.spawnSlimeEntitiesChanged = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user