Fix being unable to switch worlds while self disguised (paper?), fixes #476

This commit is contained in:
libraryaddict 2020-06-14 12:47:43 +12:00
parent a19b9e4023
commit f12c1192e1
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
3 changed files with 18 additions and 16 deletions

View File

@ -171,10 +171,6 @@ public class LibsDisguises extends JavaPlugin {
new MetricsInitalizer(); new MetricsInitalizer();
} }
private void startTask() {
}
public void unregisterCommands(boolean force) { public void unregisterCommands(boolean force) {
CommandMap map = ReflectionManager.getCommandMap(); CommandMap map = ReflectionManager.getCommandMap();
Map<String, Command> commands = ReflectionManager.getCommands(map); Map<String, Command> commands = ReflectionManager.getCommands(map);

View File

@ -1280,10 +1280,6 @@ public class DisguiseUtilities {
file.delete(); file.delete();
} }
public static void doDisguiseTick(Disguise disguise) {
}
public static void removeSelfDisguise(Disguise disguise) { public static void removeSelfDisguise(Disguise disguise) {
if (!Bukkit.isPrimaryThread()) if (!Bukkit.isPrimaryThread())
throw new IllegalStateException("Cannot modify disguises on an async thread"); throw new IllegalStateException("Cannot modify disguises on an async thread");

View File

@ -582,6 +582,19 @@ public class DisguiseListener implements Listener {
} }
}.runTaskLater(LibsDisguises.getInstance(), 4); }.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 { } 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()); final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer());
if (viewSelfToggled) { if (viewSelfToggled) {
final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer()); final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer());
disguise.setViewSelfDisguise(false); if (disguise.isSelfDisguiseVisible()) {
disguise.setViewSelfDisguise(false);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(plugin, () -> disguise.setViewSelfDisguise(true), 20L);
@Override }
public void run() {
disguise.setViewSelfDisguise(true);
}
}, 20L); // I wish I could use lambdas here, so badly
} }
} }
} }