Skip to content

NullPointerException in VotifierEvent Handling When Broadcasting Vote Message on Purpur 1.16.5 with SimpleVoteListener #140

@ArchaeologyNerd

Description

@ArchaeologyNerd

Environment:

Issue Summary:

When a vote is received on my server, the vote is detected and broadcasted by SimpleVoteListener (SVL) indicating that the vote has been registered. However, the reward command configured in SVL often fails to execute. This is accompanied by a NullPointerException in the console during the handling of the VotifierEvent.

The error occurs specifically when attempting to broadcast a message via Bukkit.broadcastMessage(), which internally tries to send messages to players but fails because playerConnection is null for some entity.

This issue appears intermittently (not every vote triggers it, sometimes restart fixes it, but after 1 day someone reports me again that he didnt got his reward), but it's frequent enough to disrupt vote rewards.

Steps to Reproduce:

  1. Set up a Purpur 1.16.5 server running under Java 17.
  2. Install VotifierPlus and configure it to receive votes (e.g., from a voting site like PlanetMinecraft).
  3. Install SimpleVoteListener v1.0.0 and configure a reward command in its config (e.g., something like /give %player% diamond 1).
  4. Ensure the server has players online (or test with varying player counts).
  5. Submit a vote from an external voting site.
  6. Observe the console for the error; the broadcast message may appear, but the reward command often doesn't execute.

Expected Behavior:

  • The vote should be processed without errors.
  • The configured reward command in SVL should execute reliably after the vote is broadcasted.

Actual Behavior:

  • Vote is detected and broadcasted.
  • Reward command fails to execute in many cases.
  • Console logs the following NullPointerException:
[Fri 14:05:20 ERROR Minecraft] Could not pass event VotifierEvent to SimpleVoteListener v1.0.0
java.lang.NullPointerException: Cannot invoke "net.minecraft.server.v1_16_R3.PlayerConnection.sendPacket(net.minecraft.server.v1_16_R3.Packet)" because "org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.getHandle().playerConnection" is null
    at org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer.sendMessage(CraftPlayer.java:2143)
    at net.kyori.adventure.audience.Audience.sendMessage(Audience.java:215)
    at net.kyori.adventure.audience.Audience.sendMessage(Audience.java:189)
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.broadcast(CraftServer.java:1597)
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.broadcast(CraftServer.java:1569)
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.broadcastMessage(CraftServer.java:600)
    at org.bukkit.Bukkit.broadcastMessage(Bukkit.java:308)
    at com.sweepingloutus.simplevotelistener.votifierEvent.onVotifierEvent(votifierEvent.java:49)
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor394.execute(Unknown Source)
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69)
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:624)
    at com.vexsoftware.votifier.VotifierPlus$4$1.run(VotifierPlus.java:324)
    at com.bencodez.votifierplus.simpleapi.scheduler.BukkitScheduler.lambda$executeOrScheduleSync$0(BukkitScheduler.java:24)
    at com.bencodez.votifierplus.simpleapi.folialib.impl.SpigotImplementation.lambda$runNextTick$0(SpigotImplementation.java:42)
    at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:102)
    at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468)
    at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1503)
    at ...

Additional Notes:

  • The error seems related to the event being fired from VotifierPlus and handled in SVL's onVotifierEvent at line 49, where it calls Bukkit.broadcastMessage().
  • This might be tied to threading/scheduling in VotifierPlus (e.g., via BukkitScheduler and runNextTick), potentially causing issues with player connections on Purpur.
  • No other plugins are interfering (tested in a minimal setup).
  • I've checked SVL's code on GitHub, and the broadcast logic appears standard, so the root cause might be in how VotifierPlus dispatches the event or interacts with the Bukkit API on this server version.

If you need logs, config files, or further details, let me know! Thanks for looking into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions