hollow-cube / minestom-ce

1.20.4 Lightweight Minecraft server
https://minestom.net
Apache License 2.0
108 stars 36 forks source link

1.20.4 Support #92

Closed mworzala closed 8 months ago

mworzala commented 9 months ago

Currently based against the 1.20.2 PR, but it's just for comparison. Later I will close that PR and target main.

Closes #83

mworzala commented 9 months ago

I switched the base immediately because I wanted the ci to run and the PR has to target main for it to run :)

davidmayr commented 9 months ago

Will there be API for awaiting a resource pack in the configuration phase? Because as of now the server switches back to play as fast as it can without awaiting anything. Theoretically, I think I could block the AsyncPlayerConfigurationEvent until the pack is present, but I think there could be better options implemented.

davidmayr commented 9 months ago

Will there be API for awaiting a resource pack in the configuration phase? Because as of now the server switches back to play as fast as it can without awaiting anything. Theoretically, I think I could block the AsyncPlayerConfigurationEvent until the pack is present, but I think there could be better options implemented.

This might be especially important because of the velocity proxies shortcomings: PaperMC/Velocity#1164

MelonHell commented 9 months ago

Will there be API for awaiting a resource pack in the configuration phase? Because as of now the server switches back to play as fast as it can without awaiting anything. Theoretically, I think I could block the AsyncPlayerConfigurationEvent until the pack is present, but I think there could be better options implemented.

That's what I do, here's my code. But I think in any case it’s worth adding a similar API to Minestom

fun Player.setResourcePackAsync(resourcePack: ResourcePack): CompletableFuture<Unit> {
    val completableFuture = CompletableFuture<Unit>()
    val rpStatusListener = EventListener.builder(PlayerResourcePackStatusEvent::class.java)
        .expireWhen {
            val status = it.status
            if (status != ResourcePackStatus.ACCEPTED && status != ResourcePackStatus.DOWNLOADED) {
                completableFuture.complete(Unit)
                return@expireWhen true
            }
            return@expireWhen false
        }
        .build()
    val disconnectListener = EventListener.builder(PlayerDisconnectEvent::class.java).expireWhen {
        completableFuture.complete(Unit)
        return@expireWhen true
    }.build()
    eventNode().addListener(rpStatusListener)
    eventNode().addListener(disconnectListener)
    setResourcePack(resourcePack)
    return completableFuture
}
mworzala commented 8 months ago

Yeah I agree there should be an api for this.

mworzala commented 8 months ago

Expanding on above: Adventure has a resource pack API in Audience now (including a callback api). I will implement this for Player.

Most likely if you want to send a resource pack without waiting you will need to send the rp push packet yourself.

mworzala commented 8 months ago

@MelonHell @MenschenToaster as of https://github.com/hollow-cube/minestom-ce/pull/92/commits/489ba514711c3149203fadc4230fae88e0541883, this branch conforms to the Adventure resource pack api.

mworzala commented 8 months ago

The remaining tasks before merge that I know of: