From 871920f2f521db05c4e1cfa953dcc9b341e99eba Mon Sep 17 00:00:00 2001 From: kashike Date: Sat, 2 Apr 2016 18:10:38 -0700 Subject: [PATCH] Add PlayerUseUnknownEntityEvent --- ...0035-Add-PlayerUseUnknownEntityEvent.patch | 57 +++++++++++++++++++ ...0124-Add-PlayerUseUnknownEntityEvent.patch | 43 ++++++++++++++ importmcdev.sh | 1 + 3 files changed, 101 insertions(+) create mode 100644 Spigot-API-Patches/0035-Add-PlayerUseUnknownEntityEvent.patch create mode 100644 Spigot-Server-Patches/0124-Add-PlayerUseUnknownEntityEvent.patch diff --git a/Spigot-API-Patches/0035-Add-PlayerUseUnknownEntityEvent.patch b/Spigot-API-Patches/0035-Add-PlayerUseUnknownEntityEvent.patch new file mode 100644 index 0000000000..0d37625480 --- /dev/null +++ b/Spigot-API-Patches/0035-Add-PlayerUseUnknownEntityEvent.patch @@ -0,0 +1,57 @@ +From 248cfb570e0e1783f8342ab51c2eb7f8ac0de495 Mon Sep 17 00:00:00 2001 +From: Jedediah Smith +Date: Sat, 2 Apr 2016 05:08:36 -0400 +Subject: [PATCH] Add PlayerUseUnknownEntityEvent + + +diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java +new file mode 100644 +index 0000000..70eeaf5 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java +@@ -0,0 +1,42 @@ ++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; ++ ++public class PlayerUseUnknownEntityEvent extends PlayerEvent { ++ ++ private static final HandlerList handlers = new HandlerList(); ++ private final int entityId; ++ private final boolean attack; ++ private final EquipmentSlot hand; ++ ++ public PlayerUseUnknownEntityEvent(Player who, int entityId, boolean attack, EquipmentSlot hand) { ++ super(who); ++ this.entityId = entityId; ++ this.attack = attack; ++ this.hand = hand; ++ } ++ ++ public int getEntityId() { ++ return this.entityId; ++ } ++ ++ public boolean isAttack() { ++ return this.attack; ++ } ++ ++ public EquipmentSlot getHand() { ++ return this.hand; ++ } ++ ++ @Override ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +-- +2.7.4 + diff --git a/Spigot-Server-Patches/0124-Add-PlayerUseUnknownEntityEvent.patch b/Spigot-Server-Patches/0124-Add-PlayerUseUnknownEntityEvent.patch new file mode 100644 index 0000000000..f9e1f18444 --- /dev/null +++ b/Spigot-Server-Patches/0124-Add-PlayerUseUnknownEntityEvent.patch @@ -0,0 +1,43 @@ +From 702c81ef81451505a29dc4e69823911c21a965b9 Mon Sep 17 00:00:00 2001 +From: Jedediah Smith +Date: Sat, 2 Apr 2016 05:09:16 -0400 +Subject: [PATCH] Add PlayerUseUnknownEntityEvent + + +diff --git a/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java b/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java +index 2b23a5d..6464a84 100644 +--- a/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java ++++ b/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java +@@ -4,7 +4,7 @@ import java.io.IOException; + + public class PacketPlayInUseEntity implements Packet { + +- private int a; ++ private int a; public int getEntityId() { return this.a; } // Paper - add accessor + private PacketPlayInUseEntity.EnumEntityUseAction action; + private Vec3D c; + private EnumHand d; +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index ff64891..b60b134 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -1615,6 +1615,16 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { + } + } + } ++ // Paper start - fire event ++ else { ++ this.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent( ++ this.getPlayer(), ++ packetplayinuseentity.getEntityId(), ++ packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK, ++ packetplayinuseentity.b() == EnumHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND ++ )); ++ } ++ // Paper end + + } + +-- +2.7.4 + diff --git a/importmcdev.sh b/importmcdev.sh index 9900c11dc0..c1d71fd05d 100755 --- a/importmcdev.sh +++ b/importmcdev.sh @@ -51,6 +51,7 @@ import EntitySquid import FileIOThread import ItemBlock import PacketPlayInResourcePackStatus +import PacketPlayInUseEntity import PacketPlayOutPlayerListHeaderFooter import PacketPlayOutTitle import PacketPlayOutUpdateTime