|
| 1 | +From f4a853766da3be371ba55bba97c3e8b2f0aaefd9 Mon Sep 17 00:00:00 2001 |
| 2 | +From: KennyTV <kennytv@t-online.de> |
| 3 | +Date: Mon, 20 Apr 2020 13:57:13 +0200 |
| 4 | +Subject: [PATCH] PlayerItemCooldownEvent |
| 5 | + |
| 6 | +--- |
| 7 | + .../event/player/PlayerItemCooldownEvent.java | 77 +++++++++++++++++++ |
| 8 | + 1 file changed, 77 insertions(+) |
| 9 | + create mode 100644 src/main/java/net/pl3x/purpur/event/player/PlayerItemCooldownEvent.java |
| 10 | + |
| 11 | +diff --git a/src/main/java/net/pl3x/purpur/event/player/PlayerItemCooldownEvent.java b/src/main/java/net/pl3x/purpur/event/player/PlayerItemCooldownEvent.java |
| 12 | +new file mode 100644 |
| 13 | +index 00000000..ffc2512e |
| 14 | +--- /dev/null |
| 15 | ++++ b/src/main/java/net/pl3x/purpur/event/player/PlayerItemCooldownEvent.java |
| 16 | +@@ -0,0 +1,77 @@ |
| 17 | ++package net.pl3x.purpur.event.player; |
| 18 | ++ |
| 19 | ++import com.google.common.base.Preconditions; |
| 20 | ++import org.bukkit.Material; |
| 21 | ++import org.bukkit.entity.Player; |
| 22 | ++import org.bukkit.event.Cancellable; |
| 23 | ++import org.bukkit.event.HandlerList; |
| 24 | ++import org.bukkit.event.player.PlayerEvent; |
| 25 | ++import org.jetbrains.annotations.NotNull; |
| 26 | ++ |
| 27 | ++/** |
| 28 | ++ * Called when a player receives a cooldown on an item. |
| 29 | ++ */ |
| 30 | ++public final class PlayerItemCooldownEvent extends PlayerEvent implements Cancellable { |
| 31 | ++ private static final HandlerList handlers = new HandlerList(); |
| 32 | ++ @NotNull |
| 33 | ++ private final Material type; |
| 34 | ++ private int cooldown; |
| 35 | ++ private boolean cancelled; |
| 36 | ++ |
| 37 | ++ public PlayerItemCooldownEvent(@NotNull Player player, @NotNull Material type, int cooldown) { |
| 38 | ++ super(player); |
| 39 | ++ this.type = type; |
| 40 | ++ this.cooldown = cooldown; |
| 41 | ++ } |
| 42 | ++ |
| 43 | ++ /** |
| 44 | ++ * Get the material affected by the cooldown. |
| 45 | ++ * |
| 46 | ++ * @return material affected by the cooldown |
| 47 | ++ */ |
| 48 | ++ @NotNull |
| 49 | ++ public Material getType() { |
| 50 | ++ return type; |
| 51 | ++ } |
| 52 | ++ |
| 53 | ++ /** |
| 54 | ++ * Gets the cooldown in ticks. |
| 55 | ++ * |
| 56 | ++ * @return cooldown in ticks |
| 57 | ++ */ |
| 58 | ++ public int getCooldown() { |
| 59 | ++ return cooldown; |
| 60 | ++ } |
| 61 | ++ |
| 62 | ++ /** |
| 63 | ++ * Sets the cooldown of the material in ticks. |
| 64 | ++ * Setting the cooldown to 0 results in removing an already existing cooldown for the material. |
| 65 | ++ * |
| 66 | ++ * @param cooldown cooldown in ticks, has to be a positive number |
| 67 | ++ */ |
| 68 | ++ public void setCooldown(int cooldown) { |
| 69 | ++ Preconditions.checkArgument(cooldown >= 0, "The cooldown has to be equal to or greater than 0!"); |
| 70 | ++ this.cooldown = cooldown; |
| 71 | ++ } |
| 72 | ++ |
| 73 | ++ @Override |
| 74 | ++ public boolean isCancelled() { |
| 75 | ++ return cancelled; |
| 76 | ++ } |
| 77 | ++ |
| 78 | ++ @Override |
| 79 | ++ public void setCancelled(boolean cancel) { |
| 80 | ++ cancelled = cancel; |
| 81 | ++ } |
| 82 | ++ |
| 83 | ++ @Override |
| 84 | ++ @NotNull |
| 85 | ++ public HandlerList getHandlers() { |
| 86 | ++ return handlers; |
| 87 | ++ } |
| 88 | ++ |
| 89 | ++ @NotNull |
| 90 | ++ public static HandlerList getHandlerList() { |
| 91 | ++ return handlers; |
| 92 | ++ } |
| 93 | ++} |
| 94 | +-- |
| 95 | +2.26.1.windows.1 |
| 96 | + |
0 commit comments