Make sure disguise isn't running in an unloaded world
This commit is contained in:
parent
08deb7ee30
commit
3370a1353d
@ -682,8 +682,9 @@ public abstract class Disguise {
|
||||
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
// If this disguise is not in use, and the entity isnt a player that's offline
|
||||
if (event.isCancelled() && (!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) {
|
||||
// Can only continue a disguise that's valid
|
||||
if (event.isCancelled() && getEntity() != null && Bukkit.getWorlds().contains(getEntity().getWorld()) &&
|
||||
(!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -64,8 +65,13 @@ class DisguiseRunnable extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!disguise.isDisguiseInUse() || disguise.getEntity() == null) {
|
||||
if (!disguise.isDisguiseInUse() || disguise.getEntity() == null || !Bukkit.getWorlds().contains(disguise.getEntity().getWorld())) {
|
||||
disguise.stopDisguise();
|
||||
|
||||
// If still somehow not cancelled
|
||||
if (!isCancelled()) {
|
||||
cancel();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user