Minor fixes
This commit is contained in:
		| @@ -38,6 +38,14 @@ | |||||||
|             </resource> |             </resource> | ||||||
|         </resources> |         </resources> | ||||||
|         <plugins> |         <plugins> | ||||||
|  |             <plugin> | ||||||
|  |                 <groupId>org.apache.maven.plugins</groupId> | ||||||
|  |                 <artifactId>maven-jar-plugin</artifactId> | ||||||
|  |                 <version>2.3.1</version> | ||||||
|  |                 <configuration> | ||||||
|  |                     <outputDirectory>../target</outputDirectory> | ||||||
|  |                 </configuration> | ||||||
|  |             </plugin> | ||||||
|             <plugin> |             <plugin> | ||||||
|                 <artifactId>maven-surefire-plugin</artifactId> |                 <artifactId>maven-surefire-plugin</artifactId> | ||||||
|                 <version>3.0.0-M5</version> |                 <version>3.0.0-M5</version> | ||||||
|   | |||||||
| @@ -480,7 +480,12 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|         // If we are on 1.17, you need this release or dev build |         // If we are on 1.17, you need this release or dev build | ||||||
|         // ProtocolLib is a little funny in that it provides next release version as the current version |         // ProtocolLib is a little funny in that it provides next release version as the current version | ||||||
|         return new String[]{"4.7.0", "528"}; |         if (!NmsVersion.v1_18.isSupported()) { | ||||||
|  |             return new String[]{"4.7.0", "528"}; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         // If you're on 1.18.. | ||||||
|  |         return new String[]{"4.8.0", "538"}; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isProtocolLibOutdated() { |     public static boolean isProtocolLibOutdated() { | ||||||
| @@ -1609,8 +1614,8 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); |                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                 Method clear = ReflectionManager |                 Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", | ||||||
|                         .getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer")); |                         ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
|  |  | ||||||
|                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer", |                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer", | ||||||
|                         ReflectionManager.getNmsClass("EntityPlayer")); |                         ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
| @@ -1665,8 +1670,8 @@ public class DisguiseUtilities { | |||||||
|                 if (entityTrackerEntry != null) { |                 if (entityTrackerEntry != null) { | ||||||
|                     Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); |                     Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                     Method clear = ReflectionManager |                     Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", | ||||||
|                             .getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer")); |                             ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
|  |  | ||||||
|                     final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer", |                     final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer", | ||||||
|                             ReflectionManager.getNmsClass("EntityPlayer")); |                             ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
| @@ -1732,8 +1737,8 @@ public class DisguiseUtilities { | |||||||
|                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); |                 Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry); | ||||||
|  |  | ||||||
|                 // TODO Store the fields |                 // TODO Store the fields | ||||||
|                 final Method clear = ReflectionManager |                 final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", | ||||||
|                         .getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer")); |                         ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
|  |  | ||||||
|                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer", |                 final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer", | ||||||
|                         ReflectionManager.getNmsClass("EntityPlayer")); |                         ReflectionManager.getNmsClass("EntityPlayer")); | ||||||
| @@ -1859,8 +1864,8 @@ public class DisguiseUtilities { | |||||||
|  |  | ||||||
|                     ((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getPlayerConnectionOrPlayer(player)); |                     ((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getPlayerConnectionOrPlayer(player)); | ||||||
|                 } else { |                 } else { | ||||||
|                     ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry)) |                     ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry)).remove( | ||||||
|                             .remove(ReflectionManager.getPlayerConnectionOrPlayer(player)); |                             ReflectionManager.getPlayerConnectionOrPlayer(player)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } catch (Exception ex) { |         } catch (Exception ex) { | ||||||
| @@ -2962,8 +2967,8 @@ public class DisguiseUtilities { | |||||||
|                     name = ChatColor.translateAlternateColorCodes('&', newNames[i]); |                     name = ChatColor.translateAlternateColorCodes('&', newNames[i]); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager |                 WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject( | ||||||
|                         .createDataWatcherObject(NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD, name); |                         NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD, name); | ||||||
|  |  | ||||||
|                 watcher.setObject(obj, ReflectionManager.convertInvalidMeta(name)); |                 watcher.setObject(obj, ReflectionManager.convertInvalidMeta(name)); | ||||||
|  |  | ||||||
| @@ -2985,7 +2990,7 @@ public class DisguiseUtilities { | |||||||
|                 Location loc = disguise.getEntity().getLocation(); |                 Location loc = disguise.getEntity().getLocation(); | ||||||
|  |  | ||||||
|                 packet.getDoubles().write(0, loc.getX()); |                 packet.getDoubles().write(0, loc.getX()); | ||||||
|                 packet.getDoubles().write(1, loc.getY() + height  + (0.28 * i)); |                 packet.getDoubles().write(1, loc.getY() + height + (0.28 * i)); | ||||||
|                 packet.getDoubles().write(2, loc.getZ()); |                 packet.getDoubles().write(2, loc.getZ()); | ||||||
|                 packets.add(packet); |                 packets.add(packet); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -108,7 +108,6 @@ public class ReflectionManager { | |||||||
|     private static Field noDamageTicks; |     private static Field noDamageTicks; | ||||||
|     private static Method isInvul; |     private static Method isInvul; | ||||||
|     private static Object genericDamage; |     private static Object genericDamage; | ||||||
|     private static HashMap<String, String> classLocations = new HashMap<>(); |  | ||||||
|     private static Field playerConnection; |     private static Field playerConnection; | ||||||
|     private static Method incrementedInventoryStateId; |     private static Method incrementedInventoryStateId; | ||||||
|     private static Field playerInventoryContainer; |     private static Field playerInventoryContainer; | ||||||
| @@ -766,7 +765,7 @@ public class ReflectionManager { | |||||||
|  |  | ||||||
|     public static ReflectionManagerAbstract getReflectionManager(NmsVersion nmsVersion) { |     public static ReflectionManagerAbstract getReflectionManager(NmsVersion nmsVersion) { | ||||||
|         try { |         try { | ||||||
|             Class<?> aClass = Class.forName("me.libraryaddict.disguise." + nmsVersion.name() + ".utilities.reflection.ReflectionManager"); |             Class<?> aClass = Class.forName("me.libraryaddict.disguise.utilities.reflection." + nmsVersion.name() + ".ReflectionManager"); | ||||||
|             Object o = aClass.getConstructor().newInstance(); |             Object o = aClass.getConstructor().newInstance(); | ||||||
|             return (ReflectionManagerAbstract) o; |             return (ReflectionManagerAbstract) o; | ||||||
|         } catch (ReflectiveOperationException e) { |         } catch (ReflectiveOperationException e) { | ||||||
| @@ -970,31 +969,7 @@ public class ReflectionManager { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static String getLocation(String pack, String className) { |     private static String getLocation(String pack, String className) { | ||||||
|         if (NmsVersion.v1_18.isSupported()) { |         return ClassMappings.getClass(pack, className); | ||||||
|             return ClassMappings.getClass(pack, className); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         String toReturn = classLocations.get(className); |  | ||||||
|  |  | ||||||
|         if (toReturn != null) { |  | ||||||
|             return toReturn; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         try { |  | ||||||
|             ArrayList<String> classes = ClassGetter.getEntriesForPackage(pack); |  | ||||||
|  |  | ||||||
|             String realLocation = classes.stream().filter(s -> s.endsWith("/" + className + ".class")).findAny().get().replace("/", ".").replace(".class", ""); |  | ||||||
|  |  | ||||||
|             classLocations.put(className, realLocation); |  | ||||||
|  |  | ||||||
|             return realLocation; |  | ||||||
|         } catch (Throwable throwable) { |  | ||||||
|             //  System.err.println(pack + " - " + className); |  | ||||||
|             // throwable.printStackTrace(); |  | ||||||
|             classLocations.put(className, className); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return className; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static Class getNmsClass(String className) { |     public static Class getNmsClass(String className) { | ||||||
| @@ -1865,7 +1840,8 @@ public class ReflectionManager { | |||||||
|  |  | ||||||
|     public static Object getNmsEntityPose(EntityPose entityPose) { |     public static Object getNmsEntityPose(EntityPose entityPose) { | ||||||
|         if (NmsVersion.v1_18.isSupported()) { |         if (NmsVersion.v1_18.isSupported()) { | ||||||
|             return v1_18ReflectionManager.getNmsEntityPose(entityPose == EntityPose.SNEAKING && NmsVersion.v1_15.isSupported() ? "CROUCHING" : entityPose.name()); |             return v1_18ReflectionManager.getNmsEntityPose( | ||||||
|  |                     entityPose == EntityPose.SNEAKING && NmsVersion.v1_15.isSupported() ? "CROUCHING" : entityPose.name()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return Enum.valueOf(entityPoseClass, entityPose == EntityPose.SNEAKING && NmsVersion.v1_15.isSupported() ? "CROUCHING" : entityPose.name()); |         return Enum.valueOf(entityPoseClass, entityPose == EntityPose.SNEAKING && NmsVersion.v1_15.isSupported() ? "CROUCHING" : entityPose.name()); | ||||||
| @@ -2263,7 +2239,8 @@ public class ReflectionManager { | |||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             Object nmsEntity = ReflectionManager.createEntityInstance(disguiseType, NmsVersion.v1_18.isSupported() ? disguiseType.getEntityType().getKey().getKey() : nmsEntityName); |             Object nmsEntity = ReflectionManager.createEntityInstance(disguiseType, | ||||||
|  |                     NmsVersion.v1_18.isSupported() ? disguiseType.getEntityType().getKey().getKey() : nmsEntityName); | ||||||
|  |  | ||||||
|             if (nmsEntity == null) { |             if (nmsEntity == null) { | ||||||
|                 DisguiseUtilities.getLogger().warning("Entity not found! (" + nmsEntityName + ")"); |                 DisguiseUtilities.getLogger().warning("Entity not found! (" + nmsEntityName + ")"); | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ public class CompileMethods { | |||||||
|             list.add(sound.toString()); |             list.add(sound.toString()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         File soundsFile = new File("plugin/target/classes/ANTI_PIRACY_ENCRYPTION"); |         File soundsFile = new File("plugin/target/classes/ANTI_PIRACY_SECRET_FILE"); | ||||||
|  |  | ||||||
|         try (FileOutputStream fos = new FileOutputStream(soundsFile)) { |         try (FileOutputStream fos = new FileOutputStream(soundsFile)) { | ||||||
|             byte[] array = String.join("\n", list).getBytes(StandardCharsets.UTF_8); |             byte[] array = String.join("\n", list).getBytes(StandardCharsets.UTF_8); | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package me.libraryaddict.disguise.v1_18.utilities.reflection; | package me.libraryaddict.disguise.utilities.reflection.v1_18; | ||||||
| 
 | 
 | ||||||
| import com.comphenix.protocol.wrappers.*; | import com.comphenix.protocol.wrappers.*; | ||||||
| import com.comphenix.protocol.wrappers.EnumWrappers.Direction; | import com.comphenix.protocol.wrappers.EnumWrappers.Direction; | ||||||
		Reference in New Issue
	
	Block a user