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