Looking for some constructive criticism

Discussion in 'Plugin Development' started by d3x, Mar 2, 2011.

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

    d3x

    I don't want to pick up any bad habits so could you go over my code quickly and point out flaws/bad habits? Thanks in advance!

    http://pastie.org/1626562
     
  2. Offline

    Plague

    Code:
    new File(getDataFolder(), "config.yml")
    that'S there n times, it's better to save it
    Code:
    File configFile =new File(getDataFolder(), "config.yml")
    and use that instead.

    I don't really see anything besides that, but I'm a C programmer...
     
  3. Offline

    Afforess

    Agree with plague - If you have the same thing in both the if and the else statement, just move it outside the if else.

    I'm not a big fan of putting a whole bunch of random methods inside the main plugin class. It really doesn't make sense, because the plugin is actually an object, so you just added a random method to the object, and stuff that doesn't pertain to the plugin as a whole doesn't really belong there. Utility classes are were that stuff belongs.

    Also, blockAction doesn't need to be on the main thread, wasting a ton of cpu cycles lagging the server. In fact - I'd turn the whole blockAction into a runnable object, give it the type, data, and x,y,z coordinates as parameters to avoid the block function calls, and run it on an Aysnc thread with the bukkit scheduler.

    Okay - so I've given you a lot of crap. ;)

    Here's a rough idea of what I'm talking about. The imports aren't right, cause I fired it up in NP++.
    http://dl.dropbox.com/u/49805/LogBlockLite.java

    Should be totally thread-safe, fast, and easy to understand.
     
Thread Status:
Not open for further replies.

Share This Page