fix npe in combination with some plugins

This commit is contained in:
Brokkonaut
2024-10-04 10:40:24 +02:00
parent ecb281ccaa
commit 8c024532b2

View File

@@ -335,6 +335,9 @@ public class ChestAccessLogging extends LoggingListener {
if (clicked.getBlockData() instanceof ChiseledBookshelf blockData && blockData.getFacing() == event.getBlockFace() && clicked.getState() instanceof org.bukkit.block.ChiseledBookshelf bookshelf) { if (clicked.getBlockData() instanceof ChiseledBookshelf blockData && blockData.getFacing() == event.getBlockFace() && clicked.getState() instanceof org.bukkit.block.ChiseledBookshelf bookshelf) {
// calculate the slot the same way as minecraft does it // calculate the slot the same way as minecraft does it
Vector pos = event.getClickedPosition(); Vector pos = event.getClickedPosition();
if (pos == null) {
return; // some plugins create this event without a clicked pos
}
double clickx = switch (blockData.getFacing()) { double clickx = switch (blockData.getFacing()) {
case NORTH -> 1 - pos.getX(); case NORTH -> 1 - pos.getX();
case SOUTH -> pos.getX(); case SOUTH -> pos.getX();