Mrnice98 / BossingInfo

My Kills Per Hour Plugin
BSD 2-Clause "Simplified" License
4 stars 3 forks source link

NullPointerException at ToA #4

Closed Thedyolf2 closed 1 year ago

Thedyolf2 commented 1 year ago

After killing Akkha, going into Ba-ba puzzle room (not sure at what point it exactly triggers), an uncaught exception is thrown. This caused my framerate to become unbearable until relog since ram was capped. Running RuneLite with -Xmx512m -Xss6m causes no performance issues.

unknown

Mrnice98 commented 1 year ago

interesting, ill take a look later ty

Giovds commented 1 year ago

You get the same exception when killing Skeletal Wyverns (and probably more NPCs).

2022-12-16 19:19:20 [Client] WARN  n.runelite.client.eventbus.EventBus - Uncaught exception in event subscriber
java.lang.NullPointerException: null
    at com.killsperhour.FileReadWriter.bossNameMatcher(FileReadWriter.java:171)
    at com.killsperhour.FileReadWriter.lootReceived(FileReadWriter.java:210)
    at com.killsperhour.KphPlugin.onLootReceived(KphPlugin.java:223)
    at net.runelite.client.eventbus.EventBus$Subscriber.invoke(EventBus.java:70)
    at net.runelite.client.eventbus.EventBus.post(EventBus.java:223)
    at net.runelite.client.plugins.loottracker.LootTrackerPlugin.addLoot(LootTrackerPlugin.java:609)
    at net.runelite.client.plugins.loottracker.LootTrackerPlugin.addLoot(LootTrackerPlugin.java:595)
    at net.runelite.client.plugins.loottracker.LootTrackerPlugin.onNpcLootReceived(LootTrackerPlugin.java:626)
    at net.runelite.client.eventbus.EventBus$Subscriber.invoke(EventBus.java:70)
    at net.runelite.client.eventbus.EventBus.post(EventBus.java:223)
    at net.runelite.client.game.LootManager.processNpcLoot(LootManager.java:323)
    at net.runelite.client.game.LootManager.onNpcDespawned(LootManager.java:139)
    at net.runelite.client.eventbus.EventBus$Subscriber.invoke(EventBus.java:70)
    at net.runelite.client.eventbus.EventBus.post(EventBus.java:223)
    at net.runelite.client.callback.Hooks.post(Hooks.java:190)
    at cg.lv(cg.java:62259)
    at lb.jq(lb.java:8416)
    at client.il(client.java:6914)
    at client.gg(client.java:2813)
    at client.an(client.java:1119)
    at an.xi(an.java:390)
    at an.run(an.java:369)
    at java.base/java.lang.Thread.run(Thread.java:829)

Looking at the code you can simply tackle this by making the equals check null safe.

Simply swap the checks in the bossNameMatcher() if statements as follows:

-plugin.currentBoss.equals("Theatre of Blood HM") && plugin.bossName.equals("Theatre of Blood")
+"Theatre of Blood HM".equals(plugin.currentBoss) && "Theatre of Blood".equals(plugin.bossName)

You can test it yourself with the following:

"some string".equals(null); // Will be false, where as
((String)null).equals("some string"); // will throw an NPE
Mrnice98 commented 1 year ago

thats neat i never noticed that, im updating the plugin now and the new version will reflect this change