1.15.2 Error in Command class

Discussion in 'Spigot Plugin Development' started by Phoenix852, Mar 18, 2020.

  1. I am getting error repeatedly in my plugin TrollEmup. I kinda messed the whole project of RandomMOTD and TrollEmUP by putting all the code in one class, but yesterday I separated the classes of RandomMOTD and now I am trying to do with TrollEmUp. But the thing is I am getting error saying NoSuchMethodError.
    Here is my whole error
    Code (Text):

    [20:54:44] [Server thread/ERROR]: Error occurred while enabling TrollEmUp v1.0.0 (Is it up to date?)
    java.lang.NoSuchMethodError: com.ThunderKofy.Commands.<init>(Lcom/ThunderKofy/TrollEmUp;)V
            at com.ThunderKofy.TrollEmUp.onEnable(TrollEmUp.java:24) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[server.jar:git-Bukkit-3e3818b]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:344) [server.jar:git-Bukkit-3e3818b]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:416) [server.jar:git-Bukkit-3e3818b]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:447) [server.jar:git-Bukkit-3e3818b]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:373) [server.jar:git-Bukkit-3e3818b]
            at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:440) [server.jar:git-Bukkit-3e3818b]
            at net.minecraft.server.v1_14_R1.DedicatedServer.init(DedicatedServer.java:253) [server.jar:git-Bukkit-3e3818b]
            at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:753) [server.jar:git-Bukkit-3e3818b]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
    These stacktraces say that the line number 24 is the error and yeah when I remove it it works fine, but the line number 24 is where I registered the command executor.
    Here is my main class
    Code (Java):
    TrollEmUp from ThunderKofy.
    For support and issues regarding this plugin, contact our developers at https://discord.gg/bFX2Vgv
    Note that we don't provide support if the source code was modified.

    package com.ThunderKofy;

    import com.ThunderKofy.Trolls.burn;
    import com.ThunderKofy.Trolls.creeperRevenge;
    import com.ThunderKofy.Trolls.takeMyFish;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.logging.Level;

    public class TrollEmUp extends JavaPlugin implements Listener {
        public void onEnable(){
            getLogger().log(Level.INFO, "Thanks for having me as a plugin at your server :)");

            // Command and TabCompleter
            this.getCommand("TrollEmUp").setTabCompleter(new TabCompleter());
            getCommand("TrollEmUp").setExecutor(new Commands(this));

            // Listeners
            getServer().getPluginManager().registerEvents(new takeMyFish(this), this);
            getServer().getPluginManager().registerEvents(new creeperRevenge(this), this);
            getServer().getPluginManager().registerEvents(new burn(this), this);
        public void onDisable(){
            getLogger().log(Level.INFO, "Goodbye!");
    and this is my Command class
    Code (Java):
    package com.ThunderKofy;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;

    public class Commands implements CommandExecutor {
        private TrollEmUp plugin;

        public Commands(TrollEmUp plugin) {
            this.plugin = plugin;
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("trollemup")) {
                if (args.length == 0) {
                    if (!sender.hasPermission("TrollEmUp.main")) return true;
                    sender.sendMessage(ChatColor.GREEN + "TrollEmUp from ThunderKofy");
                    sender.sendMessage("Version: " + ChatColor.YELLOW + this.plugin.getDescription().getVersion());
                    sender.sendMessage("Developed by " + ChatColor.YELLOW + "Phoenix852 | ThunderKofy");
                    sender.sendMessage("If you have any issues regarding this plugin, join our discord: " + ChatColor.BLUE + this.plugin.getDescription().getWebsite());
                    return true;
                }else if(args[0].equalsIgnoreCase("reload")){
                    if(!sender.hasPermission("TrollEmUp.reload")) return true;
                    sender.sendMessage("[TrollEmUp] Config reloaded!");
                    return true;
                } else if(args[0].equalsIgnoreCase("trolls")) {
                    if(!sender.hasPermission("TrollEmUp.trolls")) return true;
                    sender.sendMessage(ChatColor.AQUA + "burn: " + ChatColor.WHITE + this.plugin.getConfig().getBoolean("trolls.burn.enabled"));
                    sender.sendMessage(ChatColor.AQUA + "creeper-revenge: " + ChatColor.WHITE + this.plugin.getConfig().getBoolean("trolls.creeper-revenge.enabled"));
                    sender.sendMessage(ChatColor.AQUA + "take-my-fish: " + ChatColor.WHITE + this.plugin.getConfig().getBoolean("trolls.take-my-fish.enabled"));
                } else if(args[0].equalsIgnoreCase("author")) {
                    if(!sender.hasPermission("TrollEmUp.author")) return true;
                    sender.sendMessage("Developed by " + ChatColor.YELLOW + "Phoenix852");
                    return true;
                } else if (args[0].equalsIgnoreCase("help")) {
                    if(!sender.hasPermission("TrollEmUp.help")) return true;
                    sender.sendMessage(ChatColor.GREEN + "/TrollEmUp" + ChatColor.WHITE + " --> Shows the description of TrollEmUp.");
                    sender.sendMessage(ChatColor.GREEN + "/TrollEmUp reload" + ChatColor.WHITE + " --> Reloads the configuration file.");
                    sender.sendMessage(ChatColor.GREEN + "/TrollEmUp trolls" + ChatColor.WHITE + " --> Shows all the enabled and disabled trolls.");
                    sender.sendMessage(ChatColor.GREEN + "/TrollEmUp author" + ChatColor.WHITE + " --> Shows the author description.");
                    return true;
                } else {
                    sender.sendMessage(ChatColor.RED + "[ERROR] Unknown command!");
                    sender.sendMessage("To see the list of commands and their description, use the " + ChatColor.YELLOW + "/TrollEmUp help" + ChatColor.WHITE + " command!");
                    return true;
            return true;
    I don't know what is wrong with this, I did the same thing with RandomMOTD and RandomMOTD is good working fine since I updated it, but this is having error.
    #1 Phoenix852, Mar 18, 2020
    Last edited: Mar 18, 2020
  2. I don't see anything wrong with this code, what does your plugin yml look like?
  3. Can you follow java conventions for package naming? Thanks.
    • Agree Agree x 1
  4. drives_a_ford


    Are you changing the jar while the server is in operation?
    Are you using the reload command?
  5. no, I am starting the server everytime I export the jar.