mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
Add PlayerUseUnknownEntityEvent
This commit is contained in:
parent
9fcb513a2e
commit
67ec2cd957
55
Spigot-API-Patches/Add-PlayerUseUnknownEntityEvent.patch
Normal file
55
Spigot-API-Patches/Add-PlayerUseUnknownEntityEvent.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
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;
|
||||
+ }
|
||||
+}
|
||||
--
|
41
Spigot-Server-Patches/Add-PlayerUseUnknownEntityEvent.patch
Normal file
41
Spigot-Server-Patches/Add-PlayerUseUnknownEntityEvent.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
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<PacketListenerPlayIn> {
|
||||
|
||||
- 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
|
||||
|
||||
}
|
||||
|
||||
--
|
@ -51,6 +51,7 @@ import EntitySquid
|
||||
import FileIOThread
|
||||
import ItemBlock
|
||||
import PacketPlayInResourcePackStatus
|
||||
import PacketPlayInUseEntity
|
||||
import PacketPlayOutPlayerListHeaderFooter
|
||||
import PacketPlayOutTitle
|
||||
import PacketPlayOutUpdateTime
|
||||
|
Loading…
Reference in New Issue
Block a user