Skip to content

Commit

Permalink
fix: getProvidingClass usages in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolai committed Oct 31, 2023
1 parent 4946485 commit 223b432
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 223b432

Please sign in to comment.