Is it possible to register a command besides the plugin.yml

Discussion in 'Plugin Development' started by SugarCraft, Jul 19, 2013.

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

    SugarCraft

    I really would prefer to not use a plugin.yml for registering commands.

    So, is it possible to register a command without using the plugin.yml
     
  2. what do you mean
     
  3. Offline

    RainoBoy97

    Yes it is!

    Use the search field and search for "dynamic commands" :)
     
  4. Offline

    Compressions

    SugarCraft Just because you prefer not to, doesnt mean that using the plugin.yml isn't essential.
     
  5. Offline

    Vislo

  6. Offline

    Rprrr

    Compressions
    It's possible, so it's not essential to use the plugin.yml. I believe there's a tutorial in the resources section.
     
  7. Offline

    Compressions

    Rprrr From the looks of it, he isn't trying to make dynamic commands, and is just looking for convenience.
     
  8. Offline

    SugarCraft

    So, like this?:

    Code:java
    1.  
    2. @EventHandler
    3. public void ssd(PlayerCommandPreprocessEvent e)
    4. {
    5. if(e.equals("command"))
    6. {
    7. Player p = e.getPlayer();
    8.  
    9.  
    10.  
    11. }
    12. }
    13.  
     
  9. Offline

    Vislo

    Its kind of different this is an example:
    Code:java
    1. @EventHandler
    2. public void commandProcess(PlayerCommandPreprocessEvent event)
    3. {
    4. Player player = event.getPlayer();
    5. if (event.getMessage().startsWith("/command"))
    6. {
    7. player.sendMessage(ChatColor.GREEN + "You make a command :D.");
    8. }
    9. }
     
    SugarCraft likes this.
  10. Offline

    alexander7567

    I am currently working on a plugin and I used this for it. However, when I use it, it says "Command Not found"... even though the command is processed using this function. What can I do to tell bukkit that the command is found?
     
  11. Offline

    Goblom

    alexander7567 tried remove the "/" from the getMessage().startsWith(); ?
     
  12. Offline

    jokie666

    you can actually create every command you want with listeners, but I think it is not recommended because I think it takes a lot of server memory to handle it
     
  13. Offline

    alexander7567

    It made setting up the config file a little easier, but no it did not help any.

    Maybe I should rephrase my initial posting...

    It runs the code just fine. I get the message "You make a command :D.". But I STILL get unknown command, even though i get the massage as I should.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  14. Offline

    1Rogue


    Cancel the event if you caught the correct command.
     
  15. Offline

    viper_monster

    alexander7567, try adding e.setCanceled(true); ?

    Awww, Ninja'd :p
     
    alexander7567 likes this.
  16. Offline

    alexander7567

    Yep, that has it! Well, e.setCancelled(true); did... Its 2 l's lol. Thanks very much for your help!
     
    spoljo666 likes this.
Thread Status:
Not open for further replies.

Share This Page