monun / tap

GNU General Public License v3.0
64 stars 22 forks source link

MojangAPI.fetchSkinProfile(uuid)!!.profileProperties() 에러!! #52

Closed cozy06 closed 1 year ago

cozy06 commented 1 year ago

[17:56:22 ERROR]: Could not pass event PlayerInteractEvent to ServerManagement v1.0-SNAPSHOT java.util.concurrent.ExecutionException: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 1262: Encountered an unknown key 'profileActions' at path: $.properties Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys. JSON input: .....30+71awLoJj7xozFw=" } ], "profileActions" : { } } at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) ~[?:?] at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073) ~[?:?] at com.github.cozy06.Main.onPlayerInteract(Main.kt:91) ~[ServerManagement-1.0-SNAPSHOT.jar:?] at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor2.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:git-Paper-96] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.20.1.jar:git-Paper-96] at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.20.1.jar:git-Paper-96] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:566) ~[paper-1.20.1.jar:git-Paper-96] at org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:523) ~[paper-1.20.1.jar:git-Paper-96] at org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:517) ~[paper-1.20.1.jar:git-Paper-96] at org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:513) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.server.network.ServerGamePacketListenerImpl.handleAnimate(ServerGamePacketListenerImpl.java:2619) ~[?:?] at net.minecraft.network.protocol.game.ServerboundSwingPacket.handle(ServerboundSwingPacket.java:25) ~[?:?] at net.minecraft.network.protocol.game.ServerboundSwingPacket.a(ServerboundSwingPacket.java:11) ~[?:?] at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:51) ~[?:?] at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?] at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?] at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1339) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?] at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1316) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1309) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?] at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1287) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1175) ~[paper-1.20.1.jar:git-Paper-96] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-96] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 1262: Encountered an unknown key 'profileActions' at path: $.properties Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys. JSON input: .....30+71awLoJj7xozFw=" } ], "profileActions" : { } } at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24) ~[?:?] at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32) ~[?:?] at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:530) ~[?:?] at kotlinx.serialization.json.internal.AbstractJsonLexer.failOnUnknownKey(AbstractJsonLexer.kt:525) ~[?:?] at kotlinx.serialization.json.internal.StreamingJsonDecoder.handleUnknown(StreamingJsonDecoder.kt:251) ~[?:?] at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeObjectIndex(StreamingJsonDecoder.kt:237) ~[?:?] at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeElementIndex(StreamingJsonDecoder.kt:172) ~[?:?] at io.github.monun.tap.mojangapi.MojangAPI$SkinProfile$$serializer.deserialize(MojangAPI.kt:64) ~[?:?] at io.github.monun.tap.mojangapi.MojangAPI$SkinProfile$$serializer.deserialize(MojangAPI.kt:64) ~[?:?] at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70) ~[?:?] at kotlinx.serialization.json.Json.decodeFromString(Json.kt:95) ~[?:?] at io.github.monun.tap.mojangapi.MojangAPI$fetchSkinProfileAsync$$inlined$fetchAsync$1.invoke(MojangAPI.kt:121) ~[?:?] at io.github.monun.tap.mojangapi.MojangAPI$fetchSkinProfileAsync$$inlined$fetchAsync$1.invoke(MojangAPI.kt:53) ~[?:?] at io.github.monun.tap.mojangapi.MojangAPI$sam$java_util_function_Function$0.apply(MojangAPI.kt) ~[?:?] at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646) ~[?:?] at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?] at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614) ~[?:?] at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:844) ~[?:?] at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483) ~[?:?] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]

라는 에러가 뜨네요.....ㅠㅠ

dolphin2410 commented 1 year ago

@cozy06 혹시 코드 보여주실 수 있나요?

cozy06 commented 1 year ago

@dolphin2410 일단 test용 코드라 별건 없는데

package com.github.cozy06

import io.github.monun.invfx.InvFX import io.github.monun.invfx.frame.InvSlot import io.github.monun.invfx.openFrame import io.github.monun.kommand.KommandArgument import io.github.monun.kommand.getValue import io.github.monun.kommand.kommand import io.github.monun.tap.fake.FakeEntity import io.github.monun.tap.fake.FakeEntityServer import io.github.monun.tap.fake.FakeSkinParts import io.github.monun.tap.mojangapi.MojangAPI import net.kyori.adventure.text.Component import net.kyori.adventure.text.format.TextColor import org.bukkit.Bukkit import org.bukkit.ChatColor import org.bukkit.Material import org.bukkit.command.CommandSender import org.bukkit.entity.ArmorStand import org.bukkit.entity.FallingBlock import org.bukkit.entity.Item import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.block.Action import org.bukkit.event.inventory.InventoryClickEvent import org.bukkit.event.player.PlayerInteractEvent import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.event.player.PlayerQuitEvent import org.bukkit.inventory.EquipmentSlot import org.bukkit.inventory.ItemStack import org.bukkit.inventory.meta.SkullMeta import org.bukkit.plugin.java.JavaPlugin import org.bukkit.scheduler.BukkitRunnable import java.util.*

