Nub promblems

Discussion in 'Plugin Development' started by porrinialex, Aug 21, 2013.

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

    porrinialex

    When i do /cjoin it also does /cleave at the same time without me typing it! How do i stop this?


    Code:java
    1. package me.porrinialex.S;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Main extends JavaPlugin
    9. {
    10.  
    11. public void onEnable() {
    12.  
    13. }
    14. public void onDisable() {
    15.  
    16. }
    17. public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    18. Player player = (Player) sender;
    19. if (command.getName().equalsIgnoreCase("cjoin")) {
    20. player.chat("/clan clanchat join"); {
    21. }
    22.  
    23. if(command.getName().equalsIgnoreCase("cleave"));
    24. player.chat("/clan clanchat leave");
    25. }
    26.  
    27.  
    28.  
    29. return false;
    30.  
    31. }
    32.  
    33.  
    34.  
    35.  
    36. }


    Problems* :D

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

    exload

    Use an else if or put each command in a different class.
    Code:java
    1. if command equals "cjoin"
    2. //do stuff
    3. else if command equals "cleave"
    4. //do stuff
     
  3. Offline

    porrinialex

    exload Thanks i ended up making them in diffrent classes!
     
  4. or use
    Code:java
    1. return true;

    and try to read the bukkit plugin developement beginners guide here.
    if that doesn't work, tahg me in this thread and I will rewrite it, telling you what I corrected.
     
Thread Status:
Not open for further replies.

Share This Page