(HELP) I need to learn to code

Discussion in 'Plugin Development' started by CheifKeef, Jun 8, 2014.

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

    CheifKeef

    Ok lets say i have a blank mind and i want to learn everything about Bukkit coding.I need to learn how to code plugins from begging to end. I don't know nothing about coding how would you teach a Brain dead bukkit coder how to code Please no bullcrap follow along videos i tried those and they didn't help i am looking for online tutorials and all that I mostly want to code plugins like essentials in my own version and much much more so can you give me a step by step guide on where to learn to code plugins or just give me links
     
  2. Offline

    gamemster2468

  3. Offline

    CheifKeef

    Can you give me a link to the bukkit API? or the codes or whatever
     
  4. Offline

    gamemster2468

    Java docs.
     
  5. Offline

    CheifKeef

    Wheres that at?
     
  6. Offline

    gamemster2468

  7. Offline

    CheifKeef

  8. Offline

    mine-care

    1. Learn java
    2. Beware of conventions and differences of Boolean and boolean for instance,
    3. Thing logically
    4. Don't go in deep waters from the beginning, don't try making a mini game as your first plugin...
    5. Never store and pass player object! Ram leaks!, instead use it as a string
    6. Don't be afraid to ask,
     
    Plo124 likes this.
  9. Offline

    1Rogue


    wat
     
  10. Offline

    mine-care

    1Rogue as I've read, passing player object or storing it to maps causes leaks, so instead we use string but that will be gone after the uuid thingy
     
  11. Offline

    Plo124

    There is never an end in Java programming
     
    ZodiacTheories and mine-care like this.
  12. Offline

    mine-care

    Plo124 I can't argue with that....
    Btw you received your 50th like :D
     
  13. mine-care You can store player objects, just as long as you remember to handle it when you no longer need them, and you can definitely pass a player object.
     
  14. Offline

    mine-care

    AdamQpzm yep, but for a beginner that might mean trouble, and why not storing a string :p
    And I haven't said you can't, I said you should not.
    :)
     
  15. mine-care I'll give you the "storing" is probably best to avoid for beginners, but the passing is just wrong.
     
  16. Offline

    mine-care

    AdamQpzm lol rly? A guy that helped me thru bukkit API a while ago told me that passing it to methods is bad too!
    Sorry...
     
    AdamQpzm likes this.
  17. Offline

    fireblast709

    CheifKeef Oracle tutorials!

    mine-care In general storing it is no issue, but people forget to clean up their mess (variables) which causes the memory leaks. Using Player objects in methods is no issue since the variable would be out of scope after it left the method it was first used in.
    Code:java
    1. public void foo()
    2. {
    3. // We create a reference to a Player
    4. Player p = Bukkit.getPlayer("Notch");
    5. bar(p);
    6. // Now here is where the method ends, and so ends the lifetime of the reference 'p' to the Player object
    7. }
    8.  
    9. public void bar(Player p)
    10. {
    11. // Do some fancy stuff
    12. }


    Advanced part

    Storing it as class variables and Collections is a different story. Since that reference is not automatically cleared, it is up to you, the developer, to ensure that. As keys in a Map<Player, ?>, a WeakHashMap is a good solution. Sets can use
    Code:java
    1. Collections.newSetFromMap(new WeakHashMap<Player, Boolean>());
    (link) which basically uses a WeakHashMap rather than a HashMap to back the Set. Lists, arrays and single fields can use WeakReference<Player> instead of storing the Player directly.

    With this all said, that is still no excuse to just clean up your own mess by removing the elements yourself. Aside that it is good practice, it adds to the consistency that you are sure that the object is removed after you did the cleanup.
     
  18. Offline

    mine-care

    Right.. Just read about it, the guy that thought me, was a bit outdated.. He is nowhere to be found for the last year...
     
  19. Offline

    1Rogue


    That simply isn't true.
     
  20. Offline

    Plo124

    Why thank you :D
    Already 1/2 way to what bigteddy98 had about a month ago
     
Thread Status:
Not open for further replies.

Share This Page