mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-01-20 06:41:20 +01:00
Refactoring
This commit is contained in:
parent
1d44491457
commit
825b0f2b2e
@ -8,6 +8,7 @@ package me.filoghost.holographicdisplays.plugin.hologram.base;
|
||||
import me.filoghost.fcommons.Preconditions;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -47,4 +48,12 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements
|
||||
return hologram.getCreatorPlugin();
|
||||
}
|
||||
|
||||
protected boolean canInteract(Player player) {
|
||||
return !isDeleted()
|
||||
&& player.isOnline()
|
||||
&& player.getGameMode() != GameMode.SPECTATOR
|
||||
&& isTrackedPlayer(player)
|
||||
&& isVisibleTo(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import me.filoghost.fcommons.logging.Log;
|
||||
import me.filoghost.holographicdisplays.api.hologram.PickupHandler;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.ItemLineTracker;
|
||||
import me.filoghost.holographicdisplays.plugin.hologram.tracking.LineTrackerManager;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||
@ -32,12 +31,7 @@ public abstract class BaseItemLine extends BaseTouchableLine {
|
||||
}
|
||||
|
||||
public void onPickup(Player player) {
|
||||
if (isDeleted()
|
||||
|| !player.isOnline()
|
||||
|| !isTrackedPlayer(player)
|
||||
|| player.getGameMode() == GameMode.SPECTATOR
|
||||
|| pickupHandler == null
|
||||
|| !isVisibleTo(player)) {
|
||||
if (pickupHandler == null || !canInteract(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ package me.filoghost.holographicdisplays.plugin.hologram.base;
|
||||
|
||||
import me.filoghost.fcommons.logging.Log;
|
||||
import me.filoghost.holographicdisplays.api.hologram.TouchHandler;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -26,12 +25,7 @@ public abstract class BaseTouchableLine extends BaseHologramLine {
|
||||
}
|
||||
|
||||
public void onTouch(Player player) {
|
||||
if (isDeleted()
|
||||
|| !player.isOnline()
|
||||
|| !isTrackedPlayer(player)
|
||||
|| player.getGameMode() == GameMode.SPECTATOR
|
||||
|| touchHandler == null
|
||||
|| !isVisibleTo(player)) {
|
||||
if (touchHandler == null || !canInteract(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user