From 733d3ddb81515eb22c85d34944990a13c1396e62 Mon Sep 17 00:00:00 2001
From: Alberto Gusmeroli <96133902+guss-alberto@users.noreply.github.com>
Date: Sat, 13 Dec 2025 12:52:37 +0100
Subject: [PATCH 1/5] add shelf logging
---
pom.xml | 4 +-
.../net/coreprotect/bukkit/BukkitAdapter.java | 16 +++++++
.../coreprotect/bukkit/BukkitInterface.java | 26 +++++++++++
.../net/coreprotect/bukkit/Bukkit_v1_21.java | 26 ++++++++++-
.../player/PlayerInteractListener.java | 43 +++++++++++++++++++
5 files changed, 112 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index e888e33ca..3fcbe0266 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,9 +2,9 @@
4.0.0
net.coreprotect
CoreProtect
- 23.0
+ 23.1
-
+ development
UTF-8
true
11
diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
index 23f92078c..0721d87c4 100644
--- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
+++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
@@ -278,6 +278,12 @@ public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractE
return null;
}
+ @Override
+ public ItemStack getShelfItemStack(BlockState blockState, PlayerInteractEvent event){
+ return null;
+ }
+
+
// -------------------- Sign handling methods --------------------
@Override
@@ -366,8 +372,18 @@ public boolean isCopperChest(Material material) {
return false;
}
+ @Override
+ public boolean isShelf(Material material){
+ return false;
+ }
+
@Override
public Set copperChestMaterials() {
return EMPTY_SET;
}
+
+ @Override
+ public Set shelfMaterials() {
+ return EMPTY_SET;
+ }
}
diff --git a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java
index c66d7fcbb..a2404db7a 100644
--- a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java
+++ b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java
@@ -132,6 +132,17 @@ public interface BukkitInterface {
*/
boolean isChiseledBookshelf(Material material);
+
+ /**
+ * Checks if a material is a shelf of any wood kind.
+ *
+ * @param material
+ * The material to check
+ * @return true if the material is a shelf, false otherwise
+ */
+ boolean isShelf(Material material);
+
+
/**
* Checks if a material is a bookshelf book.
*
@@ -204,6 +215,19 @@ public interface BukkitInterface {
*/
ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event);
+
+ /**
+ * Gets an item from a shelf.
+ *
+ * @param blockState
+ * The block state
+ * @param event
+ * The player interact event
+ * @return The item stack, or null if not applicable
+ */
+ ItemStack getShelfItemStack(BlockState blockState, PlayerInteractEvent event);
+
+
/**
* Gets arrow metadata for an item stack.
*
@@ -441,4 +465,6 @@ public interface BukkitInterface {
Set copperChestMaterials();
+ Set shelfMaterials();
+
}
diff --git a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
index 4d52be823..687338050 100644
--- a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
+++ b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
@@ -23,9 +23,10 @@
* - Registry handling for named objects
* - Updated interaction blocks
*/
-public class Bukkit_v1_21 extends Bukkit_v1_20 implements BukkitInterface {
+public class Bukkit_v1_21 extends Bukkit_v1_20 {
public static Set COPPER_CHESTS = new HashSet<>(Arrays.asList());
+ public static Set SHELVES = new HashSet<>(Arrays.asList());
/**
* Initializes the Bukkit_v1_21 adapter with 1.21-specific block groups and mappings.
@@ -37,6 +38,7 @@ public Bukkit_v1_21() {
BlockGroup.INTERACT_BLOCKS.addAll(copperChestMaterials());
BlockGroup.CONTAINERS.addAll(copperChestMaterials());
BlockGroup.UPDATE_STATE.addAll(copperChestMaterials());
+ BlockGroup.CONTAINERS.addAll(shelfMaterials());
}
/**
@@ -111,6 +113,7 @@ public Object getRegistryKey(Object value) {
return ((Keyed) value).getKey().toString();
}
+
/**
* Gets a registry value from a key string and class.
* Used for deserializing registry objects.
@@ -177,6 +180,15 @@ public boolean isCopperChest(Material material) {
return false;
}
+ @Override
+ public boolean isShelf(Material material) {
+ if (SHELVES.contains(material)) {
+ return true;
+ }
+
+ return false;
+ }
+
@Override
public Set copperChestMaterials() {
if (COPPER_CHESTS.isEmpty()) {
@@ -198,4 +210,16 @@ public Set copperChestMaterials() {
return COPPER_CHESTS;
}
+
+ @Override
+ public Set shelfMaterials() {
+ if (SHELVES.isEmpty()) {;
+ Material shelf = Material.getMaterial("OAK_SHELF");
+ if (shelf != null) {
+ SHELVES.addAll(Tag.WOODEN_SHELVES.getValues());
+ }
+ }
+
+ return SHELVES;
+ }
}
diff --git a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
index 680aa6181..716da37b5 100755
--- a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
+++ b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
@@ -18,12 +18,14 @@
import org.bukkit.block.Sign;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Bisected.Half;
+import org.bukkit.block.data.SideChaining.ChainPart;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Lightable;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.block.data.type.Bed;
import org.bukkit.block.data.type.Bed.Part;
import org.bukkit.block.data.type.Cake;
+import org.bukkit.block.data.type.Shelf;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -37,6 +39,7 @@
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.util.Vector;
import net.coreprotect.CoreProtect;
import net.coreprotect.bukkit.BukkitAdapter;
@@ -465,6 +468,46 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Bu
InventoryChangeListener.inventoryTransaction(player.getName(), blockState.getLocation(), null);
}
}
+ } else if (BukkitAdapter.ADAPTER.isShelf(type) ){
+ BlockData blockState = block.getBlockData();
+ if (blockState instanceof Shelf){
+ Shelf shelf = (Shelf) blockState;
+
+ // ignore events such as clicking on the back
+ if (event.getBlockFace() != shelf.getFacing()){
+ return;
+ }
+
+ if (shelf.getSideChain() == ChainPart.UNCONNECTED){
+ InventoryChangeListener.inventoryTransaction(player.getName(), block.getLocation(), null);
+ } else {
+ Block center = block;
+ Vector direction = shelf.getFacing().getDirection();
+
+ // if connected and it's not the center, find the center one
+ if (shelf.getSideChain() == ChainPart.LEFT){
+ center = center.getRelative(direction.getBlockZ(), 0, -direction.getBlockX());
+ } else if (shelf.getSideChain() == ChainPart.RIGHT){
+ center = center.getRelative(-direction.getBlockZ(), 0, direction.getBlockX());
+ }
+
+ // log center
+ InventoryChangeListener.inventoryTransaction(player.getName(), center.getLocation(), null);
+
+ if (((Shelf)center.getBlockData()).getSideChain() != ChainPart.CENTER){
+ // if it's not the center it's just a chain of 2,
+ InventoryChangeListener.inventoryTransaction(player.getName(), block.getLocation(), null);
+ } else {
+ // once we have the center, log left and right
+ Block left = center.getRelative(-direction.getBlockZ(), 0, direction.getBlockX());
+ InventoryChangeListener.inventoryTransaction(player.getName(), left.getLocation(), null);
+
+ Block right = center.getRelative(direction.getBlockZ(), 0, -direction.getBlockX());
+ InventoryChangeListener.inventoryTransaction(player.getName(), right.getLocation(), null);
+ }
+
+ }
+ }
}
else if (BukkitAdapter.ADAPTER.isDecoratedPot(type)) {
BlockState blockState = block.getState();
From 22379f67208a58eb26f956e6a9ef1ec43d1c7155 Mon Sep 17 00:00:00 2001
From: Alberto Gusmeroli <96133902+guss-alberto@users.noreply.github.com>
Date: Sat, 13 Dec 2025 13:04:29 +0100
Subject: [PATCH 2/5] bump supported version to 1.21.11
---
src/main/java/net/coreprotect/config/ConfigHandler.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/net/coreprotect/config/ConfigHandler.java b/src/main/java/net/coreprotect/config/ConfigHandler.java
index bf5911283..40c69cc86 100644
--- a/src/main/java/net/coreprotect/config/ConfigHandler.java
+++ b/src/main/java/net/coreprotect/config/ConfigHandler.java
@@ -53,7 +53,7 @@ public enum CacheType {
public static final String JAVA_VERSION = "11.0";
public static final String MINECRAFT_VERSION = "1.16";
public static final String PATCH_VERSION = "23.0";
- public static final String LATEST_VERSION = "1.21.10";
+ public static final String LATEST_VERSION = "1.21.11";
public static String path = "plugins/CoreProtect/";
public static String sqlite = "database.db";
public static String host = "127.0.0.1";
From f657771b875ed44c405f36e03478338175efe122 Mon Sep 17 00:00:00 2001
From: Alberto Gusmeroli <96133902+guss-alberto@users.noreply.github.com>
Date: Mon, 15 Dec 2025 16:59:16 +0100
Subject: [PATCH 3/5] cleanup
---
.../java/net/coreprotect/bukkit/BukkitAdapter.java | 6 ------
.../net/coreprotect/bukkit/BukkitInterface.java | 13 -------------
.../java/net/coreprotect/bukkit/Bukkit_v1_21.java | 8 ++------
.../listener/player/PlayerInteractListener.java | 6 ++----
4 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
index 0721d87c4..dcd42baa4 100644
--- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
+++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
@@ -278,12 +278,6 @@ public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractE
return null;
}
- @Override
- public ItemStack getShelfItemStack(BlockState blockState, PlayerInteractEvent event){
- return null;
- }
-
-
// -------------------- Sign handling methods --------------------
@Override
diff --git a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java
index a2404db7a..9ccebed8e 100644
--- a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java
+++ b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java
@@ -215,19 +215,6 @@ public interface BukkitInterface {
*/
ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event);
-
- /**
- * Gets an item from a shelf.
- *
- * @param blockState
- * The block state
- * @param event
- * The player interact event
- * @return The item stack, or null if not applicable
- */
- ItemStack getShelfItemStack(BlockState blockState, PlayerInteractEvent event);
-
-
/**
* Gets arrow metadata for an item stack.
*
diff --git a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
index 687338050..4d0e2521d 100644
--- a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
+++ b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
@@ -182,11 +182,7 @@ public boolean isCopperChest(Material material) {
@Override
public boolean isShelf(Material material) {
- if (SHELVES.contains(material)) {
- return true;
- }
-
- return false;
+ return SHELVES.contains(material);
}
@Override
@@ -213,7 +209,7 @@ public Set copperChestMaterials() {
@Override
public Set shelfMaterials() {
- if (SHELVES.isEmpty()) {;
+ if (SHELVES.isEmpty()) {
Material shelf = Material.getMaterial("OAK_SHELF");
if (shelf != null) {
SHELVES.addAll(Tag.WOODEN_SHELVES.getValues());
diff --git a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
index 716da37b5..ac293caec 100755
--- a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
+++ b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
@@ -473,7 +473,7 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Bu
if (blockState instanceof Shelf){
Shelf shelf = (Shelf) blockState;
- // ignore events such as clicking on the back
+ // ignore clicking on the back face
if (event.getBlockFace() != shelf.getFacing()){
return;
}
@@ -484,7 +484,6 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Bu
Block center = block;
Vector direction = shelf.getFacing().getDirection();
- // if connected and it's not the center, find the center one
if (shelf.getSideChain() == ChainPart.LEFT){
center = center.getRelative(direction.getBlockZ(), 0, -direction.getBlockX());
} else if (shelf.getSideChain() == ChainPart.RIGHT){
@@ -494,11 +493,10 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Bu
// log center
InventoryChangeListener.inventoryTransaction(player.getName(), center.getLocation(), null);
- if (((Shelf)center.getBlockData()).getSideChain() != ChainPart.CENTER){
+ if (center instanceof Shelf && ((Shelf)center.getBlockData()).getSideChain() != ChainPart.CENTER){
// if it's not the center it's just a chain of 2,
InventoryChangeListener.inventoryTransaction(player.getName(), block.getLocation(), null);
} else {
- // once we have the center, log left and right
Block left = center.getRelative(-direction.getBlockZ(), 0, direction.getBlockX());
InventoryChangeListener.inventoryTransaction(player.getName(), left.getLocation(), null);
From c07221de65f0be3b4ab409e51cd598b10bf839a1 Mon Sep 17 00:00:00 2001
From: Intelli <6790859+Intelli@users.noreply.github.com>
Date: Mon, 15 Dec 2025 14:00:57 -0700
Subject: [PATCH 4/5] Update pom.xml
Remove project branch definition from properties.
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 345b8d48c..bb0a96a5e 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
CoreProtect
23.1
- development
+
UTF-8
true
11
From 11c8a2321ec5fd8f20fb7d5702d752d21b601e0e Mon Sep 17 00:00:00 2001
From: Alberto Gusmeroli <96133902+guss-alberto@users.noreply.github.com>
Date: Mon, 15 Dec 2025 23:11:17 +0100
Subject: [PATCH 5/5] fix incorrect instanceof check
---
.../player/PlayerInteractListener.java | 31 +++++++++++--------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
index ac293caec..9f43ff5ea 100755
--- a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
+++ b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java
@@ -490,20 +490,25 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Bu
center = center.getRelative(-direction.getBlockZ(), 0, direction.getBlockX());
}
- // log center
- InventoryChangeListener.inventoryTransaction(player.getName(), center.getLocation(), null);
-
- if (center instanceof Shelf && ((Shelf)center.getBlockData()).getSideChain() != ChainPart.CENTER){
- // if it's not the center it's just a chain of 2,
- InventoryChangeListener.inventoryTransaction(player.getName(), block.getLocation(), null);
+ BlockData centerBlockData = center.getBlockData();
+ if (centerBlockData instanceof Shelf){
+ // log center
+ InventoryChangeListener.inventoryTransaction(player.getName(), center.getLocation(), null);
+
+ if (((Shelf)centerBlockData).getSideChain() != ChainPart.CENTER){
+ // if it's not the center it's just a chain of 2
+ InventoryChangeListener.inventoryTransaction(player.getName(), block.getLocation(), null);
+ } else {
+ Block left = center.getRelative(-direction.getBlockZ(), 0, direction.getBlockX());
+ InventoryChangeListener.inventoryTransaction(player.getName(), left.getLocation(), null);
+
+ Block right = center.getRelative(direction.getBlockZ(), 0, -direction.getBlockX());
+ InventoryChangeListener.inventoryTransaction(player.getName(), right.getLocation(), null);
+ }
} else {
- Block left = center.getRelative(-direction.getBlockZ(), 0, direction.getBlockX());
- InventoryChangeListener.inventoryTransaction(player.getName(), left.getLocation(), null);
-
- Block right = center.getRelative(direction.getBlockZ(), 0, -direction.getBlockX());
- InventoryChangeListener.inventoryTransaction(player.getName(), right.getLocation(), null);
- }
-
+ // fallback if invalid block is found just log clicked shelf
+ InventoryChangeListener.inventoryTransaction(player.getName(), block.getLocation(), null);
+ }
}
}
}