Michael
Donators
Hero Member
Posts: 2166
|
|
« on: July 03, 2013, 03:52:47 PM » |
|
Mythruna Pre-Alpha APIThis is a documented API I have created for the convenience of having it for everyone, until the new API Paul is working on comes out. This is practically to get everyone started with modding Mythruna, and will be continued until Paul releases his own.
Find the API examples on Github: Java Groovy
If you would like to help with the API, you can via Github!
|
|
« Last Edit: September 14, 2013, 08:53:59 AM by Shzylo »
|
Logged
|
|
|
|
nh_99
Donators
Jr. Member
Posts: 71
|
|
« Reply #1 on: July 03, 2013, 07:10:59 PM » |
|
As a comment on you saying to leave that null on the command, that is FULL command description I think so you can set it to a map(String[] advancedHelp = new String[] { "Hello world!" };) that has that in it.
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #2 on: July 03, 2013, 07:24:36 PM » |
|
Hmm, this is a rough draft that a grabbed by looking at the first 2 tutorials that paul gave, and looking at some of his default scripts generated by the server, I am basing everything practically off of mods that people make and the examples Paul has gave. Thanks for the info!
|
|
|
Logged
|
|
|
|
pspeed
|
|
« Reply #3 on: July 03, 2013, 08:04:57 PM » |
|
Yeah, the last argument is the "help" that gets printed when you do "help command" in the console. It's a String[] basically.
This part of the API will definitely be tightened up soon. I've learned a lot more about groovy integration since then.
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #4 on: July 03, 2013, 08:09:33 PM » |
|
Yeah, the last argument is the "help" that gets printed when you do "help command" in the console. It's a String[] basically.
This part of the API will definitely be tightened up soon. I've learned a lot more about groovy integration since then.
Oh, thank you for the help, and by the way, I pulled out 24 groovy scripts from your Mythruna-Core.jar because I remembered when I went looking onto that when I was completely lost about groovy, including when I looked into one of gara's mod and I saw an import I didn't recognize, or a method or something in his code I never saw posted before, and went diggin to all those scripts.
|
|
|
Logged
|
|
|
|
pspeed
|
|
« Reply #5 on: July 03, 2013, 09:17:57 PM » |
|
Yeah, the last argument is the "help" that gets printed when you do "help command" in the console. It's a String[] basically.
This part of the API will definitely be tightened up soon. I've learned a lot more about groovy integration since then.
Oh, thank you for the help, and by the way, I pulled out 24 groovy scripts from your Mythruna-Core.jar because I remembered when I went looking onto that when I was completely lost about groovy, including when I looked into one of gara's mod and I saw an import I didn't recognize, or a method or something in his code I never saw posted before, and went diggin to all those scripts. It's fine to look at these for learning... just remember, I don't always do things the best way in the heat of the moment. I know most of these scripts will get replaced so sometimes I don't bother to clean them up properly. As APIs evolved, some scripts still do things the old ways. Still can be useful in lieu of docs, though.
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #6 on: July 03, 2013, 09:24:02 PM » |
|
Ahah, I went to look up how to make javadocs, and then I figured it out! I sat down for a couple seconds like "umm.. wait.., I don't have the source code.." do I need the actual source code of Mythruna to make actual JavaDocs?
|
|
|
Logged
|
|
|
|
pspeed
|
|
« Reply #7 on: July 03, 2013, 10:17:16 PM » |
|
Ahah, I went to look up how to make javadocs, and then I figured it out! I sat down for a couple seconds like "umm.. wait.., I don't have the source code.." do I need the actual source code of Mythruna to make actual JavaDocs?
Pretty much. Using the javap command you can find out what methods certain classes have but really the farther you stray from what is already called by my scripts the worse off you will be. Those scripts are already going to change significantly but the Java code is nearly 100% different.
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #8 on: July 03, 2013, 10:24:03 PM » |
|
I have started a repository on GitHub for tutorials, ect about this API I got going https://github.com/Shzylo/Mythruna-Pre-Alpha-API/Now its midnight, I need to go to bed (but I don't wanna!).
|
|
|
Logged
|
|
|
|
nh_99
Donators
Jr. Member
Posts: 71
|
|
« Reply #9 on: July 04, 2013, 01:39:12 PM » |
|
You need to change the helpInfo thing to String[] helpinfo. String arrays and Strings are 2 different things. Sorry to be a stickler about it, I just want people who are looking at this API stuff to have the right info.
|
|
|
Logged
|
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #10 on: July 04, 2013, 01:54:29 PM » |
|
You need to change the helpInfo thing to String[] helpinfo. String arrays and Strings are 2 different things. Sorry to be a stickler about it, I just want people who are looking at this API stuff to have the right info.
I did that, but I found that it bugged for me, I even went too groovy codehaus to make sure I was doing it right. I went and looked into one of Paul's groovy files and this is basically how he had it: def help = """\ This is the help info Here is more help info """
addShellCommand(shell, "Hello", "Justa test", help) { console.echo("Hello World!"); }
I will be doing some other testing after 7, because my grandma has OG&E smart hours, and between hours 2pm - 7pm, its called peak hour in which electricity consumption costs more (today its $0.05 per Kilowatt).
|
|
|
Logged
|
|
|
|
Sean
Donators
Hero Member
Posts: 598
|
|
« Reply #11 on: July 04, 2013, 06:46:19 PM » |
|
Nice job on the API!
|
|
|
Logged
|
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
|
|
|
Michael
Donators
Hero Member
Posts: 2166
|
|
« Reply #12 on: July 04, 2013, 07:49:40 PM » |
|
Updated with a fix to one of the examples on github and added correct imports for the methods.
|
|
|
Logged
|
|
|
|
pspeed
|
|
« Reply #13 on: July 04, 2013, 10:22:31 PM » |
|
Now that I think about it, I think the help is just a string and then I split it up on newlines. The API is defined in one of the groovy files embedded in the game jar so it would be easy to confirm the exact signature of the method.
|
|
|
Logged
|
|
|
|
Endimmion
|
|
« Reply #14 on: July 05, 2013, 02:06:31 AM » |
|
With this API, would it possible to add a sort of "query answer" plugin? You query the server with a certain command/string and the plugin return you the number of players connected, the version of the server.... It could be very usefull for my list ( http://mythruna-servers.com/).
|
|
|
Logged
|
|
|
|
|