Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ public boolean isCrafter(InventoryType type) {
return false;
}


@Override
public boolean isBundle(Material material) {
return false;
}

@Override
public boolean isCopperChest(Material material) {
return false;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ public interface BukkitInterface {
*/
boolean isBookshelfBook(Material material);


/**
* Checks if a material is a bundle.
*
* @param material
* The material to check
* @return true if the material is a bundle, false otherwise
*/
boolean isBundle(Material material);


/**
* Gets the seeds material for a plant material.
*
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/net/coreprotect/bukkit/Bukkit_v1_17.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,15 @@ public boolean getItemMeta(ItemMeta itemMeta, List<Map<String, Object>> list, Li
return super.getItemMeta(itemMeta, list, metadata, slot);
}

@Override
public boolean isBundle(Material material) {
return material == Material.BUNDLE;
}


@Override
public boolean setItemMeta(Material rowType, ItemStack itemstack, List<Map<String, Object>> map) {
if (rowType == Material.BUNDLE) {
if (BukkitAdapter.ADAPTER.isBundle(rowType)) {
BundleMeta meta = (BundleMeta) itemstack.getItemMeta();
for (Map<String, Object> itemData : map) {
ItemStack itemStack = ItemUtils.unserializeItemStack(itemData);
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Bukkit_v1_21 extends Bukkit_v1_20 {

public static Set<Material> COPPER_CHESTS = new HashSet<>(Arrays.asList());
public static Set<Material> SHELVES = new HashSet<>(Arrays.asList());
public static Set<Material> BUNDLES = new HashSet<>(Arrays.asList());

/**
* Initializes the Bukkit_v1_21 adapter with 1.21-specific block groups and mappings.
Expand All @@ -35,6 +36,7 @@ public class Bukkit_v1_21 extends Bukkit_v1_20 {
public Bukkit_v1_21() {
initializeBlockGroups();
initializeTrapdoorBlocks();
initializeBundles();
BlockGroup.INTERACT_BLOCKS.addAll(copperChestMaterials());
BlockGroup.CONTAINERS.addAll(copperChestMaterials());
BlockGroup.UPDATE_STATE.addAll(copperChestMaterials());
Expand Down Expand Up @@ -68,6 +70,20 @@ private void initializeTrapdoorBlocks() {
}
}

/**
* Initializes the bundles group to enable the ability to roll back dyed bundles correctly.
* It needs to check whether dyed bundles exist because they were added in 1.21.2.
*/
public void initializeBundles(){
if (BUNDLES.isEmpty()) {
Material bundle = Material.getMaterial("RED_BUNDLE");
if (bundle != null) {
BUNDLES.addAll(Tag.ITEMS_BUNDLES.getValues());
}
BUNDLES.add(Material.BUNDLE);
}
}

/**
* Helper method to add a block to a block group if it's not already present.
*
Expand Down Expand Up @@ -185,6 +201,12 @@ public boolean isShelf(Material material) {
return SHELVES.contains(material);
}

@Override
public boolean isBundle(Material material) {
return Tag.ITEMS_BUNDLES.getValues().contains(material);
}


@Override
public Set<Material> copperChestMaterials() {
if (COPPER_CHESTS.isEmpty()) {
Expand Down
Loading