diff --git a/NMS/NMS-v1_21_0/pom.xml b/NMS/NMS-v1_21_0/pom.xml deleted file mode 100644 index 4f480782..00000000 --- a/NMS/NMS-v1_21_0/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - 4.0.0 - - - com.craftaro - CraftaroCore-Modules - 3.4.0-SNAPSHOT - ../../pom.xml - - CraftaroCore-NMS-v1_21_0 - - - 21 - 21 - - 1.21-R0.1-SNAPSHOT - - - - - - net.md-5 - specialsource-maven-plugin - 2.0.3 - - - - remap-obf - package - - remap - - - - org.spigotmc:minecraft-server:${nms.ver}:txt:maps-mojang - true - org.spigotmc:spigot:${nms.ver}:jar:remapped-mojang - true - remapped-obf - - - - - remap-spigot - package - - remap - - - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:${nms.ver}:csrg:maps-spigot - org.spigotmc:spigot:${nms.ver}:jar:remapped-obf - - - - - - - - - - - org.spigotmc - spigot - ${nms.ver} - remapped-mojang - provided - - - - - ${project.groupId} - CraftaroCore-NMS-API - ${project.version} - provided - - - - ${project.groupId} - CraftaroCore-Compatibility - ${project.version} - provided - - - diff --git a/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilCore.java b/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilCore.java deleted file mode 100644 index 1cf9d982..00000000 --- a/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilCore.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.craftaro.core.nms.v1_21_0.anvil; - -import com.craftaro.core.nms.anvil.CustomAnvil; -import net.minecraft.server.level.ServerPlayer; -import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.inventory.InventoryHolder; - -public class AnvilCore implements com.craftaro.core.nms.anvil.AnvilCore { - @Override - public CustomAnvil createAnvil(Player player) { - ServerPlayer p = ((CraftPlayer) player).getHandle(); - return new AnvilView(p.nextContainerCounter(), p, null); - } - - @Override - public CustomAnvil createAnvil(Player player, InventoryHolder holder) { - ServerPlayer p = ((CraftPlayer) player).getHandle(); - return new AnvilView(p.nextContainerCounter(), p, holder); - } -} diff --git a/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilInventoryCustom.java b/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilInventoryCustom.java deleted file mode 100644 index f8fa5135..00000000 --- a/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilInventoryCustom.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.craftaro.core.nms.v1_21_0.anvil; - -import net.minecraft.world.Container; -import net.minecraft.world.inventory.AnvilMenu; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryAnvil; -import org.bukkit.inventory.InventoryHolder; - -public class AnvilInventoryCustom extends CraftInventoryAnvil { - final InventoryHolder holder; - - public AnvilInventoryCustom(InventoryHolder holder, Location location, Container inventory, Container resultInventory, AnvilMenu container) { - super(location, inventory, resultInventory, container); - - this.holder = holder; - } - - @Override - public InventoryHolder getHolder() { - return this.holder; - } -} diff --git a/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilView.java b/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilView.java deleted file mode 100644 index 8530a82c..00000000 --- a/NMS/NMS-v1_21_0/src/main/java/com/craftaro/core/nms/v1_21_0/anvil/AnvilView.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.craftaro.core.nms.v1_21_0.anvil; - -import com.craftaro.core.nms.anvil.CustomAnvil; -import com.craftaro.core.nms.anvil.methods.AnvilTextChange; -import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.contents.TranslatableContents; -import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.AnvilMenu; -import net.minecraft.world.inventory.ContainerLevelAccess; -import net.minecraft.world.inventory.MenuType; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryView; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; - -import java.lang.reflect.Field; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class AnvilView extends AnvilMenu implements CustomAnvil { - private final ServerPlayer entity; - private final Inventory inventory; - private String customTitle = "Repairing"; - private int cost = -1; - private boolean canUse = true; - private AnvilTextChange textChange; - - static Field mc_Container_title; - static Field mc_ContainerAnvil_bukkitEntity; - - static { - try { - mc_Container_title = AbstractContainerMenu.class.getDeclaredField("title"); - mc_Container_title.setAccessible(true); - - mc_ContainerAnvil_bukkitEntity = AnvilMenu.class.getDeclaredField("bukkitEntity"); - mc_ContainerAnvil_bukkitEntity.setAccessible(true); - } catch (Exception ex) { - Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex); - } - } - - public AnvilView(int id, ServerPlayer entity, InventoryHolder holder) { - super(entity.nextContainerCounter(), entity.getInventory(), ContainerLevelAccess.create(entity.level(), new BlockPos(0, 0, 0))); - - this.setTitle(MutableComponent.create(new TranslatableContents(this.customTitle != null ? this.customTitle : "", this.customTitle != null ? this.customTitle : "", new Object[0]))); - this.checkReachable = false; - this.entity = entity; - - if (holder != null) { - this.inventory = getBukkitView(entity, holder).getTopInventory(); - } else { - this.inventory = getBukkitView().getTopInventory(); - } - } - - public CraftInventoryView getBukkitView(Player player, InventoryHolder holder) { - try { - AnvilInventoryCustom craftInventory = new AnvilInventoryCustom(holder, - new Location(this.entity.level().getWorld(), 0, 0, 0), - this.inputSlots, - this.resultSlots, - this); - CraftInventoryView view = new CraftInventoryView(player.getBukkitEntity(), craftInventory, this); - mc_ContainerAnvil_bukkitEntity.set(this, view); - - return view; - } catch (Exception ex) { - Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex); - } catch (NoSuchMethodError err) { - //1.21 support - - } - - return getBukkitView(); - } - - @Override - public boolean stillValid(Player entityhuman) { - return this.canUse; - } - - @Override - public void broadcastFullState() { - super.broadcastFullState(); - - if (this.cost >= 0) { - this.setLevelCost(this.cost); - } - - this.textChange.onChange(); - } - - @Override - public void update() { - broadcastFullState(); - } - - @Override - public String getRenameText() { - return this.itemName; - } - - @Override - public void setRenameText(String text) { - this.setItemName(text); - } - - @Override - public void setOnChange(AnvilTextChange handler) { - this.textChange = handler; - } - - @Override - public String getCustomTitle() { - return this.customTitle; - } - - @Override - public void setCustomTitle(String title) { - this.customTitle = title; - - try { - mc_Container_title.set(this, MutableComponent.create(new TranslatableContents(this.customTitle != null ? this.customTitle : "", this.customTitle != null ? this.customTitle : "", new Object[0]))); - } catch (Exception ex) { - Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Error", ex); - } - } - - @Override - public void setLevelCost(int cost) { - this.cost = cost; - } - - @Override - public int getLevelCost() { - if (this.cost >= 0) { - return this.cost; - } - - return this.getLevelCost(); - } - - @Override - public void setCanUse(boolean bool) { - this.canUse = bool; - } - - @Override - public ItemStack getLeftInput() { - return this.inventory.getItem(0); - } - - @Override - public ItemStack getRightInput() { - return this.inventory.getItem(1); - } - - @Override - public ItemStack getOutput() { - return this.inventory.getItem(2); - } - - @Override - public void setLeftInput(ItemStack item) { - this.inventory.setItem(0, item); - } - - @Override - public void setRightInput(ItemStack item) { - this.inventory.setItem(1, item); - } - - @Override - public void setOutput(ItemStack item) { - this.inventory.setItem(2, item); - } - - @Override - public Inventory getInventory() { - return this.inventory; - } - - @Override - public void open() { - // Send the packet - this.entity.connection.send(new ClientboundOpenScreenPacket(super.containerId, MenuType.ANVIL, MutableComponent.create(new TranslatableContents(this.customTitle != null ? this.customTitle : "", this.customTitle != null ? this.customTitle : "", new Object[0])))); - - // Set their active container to this anvil - this.entity.containerMenu = this; - - // Add the slot listener - this.entity.initMenu(this.entity.containerMenu); - } -} diff --git a/NMS/NMS-v1_21_R1/pom.xml b/NMS/NMS-v1_21_R1/pom.xml index 9f87775f..5b7bddea 100644 --- a/NMS/NMS-v1_21_R1/pom.xml +++ b/NMS/NMS-v1_21_R1/pom.xml @@ -62,13 +62,6 @@ - - ${project.version} - CraftaroCore-NMS-v1_21_0 - ${project.groupId} - compile - - org.spigotmc diff --git a/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilCore.java b/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilCore.java index 61d807b0..1418684a 100644 --- a/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilCore.java +++ b/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilCore.java @@ -16,19 +16,7 @@ public CustomAnvil createAnvil(Player player) { @Override public CustomAnvil createAnvil(Player player, InventoryHolder holder) { - try { - ServerPlayer p = ((CraftPlayer) player).getHandle(); - return new AnvilView(p.nextContainerCounter(), p, holder); - } catch (NoClassDefFoundError e) { - //1.21 support - try { - Class clazz = Class.forName("com.craftaro.core.nms.v1_21_0.anvil.AnvilCore"); - Object anvilCore = clazz.newInstance(); - - return (CustomAnvil) anvilCore.getClass().getMethod("createAnvil", Player.class, InventoryHolder.class).invoke(anvilCore, player, holder); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } + ServerPlayer p = ((CraftPlayer) player).getHandle(); + return new AnvilView(p.nextContainerCounter(), p, holder); } } diff --git a/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilView.java b/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilView.java index a02dc94b..484792a0 100644 --- a/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilView.java +++ b/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/anvil/AnvilView.java @@ -75,22 +75,6 @@ public CraftAbstractInventoryView getBukkitView(Player player, InventoryHolder h return view; } catch (Exception ex) { Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex); - } catch (NoSuchMethodError err) { - //1.21 support - try { - Class clazz = Class.forName("com.craftaro.core.nms.v1_21_0.anvil.AnvilInventoryCustom"); - Object craftInventory = clazz.getConstructor(InventoryHolder.class, Location.class, net.minecraft.world.Container.class, net.minecraft.world.Container.class, AnvilMenu.class) - .newInstance(holder, new Location(this.entity.level().getWorld(), 0, 0, 0), this.inputSlots, this.resultSlots, this); - - Class craftInventoryViewClass = Class.forName("org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryView"); - //(HumanEntity player, Inventory viewing, AbstractContainerMenu container) - Object view = craftInventoryViewClass.getConstructor(HumanEntity.class, Inventory.class, AbstractContainerMenu.class).newInstance(player.getBukkitEntity(), (Inventory) craftInventory, this); - mc_ContainerAnvil_bukkitEntity.set(this, view); - - return (CraftAbstractInventoryView) view; - } catch (Exception ex) { - Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex); - } } return getBukkitView(); diff --git a/pom.xml b/pom.xml index 15a2a1f5..f5034c06 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,6 @@ NMS/NMS NMS/NMS-API NMS/NMS-v1_21_R1 - NMS/NMS-v1_21_0 NMS/NMS-v1_20_R4 NMS/NMS-v1_20_R3 NMS/NMS-v1_20_R2