Global Functions
You can use the following "global functions" with MCJava — they're just convenience methods so that you don't have to write out lots of Java code. If you have any suggestions for new global functions, just send me a PM!
loadClass("aliasNameHere", "my.package.MyClass")
Loads the class "my.package.MyClass" and gives it the alias "aliasNameHere". By default, "bukkit" is an alias for org.bukkit.Bukkit, and "material" is an alias for org.bukkit.Material. REMEMBER: You need to be running your code in a console for this to have any effect.
So, you could run something like:
will make val equal to 255 (java.lang.Integer.valueOf("ff", 16) parses "ff" from base-16 to base-10)
println(string)
Prints the string to the console. So, you could use something like
base64Encode(string)
Encodes the string to base 64
val now becomes "SGVsbG8sIFdvcmxkIQ=="
base64Decode(string)
Prints the string to the console. So, you could use something like
val now becomes "Hello, World!"
loadClass("aliasNameHere", "my.package.MyClass")
Loads the class "my.package.MyClass" and gives it the alias "aliasNameHere". By default, "bukkit" is an alias for org.bukkit.Bukkit, and "material" is an alias for org.bukkit.Material. REMEMBER: You need to be running your code in a console for this to have any effect.
So, you could run something like:
loadClass("integerAlias", "java.lang.Integer")
val = integerAlias.valueOf("ff", 16)
println(string)
Prints the string to the console. So, you could use something like
println("Hello, world!")
base64Encode(string)
Encodes the string to base 64
val = base64Encode("Hello, World!")
val now becomes "SGVsbG8sIFdvcmxkIQ=="
base64Decode(string)
Prints the string to the console. So, you could use something like
val = base64Decode("SGVsbG8sIFdvcmxkIQ==")
val now becomes "Hello, World!"