mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-11-05 09:09:40 +01:00
Try avoid infinite loops when sending self disguise
This commit is contained in:
parent
3512ca4961
commit
5801356fbf
@ -209,7 +209,7 @@ public abstract class Disguise {
|
|||||||
refreshDisguise = 0;
|
refreshDisguise = 0;
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
if (getEntity() instanceof Player && isSelfDisguiseVisible()) {
|
if (getEntity() instanceof Player && isSelfDisguiseVisible()) {
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) getEntity());
|
DisguiseUtilities.sendSelfDisguise((Player) getEntity(), disguise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ public class FlagWatcher {
|
|||||||
float newHealth = (Float) value;
|
float newHealth = (Float) value;
|
||||||
if (newHealth > 0 && hasDied) {
|
if (newHealth > 0 && hasDied) {
|
||||||
hasDied = false;
|
hasDied = false;
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity());
|
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity(), disguise);
|
||||||
} else if (newHealth <= 0 && !hasDied) {
|
} else if (newHealth <= 0 && !hasDied) {
|
||||||
hasDied = true;
|
hasDied = true;
|
||||||
}
|
}
|
||||||
|
@ -480,9 +480,9 @@ public class DisguiseUtilities {
|
|||||||
/**
|
/**
|
||||||
* Sends the self disguise to the player
|
* Sends the self disguise to the player
|
||||||
*/
|
*/
|
||||||
public static void sendSelfDisguise(final Player player) {
|
public static void sendSelfDisguise(final Player player, final Disguise disguise) {
|
||||||
try {
|
try {
|
||||||
if (!player.isValid()) {
|
if (!player.isValid() || !player.isOnline()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Object world = ReflectionManager.getWorld(player.getWorld());
|
Object world = ReflectionManager.getWorld(player.getWorld());
|
||||||
@ -494,9 +494,12 @@ public class DisguiseUtilities {
|
|||||||
// A check incase the tracker is 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.
|
// 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..
|
// Else its going to run in a infinite loop hue hue hue..
|
||||||
|
// At least until this disguise is discarded
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
sendSelfDisguise(player);
|
if (DisguiseAPI.getDisguise(player, player) == disguise) {
|
||||||
|
sendSelfDisguise(player, disguise);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -633,7 +636,7 @@ public class DisguiseUtilities {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
sendSelfDisguise(player);
|
sendSelfDisguise(player, disguise);
|
||||||
if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) {
|
if (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()) {
|
||||||
if (PacketsManager.isInventoryListenerEnabled()) {
|
if (PacketsManager.isInventoryListenerEnabled()) {
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
Loading…
Reference in New Issue
Block a user