From 00ce32c528f9af00bf47d30abf3a79a7a9e25785 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Tue, 14 Mar 2023 15:48:18 -0400 Subject: [PATCH] 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; - } }