class Main: JavaPlugin(), Listener { lateinit var fakeServer: FakeEntityServer private set

override fun onEnable() {
    logger.info("${ChatColor.GREEN}Plugin enabled")
    server.pluginManager.registerEvents(this, this)

// Bukkit.getOnlinePlayers().forEach { // generateBag(it, it) // } fakeServer = FakeEntityServer.create(this) server.scheduler.runTaskTimer(this, fakeServer::update, 0L, 1L)

    command()
}

override fun onDisable(){
    logger.info("${ChatColor.RED}Plugin disabled")
}

@EventHandler
fun onPlayerJoin(e: PlayerJoinEvent) {

// generateInventory(e.player) fakeServer.addPlayer(e.player) }

@EventHandler
fun onPlayerQuit(e: PlayerQuitEvent) {
    /* 플레이어가 실제 서버에서 나가면 가상서버에서 내보낸다 */
    fakeServer.removePlayer(e.player)
}

@EventHandler
fun onPlayerInteract(e: PlayerInteractEvent) {
    when (e.action) {
        Action.RIGHT_CLICK_BLOCK -> {
            // 갑옷 거치대 스폰
            val fakeEntity: FakeEntity<ArmorStand> = fakeServer.spawnEntity(e.player.location, ArmorStand::class.java)
        }
        Action.RIGHT_CLICK_AIR -> {
            // 떨어지는 흙 스폰
            val fakeEntity: FakeEntity<FallingBlock> = fakeServer.spawnFallingBlock(e.player.location, Material.DIRT.createBlockData())
        }
        Action.LEFT_CLICK_BLOCK -> {
            // 다이아몬드 아이템 스폰
            val fakeEntity: FakeEntity<Item> = fakeServer.spawnItem(e.player.location, ItemStack(Material.DIAMOND))
        }
        Action.LEFT_CLICK_AIR -> {
            // 이름이 NPC_1이고, Heptagram의 스킨을 가진 플레이어 스폰
            // cape와 모자 이외의 외투는 없다 (0b1000001)
            val uuid = MojangAPI.fetchProfile("Heptagram")!!.uuid()

// val profiles = MojangAPI.fetchSkinProfile(uuid)!!.profileProperties() e.player.sendMessage("${MojangAPI.fetchSkinProfileAsync(uuid.toString()).get()}")

            val fakeEntity: FakeEntity<Player> = fakeServer.spawnPlayer(
                e.player.location,
                "NPC_1",

// profiles.toSet(), // FakeSkinParts(0b1000001) ) // fakeEntity.playAnimation() }

        else -> {}
    }
}

private fun generateBag(player: Player, person: Player) {
    val bagFrame = InvFX.frame(6, Component.text("\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uEff3", TextColor.color(255,255,255))) {
        slot(0, 0) {
            val playerHead = ItemStack(Material.PLAYER_HEAD, 1)
            val meta = playerHead.itemMeta as SkullMeta
            meta.setOwningPlayer(person)
            meta.setDisplayName("${person.name}'s bag")
            playerHead.setItemMeta(meta)
            item = playerHead

// onClick { clickEvent -> // clickEvent.whoClicked.sendMessage("You clicked the diamond!") // } } slot(3, 0) { item = person.inventory.helmet } slot(4, 0) { item = person.inventory.chestplate } slot(5, 0) { item = person.inventory.leggings } slot(6, 0) { item = person.inventory.boots } slot(8, 0) { item = person.inventory.itemInOffHand } repeat(36) { slot(0 + (it % 9), 2 + (it / 9)) { item = person.inventory.getItem(it) } } } player.openFrame(bagFrame) }

private fun pickPocket(player: Player, person: Player) {
    val pickPocketFrame = InvFX.frame(6, Component.text("\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uDAFF\uDFFF\uEff3", TextColor.color(255,255,255))) {
        var equipmentSlot = "EMPTY"

        onClick {x: Int, y: Int, clickEvent: InventoryClickEvent ->
            clickEvent.isCancelled = false

            if(y == 1 || (y == 0 && (x == 0 || x == 1 || x == 2 || x == 7))) {
                return@onClick
            }

            if(x == 3 && y == 0 && !(equipmentSlot == "EMPTY" || equipmentSlot == "HEAD")) {
                return@onClick
            }
            if(x == 4 && y == 0 && !(equipmentSlot == "EMPTY" || equipmentSlot == "CHEST")) {
                return@onClick
            }
            if(x == 5 && y == 0 && !(equipmentSlot == "EMPTY" || equipmentSlot == "LEGS")) {
                return@onClick
            }
            if(x == 6 && y == 0 && !(equipmentSlot == "EMPTY" || equipmentSlot == "FEET")) {
                return@onClick
            }

            val clickedItem = clickEvent.currentItem?.type
            equipmentSlot =
                when(clickedItem?.equipmentSlot) {
                    EquipmentSlot.HEAD -> "HEAD"
                    EquipmentSlot.CHEST -> "CHEST"
                    EquipmentSlot.LEGS -> "LEGS"
                    EquipmentSlot.FEET -> "FEET"
                    null -> "EMPTY"
                    else -> "ITEM/BLOCK"
                }
        }
        onClickBottom {clickEvent: InventoryClickEvent ->
            clickEvent.isCancelled = false

            val clickedItem = clickEvent.currentItem?.type
            equipmentSlot =
                when(clickedItem?.equipmentSlot) {
                    EquipmentSlot.HEAD -> "HEAD"
                    EquipmentSlot.CHEST -> "CHEST"
                    EquipmentSlot.LEGS -> "LEGS"
                    EquipmentSlot.FEET -> "FEET"
                    null -> "EMPTY"
                    else -> "ITEM/BLOCK"
                }
        }

        repeat(9) {
            slot(it, 1) {
                onClick { clickEvent ->
                    clickEvent.isCancelled = true
                }
            }
        }
        slot(1, 0) {
            onClick { clickEvent ->
                clickEvent.isCancelled = true
            }
        }
        slot(2, 0) {
            onClick { clickEvent ->
                clickEvent.isCancelled = true
            }
        }
        slot(7, 0) {
            onClick { clickEvent ->
                clickEvent.isCancelled = true
            }
        }

        slot(0, 0) {
            val playerHead = ItemStack(Material.PLAYER_HEAD)
            val meta = playerHead.itemMeta as SkullMeta
            meta.setOwningPlayer(person)
            meta.setDisplayName("${person.name}'s bag")
            playerHead.setItemMeta(meta)
            item = playerHead

            onClick { clickEvent ->
                clickEvent.isCancelled = true
            }
        }
        slot(3, 0) {
            item = person.inventory.helmet
            onClick { clickEvent ->
                when(equipmentSlot) {
                    "HEAD", "EMPTY" -> clickEvent.isCancelled = false
                    else -> clickEvent.isCancelled = true
                }
            }
        }
        slot(4, 0) {
            item = person.inventory.chestplate
            onClick { clickEvent ->
                when(equipmentSlot) {
                    "CHEST", "EMPTY" -> clickEvent.isCancelled = false
                    else -> clickEvent.isCancelled = true
                }
            }
        }
        slot(5, 0) {
            item = person.inventory.leggings
            onClick { clickEvent ->
                when(equipmentSlot) {
                    "LEGS", "EMPTY" -> clickEvent.isCancelled = false
                    else -> clickEvent.isCancelled = true
                }
            }
        }
        slot(6, 0) {
            item = person.inventory.boots
            onClick { clickEvent ->
                when(equipmentSlot) {
                    "FEET", "EMPTY" -> clickEvent.isCancelled = false
                    else -> clickEvent.isCancelled = true
                }
            }
        }
        slot(8, 0) {
            item = person.inventory.itemInOffHand
        }
        repeat(36) {
            slot(0 + (it % 9), 2 + (it / 9)) {
                item = person.inventory.getItem(it)
            }
        }

        onClose {
            repeat(36) {
                person.inventory.setItem(it, item(0 + (it % 9), 2 + (it / 9)))
            }
            person.inventory.setItem(EquipmentSlot.HEAD, item(3, 0))
            person.inventory.setItem(EquipmentSlot.CHEST, item(4, 0))
            person.inventory.setItem(EquipmentSlot.LEGS, item(5, 0))
            person.inventory.setItem(EquipmentSlot.FEET, item(6, 0))
            person.inventory.setItem(EquipmentSlot.OFF_HAND, item(8, 0))
        }
    }
    player.openFrame(pickPocketFrame)
}

private fun command() {
    kommand {
        register("open") {
            requires { isPlayer && isOp }
            then("player" to KommandArgument.player()) {
                executes {
                    val player: Player by it
                    generateBag(sender as Player, player)
                }
            }
        }
        register("pickpocket") {
            requires { isPlayer && isOp }
            then("player" to KommandArgument.player()) {
                executes {
                    val player: Player by it
                    pickPocket(sender as Player, player)
                }
            }
        }
    }
}

private fun talk(sender: CommandSender): Any {
    return when(sender) {
        Bukkit.getConsoleSender() -> "Server"
        else -> sender
    }
}

}

이거에요

dolphin2410 commented 1 year ago

https://[sessionserver.mojang.com/session/minecraft/profile/9c4f01724af14fec991037c046050f3c?unsigned=false](https://sessionserver.mojang.com/session/minecraft/profile/9c4f01724af14fec991037c046050f3c?unsigned=false)

원래 없던 profileActions가 추가돼서 생긴 오류 같네요

dolphin2410 commented 1 year ago

일단 PR 올렸는데 일단은 사용을 못할 것 같네요ㅜㅜ

cozy06 commented 1 year ago

아 넵 ㅠㅠ