mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-26 20:55:30 +01:00
392 lines
13 KiB
Diff
392 lines
13 KiB
Diff
From a5d62d4af2c15e1f107eb5c10660d80ae025fca1 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 7 Dec 2016 00:22:09 -0500
|
|
Subject: [PATCH] EMC PlayerUseItemEvent
|
|
|
|
---
|
|
.../player/PlayerPostPlaceItemAtEvent.java | 80 +++++++++++++
|
|
.../event/player/PlayerPostUseItemEvent.java | 69 +++++++++++
|
|
.../customevents/PlayerPlaceItemAtEvent.java | 110 ++++++++++++++++++
|
|
.../customevents/PlayerUseItemEvent.java | 89 ++++++++++++++
|
|
4 files changed, 348 insertions(+)
|
|
create mode 100644 src/main/java/com/destroystokyo/paper/event/player/PlayerPostPlaceItemAtEvent.java
|
|
create mode 100644 src/main/java/com/destroystokyo/paper/event/player/PlayerPostUseItemEvent.java
|
|
create mode 100644 src/main/java/com/empireminecraft/customevents/PlayerPlaceItemAtEvent.java
|
|
create mode 100644 src/main/java/com/empireminecraft/customevents/PlayerUseItemEvent.java
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPostPlaceItemAtEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostPlaceItemAtEvent.java
|
|
new file mode 100644
|
|
index 00000000..8e83d0d9
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostPlaceItemAtEvent.java
|
|
@@ -0,0 +1,80 @@
|
|
+/*
|
|
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
|
|
+ *
|
|
+ * Permission is hereby granted, free of charge, to any person obtaining
|
|
+ * a copy of this software and associated documentation files (the
|
|
+ * "Software"), to deal in the Software without restriction, including
|
|
+ * without limitation the rights to use, copy, modify, merge, publish,
|
|
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
|
+ * permit persons to whom the Software is furnished to do so, subject to
|
|
+ * the following conditions:
|
|
+ *
|
|
+ * The above copyright notice and this permission notice shall be
|
|
+ * included in all copies or substantial portions of the Software.
|
|
+ *
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
+ */
|
|
+
|
|
+package com.destroystokyo.paper.event.player;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.block.BlockFace;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.player.PlayerEvent;
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
|
+import org.bukkit.inventory.ItemStack;
|
|
+import org.bukkit.util.Vector;
|
|
+
|
|
+public class PlayerPostPlaceItemAtEvent extends PlayerEvent {
|
|
+ private final ItemStack usedItem;
|
|
+ private final Location targetLoc;
|
|
+ private final BlockFace clickFace;
|
|
+ private final Vector hitVector;
|
|
+ private final EquipmentSlot hand;
|
|
+
|
|
+ public PlayerPostPlaceItemAtEvent(Player player, ItemStack usedItem, Location targetLoc, BlockFace clickFace, Vector hitVector, EquipmentSlot hand) {
|
|
+ super(player);
|
|
+ this.usedItem = usedItem;
|
|
+ this.targetLoc = targetLoc;
|
|
+ this.clickFace = clickFace;
|
|
+ this.hitVector = hitVector;
|
|
+ this.hand = hand;
|
|
+ }
|
|
+
|
|
+ public Location getTargetLoc() {
|
|
+ return targetLoc;
|
|
+ }
|
|
+
|
|
+ public BlockFace getClickFace() {
|
|
+ return clickFace;
|
|
+ }
|
|
+
|
|
+ public Vector getHitVector() {
|
|
+ return hitVector;
|
|
+ }
|
|
+
|
|
+ public EquipmentSlot getHand() {
|
|
+ return hand;
|
|
+ }
|
|
+
|
|
+ public ItemStack getUsedItem() {
|
|
+ return usedItem;
|
|
+ }
|
|
+
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPostUseItemEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostUseItemEvent.java
|
|
new file mode 100644
|
|
index 00000000..511082ea
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPostUseItemEvent.java
|
|
@@ -0,0 +1,69 @@
|
|
+/*
|
|
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
|
|
+ *
|
|
+ * Permission is hereby granted, free of charge, to any person obtaining
|
|
+ * a copy of this software and associated documentation files (the
|
|
+ * "Software"), to deal in the Software without restriction, including
|
|
+ * without limitation the rights to use, copy, modify, merge, publish,
|
|
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
|
+ * permit persons to whom the Software is furnished to do so, subject to
|
|
+ * the following conditions:
|
|
+ *
|
|
+ * The above copyright notice and this permission notice shall be
|
|
+ * included in all copies or substantial portions of the Software.
|
|
+ *
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
+ */
|
|
+
|
|
+package com.destroystokyo.paper.event.player;
|
|
+
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.player.PlayerEvent;
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
|
+import org.bukkit.inventory.ItemStack;
|
|
+
|
|
+public class PlayerPostUseItemEvent extends PlayerEvent {
|
|
+ private final ItemStack usedItem;
|
|
+ private ItemStack newItem;
|
|
+ private final EquipmentSlot hand;
|
|
+
|
|
+ public PlayerPostUseItemEvent(Player player, ItemStack usedItem, ItemStack newItem, EquipmentSlot hand) {
|
|
+ super(player);
|
|
+ this.usedItem = usedItem;
|
|
+ this.newItem = newItem;
|
|
+ this.hand = hand;
|
|
+ }
|
|
+
|
|
+ public EquipmentSlot getHand() {
|
|
+ return hand;
|
|
+ }
|
|
+
|
|
+ public ItemStack getUsedItem() {
|
|
+ return usedItem;
|
|
+ }
|
|
+
|
|
+ public ItemStack getNewItem() {
|
|
+ return newItem;
|
|
+ }
|
|
+
|
|
+ public void setNewItem(ItemStack newItem) {
|
|
+ this.newItem = newItem;
|
|
+ }
|
|
+
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/com/empireminecraft/customevents/PlayerPlaceItemAtEvent.java b/src/main/java/com/empireminecraft/customevents/PlayerPlaceItemAtEvent.java
|
|
new file mode 100644
|
|
index 00000000..1b1bf854
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/empireminecraft/customevents/PlayerPlaceItemAtEvent.java
|
|
@@ -0,0 +1,110 @@
|
|
+/*
|
|
+ * Copyright (c) 2016 Starlis LLC / Daniel Ennis (Aikar) - MIT License
|
|
+ *
|
|
+ * Permission is hereby granted, free of charge, to any person obtaining
|
|
+ * a copy of this software and associated documentation files (the
|
|
+ * "Software"), to deal in the Software without restriction, including
|
|
+ * without limitation the rights to use, copy, modify, merge, publish,
|
|
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
|
+ * permit persons to whom the Software is furnished to do so, subject to
|
|
+ * the following conditions:
|
|
+ *
|
|
+ * The above copyright notice and this permission notice shall be
|
|
+ * included in all copies or substantial portions of the Software.
|
|
+ *
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
+ */
|
|
+
|
|
+package com.empireminecraft.customevents;
|
|
+
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.block.BlockFace;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.player.PlayerEvent;
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
|
+import org.bukkit.inventory.ItemStack;
|
|
+import org.bukkit.util.Vector;
|
|
+
|
|
+public class PlayerPlaceItemAtEvent extends PlayerEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean canceled;
|
|
+ private final ItemStack item;
|
|
+ private final Location targetLoc;
|
|
+ private final BlockFace clickFace;
|
|
+ private final Vector hitVector;
|
|
+ private final EquipmentSlot hand;
|
|
+ private ItemStack tempItem;
|
|
+ private boolean consume = true;
|
|
+
|
|
+
|
|
+ public PlayerPlaceItemAtEvent(Player player, ItemStack item, Location targetLoc, BlockFace clickFace, Vector hitVector, EquipmentSlot hand) {
|
|
+ super(player);
|
|
+ this.item = item;
|
|
+ this.targetLoc = targetLoc;
|
|
+ this.clickFace = clickFace;
|
|
+ this.hitVector = hitVector;
|
|
+ this.hand = hand;
|
|
+ }
|
|
+
|
|
+ public ItemStack getItem() {
|
|
+ return item;
|
|
+ }
|
|
+
|
|
+ public EquipmentSlot getHand() {
|
|
+ return hand;
|
|
+ }
|
|
+
|
|
+ public Location getTargetLoc() {
|
|
+ return targetLoc;
|
|
+ }
|
|
+
|
|
+ public BlockFace getClickFace() {
|
|
+ return clickFace;
|
|
+ }
|
|
+
|
|
+ public Vector getHitVector() {
|
|
+ return hitVector;
|
|
+ }
|
|
+
|
|
+ public ItemStack getTempItem() {
|
|
+ return this.tempItem;
|
|
+ }
|
|
+
|
|
+ public void setTempItem(ItemStack item) {
|
|
+ if (item == null) {
|
|
+ canceled = true;
|
|
+ }
|
|
+ this.tempItem = item;
|
|
+ }
|
|
+
|
|
+ public boolean getConsumeItem() {
|
|
+ return this.consume;
|
|
+ }
|
|
+
|
|
+ public void setConsumeItem(boolean consume) {
|
|
+ this.consume = consume;
|
|
+ }
|
|
+ public boolean isCancelled() {
|
|
+ return canceled;
|
|
+ }
|
|
+
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ canceled = cancel;
|
|
+ }
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/com/empireminecraft/customevents/PlayerUseItemEvent.java b/src/main/java/com/empireminecraft/customevents/PlayerUseItemEvent.java
|
|
new file mode 100644
|
|
index 00000000..c61c6a44
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/empireminecraft/customevents/PlayerUseItemEvent.java
|
|
@@ -0,0 +1,89 @@
|
|
+/*
|
|
+ * Copyright (c) 2016 Starlis LLC / Daniel Ennis (Aikar) - MIT License
|
|
+ *
|
|
+ * Permission is hereby granted, free of charge, to any person obtaining
|
|
+ * a copy of this software and associated documentation files (the
|
|
+ * "Software"), to deal in the Software without restriction, including
|
|
+ * without limitation the rights to use, copy, modify, merge, publish,
|
|
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
|
+ * permit persons to whom the Software is furnished to do so, subject to
|
|
+ * the following conditions:
|
|
+ *
|
|
+ * The above copyright notice and this permission notice shall be
|
|
+ * included in all copies or substantial portions of the Software.
|
|
+ *
|
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
+ */
|
|
+
|
|
+package com.empireminecraft.customevents;
|
|
+
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.player.PlayerEvent;
|
|
+import org.bukkit.inventory.EquipmentSlot;
|
|
+import org.bukkit.inventory.ItemStack;
|
|
+
|
|
+public class PlayerUseItemEvent extends PlayerEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean canceled;
|
|
+ private final ItemStack item;
|
|
+ private final EquipmentSlot hand;
|
|
+ private ItemStack tempItem;
|
|
+ private boolean consumeItem = true;
|
|
+
|
|
+ public PlayerUseItemEvent(Player player, ItemStack item, EquipmentSlot hand) {
|
|
+ super(player);
|
|
+ this.item = item;
|
|
+ this.hand = hand;
|
|
+ }
|
|
+
|
|
+ public EquipmentSlot getHand() {
|
|
+ return hand;
|
|
+ }
|
|
+
|
|
+ public ItemStack getItem() {
|
|
+ return this.item;
|
|
+ }
|
|
+
|
|
+ public ItemStack getTempItem() {
|
|
+ return this.tempItem;
|
|
+ }
|
|
+
|
|
+ public void setTempItem(ItemStack item) {
|
|
+ if (item == null) {
|
|
+ canceled = true;
|
|
+ }
|
|
+ this.tempItem = item;
|
|
+ }
|
|
+
|
|
+ public boolean shouldConsumeItem() {
|
|
+ return this.consumeItem;
|
|
+ }
|
|
+
|
|
+ public void setConsumeItem(boolean consume) {
|
|
+ this.consumeItem = consume;
|
|
+ }
|
|
+
|
|
+ public boolean isCancelled() {
|
|
+ return canceled;
|
|
+ }
|
|
+
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ canceled = cancel;
|
|
+ }
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
--
|
|
2.25.1.windows.1
|
|
|