Ban Management

Ban Management

193k Downloads

Player is null in join listener delayed task

traksag opened this issue ยท 0 comments

commented

Issue report

Tell us about your environment

  • Server Software: Waterfall

  • Server Version: 1.17-447

  • BanManager Version: 1.17-7.5.0

  • Online/Offline mode: Back-end servers of course in offline mode

  • Bungeecoord online/offline mode (if applicable): Online mode

BanManager config.yml:

Don't really think this is needed, since I think I found the issue in the code.

Describe your issue:

We get the following error message from time to time:

[03:27:38] [BanManager Pool Thread #5719/ERROR]: Task BungeeTask(sched=net.md_5.bungee.scheduler.BungeeScheduler@bd1111a, id=44296, owner=me.confuser.banmanager.bungee.BMBungeePlugin@42c9f2cd, task=me.confuser.banmanager.common.listeners.CommonJoinListener$$Lambda$1127/0x00000008013cd680@1519f3e1, delay=1000, period=0, running=true) encountered an exception
java.lang.NullPointerException: Cannot invoke "net.md_5.bungee.api.connection.ProxiedPlayer.getName()" because the return value of "me.confuser.banmanager.bungee.BungeePlayer.getPlayer()" is null
        at me.confuser.banmanager.bungee.BungeePlayer.getName(BungeePlayer.java:86) ~[?:?]
        at me.confuser.banmanager.common.listeners.CommonJoinListener.lambda$onPlayerLogin$2(CommonJoinListener.java:427) ~[?:?]
        at net.md_5.bungee.scheduler.BungeeTask.run(BungeeTask.java:66) ~[waterfall-1.17-447.jar:git:Waterfall-Bootstrap:1.17-R0.1-SNAPSHOT:62c18d4:447]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
        at java.lang.Thread.run(Thread.java:831) [?:?]

I believe this is caused by a player leaving very fast after joining, before this scheduled task is executed:

plugin.getScheduler().runAsyncLater(() -> {
final UUID uuid = player.getUniqueId();
List<PlayerData> duplicates = plugin.getPlayerStorage().getDuplicatesInTime(ip, plugin.getConfig().getTimeAssociatedAlts());
if (duplicates.isEmpty()) {
return;
}
StringBuilder sb = new StringBuilder();
for (PlayerData playerData : duplicates) {
if (playerData.getUUID().equals(uuid)) {
continue;
}
sb.append(playerData.getName());
sb.append(", ");
}
if (sb.length() == 0) return;
if (sb.length() >= 2) sb.setLength(sb.length() - 2);
Message message = Message.get("duplicateIPAlts");
message.set("player", player.getName());
message.set("players", sb.toString());
plugin.getServer().broadcast(message.toString(), "bm.notify.alts");
}, 20L);

How to replicate:

It is possible to replicate this by kicking the player in the join listener. Simply add the following line below the code snippet listed above:

player.kick("bye");

You may need to comment out the return statements in the snippet above if you don't have any alts. Also make sure you don't have the permission bm.exempt.alts.

Further information:

We became aware of this issue when we were making a BungeeCord whitelisting plugin. That error popped up when a non-whitelisted player (with alts) attempted to join. Though later we also noticed the error happened without the whitelisting plugin installed.