Skip to content

Commit 2d48369

Browse files
committed
Workaround a paper-issue
1 parent 5ad398f commit 2d48369

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

implementations/paper/src/main/java/de/bluecolored/bluemap/bukkit/BukkitCommandSource.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,25 @@ public boolean hasPermission(String permission) {
5959
public Optional<Vector3d> getPosition() {
6060
if (delegate.getSender() instanceof ConsoleCommandSender) return Optional.empty();
6161

62-
Location location = delegate.getLocation();
63-
return Optional.of(new Vector3d(location.getX(), location.getY(), location.getZ()));
62+
try {
63+
Location location = delegate.getLocation();
64+
return Optional.of(new Vector3d(location.getX(), location.getY(), location.getZ()));
65+
} catch (NullPointerException ex) { // workaround for a paper-bug: https://github.com/PaperMC/Paper/issues/13387
66+
return Optional.empty();
67+
}
6468
}
6569

6670
@Override
6771
public Optional<ServerWorld> getWorld() {
6872
if (delegate.getSender() instanceof ConsoleCommandSender) return Optional.empty();
6973

70-
World world = delegate.getLocation().getWorld();
71-
if (world == null) return Optional.empty();
72-
return Optional.of(BukkitPlugin.getInstance().getServerWorld(world));
74+
try {
75+
World world = delegate.getLocation().getWorld();
76+
if (world == null) return Optional.empty();
77+
return Optional.of(BukkitPlugin.getInstance().getServerWorld(world));
78+
} catch (NullPointerException ex) { // workaround for a paper-bug: https://github.com/PaperMC/Paper/issues/13387
79+
return Optional.empty();
80+
}
7381
}
7482

7583
}

0 commit comments

Comments
 (0)