Fix ItemStack serializer being unable to serialize some items
Fix PlayerDisguise using code I forgot to use, instead of real code
This commit is contained in:
		| @@ -62,7 +62,6 @@ public abstract class Disguise { | |||||||
|     private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers(); |     private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers(); | ||||||
|     private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); |     private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); | ||||||
|     private boolean mobsIgnoreDisguise; |     private boolean mobsIgnoreDisguise; | ||||||
|     private boolean showName; |  | ||||||
|     private transient BukkitTask task; |     private transient BukkitTask task; | ||||||
|     private Runnable velocityRunnable; |     private Runnable velocityRunnable; | ||||||
|     private boolean velocitySent = DisguiseConfig.isVelocitySent(); |     private boolean velocitySent = DisguiseConfig.isVelocitySent(); | ||||||
| @@ -666,21 +665,6 @@ public abstract class Disguise { | |||||||
|         setViewSelfDisguise(selfDisguiseVisible); |         setViewSelfDisguise(selfDisguiseVisible); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Returns true if the entity's name is showing through the disguise |  | ||||||
|      * |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     public boolean isShowName() { |  | ||||||
|         return showName; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public Disguise setShowName(boolean showName) { |  | ||||||
|         this.showName = showName; |  | ||||||
|  |  | ||||||
|         return this; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public boolean isSoundsReplaced() { |     public boolean isSoundsReplaced() { | ||||||
|         return replaceSounds; |         return replaceSounds; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -199,7 +199,7 @@ public class PlayerDisguise extends TargetedDisguise { | |||||||
|             name = name.substring(0, 16); |             name = name.substring(0, 16); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (isDisguiseInUse() && isShowName()) { |         if (isDisguiseInUse() && isNameVisible()) { | ||||||
|             if (stopDisguise()) { |             if (stopDisguise()) { | ||||||
|                 playerName = name; |                 playerName = name; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -64,6 +64,11 @@ public class ParamInfoItemStack extends ParamInfoEnum { | |||||||
|             return name; |             return name; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         // If its not a CraftItemStack | ||||||
|  |         if (item.getClass().getSimpleName().equals("ItemStack") && item.hasItemMeta()) { | ||||||
|  |             item = ReflectionManager.getCraftItem(item); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         String itemName = ReflectionManager.getItemName(item.getType()); |         String itemName = ReflectionManager.getItemName(item.getType()); | ||||||
|         ArrayList<String> mcArray = new ArrayList<>(); |         ArrayList<String> mcArray = new ArrayList<>(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ import org.apache.commons.lang.StringUtils; | |||||||
| import org.bukkit.*; | import org.bukkit.*; | ||||||
| import org.bukkit.configuration.InvalidConfigurationException; | import org.bukkit.configuration.InvalidConfigurationException; | ||||||
| import org.bukkit.configuration.file.YamlConfiguration; | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
|  | import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; | ||||||
| import org.bukkit.entity.*; | import org.bukkit.entity.*; | ||||||
| import org.bukkit.inventory.EquipmentSlot; | import org.bukkit.inventory.EquipmentSlot; | ||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
| @@ -361,6 +362,17 @@ public class ReflectionManager { | |||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static ItemStack getCraftItem(ItemStack bukkitItem) { | ||||||
|  |         try { | ||||||
|  |             return (ItemStack) craftItemClass.getMethod("asCraftMirror", ItemStack.class).invoke(null, bukkitItem); | ||||||
|  |         } | ||||||
|  |         catch (Exception e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static NmsVersion getVersion() { |     public static NmsVersion getVersion() { | ||||||
|         if (version == null) { |         if (version == null) { | ||||||
|             getBukkitVersion(); |             getBukkitVersion(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user