Command to enable another command

Discussion in 'Plugin Development' started by YuzkoCode, Jun 22, 2013.

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

    YuzkoCode

    Hello, I'm trying to make it so that when an Owner or Admin types /sandfall start, players can they type /sandfall join. Here is what I have so far, if you could help that'd be great;

    Code:java
    1.  
    2. package me.yuzko.sandfall;
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9.  
    10. public class PlayerJoin {
    11.  
    12. public boolean onCommand(CommandSender sender, Command cmd,
    13. String commandLabel, String[] args) {
    14. Player player = (Player) sender;
    15. if (commandLabel.equalsIgnoreCase("sandfall")) {
    16.  
    17. if (args[0].equalsIgnoreCase("start")) {
    18.  
    19. Bukkit.broadcastMessage(ChatColor.BLUE + "{Sandfall} " + ChatColor.YELLOW + "Sandfall has been enabled, type /sandfall join if you wish to compete");
    20. //Players can now type /sandfall join
    21. }
    22.  
    23. }
    24. return false;
    25. }
    26. }
     
  2. Offline

    iKanak

    Create a boolean. When the owner starts sandfall, set it to true.

    Then, in onCommand check if the argument is join and the boolean is true, and if it is: execute the necessary code (tp player to event, etc.).
     
  3. Offline

    YuzkoCode

    Could you possibly show me how to do that?
     
  4. Offline

    TheDeathMachine

    YuzkoCode if you do not even know how to do that, you'd probably have a better look at java...

    at the beginning of your main class just do this

    public booloan canjoin = false;

    then when someone types /sandfall start set it to true so

    if(cmd.getName().equalsIgnoreCase("sandfallstart")){
    canjoin == true
    }

    now when someone tries to join check is canjoin is true so:

    if(cmd.getName().equalsIgnoreCase("sandfalljoin")){
    if(canjoin == true){
    //teleport them or something
    }else{
    player.sendmessage("Sandfall has not started!");
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page