From 223b432845b5ffebf74d41db06831fd1a12cd958 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Tue, 31 Oct 2023 23:41:32 +0000 Subject: [PATCH] fix: getProvidingClass usages in more places --- .../interfaces/paper/PaperInterfaceListeners.java | 8 +++++++- .../org/incendo/interfaces/paper/PlayerViewerImpl.java | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/paper/src/main/java/org/incendo/interfaces/paper/PaperInterfaceListeners.java b/paper/src/main/java/org/incendo/interfaces/paper/PaperInterfaceListeners.java index 9fa85c37..7945b2a6 100644 --- a/paper/src/main/java/org/incendo/interfaces/paper/PaperInterfaceListeners.java +++ b/paper/src/main/java/org/incendo/interfaces/paper/PaperInterfaceListeners.java @@ -5,6 +5,7 @@ import com.google.common.cache.CacheBuilder; import java.lang.reflect.Method; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -260,8 +261,13 @@ public void onInventoryClose(final @NonNull InventoryCloseEvent event) { } } if (playerInventoryView != null && VALID_REASON.contains(reason)) { + Plugin plugin = Objects.requireNonNullElseGet( + PaperInterfaceListeners.plugin(), + () -> JavaPlugin.getProvidingPlugin(this.getClass()) + ); + Bukkit.getScheduler().runTaskAsynchronously( - JavaPlugin.getProvidingPlugin(this.getClass()), + plugin, playerInventoryView::open ); } diff --git a/paper/src/main/java/org/incendo/interfaces/paper/PlayerViewerImpl.java b/paper/src/main/java/org/incendo/interfaces/paper/PlayerViewerImpl.java index be8c0e1f..f83c7c4d 100644 --- a/paper/src/main/java/org/incendo/interfaces/paper/PlayerViewerImpl.java +++ b/paper/src/main/java/org/incendo/interfaces/paper/PlayerViewerImpl.java @@ -2,6 +2,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.checkerframework.checker.nullness.qual.NonNull; import org.incendo.interfaces.core.view.InterfaceView; @@ -11,6 +12,8 @@ import org.incendo.interfaces.paper.view.CombinedView; import org.incendo.interfaces.paper.view.PlayerInventoryView; +import java.util.Objects; + final class PlayerViewerImpl implements PlayerViewer { private final @NonNull Player player; @@ -64,7 +67,12 @@ public void open(final @NonNull InterfaceView view) { runnable.run(); } else { try { - Bukkit.getScheduler().callSyncMethod(JavaPlugin.getProvidingPlugin(this.getClass()), () -> { + Plugin plugin = Objects.requireNonNullElseGet( + PaperInterfaceListeners.plugin(), + () -> JavaPlugin.getProvidingPlugin(this.getClass()) + ); + + Bukkit.getScheduler().callSyncMethod(plugin, () -> { runnable.run(); return null;