An advanced Minecraft plugin template made in Gradle

Overview

//DONT_APPLY_TEMPLATE_CHANGE

Gradle Plugin Template  Kotlin DSL Version

ℹ️ This template was planned to support only kotlin, but it also supports Java!

⚠️ This template is still in beta! If you have any issue using this template, please let us know!

ℹ️ This is a Developer Note, you don't need to worry about this if you are a texture pack developer.

Contents

Gradle Plugin Template  Kotlin DSL Version

Info

Template Maintainer: fan87
Template Developer: fan87

Requirements

This template is not a template that everyone can use. It requires more skill than Maven Template, and I'm not joking. Most maven users who don't understand Gradle will be very confused since they misunderstand what Gradle is.

If you still want to use this template because you were attracted by features it provides, you can watch This YouTube Video, I think he explains it pretty well and make everything clear.

Why Gradle?

Watch the video I mentioned above first, then ask again. If you lazy, then here's why:

  1. Gradle is using Build Script (build.gradle) instead of structured file (pom.xml), so you can do anything you want in build script (including shut the computer down) without any plugin.

    Responsive image

    ⬆️ build.gradle.kts: Gradle allows you to run code in Kotlin or Groovy, execute them, and use return value, so you can do custom behavior without modifying source code of plugins

  2. Gradle is way faster than Maven. If you are experienced, you probably know that Build Artifact feature in IntelliJ IDEA is way faster than a maven mvn package build. Good new is Gradle is as fast as IntelliJ IDEA's Build Artifact! Bad new is it's way harder than maven, so there are still a lot of people using Maven.

Features

Here are some features that you didn't expect to get (lol):

PlaceHolders

You can use and create your own PlaceHolder, so you can put something like CommitID, build date, project version into strings like this:

Responsive image

⬆️ Output

Responsive image

⬆️ Source Code

They are all calculated while Gradle is building it, so wherever you go the message will always be the same. Here's the compiled code:

Responsive image

⬆️ Decompiled code

Auto Copy + Reload

ℹ️ You need to enable RCON for this! If you want to change the host, port, or password, please check the build.gradle.kts

You can now reload the plugin automatically every time you build!

Responsive image

Auto-Reload Setup

To set Auto Reload up, you need to do these following things:

  1. Go to your server.properties, enable RCON, change the password to non-default value

Responsive image

  1. Now go to your run configuration (See also: Debug/Test Build), and add SERVER_DIR environment variable:

Responsive image

Advanced Setup

