Skip to content

Commit

Permalink
fix(vanish): chest silent
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Oct 6, 2024
1 parent d795a2a commit 9229b02
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import com.nookure.staff.api.StaffPlayerWrapper;
import com.nookure.staff.api.manager.PlayerWrapperManager;
import org.bukkit.Bukkit;
import org.bukkit.block.Chest;
import org.bukkit.block.Container;
import org.bukkit.block.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -30,22 +29,31 @@ public void onPlayerInteract(PlayerInteractEvent event) {
return;
}

if (
event.getClickedBlock() == null || !(event.getClickedBlock().getState() instanceof Container container)
) {
if (event.getClickedBlock() == null) {
return;
}

if (!(container instanceof Chest chest)) {
if (event.getClickedBlock().getState() instanceof EnderChest) {
event.setCancelled(true);
player.openInventory(player.getEnderChest());
return;
}

Inventory cInv = Bukkit.createInventory(null, chest.getInventory().getSize(), chest.getInventory().getType().defaultTitle());
cInv.setContents(chest.getInventory().getContents());
if (!(event.getClickedBlock().getState() instanceof Container container)) {
return;
}

player.openInventory(cInv);
if (container instanceof Chest || container instanceof Barrel || container instanceof ShulkerBox) {
Inventory bInv = Bukkit.createInventory(
null,
container.getInventory().getSize(),
container.getInventory().getType().defaultTitle()
);

event.setCancelled(true);
}
bInv.setContents(container.getInventory().getContents());

player.openInventory(bInv);
event.setCancelled(true);
}
}
}

0 comments on commit 9229b02

Please sign in to comment.