From 7f725d26bddc321d93932fbad82f276fe27c125a Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 6 Jan 2020 16:01:05 +1300 Subject: [PATCH] Don't keep old velocity changes, prevent 2 velocities --- .../disguise/utilities/DisguiseUtilities.java | 12 +++++++++--- .../PacketListenerViewSelfDisguise.java | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 9707f261..c9591aaa 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -78,7 +78,8 @@ public class DisguiseUtilities { private static File profileCache = new File("plugins/LibsDisguises/GameProfiles"), savedDisguises = new File( "plugins/LibsDisguises/SavedDisguises"); private static Gson gson; - private static boolean pluginsUsed, commandsUsed, copyDisguiseCommandUsed, grabSkinCommandUsed, saveDisguiseCommandUsed; + private static boolean pluginsUsed, commandsUsed, copyDisguiseCommandUsed, grabSkinCommandUsed, + saveDisguiseCommandUsed; private static long libsDisguisesCalled; /** * Keeps track of what tick this occured @@ -94,8 +95,13 @@ public class DisguiseUtilities { } public static void setPlayerVelocity(Player player) { - velocityID = player.getEntityId(); - velocityTime = player.getWorld().getTime(); + if (player == null) { + velocityID = 0; + velocityTime = 0; + } else { + velocityID = player.getEntityId(); + velocityTime = player.getWorld().getTime(); + } } /** 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 727d1536..b84ec41b 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 @@ -180,6 +180,8 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { // The player only sees velocity changes when there is a velocity event. As the method claims there // was no velocity event... event.setCancelled(true); + // Clear old velocity, this should only occur once. + DisguiseUtilities.setPlayerVelocity(null); } } catch (Exception ex) {