Add isBeingReplaced() to UndisguiseEvent. Fixes #309
This commit is contained in:
		| @@ -442,10 +442,20 @@ public abstract class Disguise { | ||||
|      * @return removeDiguise | ||||
|      */ | ||||
|     public boolean removeDisguise() { | ||||
|         return removeDisguise(false); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Removes the disguise and undisguises the entity if it's using this disguise. | ||||
|      * | ||||
|      * @param disguiseBeingReplaced If the entity's disguise is being replaced with another | ||||
|      * @return | ||||
|      */ | ||||
|     public boolean removeDisguise(boolean disguiseBeingReplaced) { | ||||
|         if (!isDisguiseInUse()) | ||||
|             return false; | ||||
|  | ||||
|         UndisguiseEvent event = new UndisguiseEvent(entity, this); | ||||
|         UndisguiseEvent event = new UndisguiseEvent(entity, this, disguiseBeingReplaced); | ||||
|  | ||||
|         Bukkit.getPluginManager().callEvent(event); | ||||
|  | ||||
|   | ||||
| @@ -1,12 +1,11 @@ | ||||
| package me.libraryaddict.disguise.events; | ||||
|  | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
| import org.bukkit.entity.Entity; | ||||
| import org.bukkit.event.Cancellable; | ||||
| import org.bukkit.event.Event; | ||||
| import org.bukkit.event.HandlerList; | ||||
|  | ||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||
|  | ||||
| public class UndisguiseEvent extends Event implements Cancellable { | ||||
|  | ||||
|     private static final HandlerList handlers = new HandlerList(); | ||||
| @@ -18,10 +17,12 @@ public class UndisguiseEvent extends Event implements Cancellable { | ||||
|     private Disguise disguise; | ||||
|     private Entity disguised; | ||||
|     private boolean isCancelled; | ||||
|     private boolean isBeingReplaced; | ||||
|  | ||||
|     public UndisguiseEvent(Entity entity, Disguise disguise) { | ||||
|     public UndisguiseEvent(Entity entity, Disguise disguise, boolean beingReplaced) { | ||||
|         this.disguised = entity; | ||||
|         this.disguise = disguise; | ||||
|         this.isBeingReplaced = beingReplaced; | ||||
|     } | ||||
|  | ||||
|     public Disguise getDisguise() { | ||||
| @@ -42,6 +43,10 @@ public class UndisguiseEvent extends Event implements Cancellable { | ||||
|         return isCancelled; | ||||
|     } | ||||
|  | ||||
|     public boolean isBeingReplaced() { | ||||
|         return isBeingReplaced; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setCancelled(boolean cancelled) { | ||||
|         isCancelled = cancelled; | ||||
|   | ||||
| @@ -407,7 +407,7 @@ public class DisguiseUtilities { | ||||
|                             // But the rest of the time.. Its going to conflict. | ||||
|  | ||||
|                             disguiseItel.remove(); | ||||
|                             d.removeDisguise(); | ||||
|                             d.removeDisguise(true); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user