NullPointerException when pasting entities from a clipboard using API
opl- opened this issue ยท 0 comments
Server Implementation
Paper
Server Version
1.20.2
Describe the bug
ExtentEntityCopy
assumes source
extent from which entities get copied is never null
, but it can be null
if the first constructor is used (the only one available with original WorldEdit). This triggers a NullPointerException
when an entity has Rotation
in its NBT, which is true for most if not all living entities.
To Reproduce
- Spawn a pig.
- Select the region around the pig.
//copy -e
- Run the following code:
public void test() throws WorldEditException {
org.bukkit.entity.Player player = null; // replace this with the player holding the clipboard
Player actor = BukkitAdapter.adapt(player);
SessionManager manager = WorldEdit.getInstance().getSessionManager();
LocalSession localSession = manager.get(actor);
Clipboard clipboard = localSession.getClipboard().getClipboard();
ExtentEntityCopy entityCopy = new ExtentEntityCopy(
clipboard.getOrigin().toVector3(),
BukkitAdapter.adapt(player.getWorld()),
clipboard.getOrigin().toVector3(),
new Identity()
);
for (Entity entity : clipboard.getEntities()) {
entityCopy.apply(entity);
}
}
- Get following stack trace:
java.lang.NullPointerException: null
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903) ~[guava-32.1.2-jre.jar:?]
at com.sk89q.worldedit.util.Location.<init>(Location.java:135) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
at com.sk89q.worldedit.util.Location.<init>(Location.java:107) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
at com.sk89q.worldedit.function.entity.ExtentEntityCopy.transformNbtData(ExtentEntityCopy.java:279) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
at com.sk89q.worldedit.function.entity.ExtentEntityCopy.apply(ExtentEntityCopy.java:156) ~[FastAsyncWorldEdit-Bukkit-2.8.0.jar:?]
...
Expected behaviour
Y'know, no crashes.
Screenshots / Videos
No response
Error log (if applicable)
No response
Fawe Debugpaste
https://athion.net/ISPaster/paste/view/f05eca59ab7a4e188ced658f1f9ffa4c
Fawe Version
FastAsyncWorldEdit version 2.8.0
Checklist
- I have included a Fawe debugpaste.
- I am using the newest build from https://ci.athion.net/job/FastAsyncWorldEdit/ and the issue still persists.
Anything else?
No response