Command Not Registering

Discussion in 'Plugin Development' started by KingOfTheEast01, Jan 24, 2017.

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

    KingOfTheEast01

    Hey guys, my name is Lucas. I've been having some trouble with this problem for quite some time and can't seem to fix it. Basically, I've created a command in a new CommandExecutor implementing class, but for some reason, whenever I try to use the command, I get that all too familiar and ugly message no one wants, saying "Unkown command. Type "/help" for help." I have no idea what I've been doing wrong. Here are my classes down below. Could you guys help me make this command work please? Thanks in advance! :D

    Here is my main class:
    TEFront.java (open)

    Code:
    package com.thechocolatedev.pe;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.thechocolatedev.coms.EstoreCom;
    import com.thechocolatedev.pe.handlers.Inventories;
    
    public class TEFront extends JavaPlugin{
      
        Inventories es = new Inventories();
      
        public void onEnable() {
          
            getCommand("estore").setExecutor(new EstoreCom());
          
        }
    
    }
    


    Here is my command's class:

    EstoreCom.java (open)

    Code:
    package com.thechocolatedev.coms;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import com.thechocolatedev.pe.handlers.Inventories;
    
    public class EstoreCom implements CommandExecutor{
    
        @Override
        public boolean onCommand(CommandSender sender, Command com, String label, String[] args) {
          
            if(com.getName().equalsIgnoreCase("estore")) {
              
                if(!(sender instanceof Player)) {
                  
                    sender.sendMessage("This command can not be executed by console personnel.");
                    sender.sendMessage("Please try again in-game");
                  
                }
              
                else if(args.length == 0) {
                  
                    Player player = (Player) sender;
                    player.sendMessage(ChatColor.STRIKETHROUGH + "     " + ChatColor.GREEN + "[Estore]" + ChatColor.STRIKETHROUGH + "     ");
                    player.sendMessage(ChatColor.GREEN + "/estore: " + ChatColor.AQUA + "Displays this help page.");
                    player.sendMessage(ChatColor.GREEN + "/estore menu: " + ChatColor.AQUA + "Opens up the estore menu");
                    player.sendMessage(ChatColor.STRIKETHROUGH + "     " + ChatColor.GREEN + "[Estore]" + ChatColor.STRIKETHROUGH + "     ");
                  
                }
              
                else{
                  
                    Player player = (Player) sender;
                  
                    switch (args.length) {
                  
                    case 1:
                      
                        if(args[0].equalsIgnoreCase("menu")) {
                          
                            player.openInventory(Inventories.store);
                          
                        }
                      
                        break;
                      
                    case 2:
                      
                        break;
                      
                    }
                  
                }
              
            }
          
            return false;
          
        }
    
    }
    

    Again, thank you so much for any help you can provide! :D
    -Lucas (KingOfTheEast01)
     
  2. Offline

    Sethburster

    Did you register the command in your plugin.yml?
     
  3. Offline

    KingOfTheEast01

    Yes, I did.

    Code:
    commands:
    estore:
      description: Displays the help page for the TE store.
      usage: /<command>
    
     
    Last edited by a moderator: Jan 24, 2017
  4. Offline

    timtower Moderator Moderator

  5. Offline

    KingOfTheEast01

    Oh, I used the correct indentation. Like this:
    Code:
    coomands:
      estore:
        description:
        usage:
    Also, I didn't receive any errors. The console simply told me I was trying to run the command.

    Sent from my SM-G935V using Tapatalk
     
    Last edited by a moderator: Jan 25, 2017
  6. Offline

    TheEnderman

    If you put the main command trigger in your main class, does it work?


    Sent from my iPhone using Tapatalk
     
  7. Offline

    JanTuck

    @KingOfTheEast01

    You gotta give us console logs... We cant solve anything looking at this, does your plugin load? Are you sure you dont receive any errors? Is the plugin.yml registering the command correct? There are even more things that could go wrong, so please provide server startup logs.
     
  8. Offline

    timtower Moderator Moderator

    @KingOfTheEast01 Console will always tell that you are trying to run a command, regardless if it exists or not.
    Please post your full plugin.yml using http://pastebin.com as well as your full server log.
     
    JanTuck likes this.
  9. Offline

    KingOfTheEast01

    Here is my plugin.yml file: http://pastebin.com/Eby1aK97
    Also, I actually did find an error in the console logs, which you can see for yourself in the spoiler below. I'm going to show you the entire console log just incase though. This is from starting up my server.
    Console Log (open)
    25.01 17:22:20 [Multicraft] Starting server!
    25.01 17:22:20 [Multicraft] Loaded config for "Spigot 1.11"
    25.01 17:22:20 [Multicraft] Updating eula.txt file
    25.01 17:22:20 [Server] INFO *** Error, this build is outdated ***
    25.01 17:22:20 [Server] INFO *** Please download a new build as per instructions from https://www.spigotmc.org/ ***
    25.01 17:22:20 [Server] INFO *** Server will start in 15 seconds ***
    25.01 17:22:35 [Server] INFO Loading libraries, please wait...
    25.01 17:22:39 [Server] INFO Starting minecraft server version
    1.11 25.01 17:22:39 [Server] INFO Loading properties
    25.01 17:22:39 [Server] INFO Default game type: SURVIVAL
    25.01 17:22:39 [Server] INFO This server is running CraftBukkit version git-Spigot-f950f8e-4d99fed (MC: 1.11) (Implementing API version 1.11-R0.1-SNAPSHOT)
    25.01 17:22:39 [Server] INFO Server Ping Player Sample Count: 12
    25.01 17:22:39 [Server] INFO Using 4 threads for Netty based IO
    25.01 17:22:39 [Server] INFO Debug logging is disabled
    25.01 17:22:39 [Server] INFO Generating keypair
    25.01 17:22:40 [Server] INFO Starting Minecraft server on 142.4.217.80:26046
    25.01 17:22:40 [Server] INFO Using epoll channel type
    25.01 17:22:40 [Server] ERROR Could not load 'plugins/worldedit-forge-mc1.11-6.1.6-dist.jar' in folder 'plugins'
    25.01 17:22:40 [Server] INFO org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    25.01 17:22:40 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at org.bukkit.craftbukkit.v1_11_R1.CraftServer.loadPlugins(CraftServer.java:300) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:204) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:542) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_05]
    25.01 17:22:40 [Server] INFO Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml 25.01 17:22:40 [Server] INFO ... 6 more
    25.01 17:22:40 [Server] INFO Set PluginClassLoader as parallel capable
    25.01 17:22:40 [Server] ERROR Could not load 'plugins/TE.jar' in folder 'plugins'
    25.01 17:22:40 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
    25.01 17:22:40 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at org.bukkit.craftbukkit.v1_11_R1.CraftServer.loadPlugins(CraftServer.java:300) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:204) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:542) [spigot_1.11.jar:git-Spigot-f950f8e-4d99fed]
    25.01 17:22:40 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_05]
    25.01 17:22:40 [Multicraft] Skipped 124 lines due to rate limit (30/s)
    25.01 17:22:40 [Server] INFO Preparing start region for level 0 (Seed: 7304886062296302388) 25.01 17:22:41 [Server] INFO Preparing spawn area: 52%
    25.01 17:22:41 [Server] INFO Preparing start region for level 1 (Seed: 7304886062296302388) 25.01 17:22:42 [Server] INFO Preparing start region for level 2 (Seed: 7304886062296302388) 25.01 17:22:42 [Server] INFO Enabling PermissionsEx v1.23.4
    25.01 17:22:42 [Server] INFO Initializing file backend
    25.01 17:22:42 [Server] INFO Permissions file successfully reloaded
    25.01 17:22:42 [Server] INFO [Vault][Permission] PermissionsEx hooked.
    25.01 17:22:42 [Server] INFO [Vault][Chat] PermissionsEx_Chat hooked.
    25.01 17:22:42 [Server] INFO Enabling ChocoPlayerSpawn v0.1
    25.01 17:22:42 [Server] INFO Enabling AdminEssentials v1.0
    25.01 17:22:42 [Server] INFO Enabling Essentials vTeamCity
    25.01 17:22:42 [Server] INFO Bukkit version format changed. Version not checked.
    25.01 17:22:42 [Server] INFO git-Spigot-f950f8e-4d99fed (MC: 1.11)
    25.01 17:22:42 [Server] INFO 1.11-R0.1-SNAPSHOT
    25.01 17:22:42 [Server] INFO Using locale en_US
    25.01 17:22:42 [Server] INFO Using locale en_US
    25.01 17:22:42 [Server] INFO [Vault][Economy] Essentials Economy hooked.
    25.01 17:22:42 [Server] INFO Essentials: Using PermissionsEx based permissions.
    25.01 17:22:42 [Server] INFO Enabling Multiverse-Core v2.4-b527
    25.01 17:22:42 [Server] INFO - Version 2.4-b527 (API v14) Enabled - By Rigby, fernferret, lithium3141 and main--
    25.01 17:22:42 [Server] INFO - Version 10.0 - hooked into Essentials Economy for Multiverse-Core v2.4-b527
    25.01 17:22:43 [Server] INFO Loading World & Settings - 'world' - Env: NORMAL - Type: NORMAL & seed: 7304886062296302388
    25.01 17:22:43 [Server] INFO Loading World & Settings - 'world_nether' - Env: NETHER - Type: NORMAL & seed: 7304886062296302388
    25.01 17:22:43 [Server] INFO Loading World & Settings - 'world_the_end' - Env: THE_END - Type: NORMAL & seed: 7304886062296302388
    25.01 17:22:43 [Server] INFO Loading World & Settings - 'Lobby' - Env: NORMAL - Type: FLAT & seed: 5944903546634265400
    25.01 17:22:43 [Server] INFO -------- World Settings For [Lobby] --------
    25.01 17:22:43 [Server] INFO Mob Spawn Range: 4
    25.01 17:22:43 [Server] INFO Cactus Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Cane Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Melon Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Mushroom Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Pumpkin Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Sapling Growth Modifier: 100% 25.01 17:22:43 [Server] INFO Wheat Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO NetherWart Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Vine Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Cocoa Growth Modifier: 100%
    25.01 17:22:43 [Server] INFO Entity Activation Range: An 32 / Mo 32 / Mi 16
    25.01 17:22:43 [Server] INFO Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    25.01 17:22:43 [Server] INFO Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    25.01 17:22:43 [Server] INFO Random Lighting Updates: false
    25.01 17:22:43 [Server] INFO Structure Info Saving: true
    25.01 17:22:43 [Server] INFO Custom Map Seeds: Village: 10387312 Feature: 14357617
    25.01 17:22:43 [Server] INFO Max TNT Explosions: 100
    25.01 17:22:43 [Server] INFO Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    25.01 17:22:43 [Server] INFO Item Despawn Rate: 6000
    25.01 17:22:43 [Server] INFO Item Merge Radius: 2.5
    25.01 17:22:43 [Server] INFO Arrow Despawn Rate: 1200
    25.01 17:22:43 [Server] INFO Allow Zombie Pigmen to spawn from portal blocks: true
    25.01 17:22:43 [Server] INFO View Distance: 10
    25.01 17:22:43 [Server] INFO Experience Merge Radius: 3.0
    25.01 17:22:43 [Server] INFO Zombie Aggressive Towards Villager: true
    25.01 17:22:43 [Server] INFO Nerfing mobs spawned from spawners: false
    25.01 17:22:43 [Server] INFO Preparing start region for level 7 (Seed: -3791499083949572205) 25.01 17:22:44 [Server] Startup Done (3.756s)! For help, type "help" or "?"
     
    Last edited: Jan 25, 2017
  10. Offline

    Zombie_Striker

    @KingOfTheEast01
    Please use [code][/code] tags for this. Spoilers do not keep new lines.

    I found this in the console:
    Are you sure you are exporting the plugin.yml along with the jar? Are you sure the file is in the jar?
     
  11. Offline

    KingOfTheEast01

    I organized the logs, but I should also show you this:
    https://gyazo.com/319a3d85418be5fd56cf6555eab9a7b4
    I'm pretty sure the plugin.yml was exported with the plugin.
     
  12. Offline

    ipodtouch0218

    Nope, referenced libraries are different. Move it into the src of the project (or any package)
     
  13. Offline

    mehboss

  14. Offline

    KingOfTheEast01

    Lol, I'm blind. I thought it was in src, but I guess it has to be above the referenced libraries if it is. Anyways, I moved it to src and am still getting the same error. I even tried moving it into the same package as my main class, but that won't work either.

    Well, its exporting extremely fast for me. I'm pretty sure its not taking 5 seconds to export after it said the project already was.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  15. Offline

    mehboss

    @ipodtouch0218
    That's not true. Look this plugin I made acouple months ago works.
    [​IMG]

    do you include the main?
    @KingOfTheEast01
    Code:
    main: com.thechocolatedevs.coms.<MAIN>
    commands:
      estore:
        description: Displays the help page for the TE store.
        usage: /<command>
    http://wiki.bukkit.org/Plugin_YAML
     
  16. Offline

    KingOfTheEast01

    If you're going to comment on a thread, please read through all the comments first. If you looked in the pastebin above, you'd see I did register my main class.
     
  17. Offline

    mehboss

    @KingOfTheEast01
    ahaha didn't see that.

    UPDATE: It looks like you only space them one space everytime, they need to be spaced two times.

    EXAMPLE:
    Code:
    name: ModTools
    version: 1.0
    main: me.mehboss.modtools.ModTools
    author: mehboss
    commands:
      mod:
        description: Toggles mod mode.
      sc:
        description: Sends a desired message to all staff members.
    permissions:
      modtools.sc:
        description: Gives a player access to /sc
        default: op
      modtools.mod:
        description: Gives a player access to /mod
        default: op
     
  18. Offline

    KingOfTheEast01

    Haha! Lol mate. Well anyways, do you have any other suggestions as to what the problem may be?
     
  19. Offline

    mehboss

    @KingOfTheEast01
    As I said, the plugin.yml spacing..

     
  20. Offline

    KingOfTheEast01

    Actually, I had an object being initialized in my main class before the onEnable method. This was messing something up and your spacing also messed things up for my plugin.yml, but thanks for the help guys! :D I can finally set the prefix of a plugin to solved. XD
     
  21. Offline

    mehboss

    my spacing didn't mess anything up :p
    I'm actually using the spacing and that is how the format of plugin.yml is supposed to be.. Anyways, np.
     
  22. Offline

    KingOfTheEast01

    Well it didn't work for me, so as far as I'm concerned, it isn't correct. Also, I don't see why you would want to use two extra spaces per substring, considering one is enough and can easily be noticed as an indentation. But anyways, again, thanks, to you, and everybody else who helped me out in this thread.

    Sent from my SM-G935V using Tapatalk
     
Thread Status:
Not open for further replies.

Share This Page