fix: dismount before changing servers, close #555

This commit is contained in:
William committed 2024-03-31 19:33:53 +01:00
1 parent 9d2a73fd2c
commit f4437806b6
5 files changed
+61 -5

No files matched your search

@@ -34,6 +34,7 @@ import space.arim.morepaperlib.scheduling.GracefulScheduling;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.stream.Collectors;
@@ -106,6 +107,23 @@ public class BukkitUser extends OnlineUser {
));
}
@Override
public CompletableFuture<Void> dismount() {
final CompletableFuture<Void> future = new CompletableFuture<>();
((BukkitHuskHomes) plugin).getScheduler().entitySpecificScheduler(player).run(
() -> {
player.leaveVehicle();
player.eject();
future.complete(null);
},
() -> {
plugin.log(Level.WARNING, "User offline when dismounting: " + player.getName());
future.complete(null);
}
);
return future;
}
@Override
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
// Ensure the world exists