Getting Started
Creating New Project
We're going to use Intellij IDEA as our development tool, here's how we can create new gradle project with JFDF:
- Go to File > New > Project.
- Set project name and location.
- Select
Gradleas build system. - Toggle
Add sample code. - Copy JFDF jar to project's directory.
- Open
build.gradle. -
Add this to dependencies section:
implementation files('./JFDF-2.0.0b3-all.jar') -
Now we got project ready for use with JFDF.
Writing Hello World Example
Now let's try to implement Hello World ! example using Java and compile that to DiamondFire templates using JFDF.
First let's create a class inside org.example and call it HelloWorld, like this:
Then let's create a static method called onJoin, inside our new class
Now we want onJoin method to be executed whenever the player joins our plot,
we can use @PlayerEvent annotation for that and we can set the event to join by setting
eventType of the annotation to PlayerEventBlock.Event.JOIN
@PlayerEvent annotation is used to define a method as a player event,
now we want to send Hello World ! to the player who joined,
we can do that by using System.out.println
Compiling Code
Now we need to compile our code, to compile our class we need to use compileClass method
inside JFDFCompiler class, now let's open Main class generated by Intellij IDEA
and call compileClass method inside main method to compile our HelloWorld class.
Exporting to DiamondFire
Since JFDF is a library, there's no executeable that exports our code, if we wanted to export our code, we need to export the code ourselves.
Luckily JFDF has a bunch of methods to help us to export our code, we're going
to get give commands using JFDF, we can do that by using getGiveCommands method
from CodeManager class and printing each command from it.
Now all we need to do is running our Main class and
we're going to get give commands on the terminal,
after that we need to:
- Go to creative singleplayer world.
- Get a command block using
/give @s command_block. - Place a command block.
- Type a command inside command block.
- Run command block.
- Repeat 3-5 until you do that for each command.
- Save templates inside your toolbar
- Go to DiamondFire and load templates from your toolbar
Of course, this is not the only way to export templates, there're much more advanced ways to do it, but that's up to you.