Solved Commands send only a message with /(the command)

Discussion in 'Bukkit Help' started by Lupus_Z, Aug 4, 2016.

Thread Status:
Not open for further replies.
  1. [​IMG] I have a problem: I "created" a command using plugin.yml etc... but when I do the command ( in this case: /souls) in the chat it appears /souls. (any sender)
    This is all the plugin code. What's the mistake?
    Code:
    package it.mnplugin.lupus;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Monster;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener{
    
        public void onEnable(){
        
            getConfig().options().copyDefaults(true);
            saveConfig();
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "MagikNova " + ChatColor.DARK_AQUA + getConfig().getString("version") + ChatColor.AQUA + " enabled" );
            getConfig().set("souls", 33);
    
        }
    
        public void onDisable(){
        
            getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "MagikNova " + ChatColor.DARK_AQUA + getConfig().getString("version") + ChatColor.AQUA + " disabled" );
            saveConfig();
        
        }
    
        @EventHandler
        public void onEntityDeath(EntityDeathEvent e){
        
            if(e.getEntity() instanceof Monster){
            
                Monster mdeath = (Monster) e.getEntity();
            
                if(mdeath.getKiller() instanceof Player){
                
                    getConfig().set("souls", getConfig().getInt("souls") + 1);
                    saveConfig();
                
                }
            
            }
        }
    
        public boolean onCommand(Command cmd, CommandSender sender, String label, String[] args){
        
            if(cmd.getName().equalsIgnoreCase("souls")){
            
                sender.sendMessage(ChatColor.AQUA + "(!)You have" + ChatColor.LIGHT_PURPLE + getConfig().getString("souls") + ChatColor.AQUA + "Souls!");
            
            }
        
            return false;
        
        }
    
    }
    
    The plugin.yml looks like:
    name: MagikNova Plugin
    version: 0.0.1
    main: it.mnplugin.lupus.Main
    description: Enjoy the Magic....

    commands:
    souls:
    usage: /souls
    description: states your current Soul balance

    The file is the screenshot of the problem
     
    Last edited: Aug 4, 2016
  2. Offline

    timtower Administrator Administrator Moderator

    @Lupus_Z You are returning false yet the command ran fine. That is the issue.
    No need for the enable / disable messages anyways, bukkit does that for you
     
  3. @timtower I tried to change return false; to true but I have the same problem
     
    Last edited: Aug 4, 2016
  4. Offline

    timtower Administrator Administrator Moderator

    @Lupus_Z Then try to find out if the entire onCommand is even running.
     
  5. @timtower I created a command maybe 4 weeks ago, and it had the same problem. Then I formatted the PC and now I re-installed the new eclipse version. Maybe I mess up with something in eclipse, why I has the same problem (now and 4 weeks ago) that the javadoc doesn't do anything, I validated it, applied it, but it continue to say me: "this element has attached....". Another problem is that when I use econ.withdrawPlayer() (Vault) it doesn't work and in eclipse it says that "the metod is deprecated" and to add SuppressWarning (obviously, if I add it it doesn't work to :p) I hope it's eclipse, because in the web I found someone with my same problem. If not, I have Windows 7 (seven ice, exactly) with 32bit, but I hope it's not my computer
     
    Last edited: Aug 5, 2016
  6. I solved it, I have copy-pasted an internet code and I editd it
     
Thread Status:
Not open for further replies.

Share This Page