Where can I learn Sponge Coding

Hi, my name is frogocomics and I own a small server. I’m just starting to learn Java code and I am currently progressing very fast. I am interested in the SpongeApi but I don’t know where I could learn it. I find it hard to read the JavaDocs and I don’t find the Sponge Docs very useful. They seem to be targeted at beginners.

public class HelpMe {
    public void static main(String args[]) {
        if (Coder.getPlayer().requiresHelp() = true) {
            System.out.println("HELP");
        }
        else {
            System.out.println("No Help Needed"):
        }
   }
}
 public class HelpMe{
    public static void main(){
    String help1="you should probably read the source code, and spend time familiarizing yourself with what connects to what.";    
    String help2=" it's not much different than bukkit in terms of what method is where. :) "
    if( true ){say(help1, help2);}
    }


public Object say (Object... list ){ 
    for (Object obj : list){ console.log(toString(obj)); } 
}

…I think. Only done the say method once so it might be wrong, as I did not look it up this time but instead did it from old memory. It should print out anything you throw at it. (removes the long sys.out.print lines from your code, I prefer it)

–EDIT-- added @Kodfod’s brilliant suggestion for the for loop, and @RobodudeMC’s explanation of console logging only strings.

1 Like

@octoshrimpy Why not just do:

for (Object obj : list) { console.log(obj); } 

I think using int i = 0; is a messy way to iterate through an array.

1 Like

Offtopic:
@Kodfod Because it’s midnight and I didn’t even consider that a pastability. :slight_smile: TIL <3

OnTopic:
@frogocomics I’d keep an eye on this and this. (the second is a link to a specific comment, that will sound familiar. :wink: )

Fair comment. They are mostly aimed at beginners.

There are plans for Advanced Topics pages, and even tutorials for writing plugins, but they will probably have to wait until the API matures a little. Nonetheless, if anyone has any good ideas for Advanced Topics that expand on the stuff already on the Docs, or wants to write a Tutorial demonstrating the use of various features, these would be welcome suggestions (and/or PR’s).

@octoshrimpy Actually its

    public void (String... list){
        for(String s : list){
            console.log(s)
        }
    }

@RobodudeMC Why limit yourself to Strings? Could be an Integer, boolean, etc!

1 Like

I think only the API team is qualified to write the advanced stuff. The problem is that the javadoc does not explain everything. Only the team knows how some of the things work.
Also, there is no way to test the plugins you write. That makes it really difficult.

The thing is, programming seems hard for me. I STILL dont get the ?: operator. I’ll need a lot of help at this. Some people call me amazing at programming: since i am only twelve.

@kodfod Trying not to go super off topic, but typically writing to a log file / console will only accept strings, not Java objects. If you wanted to plug in a object you could always run toString() but when writing to a log all that is really going to be involved is text.

@frogocomics I think that is would probably be best for you to look at existing sponge plugins (I know there is not a huge amount out there, but they are increasing) also, as octo said you should take a look at the API code itself to get a kinda-sorta idea oh how things work. It just takes pretty basic Java knowledge to interpret it a little.

1 Like

@RobodudeMC You can pass primitive data types (int bool string char etc) with the way I mentioned above, When you start passing String[]'s it wont parse that way. Unless you process it yourself.

Try running this.

    public static void main(String[] args) {
        String str = "Help String";
        char character = 'c';
        boolean bool = true;
        int Int = 1;
        double doub = 2.0d;
        float floa = 0.5654687f;
        String[] strAry = {"test", "omg is it working?"};
        
        Object[] objAry = new Object[7];
        objAry[0] = str;
        objAry[1] = character;
        objAry[2] = bool;
        objAry[3] = Int;
        objAry[4] = doub;
        objAry[5] = floa;
        objAry[6] = strAry;
        say(objAry);
    }
    
    public static void say(Object list[]) {
        for (Object obj : list) { System.out.println(obj); }
    }

Ok. I needed help and now everyone is having a code discussion. Whats with you guys? Only 3 people posted useful things.

1 Like

What we’re trying to say is. Learn Java first, inhale as much of it as you possibly can. Youtube vids, books, pamphlets, everything. Then/Also read the Sponge source, and learn how it does its thing. There are a couple sponge plugins that you can take a look at (and follow development of on github) to see how others are doing it.


On an unrelated note, there is no such thing as “geared towards beginners”, since you can always learn something new from the simplest of things. :slight_smile:
Mull over the JavaDocs till they click, and if you have any specific questions, shoot! :smiley:

5 Likes

I always click. b3c4use button.

1 Like