Minor fixes
This commit is contained in:
		@@ -38,6 +38,14 @@
 | 
			
		||||
            </resource>
 | 
			
		||||
        </resources>
 | 
			
		||||
        <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>
 | 
			
		||||
                <artifactId>maven-surefire-plugin</artifactId>
 | 
			
		||||
                <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
 | 
			
		||||
        // 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() {
 | 
			
		||||
@@ -1609,8 +1614,8 @@ public class DisguiseUtilities {
 | 
			
		||||
 | 
			
		||||
                Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
 | 
			
		||||
 | 
			
		||||
                Method clear = ReflectionManager
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear",
 | 
			
		||||
                        ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
 | 
			
		||||
                        ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
@@ -1665,8 +1670,8 @@ public class DisguiseUtilities {
 | 
			
		||||
                if (entityTrackerEntry != null) {
 | 
			
		||||
                    Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
 | 
			
		||||
 | 
			
		||||
                    Method clear = ReflectionManager
 | 
			
		||||
                            .getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                    Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear",
 | 
			
		||||
                            ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                    final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
 | 
			
		||||
                            ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
@@ -1732,8 +1737,8 @@ public class DisguiseUtilities {
 | 
			
		||||
                Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
 | 
			
		||||
 | 
			
		||||
                // TODO Store the fields
 | 
			
		||||
                final Method clear = ReflectionManager
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear",
 | 
			
		||||
                        ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
 | 
			
		||||
                        ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
@@ -1859,8 +1864,8 @@ public class DisguiseUtilities {
 | 
			
		||||
 | 
			
		||||
                    ((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getPlayerConnectionOrPlayer(player));
 | 
			
		||||
                } else {
 | 
			
		||||
                    ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry))
 | 
			
		||||
                            .remove(ReflectionManager.getPlayerConnectionOrPlayer(player));
 | 
			
		||||
                    ((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry)).remove(
 | 
			
		||||
                            ReflectionManager.getPlayerConnectionOrPlayer(player));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception ex) {
 | 
			
		||||
@@ -2962,8 +2967,8 @@ public class DisguiseUtilities {
 | 
			
		||||
                    name = ChatColor.translateAlternateColorCodes('&', newNames[i]);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager
 | 
			
		||||
                        .createDataWatcherObject(NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
 | 
			
		||||
                WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject(
 | 
			
		||||
                        NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
 | 
			
		||||
 | 
			
		||||
                watcher.setObject(obj, ReflectionManager.convertInvalidMeta(name));
 | 
			
		||||
 | 
			
		||||
@@ -2985,7 +2990,7 @@ public class DisguiseUtilities {
 | 
			
		||||
                Location loc = disguise.getEntity().getLocation();
 | 
			
		||||
 | 
			
		||||
                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());
 | 
			
		||||
                packets.add(packet);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -108,7 +108,6 @@ public class ReflectionManager {
 | 
			
		||||
    private static Field noDamageTicks;
 | 
			
		||||
    private static Method isInvul;
 | 
			
		||||
    private static Object genericDamage;
 | 
			
		||||
    private static HashMap<String, String> classLocations = new HashMap<>();
 | 
			
		||||
    private static Field playerConnection;
 | 
			
		||||
    private static Method incrementedInventoryStateId;
 | 
			
		||||
    private static Field playerInventoryContainer;
 | 
			
		||||
@@ -766,7 +765,7 @@ public class ReflectionManager {
 | 
			
		||||
 | 
			
		||||
    public static ReflectionManagerAbstract getReflectionManager(NmsVersion nmsVersion) {
 | 
			
		||||
        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();
 | 
			
		||||
            return (ReflectionManagerAbstract) o;
 | 
			
		||||
        } catch (ReflectiveOperationException e) {
 | 
			
		||||
@@ -970,31 +969,7 @@ public class ReflectionManager {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static String getLocation(String pack, String className) {
 | 
			
		||||
        if (NmsVersion.v1_18.isSupported()) {
 | 
			
		||||
            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;
 | 
			
		||||
        return ClassMappings.getClass(pack, className);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Class getNmsClass(String className) {
 | 
			
		||||
@@ -1865,7 +1840,8 @@ public class ReflectionManager {
 | 
			
		||||
 | 
			
		||||
    public static Object getNmsEntityPose(EntityPose entityPose) {
 | 
			
		||||
        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());
 | 
			
		||||
@@ -2263,7 +2239,8 @@ public class ReflectionManager {
 | 
			
		||||
                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) {
 | 
			
		||||
                DisguiseUtilities.getLogger().warning("Entity not found! (" + nmsEntityName + ")");
 | 
			
		||||
 
 | 
			
		||||
@@ -65,7 +65,7 @@ public class CompileMethods {
 | 
			
		||||
            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)) {
 | 
			
		||||
            byte[] array = String.join("\n", list).getBytes(StandardCharsets.UTF_8);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user