9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-28 19:39:14 +00:00

docs(PlayerCosmeticEquipEvent): documented class

This commit is contained in:
Craftinators
2023-03-14 15:48:18 -04:00
parent 0ddcb12b31
commit 00ce32c528

View File

@@ -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.
*
* <p>
* Canceling this event will prevent the player from equipping the cosmetic.
* </p>
*
* @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;
}
}