mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
f17519338b
* Expose server build information * squash patches * final tweaks --------- Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: masmc05 <masmc05@gmail.com>
108 lines
3 KiB
Diff
108 lines
3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: JRoy <joshroy126@gmail.com>
|
|
Date: Wed, 7 Oct 2020 12:04:17 -0400
|
|
Subject: [PATCH] Add EntityLoadCrossbowEvent
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..8434ea803e3135380f9351c82a414ccb65c478a9
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/event/entity/EntityLoadCrossbowEvent.java
|
|
@@ -0,0 +1,96 @@
|
|
+package io.papermc.paper.event.entity;
|
|
+
|
|
+import org.bukkit.entity.LivingEntity;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
|
+import org.bukkit.inventory.ItemStack;
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Called when a LivingEntity loads a crossbow with a projectile.
|
|
+ */
|
|
+public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable {
|
|
+
|
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
|
+
|
|
+ private final ItemStack crossbow;
|
|
+ private final EquipmentSlot hand;
|
|
+
|
|
+ private boolean consumeItem = true;
|
|
+ private boolean cancelled;
|
|
+
|
|
+ @ApiStatus.Internal
|
|
+ public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @NotNull ItemStack crossbow, @NotNull EquipmentSlot hand) {
|
|
+ super(entity);
|
|
+ this.crossbow = crossbow;
|
|
+ this.hand = hand;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public LivingEntity getEntity() {
|
|
+ return (LivingEntity) super.getEntity();
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the crossbow {@link ItemStack} being loaded.
|
|
+ *
|
|
+ * @return the crossbow involved in this event
|
|
+ */
|
|
+ @NotNull
|
|
+ public ItemStack getCrossbow() {
|
|
+ return this.crossbow;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the hand from which the crossbow was loaded.
|
|
+ *
|
|
+ * @return the hand
|
|
+ */
|
|
+ @NotNull
|
|
+ public EquipmentSlot getHand() {
|
|
+ return this.hand;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * @return should the itemstack be consumed
|
|
+ */
|
|
+ public boolean shouldConsumeItem() {
|
|
+ return this.consumeItem;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * @param consume should the item be consumed
|
|
+ */
|
|
+ public void setConsumeItem(boolean consume) {
|
|
+ this.consumeItem = consume;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return this.cancelled;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Set whether to cancel the crossbow being loaded. If canceled, the
|
|
+ * projectile that would be loaded into the crossbow will not be consumed.
|
|
+ */
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ this.cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ @Override
|
|
+ public HandlerList getHandlers() {
|
|
+ return HANDLER_LIST;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return HANDLER_LIST;
|
|
+ }
|
|
+}
|