If you want to use plugins like PlugMan X to reload your plugin, you can modify the command , or create a new task. (There will be example in build.gradle.kts, I added them after taking this screenshot and I'm lazy to do it again lol)

Responsive image

Advanced Setup - Windows

ℹ️ This is not required, and it happens randomly, so it doesn't matter if you are lazy to do it.

⚠️ PlugMan X or PlugMan (Unrecommended) is required!

On windows, if the file is not closed yet, it will lock the file so other program don't have access to write it. To deal with that, you probably need to run some new tasks: unloadPlugin and loadPlugin, execute it before copyPlugin, and then put loadPlugin after copyPlugin.

Responsive image

NMS Support

ℹ️ This is disabled by default! If you want to enable it, change enableNMS to true

👨‍🔬 This feature is in experimental state. If you got any issue using this feature, please let us know!

⚠️ This only supports 1.17 or above for now. If you want to have 1.17- NMS support, please change the dependency directly to org.spigotmc:spigot:<version>!

ℹ️ This is basically same as Spigot's Special Source Plugin but for Gradle. So if you want more information about it, please check me

You can call NMS methods with remapped name directly, so you can do stuff like send packet etc.

Setup

  1. Download build tool
  2. Run it:
java -jar BuildTool.jar --rev <minecraft version> --remapped
  1. Now, change the enableNMS to true (in your build.gradle.kts)

Responsive image

  1. Now, change the building command by inserting remap after applyPlaceHolder. OUTDATED

Responsive image

Singleton Support

👨‍🔬 This feature is in experimental state. If you got any issue using this feature, please let us know!

⚠️ This feature is Kotlin only! It won't work in Java!

You can finally stop using MainClass.INSTANCE! With Kotlin, MainClass will be converted into MainClass.INSTANCE

Responsive image


Project Setup

ℹ️ This is not a Kotlin, Gradle or Java tutorial. I won't be explaining everything because there are too many things that can happen while you doing them, even if you are experienced using Google, keep in mind that there aren't many resources out there on it since Gradle community is way smaller than Maven's.

  1. Load gradle.build.kts as Gradle Project
  2. Normally, it will fail with Unsupported class version. But don't worry.
  3. Go to the Gradle Settings

Responsive image

  1. Select Java 11 or above (Gradle JVM Option), then click on OK

Responsive image

  1. Choose the language you want, you can use Kotlin or Java, then delete one of those two folders. You can also keep 2 of them if you want to. If you use Java, REMEMBER TO REMOVE dependsOn("kotlinSingleton")

Responsive image

Responsive image

  1. Now, decide if you are going to use NMS, and what the Minecraft version will be, and modify the build.gradle.kts:

Responsive image

  1. After that, you can start adding your own place holders. There are some examples in those two main classes, and build.gradle.kts:

Main.kt: Example usage. It also works with Java. Keep in mind that you can't split them to make them something like "%GradlePluginTemplate.PlaceHolder" + ".CommitID%", it won't work

Responsive image

build.gradle.kts: This registers some placeholders like GradlePluginTemplate.PlaceHolder.Version. Note that GradlePluginTemplate will be replaced by GitHub to your repository name.

Responsive image

Project Build

Building

⚠️ This is still in Experimental state, if anything went wrong, please report the issue to the template maintainer or developer.

Building

You can use debug to do autorealod

Debug/Test Build

⚠️ You have to follow the instruction @ Auto Reload Setup

If you want to do debug it (like Auto Reload and stuff), run debug instead. You also need to put environment variable SERVER_DIR in (as the root directory of your server). You also have to follow instructions @ Auto Reload Setup in order to use it.

Responsive image

Output

⚠️ If you have enabled NMS, the final output will be project-name-1.0-SNAPSHOT-remapped.jar

(I know there are some people who don't use Gradle out there being confused why isn't there target directory.)

The output jar is located at build/libs/, and if you want to have version with working placeholders, choose the one with placeholder-applied prefix:

Responsive image

(3 AM if you are wondering what is 3:0 in the background lol)

Use this template

⚠️ Normally, you don't have to do this, so don't worry about it

⚠️ IN THIS VERSION, IT'S REQUIRED! YOU HAVE TO DO THIS SINCE GITHUB ACTIONS WERE NOT DONE YET!

If you are on GitHub, and you want to use this template:

  1. Click on Use this template

Responsive image

  1. Now, create a repository using that template

Responsive image

⚠️ Please use the same naming method for your Repository Name! (replace with -, and first letter of words are caps)

  1. Wait for it...

Responsive image

  1. Now, you should see this:

image-20220408113411381

  1. Clone the repository, and CD into it:

Responsive image

  1. Run apply_template.py, and use the repository name as argument

Responsive image

  1. Commit, and push:
git add .
git commit -m "Initialized Project"
git push
  1. Start following the instructions at Project Setup
You might also like...
Kauth - Open-source powerful minecraft authorization plugin
Kauth - Open-source powerful minecraft authorization plugin

KAuth KAuth is a minecraft plugin for offline-mode authorization on your server.

Simple (and useless) Minecraft plugin

CDS Minecraft plugin Simple plugin for Minecraft, without any useful feature 🖥 Installation 🧾 Requirements maven 3.0+ java 8+ spigot server 1.19+ 🔧

Plugin for Minecraft Dev projects that allows use BON2 as analog of fg.reobf from ForgeGradle

Bon2Gradle Plugin for Minecraft Dev projects that allows use BON2 as analog of fg.reobf from ForgeGradle. Usage Dependencies Gradle 6.8+ (Provider as

Easy Android camera integration, advanced features.

CameraViewEx This is an extended version of Google's cameraview library with better stability and many more features. CameraViewEx highly simplifies i

Advanced State in Jetpack Compose Codelab

Advanced State in Jetpack Compose Codelab This folder contains the source code for the Advanced State in Jetpack Compose Codelab codelab. The project

Yet another advanced Craftfting Table mod. My entry for ModFest: Singularity
Yet another advanced Craftfting Table mod. My entry for ModFest: Singularity

Crafting Bench A utility mod that adds a custom crafting table with semi-automatic crafting. Features For a complete list of features please check the

💫 A Gradle Plugin to generate your networking code from Swagger

Swagger Gradle Codegen A Gradle plugin to generate networking code from a Swagger spec file. This plugin wraps swagger-codegen, and exposes a configur

Gradle plugin for simplify Kotlin Multiplatform mobile configurations
Gradle plugin for simplify Kotlin Multiplatform mobile configurations

Mobile Multiplatform gradle plugin This is a Gradle plugin for simple setup of Kotlin Multiplatform mobile Gradle modules. Setup buildSrc/build.gradle

kinstall is an easy way to install gradle-based command-line kotlin projects that use the application plugin.

kinstall kinstall is an easy way to install gradle-based command-line kotlin projects that use the application plugin. use First, install kinstall its

Owner
A guy
null
A minecraft modification based on Fabric with Yarn Mappings, developed for the newest version of the sandbox game Minecraft.

JupiterClient A minecraft modification based on Fabric with Yarn Mappings, developed for the newest version of the sandbox game Minecraft. Building th

Cedric H. 1 Jun 27, 2022
Curie - Minecraft Forge Kotlin Template

Minecraft Forge Kotlin Template Minecraft 1.12.2 で Forge と Kotlin を用いた Mod のテンプレ

TheFakeWater 0 Feb 2, 2022
Arrow-Maven-Template - A template project for Arrow with Maven. It defines an application and a couple small examples

Arrow-Maven-Template A template project for Arrow on Maven. See the official doc

ΛRROW 0 Jan 11, 2022
A Template for a Github Actions Pipeline for building and publishing Gradle-JVM Applications

github-actions-cd-template-jvm A Template for a Github Actions Pipeline for building and publishing Gradle-JVM Applications It build a executable shad

Raphael Panic 0 Dec 5, 2021
A server code template using Kotlin, Gradle, and Ktor

This project is a server code template using Kotlin, Gradle, and Ktor. It aims to help you build a service by providing reusable code examples that is likely essential for a server.

Dooho Chang 25 Dec 26, 2022
An under development minecraft plugin (1.8.8) to learning Kotlin language

CorePlus CorePlus is a minecraft plugin coded with Kotlin language. Still under development CorePlus will be an essential for each minecraft servers !

Gonz 3 Jun 16, 2021
VirtualTag is a name tag edit plugin for minecraft server

VirtualTag VirtualTag is a NameTag Edit plugin for modern minecraft server Support Version 1.17.x Download https://github.com/jiangdashao/VirtualTag/r

RERERE 13 Dec 18, 2022
An open-source plugin that accommodates Starships on Minecraft servers.

Minecraft Starship Plugin An open-source plugin that accommodates starships on minecraft servers. 'A shameless rip-off of Star Legacy's plugins.' Mine

null 4 Dec 13, 2021
LanServers - A small plugin written in Kotlin that runs on all major Minecraft Servers

LanServers This is a small plugin written in Kotlin that runs on all major Minec

Redstonecrafter0 6 Mar 12, 2022
McMotd - Mirai Plugin for fetching motd from minecraft servers

Mirai-wiki 基于mirai的Minecraft服务器信息查询插件 关于Linux运行环境 如果你正在使用Linux而不是Windows来运行Mirai

ZRnQ 25 Dec 31, 2022