A console error that I was unable to resolve.

Discussion in 'Plugin Development' started by yLucasxz, Feb 1, 2021.

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

    yLucasxz

    Gave this error on the console, can someone help me? I left to do several things to solve and I couldn't.

    Code:
    [00:54:13 WARN]: Unexpected exception while parsing console command "tell"
    org.bukkit.command.CommandException: Unhandled exception executing command 'tell' in plugin lChat v1.8
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.command.ColouredConsoleSender cannot be cast to org.bukkit.entity.Player
            at lucas.lchat.commands.Tell.onCommand(Tell.java:15) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 8 more
    >
    SOURCE
     
  2. Offline

    timtower Administrator Administrator Moderator

    @yLucasxz Player p = (Player) sender;
    You are casting without checking if sender is a player.
    Your sender is a console, not a player.
     
    yLucasxz likes this.
  3. Offline

    yLucasxz

    @timtower, can you tell me which code I can use to check?

    @timtower,
    I decided, I just added in the code:
    if(!(sender instanceof ConsoleCommandSender))

    Thanks and I'm sorry I'm kind of dumb yet

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 2, 2021
  4. Offline

    Newdel

    You should check if the sender is a player, not if the sender is no Console...
     
Thread Status:
Not open for further replies.

Share This Page