Minecraft PC IP: play.cubecraft.net

alyphen

Well-Known Member
Jan 4, 2014
101
109
118
28
127.0.0.1
seventh-root.com
It's completely possible to write plugins in anything that can run on top of the JVM - Java is pretty much the language-of-choice for most of the Minecraft ecosystem, since there's already so much material out there already to learn from, but the most difficult thing at the moment is not learning the language (I was able to start writing plugins within a week of learning Java, but it took a few months before I started on more complex things and a while longer before I worked on bigger servers like CCG and Wayward Realms)
The exception to this is Forge, which has a lot of Scala code.
As rubik pointed out, a lot of you aren't making the distinction between Java and JavaScript - however, Java includes a scripting engine with Rhino and Nashorn, which would allow you to write the bulk of plugins in JavaScript if you particularly wanted to do that (it can actually precompile them as well). There are also third-party implementations that allow you to write in Python, Ruby, Groovy, and more.
As for C++, you'd write with JNI (Java Native Interface) which allows you to, as the name suggests, write with native code written in C, C++ or Assembly (which doesn't gain any of the optimisations of the JVM, so will most likely run slower, and memory leaks will take a bigger effect if you forget to clean up your resources properly.

Back in the Minecraft Classic days, there were entire server implementations in Python - that would still be possible nowadays, but it would be harder since the protocol is so much more complex than it was back then.

Seriously though, if you're looking at learning now, you've missed Minecraft's peak and you're going to struggle to get an audience together, assuming you do manage to get around the issue of DMCA'd server downloads, EULA and such. Better to look for another game to mod (I'm doing some stuff with Risk of Rain right now)
 
  • Like
Reactions: Matarandar

GTAaqp15

Well-Known Member
Dec 18, 2014
30
1
83
España - Madrid
It's completely possible to write plugins in anything that can run on top of the JVM - Java is pretty much the language-of-choice for most of the Minecraft ecosystem, since there's already so much material out there already to learn from, but the most difficult thing at the moment is not learning the language (I was able to start writing plugins within a week of learning Java, but it took a few months before I started on more complex things and a while longer before I worked on bigger servers like CCG and Wayward Realms)
The exception to this is Forge, which has a lot of Scala code.
As rubik pointed out, a lot of you aren't making the distinction between Java and JavaScript - however, Java includes a scripting engine with Rhino and Nashorn, which would allow you to write the bulk of plugins in JavaScript if you particularly wanted to do that (it can actually precompile them as well). There are also third-party implementations that allow you to write in Python, Ruby, Groovy, and more.
As for C++, you'd write with JNI (Java Native Interface) which allows you to, as the name suggests, write with native code written in C, C++ or Assembly (which doesn't gain any of the optimisations of the JVM, so will most likely run slower, and memory leaks will take a bigger effect if you forget to clean up your resources properly.

Back in the Minecraft Classic days, there were entire server implementations in Python - that would still be possible nowadays, but it would be harder since the protocol is so much more complex than it was back then.

Seriously though, if you're looking at learning now, you've missed Minecraft's peak and you're going to struggle to get an audience together, assuming you do manage to get around the issue of DMCA'd server downloads, EULA and such. Better to look for another game to mod (I'm doing some stuff with Risk of Rain right now)

Thanks for explaining everything was good java basics, but I wonder how you make plugins skywars, I mean with javasript? Thanks must help those who do not! regards
 

allstarninja

Well-Known Member
Apr 17, 2014
496
275
138
23
www.google.co.uk
Thanks for explaining everything was good java basics, but I wonder how you make plugins skywars, I mean with javasript? Thanks must help those who do not! regards

Don't. Java is much better and Bukkit can be used more easily with Java. Go look up some tutorials on Java basics and some tutorials on Bukkit.

Good Luck!
 

alyphen

