From 0ddcb12b31c4f39657cac0e0ab10d3ef68a6cf67 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Tue, 14 Mar 2023 15:47:27 -0400 Subject: [PATCH 01/25] feat: abstraction of `PlayerCosmetic...` styled events --- .../hmccosmetics/api/CosmeticUserEvent.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.java diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.java new file mode 100644 index 00000000..b501192d --- /dev/null +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.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 CosmeticUserEvent extends Event { + protected CosmeticUser user; + + public CosmeticUserEvent(@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; + } +} From 00ce32c528f9af00bf47d30abf3a79a7a9e25785 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Tue, 14 Mar 2023 15:48:18 -0400 Subject: [PATCH 02/25] docs(PlayerCosmeticEquipEvent): documented class --- .../api/PlayerCosmeticEquipEvent.java | 63 ++++++++++++------- 1 file changed, 39 insertions(+), 24 deletions(-) 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..7328af1b 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 CosmeticUserEvent 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 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 cosmetic that the player will equip + * + * @param cosmetic The 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; - } } From de1377dc8f2875f851737cf383aeaed8bb47e4c5 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Tue, 14 Mar 2023 18:25:47 -0400 Subject: [PATCH 03/25] docs(PlayerCosmeticEquipEvent): `@see` when referring to classes --- .../hmccosmetics/api/PlayerCosmeticEquipEvent.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 7328af1b..48c28534 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java @@ -20,9 +20,9 @@ public class PlayerCosmeticEquipEvent extends CosmeticUserEvent implements Cance } /** - * Gets the cosmetic being equipped in this event. + * Gets the {@link Cosmetic} being equipped in this event. * - * @return The {@link Cosmetic} which is being equipped in this event. + * @return The {@link Cosmetic} which is being equipped in this event */ @NotNull public Cosmetic getCosmetic() { @@ -30,9 +30,9 @@ public class PlayerCosmeticEquipEvent extends CosmeticUserEvent implements Cance } /** - * Sets the cosmetic that the player will equip + * Sets the {@link Cosmetic} that the player will equip * - * @param cosmetic The 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; From a4bd9108b1b9fe0e64ead3a7a73fd03192b5becc Mon Sep 17 00:00:00 2001 From: Craftinators Date: Tue, 14 Mar 2023 18:26:22 -0400 Subject: [PATCH 04/25] docs(PlayerCosmeticHideEvent): documented class --- .../api/PlayerCosmeticHideEvent.java | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) 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..13eb8749 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 CosmeticUserEvent 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; - } } From f08c38ff1a4d77177934d5782130d4749c7f50dd Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 01:34:58 -0400 Subject: [PATCH 05/25] docs(PlayerCosmeticEquipEvent): updated documentation --- .../hmccosmetics/api/PlayerCosmeticEquipEvent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 48c28534..3d1029fd 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java @@ -20,7 +20,7 @@ public class PlayerCosmeticEquipEvent extends CosmeticUserEvent implements Cance } /** - * Gets the {@link Cosmetic} being equipped in this event. + * Gets the {@link Cosmetic} being equipped in this event * * @return The {@link Cosmetic} which is being equipped in this event */ @@ -44,10 +44,10 @@ public class PlayerCosmeticEquipEvent extends CosmeticUserEvent implements Cance } /** - * Sets the cancellation state of this event. + * Sets the cancellation state of this event * *

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

* * @param cancel true if you wish to cancel this event From fddd5d031191dfb1f3fe0f63d4c8e680ef5cf272 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 01:37:46 -0400 Subject: [PATCH 06/25] docs(PlayerCosmeticHideEvent): updated documentation --- .../hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 13eb8749..566b3c93 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java @@ -34,10 +34,10 @@ public class PlayerCosmeticHideEvent extends CosmeticUserEvent implements Cancel } /** - * Sets the cancellation state of this event. + * Sets the cancellation state of this event * *

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

* * @param cancel true if you wish to cancel this event From c395b68d6a134e6f026f3a87de9b37a032e01558 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 01:38:33 -0400 Subject: [PATCH 07/25] docs(PlayerCosmeticRemoveEvent): documented class --- .../api/PlayerCosmeticRemoveEvent.java | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) 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..79808deb 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 CosmeticUserEvent 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 From f456ddf8a484d5ea8150d225e5f2bb8dd653c8f3 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 01:39:00 -0400 Subject: [PATCH 08/25] docs(PlayerCosmeticShowEvent): documented class --- .../api/PlayerCosmeticShowEvent.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) 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..ef805893 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java @@ -6,39 +6,44 @@ 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 CosmeticUserEvent 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 From d05072eb2ce5ebe3a91246c18df2a58776aaed35 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 01:40:06 -0400 Subject: [PATCH 09/25] fix(PlayerCosmeticShowEvent): remove unused import --- .../com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java | 1 - 1 file changed, 1 deletion(-) 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 ef805893..63e122e8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java @@ -2,7 +2,6 @@ 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; From eb925d902256a1b1bd60aeec3ea3e4ce433b4dcc Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 01:45:07 -0400 Subject: [PATCH 10/25] docs(`HMCCosmeticSetupEvent`): documented class --- .../hmccosmetics/api/HMCCosmeticSetupEvent.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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..1e6d6d38 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 enabled + */ 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; } From 961f460ffbf8a3acf9fbf86c422a3a9a0d47c6e9 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 03:57:28 -0400 Subject: [PATCH 11/25] docs(`PlayerEmoteStartEvent`): documented class --- .../api/PlayerEmoteStartEvent.java | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) 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..e97327d9 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 CosmeticUserEvent 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 From fd6553a52aee96da11c49ed23878f258913d027a Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 03:57:44 -0400 Subject: [PATCH 12/25] docs(`PlayerEmoteStopEvent`): documented class --- .../api/PlayerEmoteStopEvent.java | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) 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..abcd4bba 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,69 @@ 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 { +public class PlayerEmoteStopEvent extends CosmeticUserEvent 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; - } } From be93369a8b4293b6f0ac3bc009759dcf7405e312 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 03:58:33 -0400 Subject: [PATCH 13/25] docs(`PlayerEmoteStopEvent`): add class documentation --- .../com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java | 3 +++ 1 file changed, 3 insertions(+) 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 abcd4bba..7ffde061 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java @@ -6,6 +6,9 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +/** + * Called when a player stops playing an emote + */ public class PlayerEmoteStopEvent extends CosmeticUserEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; From 591198175af581aa91c2f4f7afb3c2b352ad874f Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:05:17 -0400 Subject: [PATCH 14/25] docs(`PlayerMenuOpenEvent`): documented class --- .../hmccosmetics/api/PlayerMenuOpenEvent.java | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) 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..20c85f23 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,56 @@ 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 { - - private final CosmeticUser user; +public class PlayerMenuOpenEvent extends CosmeticUserEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; private final Menu menu; - private boolean isCancelled; - public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) { - this.user = user; + public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { + super(who); this.menu = menu; - this.isCancelled = false; + } + + /** + * Gets the {@link Menu} that the player is opening + * + * @return The {@link Menu} which is being opened by the player + */ + @NotNull + public Menu getMenu() { + return 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; - } } From ea4d088b04f46152e059a2cd6e074ffd7385ae50 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:05:39 -0400 Subject: [PATCH 15/25] docs(`PlayerWardrobeEnterEvent`): documented class --- .../api/PlayerWardrobeEnterEvent.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) 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..1b5af1d5 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,44 @@ 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 { +public class PlayerWardrobeEnterEvent extends CosmeticUserEvent 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; - } } From 17c07d0e0122c6954cee61e7e574dc49c713fcf3 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:05:50 -0400 Subject: [PATCH 16/25] docs(`PlayerWardrobeLeaveEvent`): documented class --- .../api/PlayerWardrobeLeaveEvent.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) 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..b9849db5 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,44 @@ 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 { +public class PlayerWardrobeLeaveEvent extends CosmeticUserEvent 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; - } } From 42a01a44aa01553ff1db6a62e1eb9ca27a64507d Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:43:23 -0400 Subject: [PATCH 17/25] docs(`PlayerWardrobeEnterEvent`): add class documentation --- .../hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java | 3 +++ 1 file changed, 3 insertions(+) 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 1b5af1d5..7b4a274f 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java @@ -5,6 +5,9 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +/** + * Called when a player enters their wardrobe + */ public class PlayerWardrobeEnterEvent extends CosmeticUserEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; From cea40033f98e74ce13938a6d3dbd99926f6ce585 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:43:36 -0400 Subject: [PATCH 18/25] docs(`PlayerWardrobeLeaveEvent`): add class documentation --- .../hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java | 3 +++ 1 file changed, 3 insertions(+) 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 b9849db5..753f57be 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java @@ -5,6 +5,9 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +/** + * Called when a player leaves their wardrobe + */ public class PlayerWardrobeLeaveEvent extends CosmeticUserEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; From df2da4fc899b1d800f0db7e2c7204814b321d86c Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:43:50 -0400 Subject: [PATCH 19/25] docs(`PlayerMenuOpenEvent`): add class documentation --- .../com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 20c85f23..cfea3dfc 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java @@ -6,6 +6,9 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +/** + * Called when a menu is opened by a player + */ public class PlayerMenuOpenEvent extends CosmeticUserEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; @@ -17,7 +20,7 @@ public class PlayerMenuOpenEvent extends CosmeticUserEvent implements Cancellabl } /** - * Gets the {@link Menu} that the player is opening + * Gets the {@link Menu} that the player opened * * @return The {@link Menu} which is being opened by the player */ From ffda4ba6f5d2456e0898007fc6d2ec83a761b9da Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 04:44:18 -0400 Subject: [PATCH 20/25] feat: new `PlayerMenuOpenEvent` class --- .../api/PlayerMenuCloseEvent.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java 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..1569f429 --- /dev/null +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java @@ -0,0 +1,61 @@ +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.HandlerList; +import org.jetbrains.annotations.NotNull; + +/** + * Called when a menu is closed by a player + */ +public class PlayerMenuCloseEvent extends CosmeticUserEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private final Menu menu; + + public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { + super(who); + this.menu = menu; + } + + /** + * Gets the {@link Menu} that the player closed + * + * @return The {@link Menu} which is being closed by the player + */ + @NotNull + public Menu getMenu() { + return menu; + } + + @Override + public boolean isCancelled() { + return cancel; + } + + /** + * Sets the cancellation state of this event + * + *

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

+ * + * @param cancel true if you wish to cancel this event + */ + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @Override + @NotNull + public HandlerList getHandlers() { + return handlers; + } + + @NotNull + public static HandlerList getHandlerList() { + return handlers; + } +} From 965b6cc7404a2aed7105889014705aa46fecd676 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 08:04:28 -0400 Subject: [PATCH 21/25] fix(`PlayerCosmeticEvent`): rename to `PlayerCosmeticEvent` --- .../hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java | 2 +- .../api/{CosmeticUserEvent.java => PlayerCosmeticEvent.java} | 4 ++-- .../hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java | 2 +- .../hmccosmetics/api/PlayerCosmeticRemoveEvent.java | 2 +- .../hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java | 2 +- .../hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java | 2 +- .../com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java | 2 +- .../hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java | 2 +- .../hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) rename common/src/main/java/com/hibiscusmc/hmccosmetics/api/{CosmeticUserEvent.java => PlayerCosmeticEvent.java} (79%) 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 3d1029fd..ed50ed6f 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEquipEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player equips a cosmetic */ -public class PlayerCosmeticEquipEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private Cosmetic cosmetic; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEvent.java similarity index 79% rename from common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.java rename to common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEvent.java index b501192d..e0de0218 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/CosmeticUserEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticEvent.java @@ -7,10 +7,10 @@ import org.jetbrains.annotations.NotNull; /** * Represents a cosmetic user related event */ -public abstract class CosmeticUserEvent extends Event { +public abstract class PlayerCosmeticEvent extends Event { protected CosmeticUser user; - public CosmeticUserEvent(@NotNull final CosmeticUser who) { + public PlayerCosmeticEvent(@NotNull final CosmeticUser who) { user = who; } 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 566b3c93..3e5059d8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticHideEvent.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when cosmetics are hidden from a player */ -public class PlayerCosmeticHideEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private final CosmeticUser.HiddenReason 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 79808deb..373337e8 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticRemoveEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticRemoveEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player removes a cosmetic */ -public class PlayerCosmeticRemoveEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private final Cosmetic cosmetic; 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 63e122e8..4776e432 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerCosmeticShowEvent.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when cosmetics are shown from a player */ -public class PlayerCosmeticShowEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; 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 e97327d9..3d4e4871 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStartEvent.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player starts playing an emote */ -public class PlayerEmoteStartEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private final String animationId; 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 7ffde061..4fbb96af 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerEmoteStopEvent.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player stops playing an emote */ -public class PlayerEmoteStopEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; private final UserEmoteManager.StopEmoteReason reason; 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 7b4a274f..904642d2 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeEnterEvent.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player enters their wardrobe */ -public class PlayerWardrobeEnterEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; 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 753f57be..affc4945 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerWardrobeLeaveEvent.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player leaves their wardrobe */ -public class PlayerWardrobeLeaveEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; From 2b4e5701724dc19257f1a8fa7d19862a9af33c24 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 08:04:53 -0400 Subject: [PATCH 22/25] clean(`UserEmoteManager`): remove unused import --- .../hibiscusmc/hmccosmetics/user/manager/UserEmoteManager.java | 1 - 1 file changed, 1 deletion(-) 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; From 1ccb35ad624996d1cd4f5da0c5c60d02bd8e90fa Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 08:05:15 -0400 Subject: [PATCH 23/25] refactor: abstraction of menu related events --- .../api/PlayerMenuCloseEvent.java | 16 ++--------- .../hmccosmetics/api/PlayerMenuEvent.java | 27 +++++++++++++++++++ .../hmccosmetics/api/PlayerMenuOpenEvent.java | 16 ++--------- 3 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuEvent.java diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java index 1569f429..cbbbc4de 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java @@ -9,24 +9,12 @@ import org.jetbrains.annotations.NotNull; /** * Called when a menu is closed by a player */ -public class PlayerMenuCloseEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerMenuCloseEvent extends PlayerMenuEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; - private final Menu menu; public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { - super(who); - this.menu = menu; - } - - /** - * Gets the {@link Menu} that the player closed - * - * @return The {@link Menu} which is being closed by the player - */ - @NotNull - public Menu getMenu() { - return menu; + super(who, menu); } @Override 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 cfea3dfc..a31a09d4 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuOpenEvent.java @@ -9,24 +9,12 @@ import org.jetbrains.annotations.NotNull; /** * Called when a menu is opened by a player */ -public class PlayerMenuOpenEvent extends CosmeticUserEvent implements Cancellable { +public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel = false; - private final Menu menu; public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { - super(who); - this.menu = menu; - } - - /** - * Gets the {@link Menu} that the player opened - * - * @return The {@link Menu} which is being opened by the player - */ - @NotNull - public Menu getMenu() { - return menu; + super(who, menu); } @Override From af78424b0775c7d80e9595ab6279477b06768154 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 15:31:25 -0400 Subject: [PATCH 24/25] refactor(PlayerMenuCloseEvent): event no longer cancellable --- .../api/PlayerMenuCloseEvent.java | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java index cbbbc4de..da43ab9d 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/PlayerMenuCloseEvent.java @@ -2,40 +2,19 @@ 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.HandlerList; import org.jetbrains.annotations.NotNull; /** * Called when a menu is closed by a player */ -public class PlayerMenuCloseEvent extends PlayerMenuEvent implements Cancellable { +public class PlayerMenuCloseEvent extends PlayerMenuEvent { private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) { super(who, menu); } - @Override - public boolean isCancelled() { - return cancel; - } - - /** - * Sets the cancellation state of this event - * - *

- * Canceling this event will prevent the player from closing a {@link Menu} - *

- * - * @param cancel true if you wish to cancel this event - */ - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - @Override @NotNull public HandlerList getHandlers() { From d1a2b6a0162944a06aeb43f6d639e316c4a82018 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Wed, 15 Mar 2023 17:11:41 -0400 Subject: [PATCH 25/25] docs(HMCCosmeticSetupEvent): fix documentation --- .../com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1e6d6d38..c5639284 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticSetupEvent.java @@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** - * Called when the plugin is enabled + * Called when the plugin is set up and/or reloaded */ public class HMCCosmeticSetupEvent extends Event { private static final HandlerList handlers = new HandlerList();