From 887181e6e948993fbdeefb2ae948ff84917638bc Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 25 Jul 2019 15:06:01 +1200 Subject: [PATCH] Fixes hunger, sounds listener now sync again, fixed checks. Fixes #384 --- .../java/me/libraryaddict/disguise/LibsDisguises.java | 3 ++- .../disguise/utilities/DisguiseUtilities.java | 10 ++++++++-- .../disguise/utilities/packets/PacketsManager.java | 7 +++---- .../packets/packethandlers/PacketHandlerSpawn.java | 7 ++++++- .../PacketListenerViewSelfDisguise.java | 6 +++++- .../disguise/utilities/plugin/PluginInformation.java | 3 +-- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 275d9cd9..a0aba4d6 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -245,7 +245,8 @@ public class LibsDisguises extends JavaPlugin { // Invalidate invalid distribution if (LibsPremium.isPremium() && LibsPremium.getPaidInformation() != null && - LibsPremium.getPaidInformation().getDownloadID().equals("-1895736039")) { + (!LibsPremium.getPaidInformation().isLegit() || + LibsPremium.getPaidInformation().getDownloadID().equals("-1895736039"))) { throw new IllegalStateException( "Error while checking pi rate on startup! Please re-download the jar from SpigotMC before " + "reporting this error!"); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 1cb86111..940e86f0 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -917,7 +917,8 @@ public class DisguiseUtilities { Field cSection = chunkClass.getDeclaredField("sections"); cSection.setAccessible(true); - Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class).newInstance(0); + Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class) + .newInstance(0); Class blockClass = ReflectionManager.getNmsClass("Block"); Object REGISTRY = ReflectionManager.getNmsField("IRegistry", "BLOCK").get(null); @@ -1032,7 +1033,8 @@ public class DisguiseUtilities { Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers") .get(entityTrackerEntry); - Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "a", ReflectionManager.getNmsClass("EntityPlayer")); + Method clear = ReflectionManager + .getNmsMethod("EntityTrackerEntry", "a", ReflectionManager.getNmsClass("EntityPlayer")); final Method updatePlayer = ReflectionManager .getNmsMethod("EntityTrackerEntry", "b", ReflectionManager.getNmsClass("EntityPlayer")); @@ -1339,6 +1341,10 @@ public class DisguiseUtilities { return; } + if (LibsPremium.getPaidInformation() != null && !LibsPremium.getPaidInformation().isLegit()) { + return; + } + DisguisePushing pOption = DisguiseConfig.getPushingOption(); if (pOption == DisguisePushing.IGNORE_SCOREBOARD) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java index 4b5bb7a4..9b85b00a 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/PacketsManager.java @@ -77,10 +77,9 @@ public class PacketsManager { soundsListenerEnabled = enabled; if (soundsListenerEnabled) { - ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(soundsListener) - .syncStart(); + ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener); } else { - ProtocolLibrary.getProtocolManager().getAsynchronousManager().unregisterAsyncHandler(soundsListener); + ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener); } } } @@ -92,7 +91,7 @@ public class PacketsManager { if (inventoryModifierEnabled) { ProtocolLibrary.getProtocolManager().addPacketListener(inventoryListener); } else { - ProtocolLibrary.getProtocolManager().addPacketListener(inventoryListener); + ProtocolLibrary.getProtocolManager().removePacketListener(inventoryListener); } for (Player player : Bukkit.getOnlinePlayers()) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java index ffa2be47..472d4d6b 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packethandlers/PacketHandlerSpawn.java @@ -8,11 +8,13 @@ import com.comphenix.protocol.wrappers.WrappedAttribute; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedGameProfile; import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.*; import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher; import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.packets.IPacketHandler; import me.libraryaddict.disguise.utilities.packets.LibsPackets; import me.libraryaddict.disguise.utilities.packets.PacketsHandler; @@ -281,7 +283,10 @@ public class PacketHandlerSpawn implements IPacketHandler { deleteTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4)); if (!((PlayerDisguise) disguise).isDisplayedInTab()) { - packets.addDelayedPacket(deleteTab, DisguiseConfig.getPlayerDisguisesTablistExpires()); + if (LibsPremium.getPaidInformation() == null || + LibsPremium.getPaidInformation().getVersion().matches("[0-9]+")) { + packets.addDelayedPacket(deleteTab, DisguiseConfig.getPlayerDisguisesTablistExpires()); + } } } else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) { Vector vec = disguisedEntity.getVelocity(); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java index ca46a097..2286bfec 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java @@ -14,6 +14,7 @@ import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; +import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.packets.LibsPackets; import me.libraryaddict.disguise.utilities.packets.PacketsManager; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; @@ -112,7 +113,10 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { transformed.sendDelayed(observer); if (event.getPacketType() == Server.ENTITY_METADATA) { - event.setPacket(packet = packet.deepClone()); + if (!LibsPremium.getPluginInformation().isPremium() || LibsPremium.getPaidInformation() != null || + LibsPremium.getPluginInformation().getBuildNumber().matches("[0-9]+")) { + event.setPacket(packet = packet.deepClone()); + } for (WrappedWatchableObject watch : packet.getWatchableCollectionModifier().read(0)) { if (watch.getIndex() == 0) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/plugin/PluginInformation.java b/src/main/java/me/libraryaddict/disguise/utilities/plugin/PluginInformation.java index 7a267baa..8eaddafa 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/plugin/PluginInformation.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/plugin/PluginInformation.java @@ -54,7 +54,6 @@ public class PluginInformation { } public boolean isLegit() { - return getUserID().matches("[0-9]+") && LibsPremium.getResourceID().equals("32453") && - getDownloadID().matches("-?[0-9]+"); + return getUserID().matches("[0-9]+") && getResourceID().equals("32453") && getDownloadID().matches("-?[0-9]+"); } }