zeshan321 / ActionHealth

ActionHealth is a highly configurable Minecraft plugin that utilizes the action bar to display entity health.
MIT License
41 stars 39 forks source link

Add null check when getting effect type name #35

Closed zeshan321 closed 3 years ago

zeshan321 commented 3 years ago

Add null check before getting effect type name and adding to list: https://github.com/zeshan321/ActionHealth/blob/475e2a2c2b23d0cda7338e97811f0b866c98b6af/src/com/zeshanaslam/actionhealth/action/ActionHelper.java#L79-L80

zeshan321 commented 3 years ago
[11:43:36] [Server thread/ERROR]: Could not pass event PlayerItemHeldEvent to ActionHealth v3.5.2
java.lang.NullPointerException: null
at com.zeshanaslam.actionhealth.action.ActionHelper.getName(ActionHelper.java:80) ~[?:?]
at com.zeshanaslam.actionhealth.action.ActionHelper.executeTriggers(ActionHelper.java:31) ~[?:?]
at com.zeshanaslam.actionhealth.action.ActionListener.onSwap(ActionListener.java:99) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor136.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[minecraft_server.jar:git-Paper-592]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[minecraft_server.jar:git-Paper-592]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[minecraft_server.jar:git-Paper-592]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1905) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.PacketPlayInHeldItemSlot.a(SourceFile:30) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.PacketPlayInHeldItemSlot.a(SourceFile:8) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1252) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1245) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1319) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1116) ~[minecraft_server.jar:git-Paper-592]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[minecraft_server.jar:git-Paper-592]
at java.lang.Thread.run(Thread.java:834) [?:?]
zeshan321 commented 3 years ago

Issue occurs when Action system is enabled:

Action:
  Enabled: true
  # In seconds
  TagLength: 20
  # Amount of entities a player can tag during combat. -1 for unlimited
  TagAmount: 2
  Events:
    CONSUME:
      GOLDEN_APPLE: '&7&l{name} consumed &cgolden apple&7&l!'
      REGENERATION_POTION: '&7&l{name} consumed &cregen potion&7&l!'
    RIGHTCLICK:
      ENDER_PEARL: '&7&l{name} used &cender pearl&7&l!'
    SWAP:
      ENDER_PEARL: '&7&l{name} swapped to &cender pearls&7&l. {usestyle}&7&l'
      POTION: '&7&l{name} swapped to &cpotion&7&l. {usestyle}&7&l'
    DAMAGE:
      ANY: '&7&l{name}: {usestyle}'
      # Supports DamageCause if 'ANY' not being used
      #LAVA: '&4On fire!'
      #ENTITY_SWEEP_ATTACK: '&7You swept them!
CookieGuy123 commented 3 years ago

:) -maehb

zeshan321 commented 3 years ago

Fixed in latest. Thanks!