mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-03 07:43:22 +01:00
Move method
This commit is contained in:
parent
32fc16b2c3
commit
323998845b
@ -19,14 +19,10 @@ interface APIClickableHologramLine extends ClickableHologramLine, APIHologramLin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void invokeClickCallback(Player player) {
|
default void invokeClickCallback(Player player) {
|
||||||
try {
|
|
||||||
HologramLineClickListener clickListener = getClickListener();
|
HologramLineClickListener clickListener = getClickListener();
|
||||||
if (clickListener != null) {
|
if (clickListener != null) {
|
||||||
clickListener.onClick(new SimpleHologramLineClickEvent(player));
|
clickListener.onClick(new SimpleHologramLineClickEvent(player));
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
logClickCallbackException(getCreatorPlugin(), player, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,9 @@ class APIItemHologramLine extends BaseItemHologramLine implements ItemHologramLi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invokePickupCallback(Player player) {
|
public void invokePickupCallback(Player player) {
|
||||||
try {
|
|
||||||
if (pickupListener != null) {
|
if (pickupListener != null) {
|
||||||
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
|
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
logPickupCallbackException(getCreatorPlugin(), player, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,10 @@ interface V2CollectableLine extends CollectableLine, V2HologramLine, PickupCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void invokePickupCallback(Player player) {
|
default void invokePickupCallback(Player player) {
|
||||||
try {
|
|
||||||
PickupHandler pickupListener = getPickupHandler();
|
PickupHandler pickupListener = getPickupHandler();
|
||||||
if (pickupListener != null) {
|
if (pickupListener != null) {
|
||||||
pickupListener.onPickup(player);
|
pickupListener.onPickup(player);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
logPickupCallbackException(getCreatorPlugin(), player, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,10 @@ interface V2TouchableLine extends TouchableLine, V2HologramLine, ClickCallbackPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void invokeClickCallback(Player player) {
|
default void invokeClickCallback(Player player) {
|
||||||
try {
|
|
||||||
TouchHandler touchHandler = getTouchHandler();
|
TouchHandler touchHandler = getTouchHandler();
|
||||||
if (touchHandler != null) {
|
if (touchHandler != null) {
|
||||||
touchHandler.onTouch(player);
|
touchHandler.onTouch(player);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
|
||||||
logClickCallbackException(getCreatorPlugin(), player, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.core.base;
|
package me.filoghost.holographicdisplays.core.base;
|
||||||
|
|
||||||
|
import me.filoghost.fcommons.logging.Log;
|
||||||
import me.filoghost.holographicdisplays.common.PositionCoordinates;
|
import me.filoghost.holographicdisplays.common.PositionCoordinates;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,7 +18,12 @@ public abstract class BaseClickableHologramLine extends BaseHologramLine impleme
|
|||||||
|
|
||||||
public void onClick(Player player) {
|
public void onClick(Player player) {
|
||||||
if (hasClickCallback() && canInteract(player) && isInClickRange(player)) {
|
if (hasClickCallback() && canInteract(player) && isInClickRange(player)) {
|
||||||
|
try {
|
||||||
invokeClickCallback(player);
|
invokeClickCallback(player);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Log.warning("The plugin " + getCreatorPlugin().getName() + " generated an exception"
|
||||||
|
+ " when the player " + player.getName() + " clicked a hologram.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package me.filoghost.holographicdisplays.core.base;
|
package me.filoghost.holographicdisplays.core.base;
|
||||||
|
|
||||||
import me.filoghost.fcommons.Preconditions;
|
import me.filoghost.fcommons.Preconditions;
|
||||||
|
import me.filoghost.fcommons.logging.Log;
|
||||||
import me.filoghost.holographicdisplays.nms.common.entity.ItemNMSPacketEntity;
|
import me.filoghost.holographicdisplays.nms.common.entity.ItemNMSPacketEntity;
|
||||||
import me.filoghost.holographicdisplays.core.tracking.ItemLineTracker;
|
import me.filoghost.holographicdisplays.core.tracking.ItemLineTracker;
|
||||||
import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager;
|
import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager;
|
||||||
@ -29,7 +30,12 @@ public abstract class BaseItemHologramLine extends BaseClickableHologramLine imp
|
|||||||
|
|
||||||
public void onPickup(Player player) {
|
public void onPickup(Player player) {
|
||||||
if (hasPickupCallback() && canInteract(player)) {
|
if (hasPickupCallback() && canInteract(player)) {
|
||||||
|
try {
|
||||||
invokePickupCallback(player);
|
invokePickupCallback(player);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Log.warning("The plugin " + getCreatorPlugin().getName() + " generated an exception"
|
||||||
|
+ " when the player " + player.getName() + " picked up an item from a hologram.", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.core.base;
|
package me.filoghost.holographicdisplays.core.base;
|
||||||
|
|
||||||
import me.filoghost.fcommons.logging.Log;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public interface ClickCallbackProvider {
|
public interface ClickCallbackProvider {
|
||||||
|
|
||||||
@ -15,9 +13,4 @@ public interface ClickCallbackProvider {
|
|||||||
|
|
||||||
void invokeClickCallback(Player player);
|
void invokeClickCallback(Player player);
|
||||||
|
|
||||||
default void logClickCallbackException(Plugin plugin, Player player, Throwable t) {
|
|
||||||
Log.warning("The plugin " + plugin.getName() + " generated an exception"
|
|
||||||
+ " when the player " + player.getName() + " clicked a hologram.", t);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.core.base;
|
package me.filoghost.holographicdisplays.core.base;
|
||||||
|
|
||||||
import me.filoghost.fcommons.logging.Log;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public interface PickupCallbackProvider {
|
public interface PickupCallbackProvider {
|
||||||
|
|
||||||
@ -15,9 +13,4 @@ public interface PickupCallbackProvider {
|
|||||||
|
|
||||||
void invokePickupCallback(Player player);
|
void invokePickupCallback(Player player);
|
||||||
|
|
||||||
default void logPickupCallbackException(Plugin plugin, Player player, Throwable t) {
|
|
||||||
Log.warning("The plugin " + plugin.getName() + " generated an exception"
|
|
||||||
+ " when the player " + player.getName() + " picked up an item from a hologram.", t);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user