diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java index e4552564..292f625b 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java @@ -30,6 +30,7 @@ public class BukkitAdapter implements BukkitInterface { public static final int BUKKIT_V1_17 = 17; public static final int BUKKIT_V1_18 = 18; public static final int BUKKIT_V1_19 = 19; + public static final int BUKKIT_V1_20 = 20; public static void loadAdapter() { switch (ConfigHandler.SERVER_VERSION) { @@ -48,8 +49,10 @@ public static void loadAdapter() { BukkitAdapter.ADAPTER = new Bukkit_v1_18(); break; case BUKKIT_V1_19: - default: BukkitAdapter.ADAPTER = new Bukkit_v1_19(); + case BUKKIT_V1_20: + default: + BukkitAdapter.ADAPTER = new Bukkit_v1_20(); } } diff --git a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java new file mode 100644 index 00000000..46609e84 --- /dev/null +++ b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java @@ -0,0 +1,17 @@ +package net.coreprotect.bukkit; + +import java.util.Arrays; +import java.util.HashSet; + +import org.bukkit.Material; + +import net.coreprotect.model.BlockGroup; + +public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface { + + public Bukkit_v1_20() { + BlockGroup.CONTAINERS = new HashSet<>(Arrays.asList(Material.JUKEBOX, Material.DISPENSER, Material.CHEST, Material.FURNACE, Material.BREWING_STAND, Material.TRAPPED_CHEST, Material.HOPPER, Material.DROPPER, Material.ARMOR_STAND, Material.ITEM_FRAME, Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX, Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX, Material.LIME_SHULKER_BOX, Material.MAGENTA_SHULKER_BOX, Material.ORANGE_SHULKER_BOX, Material.PINK_SHULKER_BOX, Material.PURPLE_SHULKER_BOX, Material.RED_SHULKER_BOX, Material.LIGHT_GRAY_SHULKER_BOX, Material.WHITE_SHULKER_BOX, Material.YELLOW_SHULKER_BOX, Material.BARREL, Material.BLAST_FURNACE, Material.SMOKER, Material.LECTERN, Material.CHISELED_BOOKSHELF)); + BlockGroup.UPDATE_STATE = new HashSet<>(Arrays.asList(Material.TORCH, Material.WALL_TORCH, Material.REDSTONE_WIRE, Material.RAIL, Material.POWERED_RAIL, Material.DETECTOR_RAIL, Material.FURNACE, Material.BLAST_FURNACE, Material.SMOKER, Material.LEVER, Material.REDSTONE_TORCH, Material.REDSTONE_WALL_TORCH, Material.GLOWSTONE, Material.JACK_O_LANTERN, Material.REPEATER, Material.REDSTONE_LAMP, Material.BEACON, Material.COMPARATOR, Material.DAYLIGHT_DETECTOR, Material.REDSTONE_BLOCK, Material.HOPPER, Material.CHEST, Material.TRAPPED_CHEST, Material.ACTIVATOR_RAIL, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SHROOMLIGHT, Material.RESPAWN_ANCHOR, Material.CRYING_OBSIDIAN, Material.TARGET, Material.SMALL_AMETHYST_BUD, Material.MEDIUM_AMETHYST_BUD, Material.LARGE_AMETHYST_BUD, Material.AMETHYST_CLUSTER, Material.CAVE_VINES, Material.CAVE_VINES_PLANT, Material.GLOW_LICHEN, Material.LIGHT, Material.LAVA_CAULDRON, Material.CHISELED_BOOKSHELF)); + } + +} diff --git a/src/main/java/net/coreprotect/database/Rollback.java b/src/main/java/net/coreprotect/database/Rollback.java index aa0c2efc..09c8f95d 100644 --- a/src/main/java/net/coreprotect/database/Rollback.java +++ b/src/main/java/net/coreprotect/database/Rollback.java @@ -1716,7 +1716,27 @@ else if (type != null && type.equals(Material.JUKEBOX)) { modifiedArmor = addedItem ? setArmor : modifiedArmor; } if (!addedItem) { - addedItem = (inventory.addItem(itemstack).size() == 0); + if (type.name().equals("CHISELED_BOOKSHELF")) { + ItemStack[] inventoryContents = inventory.getStorageContents(); + int i = 0; + for (ItemStack stack : inventoryContents) { + if (stack == null) { + inventoryContents[i] = itemstack; + addedItem = true; + break; + } + i++; + } + if (addedItem) { + inventory.setStorageContents(inventoryContents); + } + else { + addedItem = (inventory.addItem(itemstack).size() == 0); + } + } + else { + addedItem = (inventory.addItem(itemstack).size() == 0); + } } if (!addedItem && isPlayerInventory) { PlayerInventory playerInventory = (PlayerInventory) inventory; diff --git a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java index dbe4ef61..06560f7d 100755 --- a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java +++ b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java @@ -37,6 +37,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.BlockInventoryHolder; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; @@ -666,6 +667,12 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Ta } } } + else if (type.name().equals("CHISELED_BOOKSHELF")) { + BlockState blockState = block.getState(); + if (blockState instanceof BlockInventoryHolder) { + InventoryChangeListener.inventoryTransaction(player.getName(), blockState.getLocation(), null); + } + } else if (type == Material.DRAGON_EGG) { clickedDragonEgg(player, block); } diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index c3bfa299..12f5fdf1 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -862,7 +862,7 @@ public static int getEntityId(EntityType type) { if (type == null) { return -1; } - + return getEntityId(type.name(), true); }