What causes an error when outputting a command to the console or player

Discussion in 'Plugin Development' started by Romalk, Jul 1, 2023.

Thread Status:
Not open for further replies.
  1. Offline

    Romalk

    Code:

    Code:
    package org.example.test.test.commands
    
    import org.bukkit.command.Command
    import org.bukkit.command.CommandExecutor
    import org.bukkit.command.CommandSender
    
    import java.io.BufferedReader
    import java.io.FileReader
    import java.io.File
    
    data class Info(
        val name : String,
        val owner : String,
        val token : String,
        val locations : MutableList<MutableMap<String, Double>>
    )
    
    class createCatalog : CommandExecutor {
        override fun onCommand(sender: CommandSender, command: Command, p2: String, args: Array<out String>?): Boolean {
    
            val name = sender.name
    
            var listInfo : MutableList<Info> = mutableListOf()
    
            val file = FileReader("files/data.txt")
            val reader = BufferedReader(file)
            var had = false
    
            var line: String? = reader.readLine()
    
            while (line != null) {
                var words = line?.split(" ") ?: continue
                var data : MutableList<MutableMap<String, Double>> = mutableListOf()
    
                if (words.size < 6) {
                    line = reader.readLine()
                    continue
                }
                var k = 3
                for (i in 0..words.size-3) {
                    if (i == k) {
                        data.add(mutableMapOf<String, Double>("x" to (words[k]).toDouble(), "y" to (words[k+1]).toDouble(), "z" to (words[k+2]).toDouble()))
                        k += 3
                    }
                }
                listInfo.add(Info(words[0], words[1], words[2], data))
                sender.sendMessage("${listInfo.size}")
    
                //println("${words[0]} ${words[1]} ${words[2]} ${data}")
    
                line = reader.readLine()
            }
            println(listInfo?.size)
            reader.close()
            file.close()
    
            return true
        }
    }
    When I try to display either listInfo.size or just listInfo, I get an error:

    [20:14:26 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'create-catalog' in plugin test v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_19_R3.CraftServer.dispatchCommand(CraftServer.java:929) ~[paper-1.19.4.jar:git-Paper-547]
    at org.bukkit.craftbukkit.v1_19_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.4.jar:git-Paper-547]
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.4.jar:?]
    at net.minecraft.commands.Commands.performCommand(Commands.java:322) ~[?:?]
    at net.minecraft.commands.Commands.performCommand(Commands.java:306) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2297) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2257) ~[?:?]
    at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.4.jar:git-Paper-547]
    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:1342) ~[paper-1.19.4.jar:git-Paper-547]
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.4.jar:git-Paper-547]
    at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
    at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1319) ~[paper-1.19.4.jar:git-Paper-547]
    at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1312) ~[paper-1.19.4.jar:git-Paper-547]
    at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
    at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1290) ~[paper-1.19.4.jar:git-Paper-547]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1178) ~[paper-1.19.4.jar:git-Paper-547]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-547]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
    Caused by: java.lang.NoClassDefFoundError: org/example/test/test/commands/Info
    at org.example.test.test.commands.createCatalog.onCommand(createCatalog.kt:52) ~[test.jar:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
    ... 23 more
    Caused by: java.lang.ClassNotFoundException: org.example.test.test.commands.Info
    at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:183) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:150) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    at org.example.test.test.commands.createCatalog.onCommand(createCatalog.kt:52) ~[test.jar:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
    ... 23 more
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Romalk Caused by: java.lang.ClassNotFoundException: org.example.test.test.commands.Info
     
Thread Status:
Not open for further replies.

Share This Page