Well-Known Member
Jan 4, 2014
101
109
118
28
127.0.0.1
seventh-root.com
Don't. Java is much better and Bukkit can be used more easily with Java. Go look up some tutorials on Java basics and some tutorials on Bukkit.

Good Luck!
"Better" is subjective - in some cases, for example dynamic loading, JavaScript may have an advantage (although in that sort of case I'd prefer to write in Python - it's the nicer language to write in)
You'd have to write some bootstrap code in Java first that would look something like this:

Code:
import javax.script.*;
import org.bukkit.plugin.java.JavaPlugin;

public class MyJavaScriptPlugin extends JavaPlugin {

    public void onEnable() {
        ScriptEngineManager engineManager = new ScriptEngineManager();
        ScriptEngine engine = engineManager.getEngineByName("javascript");
        engine.eval("function myJavaScriptFunction(plugin) {\n" +
                          "    plugin.getLogger().info('Called from JavaScript!');\n" +
                          "}\n" +
                          "myJavaScriptFunction(plugin);\n",
                          new SimpleBindings(new HashMap<>() {{
                               put("plugin", this);
                          }})
                        );
    }

}

Of course, realistically, you would take the JavaScript code from a file (you can use Scanner for this, and feed it a FileInputStream) and you would initialise your bindings properly (I used an anonymous inner subclass of HashMap here, just to keep it short; usually you call put directly on your SimpleBindings and use it's built-in internal map) but that's the general gist of it.
You could probably also do something with JavaScript's prototypal inheritance, but I feel this would be overcomplicating things.
If you're just starting however, most of the documentation for Bukkit is in Java, so it would be best to learn that first, and then look at ScriptEngineManager if you still prefer JavaScript (or Python, Ruby or Groovy) to Java (and I don't blame you if you do, Java is horribly verbose, so if you come from a background of other languages, it can be a pain)
 

allstarninja

Well-Known Member
Apr 17, 2014
496
275
138
23
www.google.co.uk
You just spent 10-20 minutes typing a message telling me about some obsolete and inefficient method of invoking JavaScript methods from a Java environment. You said it yourself:
"Better" is subjective - in some cases, for example dynamic loading, JavaScript may have an advantage (although in that sort of case I'd prefer to write in Python - it's the nicer language to write in)
. Simply, genius.
 

alyphen

Well-Known Member
Jan 4, 2014
101
109
118
28
127.0.0.1
seventh-root.com
You just spent 10-20 minutes typing a message telling me about some obsolete and inefficient method of invoking JavaScript methods from a Java environment. You said it yourself: . Simply, genius.
Writing in Python is practically the same - just link against Jython and use engineManager.getEngineByName("python")
ScriptEngineManager is a nice thing to know if anyone's interested in that sort of thing.
 
  • Like
Reactions: allstarninja

MCTravelerMC

Well-Known Member
Mar 29, 2014
655
167
119
UK
And then have people translate what they are saying in English? I think you all missed that step out :/
 

alyphen

Well-Known Member
Jan 4, 2014
101
109
118
28
127.0.0.1
seventh-root.com
Learn basics of java, try to do stuff, derp with hashmaps, and thats almost it.
Learn the entirety of the collections API, not just HashMap. Learning when it's best to use a Set or a List, or a TreeMap or HashMap is fairly fundamental.
And then have people translate what they are saying in English? I think you all missed that step out :/
This entire thread's in English. I used to have a Danish friend who said there were two languages though: English, and technical English.
 
Members Online

Latest profile posts

UncleSpect wrote on CalvinxKlein's profile.
Happy birthday!
NADER KANAAN wrote on jamesthesignificant's profile.
ty for the following !!!
jamesthesignificant wrote on NADER KANAAN's profile.
have a totally epic birthday!!! 🎈
IAmEclipsy wrote on CalvinxKlein's profile.
Happy birthday!
CrystalLegend01 wrote on NADER KANAAN's profile.
Happy Birthday!
Top Bottom