mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-04-13 09:41:09 +00:00
Add PlayerAttackCooldownEvent. (SPIGOT-7880)
Signed-off-by: ShreyasAyyengar <shreyas.ayyengar@gmail.com>
This commit is contained in:
parent
f6e7dbd76e
commit
4a8fef719c
1 changed files with 64 additions and 0 deletions
|
@ -0,0 +1,64 @@
|
||||||
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player's attack cooldown ticker starts.
|
||||||
|
* <p>
|
||||||
|
* Warning: <b>Cancelling this event has no impact on the cooldown graphic displayed to the client.</b> If cancelled,
|
||||||
|
* Bukkit will not reset the cooldown ticker, but the client will still display the cooldown graphic regardless.
|
||||||
|
*/
|
||||||
|
public class PlayerAttackCooldownEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
private final AttackCooldownCause cause;
|
||||||
|
|
||||||
|
public PlayerAttackCooldownEvent(@NotNull Player who, @NotNull AttackCooldownCause cause) {
|
||||||
|
super(who);
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public AttackCooldownCause getCause() {
|
||||||
|
return cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AttackCooldownCause {
|
||||||
|
/**
|
||||||
|
* Indicates the player switched items
|
||||||
|
*/
|
||||||
|
ITEM_SWITCH,
|
||||||
|
/**
|
||||||
|
* Indicates the player attacked an entity
|
||||||
|
*/
|
||||||
|
ATTACK_ENTITY,
|
||||||
|
/**
|
||||||
|
* Indicates the player swung their arm
|
||||||
|
*/
|
||||||
|
SWING
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue