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; | ||||
|  | ||||
| import me.libraryaddict.disguise.utilities.PacketsManager; | ||||
|  | ||||
| import org.bukkit.ChatColor; | ||||
| import org.bukkit.configuration.ConfigurationSection; | ||||
|  | ||||
| @@ -37,6 +36,7 @@ public class DisguiseConfig { | ||||
|     private static boolean showNameAboveHeadAlwaysVisible; | ||||
|     private static boolean targetDisguises; | ||||
|     private static boolean undisguiseSwitchWorlds; | ||||
|     private static boolean stopShulkerDisguisesFromMoving; | ||||
|     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 | ||||
|             + ", the new version is " + ChatColor.RED + "%s" + ChatColor.DARK_RED + "!"; | ||||
| @@ -102,6 +102,7 @@ public class DisguiseConfig { | ||||
|         setWolfDyeable(config.getBoolean("DyeableWolf")); | ||||
|         setUndisguiseOnWorldChange(config.getBoolean("UndisguiseOnWorldChange")); | ||||
|         setUpdateNotificationPermission(config.getString("Permission")); | ||||
|         setStopShulkerDisguisesFromMoving(config.getBoolean("StopShulkerDisguisesFromMoving", true)); | ||||
|     } | ||||
|  | ||||
|     public static boolean isAnimationPacketsEnabled() { | ||||
| @@ -409,6 +410,14 @@ public class DisguiseConfig { | ||||
|         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? | ||||
|      * | ||||
|   | ||||
| @@ -172,6 +172,19 @@ public class DisguiseListener implements Listener { | ||||
|                 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 | ||||
|   | ||||
| @@ -262,7 +262,8 @@ public class FlagWatcher { | ||||
|             if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) { | ||||
|                 if (disguise.getType() != DisguiseType.WOLF && | ||||
|                         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)); | ||||
|             } | ||||
|             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 | ||||
|      */ | ||||
|     //TODO: Check this method, something's not right here | ||||
|     public static void refreshTrackers(final TargetedDisguise disguise) { | ||||
|         if (disguise.getEntity().isValid()) { | ||||
|             PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId()); | ||||
| @@ -947,8 +946,8 @@ public class DisguiseUtilities { | ||||
|             if (player.isSleeping()) { | ||||
|                 sendSelfPacket( | ||||
|                         player, | ||||
|                         manager.createPacketConstructor(Server.BED, player, loc.getBlockX(), loc.getBlockY(), | ||||
|                                 loc.getBlockZ()).createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); | ||||
|                         manager.createPacketConstructor(Server.BED, player, ReflectionManager.getBlockPosition(0, 0, 0)) | ||||
|                                 .createPacket(player, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); | ||||
|             } | ||||
|  | ||||
|             // Resend any active potion effects | ||||
|   | ||||
| @@ -401,8 +401,7 @@ public class PacketsManager { | ||||
|                 value += 64; | ||||
|                 break; | ||||
|             case ENDER_DRAGON: | ||||
|                 //TODO: Enderdragon direction is... weird, consistently backwards | ||||
| //                value = (byte) (~value & 0xff); | ||||
|                 value -= 128; | ||||
|                 break; | ||||
|             case WITHER_SKULL: | ||||
|                 value -= 128; | ||||
| @@ -831,8 +830,6 @@ public class PacketsManager { | ||||
|                                 || event.getPacketType() == Server.ENTITY_EFFECT | ||||
|                                 || event.getPacketType() == Server.ENTITY_EQUIPMENT) { | ||||
|                             event.setCancelled(true); | ||||
|                         } else if (event.getPacketType() == Server.BED) { | ||||
|                             ReflectionManager.setAllowSleep(observer); | ||||
|                         } else if (event.getPacketType() == Server.ENTITY_STATUS) { | ||||
|                             Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); | ||||
|                             if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() | ||||
| @@ -1300,7 +1297,8 @@ public class PacketsManager { | ||||
|                 else if (sentPacket.getType() == Server.ENTITY_METADATA) { | ||||
|                     if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && | ||||
|                             disguise.getType() != DisguiseType.OCELOT && | ||||
|                             disguise.getType() != DisguiseType.ENDERMAN)) { | ||||
|                             disguise.getType() != DisguiseType.ENDERMAN && | ||||
|                             disguise.getType() != DisguiseType.SHULKER)) { | ||||
|                         List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert( | ||||
|                                 packets[0].getWatchableCollectionModifier().read(0)); | ||||
|                         packets[0] = new PacketContainer(sentPacket.getType()); | ||||
| @@ -1414,7 +1412,8 @@ public class PacketsManager { | ||||
|                             List<WrappedWatchableObject> list = new ArrayList<>(); | ||||
|                             if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && | ||||
|                                     disguise.getType() != DisguiseType.OCELOT && | ||||
|                                     disguise.getType() != DisguiseType.ENDERMAN)) { | ||||
|                                     disguise.getType() != DisguiseType.ENDERMAN && | ||||
|                                     disguise.getType() != DisguiseType.SHULKER)) { | ||||
|                                 WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, | ||||
|                                         WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); | ||||
|                                 list.add(watch); | ||||
|   | ||||
| @@ -496,18 +496,6 @@ public class ReflectionManager { | ||||
|         //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) { | ||||
|         try { | ||||
|             Location loc = entity.getLocation(); | ||||
|   | ||||
| @@ -60,6 +60,9 @@ MonstersIgnoreDisguises: false | ||||
| BlowDisguises: false | ||||
| 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 | ||||
| DisguiseEntityExpire: 10 | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user