ProtocolLibrary.getProtocolManager() returns null when using latest dev build on 1.19
demenik opened this issue ยท 11 comments
Make sure you're doing the following
- You're using the latest build for your server version
- This isn't an issue caused by another plugin
- You've checked for duplicate issues
- The other issues I saw were issues about not using the latest dev build
- You didn't use
/reload
Describe the question
When I try to get the ProtocolManager using ProtocolLibrary.getProtocolManager()
, I get null instead of the ProtocolManager
API method(s) used
ProtocolLibrary.getProtocolManager();
Expected behavior
ProtocolLibrary.getProtocolManager()
should return the ProtocolManager instance
Code
- This error occurs after both my plugin and ProtocolLib were loaded
- I am using the latest dev build (build 575) on a 1.19 localhost spigot server
pom.xml
<repositories>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
me.demenik.powermining.utils.Packets
public static void sendBlockBreak(Player player, Location loc) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
Random rand = new Random();
int id = rand.nextInt(Integer.MAX_VALUE);
PacketContainer packet = manager.createPacket(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
packet.getIntegers().write(0, id);
packet.getBlockPositionModifier().write(0, new BlockPosition(loc.add(1, 0, 0).toVector()));
packet.getBytes().write(0, (byte) 1);
manager.sendServerPacket(player, packet);
}
Additional context
Console Log
[13:37:36] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Powermining v1.0.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:505) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:472) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:187) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1517) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.network.protocol.game.PacketPlayInBlockDig.a(SourceFile:42) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.network.protocol.game.PacketPlayInBlockDig.a(SourceFile:8) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:31) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:157) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1150) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:131) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.bh(MinecraftServer.java:1129) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1122) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:140) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1106) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1014) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3551-Spigot-14a2382-9a8e080]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.ProtocolManager.createPacket(com.comphenix.protocol.PacketType)" because "manager" is null
at me.demenik.powermining.utils.Packets.sendBlockBreak(Packets.java:26) ~[?:?]
at me.demenik.powermining.items.Hammer.onItemMine(Hammer.java:44) ~[?:?]
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
... 23 more
I did include ProtocolLib as a depend
main: me.demenik.powermining.Powermining
name: Powermining
version: '1.0.0'
api-version: '1.19'
depend: [ProtocolLib]
But this error occurred long after both plugins were loaded:
[...]
[11:28:07] [Server thread/INFO]: [ProtocolLib] Loading ProtocolLib v5.0.0-SNAPSHOT-b575
[11:28:08] [Server thread/INFO]: [Powermining] Loading Powermining v1.0.0
[11:28:08] [Server thread/INFO]: [ProtocolLib] Enabling ProtocolLib v5.0.0-SNAPSHOT-b575
[11:28:08] [Server thread/INFO]: [ProtocolLib] Started structure compiler thread.
[11:28:08] [Server thread/INFO]: [Powermining] Enabling Powermining v1.0.0
[11:28:08] [Server thread/INFO]: ProtocolManager could not be loaded # <-- ProtocolManager is null in onEnable
[11:28:08] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[11:28:08] [Server thread/INFO]: sugarmommy07: Reload complete.
[11:28:09] [Server thread/INFO]: Sending block break packet
[11:28:09] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Powermining v1.0.0
org.bukkit.event.EventException: null # <-- ProtocolManager is null in onPlayerInteractEvent
I did try restarting my server once before submitting my issue, which resulted in the same outcome. I can try to do that again tomorrow.
I don't think I did, because I included the provided
scope in the pom.xml
, but I could be wrong. I'm not that experienced in java and maven.
Logs after starting the server:
Unbundling libraries to C:\Users\domer\code\spigot-server\bundler
Starting server
Loading libraries, please wait...
[...]
[16:04:45] [Server thread/INFO]: [ProtocolLib] Loading ProtocolLib v5.0.0-SNAPSHOT-b575
[16:04:46] [Server thread/INFO]: [Powermining] Loading Powermining v1.0.0
[16:04:46] [Server thread/INFO]: [ProtocolLib] Enabling ProtocolLib v5.0.0-SNAPSHOT-b575
[16:04:46] [Server thread/INFO]: [ProtocolLib] Started structure compiler thread.
[16:04:46] [Server thread/INFO]: Preparing level "world"
[...]
[16:04:55] [Server thread/INFO]: [Powermining] Enabling Powermining v1.0.0
[16:04:55] [Server thread/INFO]: ProtocolManager could not be loaded
[16:04:55] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[16:04:55] [Server thread/INFO]: Done (9.137s)! For help, type "help"
@demenik
I had same problem for a while, but got it solved by switching to different JDK
I also deleted target
folder and switched from MacOS to Windows, but it's probably unrelated.
Hope it helps you too!
Have we found an actual solution to this issue? It just happened to me as well and I cannot seem to find a fix.
Did you try switching your JDK as proposed above?
@TastyFrenchBun Yes, I tried a few of them to no avail. Has the source of the problem been found yet?
Edit: Took a brief look and noticed this code, I would assume issue is a result of the Builder
// api init
protocolManager = PacketFilterManager.newBuilder()
.server(this.getServer())
.library(this)
.minecraftVersion(version)
.reporter(reporter)
.build();
ProtocolLibrary.init(this, config, protocolManager, reporter);