CastContext may load mage when sending target message
killme opened this issue ยท 3 comments
[23:06:19 WARN]: [Magic] Player data for <mage id> (<username>) loaded while offline!
[23:06:19 WARN]: java.lang.Exception: Stack trace
[23:06:19 WARN]: at java.lang.Thread.dumpStack(Thread.java:1329)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.MagicController.getMage(MagicController.java:215)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.MagicController.getMage(MagicController.java:194)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.MagicController.getMage(MagicController.java:335)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.MagicController.getMage(MagicController.java:323)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.MagicController.getMage(MagicController.java:159)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.action.CastContext.messageTargets(CastContext.java:863)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.spell.BaseSpell.messageTargets(BaseSpell.java:1504)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.spell.BaseSpell.finish(BaseSpell.java:2580)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.action.CastContext.finish(CastContext.java:956)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.batch.ActionBatch.finish(ActionBatch.java:53)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.batch.ActionBatch.process(ActionBatch.java:38)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.Mage.processPendingBatches(Mage.java:1338)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.MagicController.processPendingBatches(MagicController.java:1116)
[23:06:19 WARN]: at com.elmakers.mine.bukkit.magic.BatchUpdateTask.run(BatchUpdateTask.java:12)
[23:06:19 WARN]: at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:58)
[23:06:19 WARN]: at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:356)
[23:06:19 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:833)
[23:06:19 WARN]: at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:427)
[23:06:19 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767)
[23:06:19 WARN]: at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665)
[23:06:19 WARN]: at java.lang.Thread.run(Thread.java:745)
This happened after the player had quit the game.
What would be the way to properly fix this?
Should I just put an .isOnline()
check there?
Or perhaps some kind of "getMageIfPresent" and check for null/Optional.
I have a getRegisteredMage method for this purpose, but it looks like it only works with id. I'll take a look and see if there's a clean way to use it inside of messageTargets.
Should be fixed here, though I can't easily test it: