diff --git a/BuildTools/build-1.18+.sh b/BuildTools/build-1.18+.sh
index a0f44c5..28ba421 100644
--- a/BuildTools/build-1.18+.sh
+++ b/BuildTools/build-1.18+.sh
@@ -8,7 +8,7 @@ MAVEN_DIR="$HOME/.m2"
SPIGOT="${MAVEN_DIR}/repository/org/spigotmc/spigot"
#Versions
-array=("1.18.1" "1.18.2" "1.19" "1.19.3" "1.19.4" "1.20" "1.20.4")
+array=("1.18.1" "1.18.2" "1.19" "1.19.3" "1.19.4" "1.20" "1.20.4" "1.21")
#Download BuildTools jar
curl -s -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
diff --git a/ChestsPlusPlus_1_21_R1/pom.xml b/ChestsPlusPlus_1_21_R1/pom.xml
new file mode 100644
index 0000000..3023da5
--- /dev/null
+++ b/ChestsPlusPlus_1_21_R1/pom.xml
@@ -0,0 +1,104 @@
+
+
+
+ ChestsPlusPlus-Parent
+ com.jamesdpeters.minecraft.chests
+ 1.0-SNAPSHOT
+ ../pom.xml
+
+
+
+ 1.21
+
+
+ 4.0.0
+ jar
+ ChestsPlusPlus_1_21_R1
+ 1.0-SNAPSHOT
+
+
+
+ spigotmc-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+
+
+
+ com.jamesdpeters.minecraft.chests
+ ChestsPlusPlus-API
+ 1.0-SNAPSHOT
+
+
+
+ org.spigotmc
+ spigot-api
+ ${minecraft.version}-R0.1-SNAPSHOT
+ provided
+
+
+ com.jamesdpeters.minecraft.chests
+ ChestsPlusPlus_1_17_R1
+ 1.0-SNAPSHOT
+ compile
+
+
+
+ org.spigotmc
+ spigot
+ ${minecraft.version}-R0.1-SNAPSHOT
+ remapped-mojang
+ provided
+
+
+
+
+
+
+ net.md-5
+ specialsource-maven-plugin
+ 1.2.3
+
+
+ package
+
+ remap
+
+ remap-obf
+
+ org.spigotmc:minecraft-server:${minecraft.version}-R0.1-SNAPSHOT:txt:maps-mojang
+ true
+ org.spigotmc:spigot:${minecraft.version}-R0.1-SNAPSHOT:jar:remapped-mojang
+ true
+ remapped-obf
+
+
+
+ package
+
+ remap
+
+ remap-spigot
+
+ ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
+ org.spigotmc:minecraft-server:${minecraft.version}-R0.1-SNAPSHOT:csrg:maps-spigot
+ org.spigotmc:spigot:${minecraft.version}-R0.1-SNAPSHOT:jar:remapped-obf
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 16
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/Crafting.java b/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/Crafting.java
new file mode 100644
index 0000000..55b4abe
--- /dev/null
+++ b/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/Crafting.java
@@ -0,0 +1,106 @@
+package com.jamesdpeters.minecraft.chests.v1_21_R1;
+
+import com.jamesdpeters.minecraft.chests.CraftingProvider;
+import com.jamesdpeters.minecraft.chests.CraftingResult;
+import net.minecraft.core.NonNullList;
+import net.minecraft.core.RegistryAccess;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.CraftingContainer;
+import net.minecraft.world.inventory.TransientCraftingContainer;
+import net.minecraft.world.item.crafting.CraftingInput;
+import net.minecraft.world.item.crafting.RecipeType;
+import net.minecraft.world.level.Level;
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+import org.bukkit.craftbukkit.v1_21_R1.CraftServer;
+import org.bukkit.craftbukkit.v1_21_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.Recipe;
+
+import java.util.ArrayList;
+
+public class Crafting implements CraftingProvider {
+
+ @Override
+ public CraftingResult craft(World world, ItemStack[] items) {
+ CraftWorld craftWorld = (CraftWorld) world;
+
+ // Setup crafting inventories.
+ CraftingContainer inventoryCrafting = new TransientCraftingContainer(new AbstractContainerMenu(null, -1) {
+ @Override
+ public InventoryView getBukkitView() {
+ return null;
+ }
+
+ @Override
+ public net.minecraft.world.item.ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int i) {
+ return null;
+ }
+
+ @Override
+ public boolean stillValid(net.minecraft.world.entity.player.Player player) {
+ return false;
+ }
+
+ }, 3, 3);
+
+ for (int i = 0; i < items.length; i++) {
+ inventoryCrafting.setItem(i, CraftItemStack.asNMSCopy(items[i]));
+ }
+
+ var craftInput = inventoryCrafting.asCraftInput();
+ var recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftInput, craftWorld.getHandle());
+
+ // Generate the resulting ItemStack from the Crafting Matrix
+ net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.EMPTY;
+
+ if (recipe.isPresent()) {
+ itemStack = recipe.get().value().assemble(craftInput, RegistryAccess.EMPTY);
+ }
+
+ return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle(), craftInput);
+ }
+
+ @Override
+ public Recipe getRecipe(Player player, World world, ItemStack[] items) {
+ return Bukkit.getCraftingRecipe(items, world);
+ }
+
+ private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer, CraftingInput craftingInput) {
+ CraftServer server = (CraftServer) Bukkit.getServer();
+ NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, craftingInput, worldServer);
+
+ CraftingResult craftItemResult = new CraftingResult(itemStack, new ItemStack[9], new ArrayList<>());
+
+ // Create resulting matrix and overflow items
+ for (int i = 0; i < remainingItems.size(); ++i) {
+ net.minecraft.world.item.ItemStack itemstack1 = inventoryCrafting.getItem(i);
+ net.minecraft.world.item.ItemStack itemstack2 = remainingItems.get(i);
+
+ if (!itemstack1.isEmpty()) {
+ inventoryCrafting.removeItem(i, 1);
+ itemstack1 = inventoryCrafting.getItem(i);
+ }
+
+ if (!itemstack2.isEmpty()) {
+ if (itemstack1.isEmpty()) {
+ inventoryCrafting.setItem(i, itemstack2);
+ } else if (net.minecraft.world.item.ItemStack.matches(itemstack1, itemstack2)) {
+ itemstack2.grow(itemstack1.getCount());
+ inventoryCrafting.setItem(i, itemstack2);
+ } else {
+ craftItemResult.overflowItems().add(CraftItemStack.asBukkitCopy(itemstack2));
+ }
+ }
+ }
+
+ for (int i = 0; i < inventoryCrafting.getContents().size(); i++) {
+ craftItemResult.setResultMatrix(i, CraftItemStack.asBukkitCopy(inventoryCrafting.getItem(i)));
+ }
+
+ return craftItemResult;
+ }
+}
diff --git a/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/NMSProviderImpl.java b/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/NMSProviderImpl.java
new file mode 100644
index 0000000..9cf9341
--- /dev/null
+++ b/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/NMSProviderImpl.java
@@ -0,0 +1,49 @@
+package com.jamesdpeters.minecraft.chests.v1_21_R1;
+
+import com.jamesdpeters.minecraft.chests.ChestOpener;
+import com.jamesdpeters.minecraft.chests.CraftingProvider;
+import com.jamesdpeters.minecraft.chests.EntityEventListener;
+import com.jamesdpeters.minecraft.chests.MaterialChecker;
+import com.jamesdpeters.minecraft.chests.NMSProvider;
+import com.jamesdpeters.minecraft.chests.v1_17_R1.EntityEventListener_1_17;
+import com.jamesdpeters.minecraft.chests.v1_17_R1.MaterialChecker_1_17_R1;
+import org.bukkit.block.Lidded;
+import org.bukkit.entity.ItemFrame;
+
+public class NMSProviderImpl implements NMSProvider {
+
+ @Override
+ public ChestOpener getChestOpener() {
+ return (inventory, container, tileEntityOpener) -> {
+ if(container instanceof Lidded){
+ if(!inventory.getViewers().isEmpty()){
+ ((Lidded) container).open();
+ } else {
+ ((Lidded) container).close();
+ }
+ }
+ return null;
+ };
+ }
+
+ @Override
+ public MaterialChecker getMaterialChecker() {
+ return new MaterialChecker_1_17_R1();
+ }
+
+ @Override
+ public CraftingProvider getCraftingProvider() {
+ return new Crafting();
+ }
+
+ @Override
+ public EntityEventListener getEntityEventListener() {
+ return new EntityEventListener_1_17();
+ }
+
+ @Override
+ public void setItemFrameVisible(ItemFrame itemFrame, boolean visible) {
+ itemFrame.setVisible(visible);
+ }
+
+}
\ No newline at end of file
diff --git a/ChestsPlusPlus_Main/pom.xml b/ChestsPlusPlus_Main/pom.xml
index 7033fe1..aa0e9b2 100644
--- a/ChestsPlusPlus_Main/pom.xml
+++ b/ChestsPlusPlus_Main/pom.xml
@@ -11,7 +11,7 @@
ChestsPlusPlus-Master
- 2.11-Release
+ 2.12-Release
16
@@ -63,7 +63,7 @@
net.wesjd
anvilgui
- 1.9.2-SNAPSHOT
+ 1.9.6-SNAPSHOT
@@ -72,6 +72,13 @@
2.2.1
+
+ com.jamesdpeters.minecraft.chests
+ ChestsPlusPlus_1_21_R1
+ 1.0-SNAPSHOT
+ compile
+
+
com.jamesdpeters.minecraft.chests
ChestsPlusPlus_1_20_R3
diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/NMSProviderDefault.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/NMSProviderDefault.java
index 97a3fae..1af897a 100644
--- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/NMSProviderDefault.java
+++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/NMSProviderDefault.java
@@ -25,6 +25,7 @@ public class NMSProviderDefault implements NMSProvider {
case "v1_20_R1" -> defaultProvider = new com.jamesdpeters.minecraft.chests.v1_20_R1.NMSProviderImpl();
case "v1_20_R2" -> defaultProvider = new com.jamesdpeters.minecraft.chests.v1_20_R2.NMSProviderImpl();
case "v1_20_R3" -> defaultProvider = new com.jamesdpeters.minecraft.chests.v1_20_R3.NMSProviderImpl();
+ case "v1_21_R1" -> defaultProvider = new com.jamesdpeters.minecraft.chests.v1_21_R1.NMSProviderImpl();
default -> {
ChestsPlusPlus.PLUGIN.getLogger().severe("§c=======================================================");
ChestsPlusPlus.PLUGIN.getLogger().severe("§cThis version is not supported. Please update your server or the plugin!");
diff --git a/pom.xml b/pom.xml
index 32a460c..c315e8d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,7 @@
ChestsPlusPlusAPI
+ ChestsPlusPlus_1_21_R1
ChestsPlusPlus_1_20_R3
ChestsPlusPlus_1_20_R2
ChestsPlusPlus_1_20_R1