mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
fix: dismount before changing servers, close #555
This commit is contained in:
5 files changed
+61
-5
No files matched your search
@@ -23,6 +23,7 @@ import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -39,6 +40,7 @@ import net.william278.huskhomes.teleport.TeleportationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class FabricUser extends OnlineUser {
|
||||
|
||||
@@ -122,6 +124,17 @@ public class FabricUser extends OnlineUser {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> dismount() {
|
||||
final CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
plugin.runSync(() -> {
|
||||
player.stopRiding();
|
||||
player.getPassengerList().forEach(Entity::stopRiding);
|
||||
future.complete(null);
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
|
||||
final MinecraftServer server = player.getServer();
|
||||
@@ -129,7 +142,9 @@ public class FabricUser extends OnlineUser {
|
||||
throw new TeleportationException(TeleportationException.Type.ILLEGAL_TARGET_COORDINATES, plugin);
|
||||
}
|
||||
|
||||
player.dismountVehicle();
|
||||
player.stopRiding();
|
||||
player.getPassengerList().forEach(Entity::stopRiding);
|
||||
|
||||
FabricDimensions.teleport(
|
||||
player,
|
||||
server.getWorld(server.getWorldRegistryKeys().stream()
|
||||
|
||||
Reference in new issue
Block a user