From 5a1188928a48b2c3c075d3b0f38a5adf7747fd1f Mon Sep 17 00:00:00 2001 From: James Peters Date: Sat, 3 Aug 2024 12:14:12 +0100 Subject: [PATCH] Make 1.21 new baseline version Upgrade to 1.21 Bukkit API Remove all old NMS versions --- .../minecraft/chests/ChestOpener.java | 8 -- .../minecraft/chests/NMSProvider.java | 6 - .../minecraft/chests/TileEntityOpener.java | 9 -- ChestsPlusPlus_1_17_R1/pom.xml | 98 ---------------- .../minecraft/chests/v1_17_R1/Crafting.java | 97 ---------------- .../v1_17_R1/EntityEventListener_1_17.java | 13 --- .../chests/v1_17_R1/NMSProviderImpl.java | 47 -------- ChestsPlusPlus_1_18_R1/pom.xml | 105 ------------------ .../minecraft/chests/v1_18_R1/Crafting.java | 97 ---------------- .../chests/v1_18_R1/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_18_R2/pom.xml | 105 ------------------ .../minecraft/chests/v1_18_R2/Crafting.java | 97 ---------------- .../chests/v1_18_R2/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_19_R1/pom.xml | 104 ----------------- .../minecraft/chests/v1_19_R1/Crafting.java | 102 ----------------- .../chests/v1_19_R1/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_19_R2/pom.xml | 104 ----------------- .../minecraft/chests/v1_19_R2/Crafting.java | 102 ----------------- .../chests/v1_19_R2/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_19_R3/pom.xml | 104 ----------------- .../minecraft/chests/v1_19_R3/Crafting.java | 103 ----------------- .../chests/v1_19_R3/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_20_R1/pom.xml | 104 ----------------- .../minecraft/chests/v1_20_R1/Crafting.java | 104 ----------------- .../chests/v1_20_R1/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_20_R2/pom.xml | 104 ----------------- .../minecraft/chests/v1_20_R2/Crafting.java | 104 ----------------- .../chests/v1_20_R2/NMSProviderImpl.java | 49 -------- ChestsPlusPlus_1_20_R3/pom.xml | 104 ----------------- .../minecraft/chests/v1_20_R3/Crafting.java | 104 ----------------- .../chests/v1_20_R3/NMSProviderImpl.java | 49 -------- .../v1_21_R1/MaterialChecker_1_21_R1.java | 9 +- .../chests/v1_21_R1/NMSProviderImpl.java | 33 +----- ChestsPlusPlus_Main/pom.xml | 72 +----------- .../minecraft/chests/ChestsPlusPlus.java | 5 +- .../minecraft/chests/api/ApiSpecific.java | 6 +- .../chests/filters/ItemTypeUtil.java | 2 +- .../chests/interfaces/InventoryViewImpl.java | 49 -------- .../listeners}/EntityEventListener.java | 32 ++++-- .../listeners/HopperFilterListener.java | 5 +- .../minecraft/chests/misc/Utils.java | 20 ++-- .../chests/serialize/LocationInfo.java | 10 -- .../src/main/resources/lang/en_GB.properties | 2 +- pom.xml | 9 -- 44 files changed, 47 insertions(+), 2524 deletions(-) delete mode 100644 ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/ChestOpener.java delete mode 100644 ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/TileEntityOpener.java delete mode 100644 ChestsPlusPlus_1_17_R1/pom.xml delete mode 100644 ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/Crafting.java delete mode 100644 ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/EntityEventListener_1_17.java delete mode 100644 ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_18_R1/pom.xml delete mode 100644 ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/Crafting.java delete mode 100644 ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_18_R2/pom.xml delete mode 100644 ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/Crafting.java delete mode 100644 ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_19_R1/pom.xml delete mode 100644 ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/Crafting.java delete mode 100644 ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_19_R2/pom.xml delete mode 100644 ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/Crafting.java delete mode 100644 ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_19_R3/pom.xml delete mode 100644 ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/Crafting.java delete mode 100644 ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_20_R1/pom.xml delete mode 100644 ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/Crafting.java delete mode 100644 ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_20_R2/pom.xml delete mode 100644 ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/Crafting.java delete mode 100644 ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/NMSProviderImpl.java delete mode 100644 ChestsPlusPlus_1_20_R3/pom.xml delete mode 100644 ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/Crafting.java delete mode 100644 ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/NMSProviderImpl.java rename ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/MaterialChecker_1_17_R1.java => ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/MaterialChecker_1_21_R1.java (77%) delete mode 100644 ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/interfaces/InventoryViewImpl.java rename {ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests => ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners}/EntityEventListener.java (57%) diff --git a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/ChestOpener.java b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/ChestOpener.java deleted file mode 100644 index 402fac3..0000000 --- a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/ChestOpener.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.jamesdpeters.minecraft.chests; - -import org.bukkit.block.Container; -import org.bukkit.inventory.Inventory; - -public interface ChestOpener { - TileEntityOpener updateState(Inventory inventory, Container chest, TileEntityOpener tileEntityOpener); -} diff --git a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/NMSProvider.java b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/NMSProvider.java index 718a005..2d2daaf 100644 --- a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/NMSProvider.java +++ b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/NMSProvider.java @@ -1,12 +1,6 @@ package com.jamesdpeters.minecraft.chests; -import org.bukkit.entity.ItemFrame; - public interface NMSProvider { - ChestOpener getChestOpener(); MaterialChecker getMaterialChecker(); CraftingProvider getCraftingProvider(); - EntityEventListener getEntityEventListener(); - - void setItemFrameVisible(ItemFrame itemFrame, boolean visible); } diff --git a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/TileEntityOpener.java b/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/TileEntityOpener.java deleted file mode 100644 index 6e4ba0a..0000000 --- a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/TileEntityOpener.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jamesdpeters.minecraft.chests; - -import org.bukkit.entity.HumanEntity; - -import java.util.List; - -public interface TileEntityOpener { - void setViewers(List viewers); -} diff --git a/ChestsPlusPlus_1_17_R1/pom.xml b/ChestsPlusPlus_1_17_R1/pom.xml deleted file mode 100644 index 8cf27ba..0000000 --- a/ChestsPlusPlus_1_17_R1/pom.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.17.1 - - - 4.0.0 - jar - ChestsPlusPlus_1_17_R1 - 1.0-SNAPSHOT - - - - spigot-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 - - - - org.spigotmc - spigot - ${minecraft.version}-R0.1-SNAPSHOT - provided - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.2 - - - 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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/Crafting.java b/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/Crafting.java deleted file mode 100644 index b09c5c4..0000000 --- a/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/Crafting.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_17_R1; - -import com.jamesdpeters.minecraft.chests.CraftingProvider; -import com.jamesdpeters.minecraft.chests.CraftingResult; -import net.minecraft.core.NonNullList; -import net.minecraft.server.level.WorldServer; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.inventory.Container; -import net.minecraft.world.inventory.InventoryCrafting; -import net.minecraft.world.item.crafting.Recipes; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_17_R1.CraftServer; -import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_17_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. - InventoryCrafting inventoryCrafting = new InventoryCrafting(new Container(null, -1) { - @Override - public InventoryView getBukkitView() { - return null; - } - - @Override - public boolean canUse(EntityHuman entityHuman) { - return false; - } - }, 3, 3); - - for (int i = 0; i < items.length; i++) { - inventoryCrafting.setItem(i, CraftItemStack.asNMSCopy(items[i])); - } - - var recipe = ((CraftServer) Bukkit.getServer()).getServer().getCraftingManager().craft(Recipes.a, inventoryCrafting, craftWorld.getHandle()); - - // Generate the resulting ItemStack from the Crafting Matrix - net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.b; - - if (recipe.isPresent()) { - itemStack = recipe.get().a(inventoryCrafting); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, InventoryCrafting inventoryCrafting, WorldServer worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getCraftingManager().c(Recipes.a, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) remainingItems.get(i); - - if (!itemstack1.isEmpty()) { - inventoryCrafting.splitStack(i, 1); - itemstack1 = inventoryCrafting.getItem(i); - } - - if (!itemstack2.isEmpty()) { - if (itemstack1.isEmpty()) { - inventoryCrafting.setItem(i, itemstack2); - } else if (net.minecraft.world.item.ItemStack.equals(itemstack1, itemstack2) && net.minecraft.world.item.ItemStack.matches(itemstack1, itemstack2)) { - itemstack2.add(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_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/EntityEventListener_1_17.java b/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/EntityEventListener_1_17.java deleted file mode 100644 index 9bca68c..0000000 --- a/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/EntityEventListener_1_17.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_17_R1; - -import com.jamesdpeters.minecraft.chests.EntityEventListener; -import org.bukkit.event.EventHandler; -import org.bukkit.event.world.EntitiesLoadEvent; - -public class EntityEventListener_1_17 extends EntityEventListener { - - @EventHandler - public void onEntityLoad(EntitiesLoadEvent event) { - event.getEntities().forEach(this::removeEntity); - } -} diff --git a/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/NMSProviderImpl.java b/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/NMSProviderImpl.java deleted file mode 100644 index 48c00ba..0000000 --- a/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/NMSProviderImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_17_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 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().size() > 0){ - ((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); - } - -} diff --git a/ChestsPlusPlus_1_18_R1/pom.xml b/ChestsPlusPlus_1_18_R1/pom.xml deleted file mode 100644 index 17076a3..0000000 --- a/ChestsPlusPlus_1_18_R1/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.18.1 - - - 4.0.0 - jar - ChestsPlusPlus_1_18_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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/Crafting.java b/ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/Crafting.java deleted file mode 100644 index 8c38c58..0000000 --- a/ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/Crafting.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_18_R1; - -import com.jamesdpeters.minecraft.chests.CraftingProvider; -import com.jamesdpeters.minecraft.chests.CraftingResult; -import net.minecraft.core.NonNullList; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; -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_18_R1.CraftServer; -import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_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 CraftingContainer(new AbstractContainerMenu(null, -1) { - @Override - public InventoryView getBukkitView() { - 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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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().assemble(inventoryCrafting); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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.tagMatches(itemstack1, itemstack2) && 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_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/NMSProviderImpl.java b/ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/NMSProviderImpl.java deleted file mode 100644 index 929a60f..0000000 --- a/ChestsPlusPlus_1_18_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R1/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_18_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().size() > 0){ - ((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); - } - -} diff --git a/ChestsPlusPlus_1_18_R2/pom.xml b/ChestsPlusPlus_1_18_R2/pom.xml deleted file mode 100644 index f39aad3..0000000 --- a/ChestsPlusPlus_1_18_R2/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.18.2 - - - 4.0.0 - jar - ChestsPlusPlus_1_18_R2 - 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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/Crafting.java b/ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/Crafting.java deleted file mode 100644 index df14a70..0000000 --- a/ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/Crafting.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_18_R2; - -import com.jamesdpeters.minecraft.chests.CraftingProvider; -import com.jamesdpeters.minecraft.chests.CraftingResult; -import net.minecraft.core.NonNullList; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; -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_18_R2.CraftServer; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.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 CraftingContainer(new AbstractContainerMenu(null, -1) { - @Override - public InventoryView getBukkitView() { - 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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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().assemble(inventoryCrafting); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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.tagMatches(itemstack1, itemstack2) && 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_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/NMSProviderImpl.java b/ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/NMSProviderImpl.java deleted file mode 100644 index 78f6661..0000000 --- a/ChestsPlusPlus_1_18_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_18_R2/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_18_R2; - -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().size() > 0){ - ((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); - } - -} diff --git a/ChestsPlusPlus_1_19_R1/pom.xml b/ChestsPlusPlus_1_19_R1/pom.xml deleted file mode 100644 index 1d15213..0000000 --- a/ChestsPlusPlus_1_19_R1/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.19 - - - 4.0.0 - jar - ChestsPlusPlus_1_19_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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/Crafting.java b/ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/Crafting.java deleted file mode 100644 index 473c3dc..0000000 --- a/ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/Crafting.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_19_R1; - -import com.jamesdpeters.minecraft.chests.CraftingProvider; -import com.jamesdpeters.minecraft.chests.CraftingResult; -import net.minecraft.core.NonNullList; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; -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_19_R1.CraftServer; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_19_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 CraftingContainer(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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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().assemble(inventoryCrafting); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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.tagMatches(itemstack1, itemstack2) && 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_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/NMSProviderImpl.java b/ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/NMSProviderImpl.java deleted file mode 100644 index 5f0e2a0..0000000 --- a/ChestsPlusPlus_1_19_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R1/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_19_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().size() > 0){ - ((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_1_19_R2/pom.xml b/ChestsPlusPlus_1_19_R2/pom.xml deleted file mode 100644 index 6fdd309..0000000 --- a/ChestsPlusPlus_1_19_R2/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.19.3 - - - 4.0.0 - jar - ChestsPlusPlus_1_19_R2 - 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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/Crafting.java b/ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/Crafting.java deleted file mode 100644 index c438917..0000000 --- a/ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/Crafting.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_19_R2; - -import com.jamesdpeters.minecraft.chests.CraftingProvider; -import com.jamesdpeters.minecraft.chests.CraftingResult; -import net.minecraft.core.NonNullList; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; -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_19_R2.CraftServer; -import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R2.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 CraftingContainer(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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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().assemble(inventoryCrafting); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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.tagMatches(itemstack1, itemstack2) && 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_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/NMSProviderImpl.java b/ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/NMSProviderImpl.java deleted file mode 100644 index b01ad14..0000000 --- a/ChestsPlusPlus_1_19_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R2/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_19_R2; - -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().size() > 0){ - ((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_1_19_R3/pom.xml b/ChestsPlusPlus_1_19_R3/pom.xml deleted file mode 100644 index 446c223..0000000 --- a/ChestsPlusPlus_1_19_R3/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.19.4 - - - 4.0.0 - jar - ChestsPlusPlus_1_19_R3 - 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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/Crafting.java b/ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/Crafting.java deleted file mode 100644 index 03f2924..0000000 --- a/ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/Crafting.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_19_R3; - -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.item.crafting.RecipeType; -import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R3.CraftServer; -import org.bukkit.craftbukkit.v1_19_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R3.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 CraftingContainer(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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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().assemble(inventoryCrafting, RegistryAccess.EMPTY); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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.tagMatches(itemstack1, itemstack2) && 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_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/NMSProviderImpl.java b/ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/NMSProviderImpl.java deleted file mode 100644 index 1f5fe69..0000000 --- a/ChestsPlusPlus_1_19_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_19_R3/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_19_R3; - -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().size() > 0){ - ((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_1_20_R1/pom.xml b/ChestsPlusPlus_1_20_R1/pom.xml deleted file mode 100644 index b730502..0000000 --- a/ChestsPlusPlus_1_20_R1/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.20 - - - 4.0.0 - jar - ChestsPlusPlus_1_20_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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/Crafting.java b/ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/Crafting.java deleted file mode 100644 index 674374b..0000000 --- a/ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/Crafting.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_20_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.RecipeType; -import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R1.CraftServer; -import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_20_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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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().assemble(inventoryCrafting, RegistryAccess.EMPTY); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/NMSProviderImpl.java b/ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/NMSProviderImpl.java deleted file mode 100644 index f7ddf24..0000000 --- a/ChestsPlusPlus_1_20_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R1/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_20_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().size() > 0){ - ((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_1_20_R2/pom.xml b/ChestsPlusPlus_1_20_R2/pom.xml deleted file mode 100644 index 5bb65c0..0000000 --- a/ChestsPlusPlus_1_20_R2/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.20.2 - - - 4.0.0 - jar - ChestsPlusPlus_1_20_R2 - 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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/Crafting.java b/ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/Crafting.java deleted file mode 100644 index cda943c..0000000 --- a/ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/Crafting.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_20_R2; - -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.RecipeType; -import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R2.CraftServer; -import org.bukkit.craftbukkit.v1_20_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R2.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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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(inventoryCrafting, RegistryAccess.EMPTY); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/NMSProviderImpl.java b/ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/NMSProviderImpl.java deleted file mode 100644 index c5f5ae3..0000000 --- a/ChestsPlusPlus_1_20_R2/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R2/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_20_R2; - -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().size() > 0){ - ((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_1_20_R3/pom.xml b/ChestsPlusPlus_1_20_R3/pom.xml deleted file mode 100644 index 8c8bca6..0000000 --- a/ChestsPlusPlus_1_20_R3/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - ChestsPlusPlus-Parent - com.jamesdpeters.minecraft.chests - 1.0-SNAPSHOT - ../pom.xml - - - - 1.20.4 - - - 4.0.0 - jar - ChestsPlusPlus_1_20_R3 - 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 - 16 - - - - - - - \ No newline at end of file diff --git a/ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/Crafting.java b/ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/Crafting.java deleted file mode 100644 index 270b812..0000000 --- a/ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/Crafting.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_20_R3; - -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.RecipeType; -import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R3.CraftServer; -import org.bukkit.craftbukkit.v1_20_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_20_R3.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 recipe = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventoryCrafting, 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(inventoryCrafting, RegistryAccess.EMPTY); - } - - return createItemCraftResult(CraftItemStack.asBukkitCopy(itemStack), inventoryCrafting, craftWorld.getHandle()); - } - - @Override - public Recipe getRecipe(Player player, World world, ItemStack[] items) { - return Bukkit.getCraftingRecipe(items, world); - } - - private CraftingResult createItemCraftResult(ItemStack itemStack, CraftingContainer inventoryCrafting, Level worldServer) { - CraftServer server = (CraftServer) Bukkit.getServer(); - NonNullList remainingItems = server.getServer().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, inventoryCrafting, 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 = (net.minecraft.world.item.ItemStack) 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_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/NMSProviderImpl.java b/ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/NMSProviderImpl.java deleted file mode 100644 index ff845a0..0000000 --- a/ChestsPlusPlus_1_20_R3/src/main/java/com/jamesdpeters/minecraft/chests/v1_20_R3/NMSProviderImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.v1_20_R3; - -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().size() > 0){ - ((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_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/MaterialChecker_1_17_R1.java b/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/MaterialChecker_1_21_R1.java similarity index 77% rename from ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/MaterialChecker_1_17_R1.java rename to ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/MaterialChecker_1_21_R1.java index ab72966..d546215 100644 --- a/ChestsPlusPlus_1_17_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_17_R1/MaterialChecker_1_17_R1.java +++ b/ChestsPlusPlus_1_21_R1/src/main/java/com/jamesdpeters/minecraft/chests/v1_21_R1/MaterialChecker_1_21_R1.java @@ -1,4 +1,4 @@ -package com.jamesdpeters.minecraft.chests.v1_17_R1; +package com.jamesdpeters.minecraft.chests.v1_21_R1; import com.jamesdpeters.minecraft.chests.BaseMaterialChecker; import com.jamesdpeters.minecraft.chests.MaterialChecker; @@ -7,14 +7,11 @@ import org.bukkit.inventory.ItemStack; import java.util.List; -/** - * Material Checker for items available in 1.17+ - */ -public class MaterialChecker_1_17_R1 extends MaterialChecker { +public class MaterialChecker_1_21_R1 extends MaterialChecker { private final BaseMaterialChecker baseMaterialChecker; - public MaterialChecker_1_17_R1(){ + public MaterialChecker_1_21_R1(){ baseMaterialChecker = new BaseMaterialChecker(); } 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 index 9cf9341..cfa1f50 100644 --- 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 @@ -1,34 +1,13 @@ 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(); + return new MaterialChecker_1_21_R1(); } @Override @@ -36,14 +15,4 @@ public class NMSProviderImpl implements NMSProvider { 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 bfb2f8f..5f713c7 100644 --- a/ChestsPlusPlus_Main/pom.xml +++ b/ChestsPlusPlus_Main/pom.xml @@ -36,7 +36,7 @@ org.spigotmc spigot-api - 1.17.1-R0.1-SNAPSHOT + 1.21-R0.1-SNAPSHOT provided @@ -79,76 +79,6 @@ compile - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_20_R3 - 1.0-SNAPSHOT - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_20_R2 - 1.0-SNAPSHOT - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_20_R1 - 1.0-SNAPSHOT - jar - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_19_R3 - 1.0-SNAPSHOT - jar - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_19_R2 - 1.0-SNAPSHOT - jar - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_19_R1 - 1.0-SNAPSHOT - jar - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_18_R2 - 1.0-SNAPSHOT - jar - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_18_R1 - 1.0-SNAPSHOT - jar - compile - - - - com.jamesdpeters.minecraft.chests - ChestsPlusPlus_1_17_R1 - 1.0-SNAPSHOT - jar - compile - - com.jamesdpeters.minecraft.chests ChestsPlusPlus-API diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java index 8edd5f0..347a3bb 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java @@ -7,6 +7,7 @@ import com.jamesdpeters.minecraft.chests.commands.ChestsPlusPlusCommand; import com.jamesdpeters.minecraft.chests.crafting.Crafting; import com.jamesdpeters.minecraft.chests.lang.LangFileProperties; import com.jamesdpeters.minecraft.chests.listeners.AutoCrafterListener; +import com.jamesdpeters.minecraft.chests.listeners.EntityEventListener; import com.jamesdpeters.minecraft.chests.listeners.HopperFilterListener; import com.jamesdpeters.minecraft.chests.listeners.InventoryListener; import com.jamesdpeters.minecraft.chests.listeners.LinkedChestHopperListener; @@ -169,8 +170,8 @@ public class ChestsPlusPlus extends JavaPlugin { } }); - getServer().getPluginManager().registerEvents(ApiSpecific.getNmsProvider().getEntityEventListener(), this); - Bukkit.getWorlds().forEach(world -> ApiSpecific.getNmsProvider().getEntityEventListener().fixEntities(world)); + getServer().getPluginManager().registerEvents(new EntityEventListener(), this); + Bukkit.getWorlds().forEach(EntityEventListener::fixEntities); getLogger().info("Chests++ enabled!"); }, 1); } diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/ApiSpecific.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/ApiSpecific.java index f9ea442..cbcdea5 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/ApiSpecific.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/api/ApiSpecific.java @@ -1,7 +1,6 @@ package com.jamesdpeters.minecraft.chests.api; import com.jamesdpeters.minecraft.chests.Api; -import com.jamesdpeters.minecraft.chests.ChestOpener; import com.jamesdpeters.minecraft.chests.MaterialChecker; import com.jamesdpeters.minecraft.chests.NMSProvider; import lombok.Getter; @@ -12,17 +11,14 @@ public class ApiSpecific { @Getter private static MaterialChecker materialChecker; @Getter - private static ChestOpener chestOpener; - @Getter private static NMSProvider nmsProvider; public static boolean init(Plugin plugin) { nmsProvider = Api.init(plugin); if (nmsProvider != null) { materialChecker = nmsProvider.getMaterialChecker(); - chestOpener = nmsProvider.getChestOpener(); } - return (nmsProvider != null && materialChecker != null && chestOpener != null); + return (nmsProvider != null && materialChecker != null); } } diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/ItemTypeUtil.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/ItemTypeUtil.java index d8a05f5..d03c85e 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/ItemTypeUtil.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/filters/ItemTypeUtil.java @@ -58,7 +58,7 @@ public class ItemTypeUtil { tags.add(Tag.ITEMS_BANNERS); tags.add(Tag.ITEMS_BOATS); tags.add(Tag.ITEMS_FISHES); - tags.add(Tag.ITEMS_MUSIC_DISCS); + tags.add(Tag.ITEMS_CREEPER_DROP_MUSIC_DISCS); tags.add(Tag.ITEMS_COALS); tags.add(Tag.ITEMS_ARROWS); } diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/interfaces/InventoryViewImpl.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/interfaces/InventoryViewImpl.java deleted file mode 100644 index 54bda9f..0000000 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/interfaces/InventoryViewImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.jamesdpeters.minecraft.chests.interfaces; - -import org.bukkit.entity.HumanEntity; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryView; -import org.jetbrains.annotations.NotNull; - -public class InventoryViewImpl extends InventoryView { - - Inventory top, bottom; - HumanEntity humanEntity; - - public InventoryViewImpl(Inventory top, Inventory bottom, HumanEntity humanEntity){ - this.top = top; - this.bottom = bottom; - this.humanEntity = humanEntity; - } - - @NotNull - @Override - public Inventory getTopInventory() { - return top; - } - - @NotNull - @Override - public Inventory getBottomInventory() { - return bottom; - } - - @NotNull - @Override - public HumanEntity getPlayer() { - return humanEntity; - } - - @NotNull - @Override - public InventoryType getType() { - return InventoryType.WORKBENCH; - } - - @NotNull - @Override - public String getTitle() { - return "ChestsPlusPlusInventoryView"; - } -} diff --git a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/EntityEventListener.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/EntityEventListener.java similarity index 57% rename from ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/EntityEventListener.java rename to ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/EntityEventListener.java index 17f4e44..61e82a1 100644 --- a/ChestsPlusPlusAPI/src/main/java/com/jamesdpeters/minecraft/chests/EntityEventListener.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/EntityEventListener.java @@ -1,57 +1,67 @@ -package com.jamesdpeters.minecraft.chests; +package com.jamesdpeters.minecraft.chests.listeners; +import com.jamesdpeters.minecraft.chests.PluginConfig; +import com.jamesdpeters.minecraft.chests.Values; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Hopper; import org.bukkit.entity.Entity; import org.bukkit.entity.ItemFrame; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.world.EntitiesLoadEvent; import org.bukkit.persistence.PersistentDataType; import java.util.Arrays; import java.util.stream.Stream; -public abstract class EntityEventListener implements Listener { +public class EntityEventListener implements Listener { - protected void fixEntities(Chunk chunk) { + @EventHandler + void onEntityLoad(EntitiesLoadEvent event) { + event.getEntities().forEach(EntityEventListener::removeEntity); + } + + protected static void fixEntities(Chunk chunk) { removeEntities(chunk); setItemFrames(chunk); } - public void fixEntities(World world) { + public static void fixEntities(World world) { removeEntities(world); setItemFrames(world); } - private void removeEntities(World world) { - world.getEntities().forEach(this::removeEntity); + private static void removeEntities(World world) { + world.getEntities().forEach(EntityEventListener::removeEntity); } - private void removeEntities(Chunk chunk) { + private static void removeEntities(Chunk chunk) { for (Entity entity : chunk.getEntities()) { removeEntity(entity); } } - protected void removeEntity(Entity entity) { + protected static void removeEntity(Entity entity) { Integer val = entity.getPersistentDataContainer().get(Values.Instance().PluginKey, PersistentDataType.INTEGER); if (val != null && val == 1) entity.remove(); } - private void setItemFrames(World world) { + private static void setItemFrames(World world) { setItemFrames(world.getEntities().stream()); } - private void setItemFrames(Chunk chunk) { + private static void setItemFrames(Chunk chunk) { setItemFrames(Arrays.stream(chunk.getEntities())); } - private void setItemFrames(Stream entityStream) { + private static void setItemFrames(Stream entityStream) { entityStream // Filter Item frames that are connected to Hoppers. .filter(entity -> (entity instanceof ItemFrame && entity.getLocation().getBlock().getRelative(((ItemFrame) entity).getAttachedFace()).getState() instanceof Hopper)) .forEach(entity -> ((ItemFrame) entity).setVisible(!PluginConfig.INVISIBLE_FILTER_ITEM_FRAMES.get())); } + } diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/HopperFilterListener.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/HopperFilterListener.java index 246fcd9..a12753b 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/HopperFilterListener.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/listeners/HopperFilterListener.java @@ -1,13 +1,12 @@ package com.jamesdpeters.minecraft.chests.listeners; import com.jamesdpeters.minecraft.chests.ChestsPlusPlus; -import com.jamesdpeters.minecraft.chests.api.ApiSpecific; +import com.jamesdpeters.minecraft.chests.PluginConfig; import com.jamesdpeters.minecraft.chests.filters.HopperFilter; import com.jamesdpeters.minecraft.chests.lang.Message; import com.jamesdpeters.minecraft.chests.misc.ServerType; import com.jamesdpeters.minecraft.chests.misc.Utils; import com.jamesdpeters.minecraft.chests.serialize.Config; -import com.jamesdpeters.minecraft.chests.PluginConfig; import com.jamesdpeters.minecraft.chests.serialize.SpigotConfig; import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage; import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorageType; @@ -119,7 +118,7 @@ public class HopperFilterListener implements Listener { Rotation rotation = itemFrame.getRotation(); //Set ItemFrame invisible based on config. - ApiSpecific.getNmsProvider().setItemFrameVisible(itemFrame, !PluginConfig.INVISIBLE_FILTER_ITEM_FRAMES.get()); + itemFrame.setVisible(!PluginConfig.INVISIBLE_FILTER_ITEM_FRAMES.get()); //ItemFrame event acts weird, it returns the values of the itemframe *before* the event. So we have to calculate what the next state will be. if (!itemFrame.getItem().getType().equals(Material.AIR)) rotation = rotation.rotateClockwise(); diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Utils.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Utils.java index f99e5a5..4d92ac6 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Utils.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/misc/Utils.java @@ -1,12 +1,11 @@ package com.jamesdpeters.minecraft.chests.misc; import com.jamesdpeters.minecraft.chests.ChestsPlusPlus; -import com.jamesdpeters.minecraft.chests.api.ApiSpecific; +import com.jamesdpeters.minecraft.chests.PluginConfig; import com.jamesdpeters.minecraft.chests.filters.Filter; import com.jamesdpeters.minecraft.chests.filters.HopperFilter; import com.jamesdpeters.minecraft.chests.interfaces.VirtualInventoryHolder; import com.jamesdpeters.minecraft.chests.serialize.LocationInfo; -import com.jamesdpeters.minecraft.chests.PluginConfig; import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -18,7 +17,7 @@ import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.Container; +import org.bukkit.block.Lidded; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; @@ -30,7 +29,6 @@ import org.bukkit.util.Vector; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; @@ -59,18 +57,26 @@ public class Utils { private static void containerAnimation(Inventory inventory, LocationInfo location, boolean open) { if (location != null && Utils.isLocationChunkLoaded(location.getLocation())) { Block block = location.getLocation().getBlock(); - if (block.getState() instanceof Container chest) { + if (block.getState() instanceof Lidded chest) { if (open) { - location.setTileEntityOpener(ApiSpecific.getChestOpener().updateState(inventory, chest, location.getTileEntityOpener())); + checkChestState(chest, inventory); } else { Bukkit.getScheduler().scheduleSyncDelayedTask(ChestsPlusPlus.PLUGIN, () -> { - location.setTileEntityOpener(ApiSpecific.getChestOpener().updateState(inventory, chest, location.getTileEntityOpener())); + checkChestState(chest, inventory); }, 1); } } } } + private static void checkChestState(Lidded lidded, Inventory inventory) { + if (!inventory.getViewers().isEmpty()) { + lidded.open(); + } else { + lidded.close(); + } + } + public static void closeStorageInventory(ChestLinkStorage storage) { storage.getLocations().forEach(locationInfo -> { Location location = locationInfo.getLocation(); diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/serialize/LocationInfo.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/serialize/LocationInfo.java index df38bbb..a0bf2c5 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/serialize/LocationInfo.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/serialize/LocationInfo.java @@ -1,6 +1,5 @@ package com.jamesdpeters.minecraft.chests.serialize; -import com.jamesdpeters.minecraft.chests.TileEntityOpener; import org.bukkit.Location; import org.bukkit.block.Sign; import org.bukkit.configuration.serialization.ConfigurationSerializable; @@ -20,7 +19,6 @@ public class LocationInfo implements ConfigurationSerializable { private final Location location; private Location signLocation; private ArmorStand itemStand, blockStand, toolItemStand; - private TileEntityOpener tileEntityOpener; @Override public Map serialize() { @@ -80,14 +78,6 @@ public class LocationInfo implements ConfigurationSerializable { this.signLocation = signLocation; } - public void setTileEntityOpener(TileEntityOpener tileEntityOpener) { - this.tileEntityOpener = tileEntityOpener; - } - - public TileEntityOpener getTileEntityOpener() { - return tileEntityOpener; - } - public static List convert(List locationList) { List locationInfos = new ArrayList<>(); for (Location location : locationList) { diff --git a/ChestsPlusPlus_Main/src/main/resources/lang/en_GB.properties b/ChestsPlusPlus_Main/src/main/resources/lang/en_GB.properties index f8f9949..e003921 100644 --- a/ChestsPlusPlus_Main/src/main/resources/lang/en_GB.properties +++ b/ChestsPlusPlus_Main/src/main/resources/lang/en_GB.properties @@ -1,4 +1,4 @@ -# Chests++ Language File (Version 2.12-Release) +# Chests++ Language File (Version 2.13-Release) # NOTE: This file gets replaced when the plugin launches! If you want to make modifications create a copy first! # To create a new language file simply create a copy of this file and rename it to your desired choice for example 'en_US.properties' # It should be located in the 'lang' folder diff --git a/pom.xml b/pom.xml index 037edf3..b6900d9 100644 --- a/pom.xml +++ b/pom.xml @@ -17,15 +17,6 @@ ChestsPlusPlusAPI ChestsPlusPlus_1_21_R1 - ChestsPlusPlus_1_20_R3 - ChestsPlusPlus_1_20_R2 - ChestsPlusPlus_1_20_R1 - ChestsPlusPlus_1_19_R3 - ChestsPlusPlus_1_19_R2 - ChestsPlusPlus_1_19_R1 - ChestsPlusPlus_1_18_R2 - ChestsPlusPlus_1_18_R1 - ChestsPlusPlus_1_17_R1 ChestsPlusPlus_Main