Solved My plugin commands don't work

Discussion in 'Plugin Development' started by EdwardBailie, Dec 2, 2013.

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

    EdwardBailie

    When I do /pl or /plugins it shows my plugin, but when I do the commands it doesn't show anything. In the console it says "Player issued server command blah blah"
    Can someone help me? I'm gonna send the source with private messages.
     
  2. Offline

    RainoBoy97

    It would be good if you could post the relevant source code here, even though it's private.
     
  3. Offline

    EdwardBailie

    ------ Link Removed (This is a private plugin) ------
     
  4. Offline

    RainoBoy97

    1. You cannot override /plugins like that, you need to use PlayerCommandPreprocessEvent for that.
    2. The onCommand MUST be named onCommand. And to have more commands, do like this:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
      if(cmd.getName().equalsIgnoreCase("hi") {
        //DO STUFF HERE
      }
     
      if(cmd.getName().equalsIgnoreCase("test") {
        //ANOTHER COMMAND HERE
      }
     
      //tells bukkit that the command was successful, therefore not printing command usage
      return true;
    }
    
     
  5. Offline

    Kyozum0

    im not up to reading all your code but there are somethings that i can point

    Code:java
    1. public void onEnable(){
    2. getLogger().info("Disabled!");
    3. }
    4.  
    5. public void onDisable(){
    6. getLogger().info("Enabled!");
    7. }

    On Enable says "Disabled" and onDisable says enabled

    you use alot of:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. }


    you can put all the commands inside only 1 of those, it decreases LAG!

    i didnt awnser your question because your code is A MESS! you should try fixing it so it is easy to read for me and for you. its just impossible to find the error, and what IDE you use?
     
  6. Offline

    EdwardBailie

    Can I replace /help?
     
  7. Offline

    Kyozum0

    No, it would break your plugin!
     
  8. Offline

    Zarko

    use something like that if you want to prevent such commands

    PHP:
        @EventHandler(priority EventPriority.HIGHEST)
        public 
    void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
            
    Player p event.getPlayer();
            if (
    event.getMessage().startsWith("/pl")) {
                
    event.setCancelled(true);
                
    p.sendMessage("§4 Not allowed to use this!");
            }
            else if(
    event.getMessage().startsWith("/plugins")) {
                
    event.setCancelled(true);
                
    p.sendMessage("§4 Not allowed to do this!");
     
  9. Offline

    RainoBoy97

    Yes, you can. But that will override every /help command and it may cause problems.
     
  10. Offline

    EdwardBailie

    Like what problems? I want a custom help.
     
  11. Offline

    RainoBoy97

    Well, you will have more /help's, and it may not show the one you want.
     
  12. Offline

    1Rogue


    If you want a custom /help command, it's usually good practice to use "/pluginname" or "/pluginname help" for that.
     
Thread Status:
Not open for further replies.

Share This Page