Plugin Development - A HUGE tutorial!

Discussion in 'Plugin Development' started by Adamki11s, Apr 29, 2011.

?

Was this helpful to you?

  1. Yes!

    78.4%
  2. No, but it was a good tutorial :)

    16.1%
  3. No.

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

    aPunch

    Don't worry about him. He is either trolling you or legitimately a douche bag. I'll have a guide on what to do when your plugin needs updating, and it will be up soon. :)
     
    ashour likes this.
  2. Offline

    ashour

    thank you.
     
  3. Offline

    Crash

    You can't make a tutorial on "How to update your plugins" because you can't know what will break in the next build and there are so many different types of plugins it's impossible.
    The best you could do is check here :
    http://forums.bukkit.org/threads/oops-i-broke-your-plugins.599/
    If you can't figure it out what broke take a look at :
    http://ci.bukkit.org/job/dev-CraftBukkit/changes
    See if anything in there might affect your plugin and look at the code changes.

    If you still don't know then you should ask here for some help.
     
  4. Ovbiously. But useful links and general info can be provided :p
     
  5. Offline

    Windwaker

    I think you should go a little more into detail on what "doSomething" is and what you should do in the Command section.
     
  6. Offline

    alta189

    You have an error in
    if(commandLabel.equalsIgnoreCase("basic"){
    you forgot a ) to close the if
    if(commandLabel.equalsIgnoreCase("basic")){
     
  7. Thank you :) Although most IDE's would fix this problem I still want people to tell me :p
     
  8. Offline

    EpikGlow

    I'm liking how a lot of people are helping out and pitching in with developing a pretty good tutorial (in my opinion, as I do not have much Java experience - only a bit of C++ experience heheh). Anyways, nice tutorial you got so far, Adamki11s, and keep up the good work everybody! ;D
     
  9. Thanks, hope it helped :D
     
  10. Offline

    1337

    Nope its bad to be able to copy and paste,You get it into your memory if you have to type it :D also add java-made-easy.com to the tut list,its where i learnt
     
  11. Support 100% :D
     
  12. Offline

    nickguletskii

    Yes, because you have missed the step where you have to ANALYSE it.
     
  13. Offline

    EpikGlow

    Ok guys, you should probably stop now. Nobody wants to start a flame war or anything. At least I don't.
     
  14. Probably a good idea, keeps the thread at the top though :p
     
    EpikGlow likes this.
  15. Offline

    Kalade

    Stop being a D*** once, ok?

    ===========================

    @Adamki11s wow dude, this is THE BEST tutorial :) Thanks man.
     
    mbsuperstar1 likes this.
  16. You welcome :D
     
  17. Offline

    Jonni

    I got a question for the Save Files thing.
    I am trying to store some strings (A String Array) to the File and it works. But is there any way how to sort how the variables are written into the file?
    I get something like:

    line20
    line9
    line8
    ...
    line19
    etc.

    Hopefully you can help me^^
     
  18. I don't think there's an EASY way to control which lines the files are written to but you could store them all with a unique identifier by using a for loop, example :
    Code:
    int a;
        for(a = 1; a <= YourArryLength; a++){
            putintopropertiesfile("YourArray" + (a - 1), array[a - 1]);
        }
    That way you would have in your file:

    YourArray0=value of array[0]
    YourArray1=value of array[1]
    YourArray2=value of array[2]
    YourArray3=value of array[3]
    YourArray4=value of array[4]

    Get it? :p
     
  19. Offline

    Jonni

    For now i have it this way:

    Code:
    for ( int i = 0; i <= 20; i++ )
    {
        prop.put( "line" + i, "" );
    }
    When i use this:
    Code:
    for ( int i = 1; i <= 21; i++ )
    {
        prop.put("line" + (i - 1), line[i - 1]);
    }
    I get a NullPointerException :S

    But maybe it's because i used a new bukkitSNAPSHOT?
     
  20. When you get a null pointer do you get an ArrayOutOfBounds exception also?
     
  21. Offline

    Jonni

    When i change the ArrayIndex, i get an ArrayIndexOutOfBounceException but no NullpointerException
     
  22. It doesn't matter too much what you output to the line but you need to make sure your index is within bounds eg, you cant call anything < 0 because it's out of bounds and you can't call anything above what you define the range as.

    Use this example code;


    Code:
    String[] example = new String[20];
    
    for (int i = 1; i <= 20; i++)
    {
        //the first for loop iteration will be 1, NOT 2, it checks if the condition is met, if yes it executes the code, increments the value of whatever the 3rd arguament states then starts again.
        prop.put("Value" + (i), line[i - 1]);
    }
    This would produce

    Value1=Valueofarry1index[0]
    Value2=Valueofarry1index[1]
    Value3=Valueofarry1index[2]
    Value4=Valueofarry1index[3]

    Hope this helped clear things up :)
     
  23. Offline

    Jonni

    Just found the problem.
    You couldn't know why it was an error^^
    Forgot to say that the Array is empty when i write the variables in the file, so there should only be printed an empty space.

    Another question: Do you know any fast way to initialize a String Array with 20 Spaces very fast and easy with "" or null? -> Made it...

    Also tested your way and got this^^ (Array initialized with "")
    Code:
    Value19=
    Value18=
    Value17=
    Value9=
    Value16=
    Value8=
    Value15=
    Value7=
    Value6=
    Value14=
    Value5=
    Value13=
    Value4=
    Value12=
    Value3=
    Value11=
    Value2=
    Value10=
    Value1=
    Value20=
    
     
  24. Use a for loop :p

    Code:
    String[] initArray = new String[127]; //For example :)
    
    for(int i = 1; i <= 127; i++){
        initArray[i - 1] = null;//Or whatever you want inital value to be, eg 0.
    }
     
  25. Offline

    Jonni

    Would be a possibility. I use Arrays.fill for now ;)

    Oh. What i forgot to say.
    It is a very good Tutorial :D
    except of some grammar faults :p
     
  26. Please tell me the grammar faults, I didn't do a spell check and typed most of this up on my phone at school :p I need to add to it but am very busy IRL at the moment :p
     
  27. Offline

    Jonni

    So if anyone has a good and easy method to sort the properties saved in the file please post it here :D
    I already found some Usermade classes, but they didn't work for me.
     
  28. Offline

    cholo71796

    Could you add something about why you need to put different things in the different classes? It's not crucial, but I'm curious. Excellent tutorial.
     
  29. Thanks :) Yes, I'll try to explain that in more depth for you.

    You don't need to sort them. Just assign unique identifiers to each property and then loops like I showed you earlier to find the value.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 14, 2016
    cholo71796 likes this.
  30. Offline

    PatrickFreed

    This is great.
    I'm just curious, where did you devs learn java?
     
Thread Status:
Not open for further replies.

Share This Page