Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What`s the diffrence?

Comments in 'Plugin Development' started by Primus, May 19, 2015.

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I know that there is 2 ways to add command with:
    PHP:
    if(strtolower($command->getName()) === "cmd"){
    }
    and
    PHP:
    switch($command->getName()){
       case 
    "cmd":
    }
    What's better?
    DunxandMinecraft likes this.
  2. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    I personally think the bottom one is better. Just depends as long as it works. I guess
  3. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    If you are doing one command it doesn't matter. Both are roughly the same. If you are matching several commands, the second one looks slightly better.
    DunxandMinecraft likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Actually it is "handle comamnds" not "add commands".
    TigerHix likes this.
  5. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    I think the second one is easier to handle multiple whole commands (like /defgm or /time), and to be able to function both at once.
    Doesn't exactly matter for one command.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Falk likes this.
  7. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    In a commercial setting you don't do premature optimization. A lot of times is cheaper to buy bigger hardware to solve performance problems than pay for a programmer to optimize code.
    PEMapModder and Falk like this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    But I just love optimizing it :p It is my hobby xD

Share This Page

Advertisement