diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java index 54df4c13..c5639284 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java @@ -4,12 +4,10 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +/** + * Called when the plugin is set up and/or reloaded + */ public class HMCCosmeticSetupEvent extends Event { - - public HMCCosmeticSetupEvent() { - // Empty - } - private static final HandlerList handlers = new HandlerList(); @Override @@ -18,6 +16,7 @@ public class HMCCosmeticSetupEvent extends Event { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java index 130a3717..ed50ed6f 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java @@ -3,53 +3,68 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerCosmeticEquipEvent extends Event implements Cancellable { - - private final CosmeticUser user; +/** + * Called when a player equips a cosmetic + */ +public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; private Cosmetic cosmetic; - private boolean isCancelled; - public PlayerCosmeticEquipEvent(CosmeticUser user, Cosmetic cosmetic) { - this.user = user; + public PlayerCosmeticEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) { + super(who); + this.cosmetic = cosmetic; + } + + /** + * Gets the {@link Cosmetic} being equipped in this event + * + * @return The {@link Cosmetic} which is being equipped in this event + */ + @NotNull + public Cosmetic getCosmetic() { + return cosmetic; + } + + /** + * Sets the {@link Cosmetic} that the player will equip + * + * @param cosmetic The {@link Cosmetic} that the player will equip + */ + public void setCosmetic(@NotNull Cosmetic cosmetic) { this.cosmetic = cosmetic; - this.isCancelled = false; } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from equipping the cosmetic + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } - - public Cosmetic getCosmetic() { - return cosmetic; - } - - public void setCosmetic(Cosmetic cosmetic) { - this.cosmetic = cosmetic; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEvent.java new file mode 100644 index 00000000..e0de0218 --- /dev/null +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEvent.java @@ -0,0 +1,26 @@ +package com.hibiscusmc.hmccosmetics.api; + +import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import org.bukkit.event.Event; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a cosmetic user related event + */ +public abstract class PlayerCosmeticEvent extends Event { + protected CosmeticUser user; + + public PlayerCosmeticEvent(@NotNull final CosmeticUser who) { + user = who; + } + + /** + * Returns the user involved in this event + * + * @return User who is involved in this event + */ + @NotNull + public final CosmeticUser getUser() { + return user; + } +} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java index 405aff02..3e5059d8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java @@ -2,48 +2,59 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerCosmeticHideEvent extends Event implements Cancellable { - - private final CosmeticUser user; +/** + * Called when cosmetics are hidden from a player + */ +public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; private final CosmeticUser.HiddenReason reason; - private boolean isCancelled; - public PlayerCosmeticHideEvent(CosmeticUser user, CosmeticUser.HiddenReason reason) { - this.user = user; + public PlayerCosmeticHideEvent(@NotNull CosmeticUser who, @NotNull CosmeticUser.HiddenReason reason) { + super(who); this.reason = reason; - this.isCancelled = false; + } + + /** + * Gets the {@link CosmeticUser.HiddenReason} as to why cosmetics are being hidden for the player + * + * @return The {@link CosmeticUser.HiddenReason} why cosmetics are being hidden for the player + */ + @NotNull + public CosmeticUser.HiddenReason getReason() { + return reason; } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from hiding cosmetics + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } - public CosmeticUser.HiddenReason getReason() { - return reason; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticRemoveEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticRemoveEvent.java index ab363363..373337e8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticRemoveEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticRemoveEvent.java @@ -3,34 +3,50 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerCosmeticRemoveEvent extends Event implements Cancellable { - - private final CosmeticUser user; +/** + * Called when a player removes a cosmetic + */ +public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; private final Cosmetic cosmetic; - private boolean isCancelled; - public PlayerCosmeticRemoveEvent(CosmeticUser user, Cosmetic cosmetic) { - this.user = user; + public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) { + super(who); this.cosmetic = cosmetic; - this.isCancelled = false; + } + + /** + * Gets the {@link Cosmetic} being removed in this event + * + * @return The {@link Cosmetic} which is being removed in this event + */ + public Cosmetic getCosmetic() { + return cosmetic; } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from removing the cosmetic + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { @@ -40,12 +56,4 @@ public class PlayerCosmeticRemoveEvent extends Event implements Cancellable { public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } - - public Cosmetic getCosmetic() { - return cosmetic; - } } \ No newline at end of file diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java index 6218fcff..4776e432 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java @@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerCosmeticShowEvent extends Event implements Cancellable { +/** + * Called when cosmetics are shown from a player + */ +public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; - private final CosmeticUser user; - private boolean isCancelled; - - public PlayerCosmeticShowEvent(CosmeticUser user) { - this.user = user; - this.isCancelled = false; + public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) { + super(who); } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from showing cosmetics + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } } \ No newline at end of file diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java index 46aab719..3d4e4871 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java @@ -2,49 +2,60 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerEmoteStartEvent extends Event implements Cancellable { +/** + * Called when a player starts playing an emote + */ +public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private final String animationId; - private final CosmeticUser user; - private String animationId; // Animation id can be invalid! - private boolean isCancelled; - - public PlayerEmoteStartEvent(CosmeticUser user, String animationId) { - this.user = user; + public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) { + super(who); this.animationId = animationId; - this.isCancelled = false; + } + + /** + * Gets the animation id of the emote the player started playing + * @implNote The returned string of this method may be an invalid animation id. Make sure to validate it before use + * + * @return The animation id of the emote which the player started playing + */ + @NotNull + public String getAnimationId() { + return animationId; } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from playing the emote + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } - - public String getAnimationId() { - return animationId; - } } \ No newline at end of file diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java index 26610a89..4fbb96af 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java @@ -3,49 +3,72 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerEmoteStopEvent extends Event implements Cancellable { +/** + * Called when a player stops playing an emote + */ +public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private final UserEmoteManager.StopEmoteReason reason; - private final CosmeticUser user; - private final UserEmoteManager.StopEmoteReason stopEmoteReason; - private boolean isCancelled; + public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) { + super(who); + this.reason = reason; + } - public PlayerEmoteStopEvent(CosmeticUser user, UserEmoteManager.StopEmoteReason reason) { - this.user = user; - this.stopEmoteReason = reason; - this.isCancelled = false; + /** + * Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing + * + * @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing + * @deprecated As of release 2.2.5+, replaced by {@link #getReason()} + */ + @Deprecated + @NotNull + public UserEmoteManager.StopEmoteReason getStopEmoteReason() { + return reason; + } + + /** + * Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing + * + * @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing + * @since 2.2.5 + */ + @NotNull + public UserEmoteManager.StopEmoteReason getReason() { + return reason; } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from stopping the emote + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } - - public UserEmoteManager.StopEmoteReason getStopEmoteReason() { - return stopEmoteReason; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java new file mode 100644 index 00000000..da43ab9d --- /dev/null +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java @@ -0,0 +1,28 @@ +package com.hibiscusmc.hmccosmetics.api; + +import com.hibiscusmc.hmccosmetics.gui.Menu; +import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a menu is closed by a player + */ +public class PlayerMenuCloseEvent extends PlayerMenuEvent { + private static final HandlerList handlers = new HandlerList(); + + public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { + super(who, menu); + } + + @Override + @NotNull + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuEvent.java new file mode 100644 index 00000000..e5b74a2e --- /dev/null +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuEvent.java @@ -0,0 +1,27 @@ +package com.hibiscusmc.hmccosmetics.api; + +import com.hibiscusmc.hmccosmetics.gui.Menu; +import com.hibiscusmc.hmccosmetics.user.CosmeticUser; +import org.jetbrains.annotations.NotNull; + +/** + * Represents a menu related event + */ +public abstract class PlayerMenuEvent extends PlayerCosmeticEvent { + protected Menu menu; + + public PlayerMenuEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { + super(who); + this.menu = menu; + } + + /** + * Gets the {@link Menu} involved with this event + * + * @return The {@link Menu} which is involved with the event + */ + @NotNull + public final Menu getMenu() { + return menu; + } +} diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java index b61fe149..a31a09d4 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java @@ -3,49 +3,47 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerMenuOpenEvent extends Event implements Cancellable { +/** + * Called when a menu is opened by a player + */ +public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; - private final CosmeticUser user; - private final Menu menu; - private boolean isCancelled; - - public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) { - this.user = user; - this.menu = menu; - this.isCancelled = false; + public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { + super(who, menu); } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from opening a {@link Menu} + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } - - public Menu getMenu() { - return menu; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java index dc19c143..904642d2 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java @@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerWardrobeEnterEvent extends Event implements Cancellable { +/** + * Called when a player enters their wardrobe + */ +public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; - private final CosmeticUser user; - private boolean isCancelled; - - public PlayerWardrobeEnterEvent(CosmeticUser user) { - this.user = user; - this.isCancelled = false; + public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) { + super(who); } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from entering their wardrobe + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java index 4afb0897..affc4945 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java @@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; -public class PlayerWardrobeLeaveEvent extends Event implements Cancellable { +/** + * Called when a player leaves their wardrobe + */ +public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; - private final CosmeticUser user; - private boolean isCancelled; - - public PlayerWardrobeLeaveEvent(CosmeticUser user) { - this.user = user; - this.isCancelled = false; + public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) { + super(who); } @Override public boolean isCancelled() { - return isCancelled; + return cancel; } + /** + * Sets the cancellation state of this event + * + *

+ * Canceling this event will prevent the player from leaving their wardrobe + *

+ * + * @param cancel true if you wish to cancel this event + */ @Override public void setCancelled(boolean cancel) { - isCancelled = cancel; + this.cancel = cancel; } - private static final HandlerList handlers = new HandlerList(); - @Override @NotNull public HandlerList getHandlers() { return handlers; } + @NotNull public static HandlerList getHandlerList() { return handlers; } - - public CosmeticUser getUser() { - return user; - } } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java index 028de85b..71d1b235 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java @@ -1,6 +1,5 @@ package com.hibiscusmc.hmccosmetics.user.manager; -import com.hibiscusmc.hmccosmetics.api.PlayerCosmeticRemoveEvent; import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent; import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;