Menyiapkan IntelliJ IDEA
This article describes how to configure your IntelliJ IDEA workspace for plugin development with SpongeAPI and a build system such as Maven or Gradle or the Minecraft Development plugin.
If you want to create your project completely from scratch, please skip ahead to the Gradle or Maven sections. Using the Minecraft Dev plugin sets up a working starting point and eliminates some of the guesswork in getting your project off the ground.
Using IDEA Minecraft Dev Plugin to Create a Working Starting Point
The Minecraft Development plugin for IntelliJ is a great plugin by a community member which makes plugin project creation much easier while also providing some neat and useful features for development. By default, it will create a project which uses Gradle as the build tool.
Installing the Minecraft Dev Plugin
This plugin is available on the JetBrains IntelliJ plugin repository.
Because of this, you can install the plugin through IntelliJ's internal plugin browser. Navigate to
File -> Settings -> Plugins and click the Browse Repositories... button at the bottom of the
window. In the search box, simply search for Minecraft. You can install it from there and
restart IntelliJ to activate the plugin.
Creating Your Project from a Template
- Buka 
- Klik `` Buat Proyek Baru``. 
- Select - Minecraftin the popup.
- Make sure your Project SDK is set to some version of Java 8/1.8. 
- Select - Sponge pluginfor your project type, then click- Next.
- Masukkan ** ID Grup Anda **, ** Artifact ID **, dan ** Versi **. - ** ID Grup Anda ** biasanya harus sesuai dengan nama paket Java Anda. Lihat : doc: ../ plugin-class untuk detailnya. 
- ID Artifact ** ** Anda biasanya harus sesuai dengan ** plugin ID ** yang Anda pilih sebelumnya, misalnya `` myplugin``. 
- Your Version is up to you. See Version Numbers for details. 
 
- Select your desired build tool, either Gradle or Maven, and click - Next.
- Check your Plugin Name and Main Class Name to make sure they are what you want. 
- Specify your desired plugin description, authors, website, and dependencies if you want. 
- Click - Nextto move on.
- Verify your project name, location, and module information, then click - Finish.
- The plugin will create a main java file as a starting point, with the logger already injected. You may add a - logger.info()statement in the- onServerStartevent handler to verify that the plugin is working when you run it.
Editing the Project Configuration
Refer to the Gradle or Maven configuration sections, depending on what you chose during project creation.
Creating a Plugin from Scratch -- Gradle
- Buka 
- Klik `` Buat Proyek Baru``. 
- Select - Gradlein the popup.
- If you want, select any additional libraries and frameworks you desire, for example Kotlin. 
- Make sure your Project SDK is set to some version of Java 8/1.8. 
- Click - Nextto move on.
- Masukkan ** ID Grup Anda **, ** Artifact ID **, dan ** Versi **. - ** ID Grup Anda ** biasanya harus sesuai dengan nama paket Java Anda. Lihat : doc: ../ plugin-class untuk detailnya. 
- ID Artifact ** ** Anda biasanya harus sesuai dengan ** plugin ID ** yang Anda pilih sebelumnya, misalnya `` myplugin``. 
- Your Version is up to you. See Version Numbers for details. 
 
- Klik `` Berikutnya`` dua kali, beri nama proyek Anda, dan klik `` Selesai``. 
- The project will be created without a - srcdirectory. If you add java files to the incorrect location underneath the project, they will be ignored and not compiled, so it is a good idea to enable the checkbox "Create directories for empty content roots", found in:- Windows: - File->- Settings->- Build, Execution, Deployment->- Gradle
- Mac: - Intellij IDEA->- Preferences->- Build, Execution, Deployment->- Build Tools->- Gradle
 
- Enabling - Use Auto-importin the same location will allow change to the gradle configuration to automatically reload without IDEA prompting you each time.
- Upon enabling those settings, a - /src/main/javadirectory should be created, where you can start creating your main plugin code files.
Editing the Build Script
- Buka `` build.gradle`` di navigator dan tambahkan dependensinya. 
- Edit skrip pembangunan sesuai dengan intruksi pada Menyiapkan Gradle. 
- Buka tab ** Gradle ** di sebelah kanan jendela IntelliJ dan tekan tombol refresh. 
- Setup Gradle selesai! Sekarang Anda bisa mulai mengkodekan plugin Anda. 
Creating a Plugin from Scratch -- Maven
Creating Your Project
- Buka 
- Klik `` Buat Proyek Baru``. 
- Select - Mavenin the popup.
- Make sure your Project SDK is set to some version of Java 8/1.8. 
- Click - Nextto move on.
- Masukkan ** ID Grup Anda **, ** Artifact ID **, dan ** Versi **. - ** ID Grup Anda ** biasanya harus sesuai dengan nama paket Java Anda. Lihat : doc: ../ plugin-class untuk detailnya. 
- ID Artifact ** ** Anda biasanya harus sesuai dengan ** plugin ID ** yang Anda pilih sebelumnya, misalnya `` myplugin``. 
- Your Version is up to you. See Version Numbers for details. 
 
- Klik ' ' selanjutnya ' '. 
- Masukkan nama proyek Anda, dan klik `` Finish``. 
Editing the Project Configuration
- Buka - pom.xmlpada navigator.
- Edit konfigurasi pembangunan sesuai dengan intruksi pada Mempersiapkan Maven. 
- Segarkan maven project. 
- Impor perubahan Maven, jika diminta. 
Testing Your Plugin
The following instructions are a quick way to test your plugin, but won't be the most efficient way to iteratively develop.
To make a .jar file, using Gradle:
- Go to - View->- Tool Windows->- Gradle
- Under - Tasks->- Build, click on- jar
- The build process should create the jar underneath - build\libs
To make a .jar file, using Maven:
- Go to - View->- Tool Windows->- Maven Projects
- In the - Maven Projectswindow, expand your project's name
- Under - Plugins, expand- jar
- Double click - jar:jar
- The build process should create the jar underneath - target
Copy your jar file to the mods directory of a working Sponge server, then restart the server to test.
For a more efficient development process, see Plugin Debugging for instructions on running both the Sponge server and your plugin from within IDEA. This process allows for hot-swapping, allowing you to change plugin code without restarting the server.
Importing An Existing Project (Gradle or Maven)
Jika anda sudah mulai dengan proyek anda dan ingin mengimpor lagi pada suatu titik kemudian anda perlu impor itu bukan menciptakan kembali itu dalam IDE anda:
- Click - File > Openor- Import Project.
- Gradle: Navigate to the project's - build.gradlefile and select it.
- Maven: Navigate to the project's - pom.xmlfile and select it.
- Make sure the settings are as you desire and click - Ok.
Git Integrasi
JetBrains offers in-depth documentation on using their Git integration:
https://www.jetbrains.com/help/idea/using-git-integration.html