Solved Problem Switch-Case Loop

Discussion in 'Plugin Development' started by FameForAim, Jan 27, 2015.

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

    FameForAim

    Hi,
    for my plugin i use a switch loop to check which command it is.
    But i want to implement a general output which is given out when none of theses cases happens.
    For example:

    Code:
    Switch ("Stringcommand") {
      case "kick" :
          ...... //random code
        break;
      case "bann":
       ...// random code
       break;
    //here i want the output if there is not the command bann or kick issued
    Player.sendMessage("No Command issued!")
    but if i just add it at the end of the loop it also gives the output when a command is issued .
    So how can i make this.

    Thanks.
    Best regards
    FameForAim
     
  2. Offline

    CraftCreeper6

  3. Offline

    LegacyGaming

    I think you might be wanting:
    Code:
    case default:
    //Random code...
    break;
     
  4. Offline

    WinX64

    Use the default case. Its code will be executed if the command you specified is not defined in any of your cases.
    Code:
    switch (number) {
        case 1:
            break;
    
        case 2:
            break;
    
        default:
            //Input was something other than 1 or 2
            break;
    }
     
  5. Offline

    FameForAim

    thanks so much for this fast answers :) solved it
     
Thread Status:
Not open for further replies.

Share This Page