From 67ec2cd9572fab558e80abef4adac820dcf8e3ca Mon Sep 17 00:00:00 2001 From: Riley Park Date: Sat, 2 Apr 2016 18:10:38 -0700 Subject: [PATCH] Add PlayerUseUnknownEntityEvent --- .../Add-PlayerUseUnknownEntityEvent.patch | 55 +++++++++++++++++++ .../Add-PlayerUseUnknownEntityEvent.patch | 41 ++++++++++++++ importmcdev.sh | 1 + 3 files changed, 97 insertions(+) create mode 100644 Spigot-API-Patches/Add-PlayerUseUnknownEntityEvent.patch create mode 100644 Spigot-Server-Patches/Add-PlayerUseUnknownEntityEvent.patch diff --git a/Spigot-API-Patches/Add-PlayerUseUnknownEntityEvent.patch b/Spigot-API-Patches/Add-PlayerUseUnknownEntityEvent.patch new file mode 100644 index 0000000000..8dfdd98591 --- /dev/null +++ b/Spigot-API-Patches/Add-PlayerUseUnknownEntityEvent.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java +@@ -0,0 +0,0 @@ ++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; ++ } ++} +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/Add-PlayerUseUnknownEntityEvent.patch b/Spigot-Server-Patches/Add-PlayerUseUnknownEntityEvent.patch new file mode 100644 index 0000000000..77d1117e35 --- /dev/null +++ b/Spigot-Server-Patches/Add-PlayerUseUnknownEntityEvent.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java ++++ b/src/main/java/net/minecraft/server/PacketPlayInUseEntity.java +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -0,0 +0,0 @@ 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 + + } + +-- \ No newline at end of file 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