Fixed Shulker disguises
Fixed Enderdragon direction Added config option to stop shulker disguises from moving Fixed sleeping while in a player disguise
This commit is contained in:
		| @@ -1,7 +1,6 @@ | |||||||
| package me.libraryaddict.disguise; | package me.libraryaddict.disguise; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.utilities.PacketsManager; | import me.libraryaddict.disguise.utilities.PacketsManager; | ||||||
|  |  | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.configuration.ConfigurationSection; | import org.bukkit.configuration.ConfigurationSection; | ||||||
|  |  | ||||||
| @@ -37,6 +36,7 @@ public class DisguiseConfig { | |||||||
|     private static boolean showNameAboveHeadAlwaysVisible; |     private static boolean showNameAboveHeadAlwaysVisible; | ||||||
|     private static boolean targetDisguises; |     private static boolean targetDisguises; | ||||||
|     private static boolean undisguiseSwitchWorlds; |     private static boolean undisguiseSwitchWorlds; | ||||||
|  |     private static boolean stopShulkerDisguisesFromMoving; | ||||||
|     private static String updateMessage = ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED |     private static String updateMessage = ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED | ||||||
|             + "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED |             + "There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED | ||||||
|             + ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"; |             + ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"; | ||||||
| @@ -102,6 +102,7 @@ public class DisguiseConfig { | |||||||
|         setWolfDyeable(config.getBoolean("DyeableWolf")); |         setWolfDyeable(config.getBoolean("DyeableWolf")); | ||||||
|         setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange")); |         setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange")); | ||||||
|         setUpdateNotificationPermission(config.getString("Permission")); |         setUpdateNotificationPermission(config.getString("Permission")); | ||||||
|  |         setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isAnimationPacketsEnabled() { |     public static boolean isAnimationPacketsEnabled() { | ||||||
| @@ -409,6 +410,14 @@ public class DisguiseConfig { | |||||||
|         updateNotificationPermission = newPermission; |         updateNotificationPermission = newPermission; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static void setStopShulkerDisguisesFromMoving(boolean stopShulkerDisguisesFromMoving) { | ||||||
|  |         DisguiseConfig.stopShulkerDisguisesFromMoving = stopShulkerDisguisesFromMoving; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static boolean isStopShulkerDisguisesFromMoving() { | ||||||
|  |         return stopShulkerDisguisesFromMoving; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get? |      * Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get? | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -172,6 +172,19 @@ public class DisguiseListener implements Listener { | |||||||
|                 chunkMove(event.getPlayer(), to, from); |                 chunkMove(event.getPlayer(), to, from); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if (DisguiseConfig.isStopShulkerDisguisesFromMoving()) { | ||||||
|  |             Disguise disguise; | ||||||
|  |             if ((disguise = DisguiseAPI.getDisguise(event.getPlayer())) != null) { | ||||||
|  |                 if (disguise.getType() == DisguiseType.SHULKER) { //Stop Shulker disguises from moving their coordinates | ||||||
|  |                     Location from = event.getFrom(); | ||||||
|  |                     Location to = event.getTo(); | ||||||
|  |                     to.setX(from.getX()); | ||||||
|  |                     to.setZ(from.getZ()); | ||||||
|  |                     event.setTo(to); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @EventHandler |     @EventHandler | ||||||
|   | |||||||
| @@ -262,7 +262,8 @@ public class FlagWatcher { | |||||||
|             if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) { |             if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) { | ||||||
|                 if (disguise.getType() != DisguiseType.WOLF && |                 if (disguise.getType() != DisguiseType.WOLF && | ||||||
|                         disguise.getType() != DisguiseType.OCELOT && |                         disguise.getType() != DisguiseType.OCELOT && | ||||||
|                         disguise.getType() != DisguiseType.ENDERMAN) |                         disguise.getType() != DisguiseType.ENDERMAN && | ||||||
|  |                         disguise.getType() != DisguiseType.SHULKER) | ||||||
|                 value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); |                 value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); | ||||||
|             } |             } | ||||||
|             WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(data, value)); |             WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(data, value)); | ||||||
|   | |||||||
| @@ -700,7 +700,6 @@ public class DisguiseUtilities { | |||||||
|     /** |     /** | ||||||
|      * Resends the entity to all the watching players, which is where the magic begins |      * Resends the entity to all the watching players, which is where the magic begins | ||||||
|      */ |      */ | ||||||
|     //TODO: Check this method, something's not right here |  | ||||||
|     public static void refreshTrackers(final TargetedDisguise disguise) { |     public static void refreshTrackers(final TargetedDisguise disguise) { | ||||||
|         if (disguise.getEntity().isValid()) { |         if (disguise.getEntity().isValid()) { | ||||||
|             PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); |             PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); | ||||||
| @@ -947,8 +946,8 @@ public class DisguiseUtilities { | |||||||
|             if (player.isSleeping()) { |             if (player.isSleeping()) { | ||||||
|                 sendSelfPacket( |                 sendSelfPacket( | ||||||
|                         player, |                         player, | ||||||
|                         manager.createPacketConstructor(Server.BED, player, loc.getBlockX(), loc.getBlockY(), |                         manager.createPacketConstructor(Server.BED, player, ReflectionManager.getBlockPosition(0, 0, 0)) | ||||||
|                                 loc.getBlockZ()).createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); |                                 .createPacket(player, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // Resend any active potion effects |             // Resend any active potion effects | ||||||
|   | |||||||
| @@ -401,8 +401,7 @@ public class PacketsManager { | |||||||
|                 value += 64; |                 value += 64; | ||||||
|                 break; |                 break; | ||||||
|             case ENDER_DRAGON: |             case ENDER_DRAGON: | ||||||
|                 //TODO: Enderdragon direction is... weird, consistently backwards |                 value -= 128; | ||||||
| //                value = (byte) (~value & 0xff); |  | ||||||
|                 break; |                 break; | ||||||
|             case WITHER_SKULL: |             case WITHER_SKULL: | ||||||
|                 value -= 128; |                 value -= 128; | ||||||
| @@ -831,8 +830,6 @@ public class PacketsManager { | |||||||
|                                 || event.getPacketType() == Server.ENTITY_EFFECT |                                 || event.getPacketType() == Server.ENTITY_EFFECT | ||||||
|                                 || event.getPacketType() == Server.ENTITY_EQUIPMENT) { |                                 || event.getPacketType() == Server.ENTITY_EQUIPMENT) { | ||||||
|                             event.setCancelled(true); |                             event.setCancelled(true); | ||||||
|                         } else if (event.getPacketType() == Server.BED) { |  | ||||||
|                             ReflectionManager.setAllowSleep(observer); |  | ||||||
|                         } else if (event.getPacketType() == Server.ENTITY_STATUS) { |                         } else if (event.getPacketType() == Server.ENTITY_STATUS) { | ||||||
|                             Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); |                             Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); | ||||||
|                             if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() |                             if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() | ||||||
| @@ -1300,7 +1297,8 @@ public class PacketsManager { | |||||||
|                 else if (sentPacket.getType() == Server.ENTITY_METADATA) { |                 else if (sentPacket.getType() == Server.ENTITY_METADATA) { | ||||||
|                     if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && |                     if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && | ||||||
|                             disguise.getType() != DisguiseType.OCELOT && |                             disguise.getType() != DisguiseType.OCELOT && | ||||||
|                             disguise.getType() != DisguiseType.ENDERMAN)) { |                             disguise.getType() != DisguiseType.ENDERMAN && | ||||||
|  |                             disguise.getType() != DisguiseType.SHULKER)) { | ||||||
|                         List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert( |                         List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert( | ||||||
|                                 packets[0].getWatchableCollectionModifier().read(0)); |                                 packets[0].getWatchableCollectionModifier().read(0)); | ||||||
|                         packets[0] = new PacketContainer(sentPacket.getType()); |                         packets[0] = new PacketContainer(sentPacket.getType()); | ||||||
| @@ -1414,7 +1412,8 @@ public class PacketsManager { | |||||||
|                             List<WrappedWatchableObject> list = new ArrayList<>(); |                             List<WrappedWatchableObject> list = new ArrayList<>(); | ||||||
|                             if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && |                             if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && | ||||||
|                                     disguise.getType() != DisguiseType.OCELOT && |                                     disguise.getType() != DisguiseType.OCELOT && | ||||||
|                                     disguise.getType() != DisguiseType.ENDERMAN)) { |                                     disguise.getType() != DisguiseType.ENDERMAN && | ||||||
|  |                                     disguise.getType() != DisguiseType.SHULKER)) { | ||||||
|                                 WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, |                                 WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, | ||||||
|                                         WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); |                                         WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); | ||||||
|                                 list.add(watch); |                                 list.add(watch); | ||||||
|   | |||||||
| @@ -496,18 +496,6 @@ public class ReflectionManager { | |||||||
|         //Some future remove code if needed |         //Some future remove code if needed | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static void setAllowSleep(Player player) { |  | ||||||
|         try { |  | ||||||
|             //TODO: Fix this! |  | ||||||
|             /** |  | ||||||
|              * Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); * |  | ||||||
|              */ |  | ||||||
|         } catch (Exception ex) { |  | ||||||
|             ex.printStackTrace(System.out); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) { |     public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) { | ||||||
|         try { |         try { | ||||||
|             Location loc = entity.getLocation(); |             Location loc = entity.getLocation(); | ||||||
|   | |||||||
| @@ -60,6 +60,9 @@ MonstersIgnoreDisguises: false | |||||||
| BlowDisguises: false | BlowDisguises: false | ||||||
| BlownDisguiseMessage: '&cYour disguise was blown!' | BlownDisguiseMessage: '&cYour disguise was blown!' | ||||||
|  |  | ||||||
|  | #Stop shulker disguises from moving, they're weird. This option only effects PLAYERS that are disguised, other entities disguised as shulkers will NOT be effected! | ||||||
|  | StopShulkerDisguisesFromMoving: true | ||||||
|  |  | ||||||
| # A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring | # A option to choose how many seconds a DisguiseEntity command is valid for people to right click a entity to disguise it before expiring | ||||||
| DisguiseEntityExpire: 10 | DisguiseEntityExpire: 10 | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user