From 51b9f118ab42fcb1458d226a095949f66966b091 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sat, 27 Apr 2019 13:44:47 +0200 Subject: [PATCH] Remove unused PlayerInventory NMS stuff --- .../massivecraft/massivecore/MassiveCore.java | 4 -- .../editor/CommandEditItemStacksOpen.java | 3 +- .../massivecore/mixin/MixinInventory.java | 35 ------------ .../nms/NmsPlayerInventoryCreate.java | 32 ----------- .../nms/NmsPlayerInventoryCreate17R4P.java | 55 ------------------- .../massivecore/util/InventoryUtil.java | 7 +-- 6 files changed, 4 insertions(+), 132 deletions(-) delete mode 100644 src/com/massivecraft/massivecore/mixin/MixinInventory.java delete mode 100644 src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate.java delete mode 100644 src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate17R4P.java diff --git a/src/com/massivecraft/massivecore/MassiveCore.java b/src/com/massivecraft/massivecore/MassiveCore.java index dbb80908..fc2d9f58 100644 --- a/src/com/massivecraft/massivecore/MassiveCore.java +++ b/src/com/massivecraft/massivecore/MassiveCore.java @@ -66,7 +66,6 @@ import com.massivecraft.massivecore.mixin.MixinCommand; import com.massivecraft.massivecore.mixin.MixinDisplayName; import com.massivecraft.massivecore.mixin.MixinEvent; import com.massivecraft.massivecore.mixin.MixinGamemode; -import com.massivecraft.massivecore.mixin.MixinInventory; import com.massivecraft.massivecore.mixin.MixinKick; import com.massivecraft.massivecore.mixin.MixinLog; import com.massivecraft.massivecore.mixin.MixinMessage; @@ -87,7 +86,6 @@ import com.massivecraft.massivecore.nms.NmsEntityDamageEvent; import com.massivecraft.massivecore.nms.NmsEntityGet; import com.massivecraft.massivecore.nms.NmsItemStackTooltip; import com.massivecraft.massivecore.nms.NmsPermissions; -import com.massivecraft.massivecore.nms.NmsPlayerInventoryCreate; import com.massivecraft.massivecore.nms.NmsRecipe; import com.massivecraft.massivecore.nms.NmsSkullMeta; import com.massivecraft.massivecore.ps.PS; @@ -308,7 +306,6 @@ public class MassiveCore extends MassivePlugin NmsEntityGet.class, NmsItemStackTooltip.class, NmsPermissions.class, - NmsPlayerInventoryCreate.class, NmsSkullMeta.class, NmsRecipe.class ); @@ -369,7 +366,6 @@ public class MassiveCore extends MassivePlugin MixinCommand.class, MixinDisplayName.class, MixinGamemode.class, - MixinInventory.class, MixinKick.class, MixinLog.class, MixinMessage.class, diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacksOpen.java b/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacksOpen.java index 1ec276d1..ad94907d 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacksOpen.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacksOpen.java @@ -5,7 +5,6 @@ import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; -import com.massivecraft.massivecore.mixin.MixinInventory; import com.massivecraft.massivecore.util.InventoryUtil; import com.massivecraft.massivecore.util.MUtil; import org.bukkit.Bukkit; @@ -119,7 +118,7 @@ public class CommandEditItemStacksOpen extends CommandEditItemStacksAbstract< if (itemStacks == null) return null; // Create Ret - Inventory ret = MixinInventory.get().createInventory(me, 54, this.getProperty().getName()); + Inventory ret = Bukkit.createInventory(me, 54, this.getPropertyName()); // Fill Ret for (int i = 0; i < itemStacks.size(); i++) diff --git a/src/com/massivecraft/massivecore/mixin/MixinInventory.java b/src/com/massivecraft/massivecore/mixin/MixinInventory.java deleted file mode 100644 index 56ad7130..00000000 --- a/src/com/massivecraft/massivecore/mixin/MixinInventory.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.massivecraft.massivecore.mixin; - -import com.massivecraft.massivecore.nms.NmsPlayerInventoryCreate; -import org.bukkit.Bukkit; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.PlayerInventory; - -public class MixinInventory extends Mixin -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static MixinInventory d = new MixinInventory(); - private static MixinInventory i = d; - public static MixinInventory get() { return i; } - - // -------------------------------------------- // - // METHODS - // -------------------------------------------- // - - public PlayerInventory createPlayerInventory() - { - NmsPlayerInventoryCreate nmsPlayerInventory = NmsPlayerInventoryCreate.get(); - if ( ! nmsPlayerInventory.isAvailable()) return null; - return nmsPlayerInventory.create(); - } - - public Inventory createInventory(InventoryHolder holder, int size, String title) - { - return Bukkit.createInventory(holder, size, title); - } - -} diff --git a/src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate.java b/src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate.java deleted file mode 100644 index f137213f..00000000 --- a/src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.massivecraft.massivecore.nms; - -import com.massivecraft.massivecore.mixin.Mixin; -import org.bukkit.inventory.PlayerInventory; - -public class NmsPlayerInventoryCreate extends Mixin -{ - // -------------------------------------------- // - // DEFAULT - // -------------------------------------------- // - - private static NmsPlayerInventoryCreate d = new NmsPlayerInventoryCreate().setAlternatives( - NmsPlayerInventoryCreate17R4P.class - ); - - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static NmsPlayerInventoryCreate i = d; - public static NmsPlayerInventoryCreate get() { return i; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public PlayerInventory create() - { - throw notImplemented(); - } - -} diff --git a/src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate17R4P.java b/src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate17R4P.java deleted file mode 100644 index 43d43aa1..00000000 --- a/src/com/massivecraft/massivecore/nms/NmsPlayerInventoryCreate17R4P.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.massivecraft.massivecore.nms; - -import com.massivecraft.massivecore.particleeffect.ReflectionUtils; -import com.massivecraft.massivecore.util.ReflectionUtil; -import org.bukkit.inventory.PlayerInventory; - -import java.lang.reflect.Constructor; - -public class NmsPlayerInventoryCreate17R4P extends NmsPlayerInventoryCreate -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static NmsPlayerInventoryCreate17R4P i = new NmsPlayerInventoryCreate17R4P(); - public static NmsPlayerInventoryCreate17R4P get () { return i; } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private Class classNmsPlayerInventory; - private Class classNmsEntityHuman; - private Constructor constructorNmsPlayerInventory; - - private Class classCraftInventoryPlayer; - private Constructor constructorCraftInventoryPlayer; - - // -------------------------------------------- // - // SETUP - // -------------------------------------------- // - - @Override - public void setup() throws Throwable - { - this.classNmsPlayerInventory = ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass("PlayerInventory"); - this.classNmsEntityHuman = ReflectionUtils.PackageType.MINECRAFT_SERVER.getClass("EntityHuman"); - this.constructorNmsPlayerInventory = ReflectionUtils.getConstructor(this.classNmsPlayerInventory, this.classNmsEntityHuman); - - this.classCraftInventoryPlayer = ReflectionUtils.PackageType.CRAFTBUKKIT_INVENTORY.getClass("CraftInventoryPlayer"); - this.constructorCraftInventoryPlayer = ReflectionUtils.getConstructor(this.classCraftInventoryPlayer, this.classNmsPlayerInventory); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public PlayerInventory create() - { - Object nmsInventory = ReflectionUtil.invokeConstructor(this.constructorNmsPlayerInventory, (Object)null); - return ReflectionUtil.invokeConstructor(this.constructorCraftInventoryPlayer, nmsInventory); - } - -} diff --git a/src/com/massivecraft/massivecore/util/InventoryUtil.java b/src/com/massivecraft/massivecore/util/InventoryUtil.java index b3b64461..1d74c5a6 100644 --- a/src/com/massivecraft/massivecore/util/InventoryUtil.java +++ b/src/com/massivecraft/massivecore/util/InventoryUtil.java @@ -5,7 +5,6 @@ import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.comparator.ComparatorComparable; import com.massivecraft.massivecore.comparator.ComparatorEntryValue; import com.massivecraft.massivecore.event.EventMassiveCoreLorePriority; -import com.massivecraft.massivecore.mixin.MixinInventory; import com.massivecraft.massivecore.predicate.PredicateStringStartsWith; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -963,15 +962,15 @@ public class InventoryUtil Inventory ret = null; if (inventory instanceof PlayerInventory && playerSupport) { - ret = MixinInventory.get().createPlayerInventory(); + throw new UnsupportedOperationException("Can't clone player inventories."); } else { InventoryHolder holder = inventory.getHolder(); int size = inventory.getSize(); if (inventory instanceof PlayerInventory) size = SIZE_PLAYER_STORAGE; - String title = ""; - ret = MixinInventory.get().createInventory(holder, size, title); + String title = inventory.getType().getDefaultTitle(); + ret = Bukkit.createInventory(holder, size, title); } // Fill