Separating each command into its own .java

Discussion in 'Plugin Development' started by larperdoodle, May 10, 2013.

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

    larperdoodle

    Code:java
    1. package net.net84.larperdoodle.CommandAdder;
    2. import org.bukkit.command.Command;
    3. import org.bukkit.command.CommandExecutor;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. public class buildzoneadd implements CommandExecutor {
    7.  
    8. @Override
    9. public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
    10. //command shizzle wizzle here
    11. return false;
    12. }
    13.  
    14. }
    15.  

    This is the code for the command, will this work? What do I need to do in the main .java to get this to work.
     
  2. Offline

    chasechocolate

    In the onEnable():
    Code:java
    1. this.getCommand("thecommand").setExecutor(new <your command class>());
    2. //Repeat for all your other CommandExecutors
     
  3. Offline

    gomeow

    in the onEnable, you can specify a CommandExecutor for a command, just check the wiki, it explains this
     
  4. Offline

    larperdoodle

    Eclipse makes me change it to "this.getCommand(null).set....ect"
     
  5. Offline

    gomeow

  6. Offline

    ZeusAllMighty11

    You just have to grab the command
    Code:
    getCommand("someCommand").setExecutor(new buidlzoneadd());
     
  7. Offline

    gomeow

Thread Status:
Not open for further replies.

Share This Page