What am i doing wrong with this command

Discussion in 'Plugin Development' started by Danielh90, Sep 10, 2014.

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

    Danielh90

    I am making a gamemode command what am doing wrong when i am in creative it switch me to survival but when i try and switch to creative in does not let me here is the code
    Code:java
    1. } else if(cmd.getName().equalsIgnoreCase("sc")){
    2. if(args.length==1){
    3. p.setGameMode(GameMode.CREATIVE);
    4.  
    5. }
    6. else {
    7. p.setGameMode(GameMode.SURVIVAL);
    8. sender.sendMessage(prison + "You have switch to Survival mode");
    9. }
     
  2. What excactly do you type when you want to go into creative mode?
     
  3. Offline

    Danielh90

    /sc why ? i what it to switch if i type /sc it puts me in creative and if i do /sc again it put me in survival

    i use /gamemode but i what to make it so my command i just need to do /cs and it switchs me to creative if i am in survival

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  4. In the code you are testing if your argument length is 1, in other words, when you want creative you have to type /sc <randomWord>
     
  5. Offline

    Danielh90

    Oh but it does not do it for creative then

    it works but i don't what to type somthing to back in to survival do i have to add if(args.lengh=0) where survival is ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  6. Shall I get u a small code that when you are in survival it sends u to creative and when in creative ur sent to survival?
     
  7. Offline

    Danielh90

    sure
     
  8. Offline

    xXRobbie21Xx

    Change args.length == 1 to args.length == 0 and it should work fine
     
  9. Code:java
    1. if(cmd.getName().equalsIgnoreCase("sc")) {
    2. if(p.getGamemode() == GameMode.CREATIVE) p.setGameMode(GameMode.SURVIVAL);
    3. else p.setGamemode(GameMode.CREATIVE);
    4. }
     
Thread Status:
Not open for further replies.

Share This Page