diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 185a8e60..11bda603 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -171,10 +171,6 @@ public class LibsDisguises extends JavaPlugin { new MetricsInitalizer(); } - private void startTask() { - - } - public void unregisterCommands(boolean force) { CommandMap map = ReflectionManager.getCommandMap(); Map commands = ReflectionManager.getCommands(map); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 021ae066..8bc6dc9d 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -1280,10 +1280,6 @@ public class DisguiseUtilities { file.delete(); } - public static void doDisguiseTick(Disguise disguise) { - - } - public static void removeSelfDisguise(Disguise disguise) { if (!Bukkit.isPrimaryThread()) throw new IllegalStateException("Cannot modify disguises on an async thread"); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java index 7d838241..27d0b7ef 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/DisguiseListener.java @@ -582,6 +582,19 @@ public class DisguiseListener implements Listener { } }.runTaskLater(LibsDisguises.getInstance(), 4); } + } else if (from.getWorld() != to.getWorld()) { + // Stupid hack to fix worldswitch invisibility bug & paper packet bug + final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer()); + + if (viewSelfToggled) { + final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); + + if (disguise.isSelfDisguiseVisible()) { + disguise.setViewSelfDisguise(false); + + Bukkit.getScheduler().runTaskLater(plugin, () -> disguise.setViewSelfDisguise(true), 20L); + } + } } } @@ -641,20 +654,17 @@ public class DisguiseListener implements Listener { } } } else { - // Stupid hack to fix worldswitch invisibility bug + // Stupid hack to fix worldswitch invisibility bug & paper packet bug final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer()); if (viewSelfToggled) { final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); - disguise.setViewSelfDisguise(false); + if (disguise.isSelfDisguiseVisible()) { + disguise.setViewSelfDisguise(false); - Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { - @Override - public void run() { - disguise.setViewSelfDisguise(true); - } - }, 20L); // I wish I could use lambdas here, so badly + Bukkit.getScheduler().runTaskLater(plugin, () -> disguise.setViewSelfDisguise(true), 20L); + } } } }