Skip to content

Commit

Permalink
Make events async
Browse files Browse the repository at this point in the history
  • Loading branch information
Malfrador committed Feb 21, 2024
1 parent fbfdd03 commit f4f0a9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 9 additions & 4 deletions patches/server/0002-misc-qol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ Subject: [PATCH] misc qol

diff --git a/src/main/java/de/erethon/PacketReceiveEvent.java b/src/main/java/de/erethon/PacketReceiveEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..8cd15002fbe357811b26ba3fd37b7bcac943f51a
index 0000000000000000000000000000000000000000..328c4c0caf2454caa4a62a379042670ed5adb774
--- /dev/null
+++ b/src/main/java/de/erethon/PacketReceiveEvent.java
@@ -0,0 +1,49 @@
@@ -0,0 +1,52 @@
+package de.erethon;
+
+import io.papermc.paper.util.MCUtil;
+import net.minecraft.network.Connection;
+import net.minecraft.network.PacketListener;
+import net.minecraft.network.protocol.Packet;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
Expand All @@ -28,6 +30,7 @@ index 0000000000000000000000000000000000000000..8cd15002fbe357811b26ba3fd37b7bca
+ private final PacketListener listener;
+
+ public PacketReceiveEvent(Packet<?> packet, Connection connection, PacketListener listener) {
+ super(!MCUtil.isMainThread());
+ this.packet = packet;
+ this.connection = connection;
+ this.listener = listener;
Expand Down Expand Up @@ -61,12 +64,13 @@ index 0000000000000000000000000000000000000000..8cd15002fbe357811b26ba3fd37b7bca
+}
diff --git a/src/main/java/de/erethon/PacketSendEvent.java b/src/main/java/de/erethon/PacketSendEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..2974f6cbb6a876a004c1c39eb7a7dfce73f3f924
index 0000000000000000000000000000000000000000..a634b5743928b9eb7866dc87024160961b538d7b
--- /dev/null
+++ b/src/main/java/de/erethon/PacketSendEvent.java
@@ -0,0 +1,49 @@
@@ -0,0 +1,51 @@
+package de.erethon;
+
+import io.papermc.paper.util.MCUtil;
+import net.minecraft.network.Connection;
+import net.minecraft.network.PacketSendListener;
+import net.minecraft.network.protocol.Packet;
Expand All @@ -83,6 +87,7 @@ index 0000000000000000000000000000000000000000..2974f6cbb6a876a004c1c39eb7a7dfce
+ private final PacketSendListener listener;
+
+ public PacketSendEvent(Packet<?> packet, Connection connection, PacketSendListener listener) {
+ super(!MCUtil.isMainThread());
+ this.packet = packet;
+ this.connection = connection;
+ this.listener = listener;
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ for (name in listOf("papyrus-api", "papyrus-server")) {
include(projName)
findProject(":$projName")!!.projectDir = file(name)
}
include("test-plugin")

0 comments on commit f4f0a9c

Please sign in to comment.