Solved Plugin development error

Discussion in 'Plugin Development' started by EthanGarey, Aug 25, 2022.

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


    Console when I entered the tp command
    [17:18:48 INFO]: EthanGarey issued server command: /tp
    [17:18:48 ERROR]: null
    org.bukkit.command.CommandException: Cannot execute command 'tp' in plugin BetterCommands v1.0 Release - plugin is disabled.
            at org.bukkit.command.PluginCommand.execute( ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
            at org.bukkit.command.SimpleCommandMap.dispatch( ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
            at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand( ~[paper-1.19.2.jar:git-Paper-132]
            at ~[paper-1.19.2.jar:git-Paper-132]
            at com.mojang.brigadier.CommandDispatcher.execute( ~[paper-1.19.2.jar:?]
            at net.minecraft.commands.Commands.performCommand( ~[?:?]
            at net.minecraft.commands.Commands.performCommand( ~[?:?]
            at ~[?:?]
            at$handleChatCommand$20( ~[?:?]
            at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0( ~[?:?]
            at java.util.concurrent.CompletableFuture$ ~[?:?]
            at ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.util.thread.BlockableEventLoop.doRunTask( ~[?:?]
            at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask( ~[?:?]
            at net.minecraft.server.MinecraftServer.doRunTask( ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.server.MinecraftServer.d( ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.util.thread.BlockableEventLoop.pollTask( ~[?:?]
            at net.minecraft.server.MinecraftServer.pollTaskInternal( ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.server.MinecraftServer.pollTask( ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.util.thread.BlockableEventLoop.managedBlock( ~[?:?]
            at net.minecraft.server.MinecraftServer.waitUntilNextTick( ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.server.MinecraftServer.runServer( ~[paper-1.19.2.jar:git-Paper-132]
            at net.minecraft.server.MinecraftServer.lambda$spin$0( ~[paper-1.19.2.jar:git-Paper-132]
            at ~[?:?]
    My main file
    package BetterCommands;
    import Commands.Fly;
    import Commands.Teleport;
    import org.bukkit.Bukkit;
    public final class Main extends JavaPlugin {
        public void onEnable() {
            // Plugin startup logic
            Bukkit.getLogger().info("Hello World!");
            getCommand("tp").setExecutor(new Teleport());
            getCommand("fly").setExecutor(new Fly());
        public void onDisable() {
            // Plugin shutdown logic
            Bukkit.getLogger().info("Shutting Down!");
    The teleport and other commands
    package Commands;
    import net.md_5.bungee.api.ChatColor;
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    public class Teleport extends JavaPlugin {
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "This plugin is for players only!");
                return true;
            Player p = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("tp")) {
                if (args.length == 0) {
                    p.sendMessage(ChatColor.RED + "Please specify a player.");
                    return true;
                Player target = Bukkit.getServer().getPlayer(args[0]);
                if (target == null) {
                    p.sendMessage(ChatColor.RED + "Could not find player " + args[0] + "!");
                    return true;
                return true;
            return true;
    name: BetterCommands
    version: '${project.version}'main: BetterCommands.Main
    api-version: 1.19
    authors: [ EthanGarey ]
    usage: /<command>
    aliases: [teleport]
    description: Teleport to other players.
    permission-message: "&4&lYou do not have access to that command"permission: permissions.commands.teleport.others
    description: Toggles flight for player.
    permission: permissions.commands.flight.toggle
    permission-message: "&4&lYou do not have access to that command"usage: /fly (optional player)
    upload_2022-8-25_17-31-23.png upload_2022-8-25_17-31-50.png
    Last edited by a moderator: Aug 25, 2022
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline


    It said the plugin is disabled, so as tim said you must have other errors in your log during startup to show why the plugin puked.

    Also you really don't need to send enable/disable messages. Bukkit does that for you already, so manually doing it just clutters the log.
  4. Offline


    The problem is that when you check to see if the argument of the command is only /tp instead of /tp <player> you return true instead of return false.... :)

    Same goes for if (target == null). Should be return false; rather than return true;

    Goodness.. you should also follow naming conventions for your packages.........
    Last edited: Aug 26, 2022
  5. Offline


    And I just started plugin development, I just moved from script to this. I'm still getting used to it.

    How do I fix this?

    It's my first plugin, I'm just- experimenting.

    Solved, I had to change
    public class Teleport extends JavaPlugin {
    public class Teleport implements CommandExecutor {
    (I figured that out on my own :).)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Aug 27, 2022
Thread Status:
Not open for further replies.

Share This Page