Move method

This commit is contained in:
filoghost 2022-05-22 00:54:11 +02:00
parent 32fc16b2c3
commit 323998845b
8 changed files with 25 additions and 43 deletions

View File

@ -19,13 +19,9 @@ interface APIClickableHologramLine extends ClickableHologramLine, APIHologramLin
@Override
default void invokeClickCallback(Player player) {
try {
HologramLineClickListener clickListener = getClickListener();
if (clickListener != null) {
clickListener.onClick(new SimpleHologramLineClickEvent(player));
}
} catch (Throwable t) {
logClickCallbackException(getCreatorPlugin(), player, t);
HologramLineClickListener clickListener = getClickListener();
if (clickListener != null) {
clickListener.onClick(new SimpleHologramLineClickEvent(player));
}
}

View File

@ -53,12 +53,8 @@ class APIItemHologramLine extends BaseItemHologramLine implements ItemHologramLi
@Override
public void invokePickupCallback(Player player) {
try {
if (pickupListener != null) {
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
}
} catch (Throwable t) {
logPickupCallbackException(getCreatorPlugin(), player, t);
if (pickupListener != null) {
pickupListener.onPickup(new SimpleHologramLinePickupEvent(player));
}
}

View File

@ -19,13 +19,9 @@ interface V2CollectableLine extends CollectableLine, V2HologramLine, PickupCallb
@Override
default void invokePickupCallback(Player player) {
try {
PickupHandler pickupListener = getPickupHandler();
if (pickupListener != null) {
pickupListener.onPickup(player);
}
} catch (Throwable t) {
logPickupCallbackException(getCreatorPlugin(), player, t);
PickupHandler pickupListener = getPickupHandler();
if (pickupListener != null) {
pickupListener.onPickup(player);
}
}

View File

@ -19,13 +19,9 @@ interface V2TouchableLine extends TouchableLine, V2HologramLine, ClickCallbackPr
@Override
default void invokeClickCallback(Player player) {
try {
TouchHandler touchHandler = getTouchHandler();
if (touchHandler != null) {
touchHandler.onTouch(player);
}
} catch (Throwable t) {
logClickCallbackException(getCreatorPlugin(), player, t);
TouchHandler touchHandler = getTouchHandler();
if (touchHandler != null) {
touchHandler.onTouch(player);
}
}

View File

@ -5,6 +5,7 @@
*/
package me.filoghost.holographicdisplays.core.base;
import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.common.PositionCoordinates;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -17,7 +18,12 @@ public abstract class BaseClickableHologramLine extends BaseHologramLine impleme
public void onClick(Player player) {
if (hasClickCallback() && canInteract(player) && isInClickRange(player)) {
invokeClickCallback(player);
try {
invokeClickCallback(player);
} catch (Throwable t) {
Log.warning("The plugin " + getCreatorPlugin().getName() + " generated an exception"
+ " when the player " + player.getName() + " clicked a hologram.", t);
}
}
}

View File

@ -6,6 +6,7 @@
package me.filoghost.holographicdisplays.core.base;
import me.filoghost.fcommons.Preconditions;
import me.filoghost.fcommons.logging.Log;
import me.filoghost.holographicdisplays.nms.common.entity.ItemNMSPacketEntity;
import me.filoghost.holographicdisplays.core.tracking.ItemLineTracker;
import me.filoghost.holographicdisplays.core.tracking.LineTrackerManager;
@ -29,7 +30,12 @@ public abstract class BaseItemHologramLine extends BaseClickableHologramLine imp
public void onPickup(Player player) {
if (hasPickupCallback() && canInteract(player)) {
invokePickupCallback(player);
try {
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);
}
}
}

View File

@ -5,9 +5,7 @@
*/
package me.filoghost.holographicdisplays.core.base;
import me.filoghost.fcommons.logging.Log;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public interface ClickCallbackProvider {
@ -15,9 +13,4 @@ public interface ClickCallbackProvider {
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);
}
}

View File

@ -5,9 +5,7 @@
*/
package me.filoghost.holographicdisplays.core.base;
import me.filoghost.fcommons.logging.Log;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public interface PickupCallbackProvider {
@ -15,9 +13,4 @@ public interface PickupCallbackProvider {
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);
}
}