Fix potential infinite loop

This commit is contained in:
Andrew 2013-10-01 02:47:40 +13:00
parent f25117e461
commit 17094fdeca

View file

@ -280,7 +280,7 @@ public class DisguiseAPI {
*/
private static void setupPlayerFakeDisguise(final Disguise disguise) {
// If the disguises entity is null, or the disguised entity isn't a player return
if (disguise.getEntity() == null || !(disguise.getEntity() instanceof Player))
if (disguise.getEntity() == null || !(disguise.getEntity() instanceof Player) || !disguises.containsValue(disguise))
return;
Player player = (Player) disguise.getEntity();
// Remove the old disguise, else we have weird disguises around the place
@ -295,6 +295,7 @@ public class DisguiseAPI {
if (tracker == null) {
// A check incase the tracker is null.
// If it is, then this method will be run again in one tick. Which is when it should be constructed.
// Else its going to run in a infinite loop hue hue hue..
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
public void run() {
setupPlayerFakeDisguise(disguise);