#Simple teleport produce massive mspt latency

1 messages · Page 1 of 1 (latest)

kind tinsel
#

Hello i used this code in my plugin project

    public static void teleportToSpawn(Player player) {
        Main.getPlugin().getServer().getScheduler().runTask(SpeedRun.getPlugin(), () -> {
            player.teleport(Settings.spawnLocation);
        });
    }

and by spark profiler this produce massive lags when server reach like 90 players, there's any reason why and way to fix this?

tough sigil
#

You should use Paper's teleportAsync function instead

kind tinsel
tough sigil
#

Reading from disk is a slow-er operation

kind tinsel
tough sigil
#

player.teleportAsync() is the function

#

I believe

kind tinsel
#

right i found this, thanks i will came here with other questions, thanks blitz!

tough sigil
#

No problem

kind tinsel
# tough sigil No problem

oh i would ask you about sendactionbar packet, i mean i have problem with sending proper colors using hex

    public static void sendActionBar(Player player, String message) {
        message = Color.f(message);
        CraftPlayer craftPlayer = (CraftPlayer) player;
        net.minecraft.server.level.ServerPlayer serverPlayer = craftPlayer.getHandle();

        Component textComponent = Component.literal(message);

        ClientboundSetActionBarTextPacket packet = new ClientboundSetActionBarTextPacket(textComponent);

        serverPlayer.connection.send(packet);
    }

Thats how look Color class https://pastebin.com/raw/Ns2gMsj9

tough sigil
#

Unfortunately, I have no experience with packets. My guess would be that it does not use the same pattern as the Bungee API. May I ask why you are sending the action bar with packets and not with the API itself?

kind tinsel
tough sigil
#

I'm not sure how much that could've done. I doubt it was a lot more performant than packets.

#

Once again though, paper has Player#sendActionBar methods you can directly use