From 21a5752d5155966f56fd7901cc1776222357a008 Mon Sep 17 00:00:00 2001 From: FranciscoDadone Date: Mon, 3 Jan 2022 12:58:23 -0300 Subject: [PATCH] Creative anchor bug --- .../nightmarephoenix/anchorsell/api/StorageManager.java | 1 - .../nightmarephoenix/anchorsell/events/ActionAnchor.java | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/mc/nightmarephoenix/anchorsell/api/StorageManager.java b/src/main/java/mc/nightmarephoenix/anchorsell/api/StorageManager.java index ff97752..44f096e 100644 --- a/src/main/java/mc/nightmarephoenix/anchorsell/api/StorageManager.java +++ b/src/main/java/mc/nightmarephoenix/anchorsell/api/StorageManager.java @@ -175,7 +175,6 @@ public static String getAnchorUUID(Location location) { public static boolean belongsToPlayer(Anchor anchor, Player p) { userData = new PerUserStorage(Global.plugin, p); generalData = new GeneralStorage(Global.plugin); - try { Player actualPlayerAnchor = Bukkit.getPlayer(UUID.fromString( generalData.getConfig().getString("all_anchors." + getAnchorUUID(anchor.getLocation()) + ".owner")) diff --git a/src/main/java/mc/nightmarephoenix/anchorsell/events/ActionAnchor.java b/src/main/java/mc/nightmarephoenix/anchorsell/events/ActionAnchor.java index 179696e..d011608 100644 --- a/src/main/java/mc/nightmarephoenix/anchorsell/events/ActionAnchor.java +++ b/src/main/java/mc/nightmarephoenix/anchorsell/events/ActionAnchor.java @@ -2,6 +2,7 @@ import mc.nightmarephoenix.anchorsell.AnchorSell; import mc.nightmarephoenix.anchorsell.inventories.AnchorScreen; import mc.nightmarephoenix.anchorsell.api.StorageManager; +import mc.nightmarephoenix.anchorsell.models.Anchor; import mc.nightmarephoenix.anchorsell.utils.Utils; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -35,7 +36,12 @@ public void onBlockClick(PlayerInteractEvent e) { /** * Checks if it's my anchor and opens the inventory. */ - if(StorageManager.belongsToPlayer(StorageManager.getAnchorFromLoc(e.getClickedBlock().getLocation()), p)) { + Anchor anchor = StorageManager.getAnchorFromLoc(e.getClickedBlock().getLocation()); + + // Checks creative anchor + if(anchor == null) return; + + if(StorageManager.belongsToPlayer(anchor, p)) { e.setCancelled(true); p.openInventory(new AnchorScreen(p, plugin, e.getClickedBlock().getLocation()).getInventory()); } else {