From bd214728cda4aa69a1fff7349c147a87919d7c57 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 24 Jul 2020 23:54:47 +1200 Subject: [PATCH] Allow unignition of creeper disguise --- .../watchers/CreeperWatcher.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java index 7c4c982c..a6d177fd 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java @@ -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) {