diff --git a/src/main/java/com/comphenix/protocol/PacketType.java b/src/main/java/com/comphenix/protocol/PacketType.java index 8e8be980d..a4de543aa 100644 --- a/src/main/java/com/comphenix/protocol/PacketType.java +++ b/src/main/java/com/comphenix/protocol/PacketType.java @@ -11,6 +11,7 @@ import com.comphenix.protocol.PacketTypeLookup.ClassLookup; import com.comphenix.protocol.events.ConnectionSide; import com.comphenix.protocol.injector.packet.PacketRegistry; +import com.comphenix.protocol.scheduler.UniversalRunnable; import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftVersion; import com.google.common.base.Preconditions; @@ -19,8 +20,6 @@ import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitRunnable; - /** * Represents the type of a packet in a specific protocol. *
@@ -1022,7 +1021,7 @@ public static boolean hasClass(Class> packetClass) {
* @param name - the name of the packet.
*/
public static void scheduleRegister(final PacketType type, final String name) {
- BukkitRunnable runnable = new BukkitRunnable() {
+ UniversalRunnable runnable = new UniversalRunnable() {
@Override
public void run() {
PacketTypeEnum objEnum;
diff --git a/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java b/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java
index e4226c1bb..3d06b2445 100644
--- a/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java
+++ b/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java
@@ -166,9 +166,8 @@ public void sendServerPacket(Player receiver, PacketContainer packet, NetworkMar
// ensure we are on the main thread if any listener requires that
if (this.playerInjectionHandler.hasMainThreadListener(packet.getType()) && !this.server.isPrimaryThread()) {
NetworkMarker copy = marker; // okay fine
- this.server.getScheduler().scheduleSyncDelayedTask(
- this.plugin,
- () -> this.sendServerPacket(receiver, packet, copy, false));
+ ProtocolLibrary.getScheduler().scheduleSyncDelayedTask(
+ () -> this.sendServerPacket(receiver, packet, copy, false), 1L);
return;
}
@@ -218,8 +217,7 @@ public void receiveClientPacket(Player sender, PacketContainer packet, NetworkMa
if (!this.closed) {
// make sure we are on the main thread if any listener of the packet needs it
if (this.playerInjectionHandler.hasMainThreadListener(packet.getType()) && !this.server.isPrimaryThread()) {
- this.server.getScheduler().scheduleSyncDelayedTask(
- this.plugin,
+ ProtocolLibrary.getScheduler().runTask(
() -> this.receiveClientPacket(sender, packet, marker, filters));
return;
}
diff --git a/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java b/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java
index 6ab52bb62..eaa1a898f 100644
--- a/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java
+++ b/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java
@@ -15,6 +15,7 @@
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Protocol;
+import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.error.Report;
import com.comphenix.protocol.error.ReportType;
@@ -490,8 +491,7 @@ private void ensureInEventLoop(EventLoop eventLoop, Runnable runnable) {
void processInboundPacket(ChannelHandlerContext ctx, Object packet, Class> packetClass) {
if (this.channelListener.hasMainThreadListener(packetClass) && !this.server.isPrimaryThread()) {
// not on the main thread but we are required to be - re-schedule the packet on the main thread
- this.server.getScheduler().runTask(
- this.injectionFactory.getPlugin(),
+ ProtocolLibrary.getScheduler().runTask(
() -> this.processInboundPacket(ctx, packet, packetClass));
return;
}
@@ -555,8 +555,7 @@