Commands, and why you shouldn't just return if != instanceof Player

Discussion in 'Plugin Development' started by Dinnerbone, Feb 2, 2011.

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

    Tagette

    Well my code seems to work quite well so I think I did it correctly. It supports console commands. I'm not sure how to add support for anything like IRC though so.
     
  2. Offline

    LasTRizen

    Wow so many plugin developers :D PM me if you wanna help me make my plugin :)
     
  3. Offline

    Xemos

    an easy structure solution for this:

    // for commands console and players can use

    switch(args[0]toLower()){
    case "1": {
    doBlah;
    return true; }
    case "2": {
    doBlah;
    return true; }
    default:
    }

    //checks if command sender is console

    if ((sender instanceof ConsoleCommandSender)) {

    sender.sendMessage("You can not use " + args[0] + " from console!");
    return true;
    }

    // Player only commands

    switch(args[0].toLower()){
    case "3": {
    doBlah;
    return true; }

    case "4": {
    doBlah;
    return true; }

    default:
    }


    Easy way and low overhead way to filter out console from commands that need player interaction.
     
  4. Offline

    evilmidget38

    Not all servers run Java 7. Although I personally think they should, it's just the way it is.
     
  5. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Removing sticky status from this thread. :3
     
  6. Offline

    evilmidget38

    Any particular reason?
     
  7. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Slight delay to my post replacing it.
     
Thread Status:
Not open for further replies.

Share This Page