Skip to content

Commit

Permalink
fix: resourcePack can't be reapply after RemoveResourcePackPacket
Browse files Browse the repository at this point in the history
- use clearResourcePacks instead
  • Loading branch information
jimchen5209 committed Aug 15, 2024
1 parent 407c355 commit ce00d22
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
13 changes: 0 additions & 13 deletions src/main/kotlin/one/oktw/galaxy/proxy/extension/Player.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ package one.oktw.galaxy.proxy.resourcepack

import com.velocitypowered.api.proxy.Player
import one.oktw.galaxy.proxy.Main.Companion.main
import one.oktw.galaxy.proxy.extension.sendPacket

class ResourcePackHelper {
companion object{
fun trySendResourcePack(player: Player, galaxy: String){
val resourcePack = main.config.galaxiesResourcePack[galaxy] ?: return
// workaround Minecraft 1.20.3 not auto unload old resource pack
try {
val packet = Class.forName("com.velocitypowered.proxy.protocol.packet.RemoveResourcePackPacket").getConstructor().newInstance()
player.sendPacket(packet)
} catch (e: Exception) {
main.logger.error("Send remove resource pack packet error.", e)
}

player.clearResourcePacks()
player.sendResourcePackOffer(
main.proxy.createResourcePackBuilder(resourcePack.uri.toString())
.setHash(resourcePack.hash)
Expand Down

0 comments on commit ce00d22

Please sign in to comment.