Allow unignition of creeper disguise

This commit is contained in:
libraryaddict 2020-07-24 23:54:47 +12:00
parent 4b40a67b00
commit bd214728cd

View file

@ -2,6 +2,8 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.entity.Creeper;
public class CreeperWatcher extends InsentientWatcher {
@ -13,13 +15,23 @@ public class CreeperWatcher extends InsentientWatcher {
return getData(MetaIndex.CREEPER_IGNITED);
}
public boolean isPowered() {
return getData(MetaIndex.CREEPER_POWERED);
}
public void setIgnited(boolean ignited) {
// If creeper is already ignited and they want to set it to unignited, then resend disguise
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() &&
((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) ||
(getDisguise().getEntity() instanceof Creeper &&
((Creeper) getDisguise().getEntity()).isPowered()));
setData(MetaIndex.CREEPER_IGNITED, ignited);
sendData(MetaIndex.CREEPER_IGNITED);
if (resend) {
DisguiseUtilities.refreshTrackers(getDisguise());
}
}
public boolean isPowered() {
return getData(MetaIndex.CREEPER_POWERED);
}
public void setPowered(boolean powered) {