FastAsyncWorldEdit icon indicating copy to clipboard operation
FastAsyncWorldEdit copied to clipboard

fix: EntityType.getName() is null

Open DevScyu opened this issue 3 years ago • 3 comments

Overview

Fixes the following NPE:

Could not pass event CreatureSpawnEvent to WorldGuard v7.0.7+216b061
java.lang.NullPointerException: Cannot invoke "String.toLowerCase(java.util.Locale)" because the return value of "org.bukkit.entity.EntityType.getName()" is null
        at com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter.adapt(IBukkitAdapter.java:346) ~[FastAsyncWorldEdit-Bukkit-2.4.4-SNAPSHOT-266.jar:?]
        at com.fastasyncworldedit.bukkit.adapter.IDelegateBukkitImplAdapter.adapt(IDelegateBukkitImplAdapter.java:271) ~[FastAsyncWorldEdit-Bukkit-2.4.4-SNAPSHOT-266.jar:?]
        at com.sk89q.worldedit.bukkit.BukkitAdapter.adapt(BukkitAdapter.java:395) ~[FastAsyncWorldEdit-Bukkit-2.4.4-SNAPSHOT-266.jar:?]
        at com.sk89q.worldguard.bukkit.listener.WorldGuardEntityListener.onCreatureSpawn(WorldGuardEntityListener.java:623) ~[worldguard-bukkit-7.0.7-dist.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor255.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:git-Paper-134]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:670) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callCreatureSpawnEvent(CraftEventFactory.java:739) ~[paper-1.19.2.jar:git-Paper-134]
        at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.doEntityAddEventCalling(CraftEventFactory.java:644) ~[paper-1.19.2.jar:git-Paper-134]
        at net.minecraft.server.level.ServerLevel.addEntity(ServerLevel.java:1448) ~[?:?]
        at net.minecraft.server.level.ServerLevel.addFreshEntity(ServerLevel.java:1356) ~[?:?]

Description

Adds a null type check to the EntityType adapter.

Submitter Checklist

  • [x] Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • [x] Ensure that the pull request title represents the desired changelog entry.
  • [x] New public fields and methods are annotated with @since TODO.
  • [x] I read and followed the contribution guidelines.

DevScyu avatar Sep 06 '22 11:09 DevScyu

To trigger a test build on Jenkins, this PR requires approval by a member of the @IntellectualSites/admins team. Comment with one of the commands below:

Command/Comment Description
ok to test Accept this PR for testing
test this please Trigger a one time test
retest this please Start a new build if the last one wasn't successful

intellectualsites-bot avatar Sep 06 '22 11:09 intellectualsites-bot

Hey,

could you elaborate which issue this PR addresses? Preferably including steps to replicate the issue. Thanks!

NotMyFault avatar Sep 12 '22 09:09 NotMyFault

Either way, I'd prefer the usage of EntityType#getKey, which seems to be available at 1.15 (not sure if even earlier). That method is annotated as NotNull and is not deprecated - Would be more future proof imo

PierreSchwang avatar Sep 12 '22 22:09 PierreSchwang

Very stale, closing.

dordsor21 avatar Jul 15 '23 15:07 dordsor21