diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml
index fe47c80..4c163d8 100644
--- a/.github/workflows/gradle-publish.yml
+++ b/.github/workflows/gradle-publish.yml
@@ -1,15 +1,8 @@
-# This workflow uses actions that are not certified by GitHub.
-# They are provided by a third-party and are governed by
-# separate terms of service, privacy policy, and support
-# documentation.
-# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
-# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
-
name: Gradle Package
on:
release:
- types: [created]
+ types: [ created ]
jobs:
build:
@@ -20,25 +13,45 @@ jobs:
packages: write
steps:
- - uses: actions/checkout@v4
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: '17'
- distribution: 'temurin'
- server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
- settings-path: ${{ github.workspace }} # location for the settings.xml file
+ - uses: actions/checkout@v3
- - name: Setup Gradle
- uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
+ - name: Set up JDK 21
+ uses: actions/setup-java@v3
+ with:
+ java-version: '21'
+ distribution: 'adopt'
+ server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
+ settings-path: ${{ github.workspace }} # location for the settings.xml file
- - name: Build with Gradle
- run: ./gradlew shadowJar
+ - name: Build with Gradle
+ run: chmod +x gradlew && ./gradlew build
- # The USERNAME and TOKEN need to correspond to the credentials environment variables used in
- # the publishing section of your build.gradle
- - name: Publish to GitHub Packages
- run: ./gradlew publish
- env:
- USERNAME: ${{ github.actor }}
- TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Upload build artifacts api
+ uses: actions/upload-artifact@v3
+ with:
+ name: api-build
+ path: api/build/libs
+
+ - name: Upload build artifacts common
+ uses: actions/upload-artifact@v3
+ with:
+ name: common-build
+ path: common/build/libs
+
+ - name: Upload build artifacts spigot
+ uses: actions/upload-artifact@v3
+ with:
+ name: spigot-build
+ path: platforms/spigot/build/libs
+
+ - name: Upload build artifacts velocity
+ uses: actions/upload-artifact@v3
+ with:
+ name: spigot-velocity
+ path: platforms/velocity/build/libs
+
+ - name: Upload build artifacts standalone
+ uses: actions/upload-artifact@v3
+ with:
+ name: standalone-build
+ path: platforms/standalone/build/libs
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index e2b0212..fa2c7dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,10 +9,7 @@ test-plugin/run
!**/src/test/**/build/
### IntelliJ IDEA ###
-.idea/modules.xml
-.idea/jarRepositories.xml
-.idea/compiler.xml
-.idea/libraries/
+.idea/
*.iws
*.iml
*.ipr
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 33dd8d6..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 8928eef..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 2b63946..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index a79fc6a..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,431 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- "associatedIndex": 8
-}
-
-
-
-
-
-
- {
- "keyToString": {
- "Downloaded.Files.Path.Enabled": "false",
- "Gradle.Build EntityLib.executor": "Run",
- "Gradle.EntityLib [dependencies].executor": "Run",
- "Gradle.EntityLib [publish].executor": "Run",
- "Gradle.EntityLib [runServer] (1).executor": "Run",
- "Gradle.EntityLib [runServer].executor": "Run",
- "Gradle.EntityLib:code-gen [:code-gen:Main.main()].executor": "Run",
- "Gradle.EntityLib:test-plugin [cleanAllRunTaskCaches].executor": "Run",
- "Gradle.EntityLib:test-plugin [cleanCustomServiceCaches].executor": "Run",
- "Gradle.EntityLib:test-plugin [cleanPaperCache].executor": "Run",
- "Gradle.EntityLib:test-plugin [cleanPaperPluginsCache].executor": "Run",
- "Gradle.EntityLib:test-plugin [publish].executor": "Run",
- "Gradle.EntityLib:test-plugin [runServer].executor": "Run",
- "Gradle.EntityLib:test-plugin [shadowJar].executor": "Run",
- "JAR Application.Unnamed.executor": "Run",
- "Repository.Attach.Annotations": "false",
- "Repository.Attach.JavaDocs": "false",
- "Repository.Attach.Sources": "false",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "WebServerToolWindowFactoryState": "false",
- "git-widget-placeholder": "master",
- "ignore.virus.scanning.warn.message": "true",
- "jdk.selected.JAVA_MODULE": "corretto-17",
- "kotlin-language-version-configured": "true",
- "last_opened_file_path": "D:/Github/EntityLib",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "project.structure.last.edited": "Modules",
- "project.structure.proportion": "0.15",
- "project.structure.side.proportion": "0.2",
- "settings.editor.selected.configurable": "preferences.editor",
- "vue.rearranger.settings.migration": "true"
- },
- "keyToStringList": {
- "kotlin-gradle-user-dirs": [
- "/home/tofaa/.gradle"
- ]
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1701041928897
-
-
- 1701041928897
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/db707b55ae958245adecc7f15b611e1a571e7fe4/spigot-api-1.20.1-R0.1-SNAPSHOT-sources.jar!/org/bukkit/Material.java
- 6787
-
-
-
- file://$PROJECT_DIR$/api/src/main/java/me/tofaa/entitylib/wrapper/hologram/LegacyHologram.java
- 42
-
-
-
- file://$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/testentitylib/TestPlayerCommand.java
- 77
-
-
-
- file://$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/meta/types/DisplayMeta.java
- 153
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/api/build.gradle b/api/build.gradle
deleted file mode 100644
index 8d02277..0000000
--- a/api/build.gradle
+++ /dev/null
@@ -1,7 +0,0 @@
-
-dependencies {
- api 'org.jetbrains:annotations:24.0.0'
-
- compileOnlyApi(adventureDependencies)
- compileOnlyApi 'com.github.retrooper.packetevents:api:2.3.0'
-}
diff --git a/api/build.gradle.kts b/api/build.gradle.kts
new file mode 100644
index 0000000..b192514
--- /dev/null
+++ b/api/build.gradle.kts
@@ -0,0 +1,18 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+ `el-version`
+}
+
+dependencies {
+ api(libs.jetbrains.annotations)
+
+ compileOnlyApi(libs.bundles.adventure)
+ compileOnlyApi(libs.packetevents.api)
+}
+
+tasks {
+ generateVersionsFile {
+ packageName = "me.tofaa.entitylib.utils"
+ }
+}
diff --git a/api/src/main/java/me/tofaa/entitylib/APIConfig.java b/api/src/main/java/me/tofaa/entitylib/APIConfig.java
index 0db6d93..3cba64a 100644
--- a/api/src/main/java/me/tofaa/entitylib/APIConfig.java
+++ b/api/src/main/java/me/tofaa/entitylib/APIConfig.java
@@ -1,17 +1,8 @@
package me.tofaa.entitylib;
import com.github.retrooper.packetevents.PacketEventsAPI;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonParser;
-import me.tofaa.entitylib.utils.GithubUpdater;
-import org.jetbrains.annotations.Blocking;
import org.jetbrains.annotations.NotNull;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-
public final class APIConfig {
private final PacketEventsAPI> packetEvents;
@@ -27,13 +18,6 @@ public final class APIConfig {
this.packetEvents = packetEvents;
}
- @Blocking
- public boolean requiresUpdate() throws IOException {
- if (!checkForUpdates) return false;
- GithubUpdater updater = new GithubUpdater("Tofaa2", "EntityLib", EntityLib.getVersion());
- return !updater.isLatestVersion();
- }
-
public @NotNull APIConfig useBstats() {
this.bstats = true;
return this;
diff --git a/api/src/main/java/me/tofaa/entitylib/EntityLib.java b/api/src/main/java/me/tofaa/entitylib/EntityLib.java
index 0cfbd3f..d67b487 100644
--- a/api/src/main/java/me/tofaa/entitylib/EntityLib.java
+++ b/api/src/main/java/me/tofaa/entitylib/EntityLib.java
@@ -1,6 +1,9 @@
package me.tofaa.entitylib;
-import java.io.IOException;
+import com.github.retrooper.packetevents.util.PEVersion;
+import me.tofaa.entitylib.utils.ELVersions;
+import me.tofaa.entitylib.utils.GithubUpdater;
+
import java.util.Optional;
import java.util.logging.Level;
@@ -15,21 +18,13 @@ public final class EntityLib {
EntityLib.platform = platform;
platform.setupApi(settings);
api = platform.getAPI();
- if (api.getSettings().shouldCheckForUpdate()) {
- try {
- if (api.getSettings().isDebugMode()) {
- platform.getLogger().log(Level.INFO, "Checking for updates...");
- }
- if (api.getSettings().requiresUpdate()) {
- platform.getLogger().log(Level.WARNING, "You are using an outdated version of EntityLib. Please take a look at the Github releases page.");
- }
- else {
- platform.getLogger().log(Level.INFO, "No EntityLib updates found.");
- }
- } catch (IOException e) {
- platform.getLogger().log(Level.WARNING, e, () -> "EntityLib failed to check for updates.");
+ if (api.getSettings().shouldCheckForUpdate()) {
+ if (api.getSettings().isDebugMode()) {
+ platform.getLogger().log(Level.INFO, "Checking for updates...");
}
+
+ new GithubUpdater("Tofaa2", "EntityLib").checkForUpdates();
}
}
@@ -45,7 +40,7 @@ public final class EntityLib {
return platform;
}
- public static String getVersion() {
- return "2.3.1-SNAPSHOT";
+ public static PEVersion getVersion() {
+ return ELVersions.CURRENT;
}
}
diff --git a/api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java b/api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java
index 4d029fc..71add2a 100644
--- a/api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java
+++ b/api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java
@@ -1,7 +1,9 @@
package me.tofaa.entitylib.utils;
+import com.github.retrooper.packetevents.util.PEVersion;
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
import com.google.gson.JsonObject;
+import me.tofaa.entitylib.EntityLib;
import org.jetbrains.annotations.Blocking;
import java.io.BufferedReader;
@@ -9,45 +11,61 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
+import java.util.concurrent.CompletableFuture;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public final class GithubUpdater {
private final String org;
private final String repo;
- private final String currentVersion;
+ private final PEVersion currentVersion;
+ private final Logger logger;
- public GithubUpdater(String org, String repo, String currentVersion) {
+ public GithubUpdater(String org, String repo) {
this.org = org;
this.repo = repo;
- this.currentVersion = currentVersion;
+ this.currentVersion = ELVersions.CURRENT;
+ this.logger = EntityLib.getPlatform().getLogger();
}
- @Blocking
- public boolean isLatestVersion() throws IOException {
- String latest = getLatestVersion();
- return latest != null && latest.equals(currentVersion);
- }
-
-
- @Blocking
- public String getLatestVersion() throws IOException {
- URL url = new URL("https://api.github.com/repos/" + org + "/" + repo + "/releases/latest");
- URLConnection connection = url.openConnection();
- connection.addRequestProperty("User-Agent", "Mozilla/5.0");
- InputStreamReader isr = new InputStreamReader(connection.getInputStream());
- BufferedReader reader = new BufferedReader(isr);
- String response = reader.readLine();
- JsonObject json = AdventureSerializer.getGsonSerializer().serializer().fromJson(response, JsonObject.class);
- reader.close();
- isr.close();
- if (json.has("name")) {
- return json.get("name").getAsString();
+ public void checkForUpdates() {
+ CompletableFuture.runAsync(() -> {
+ try {
+ PEVersion latestVersion = getLatestVersion();
+ if (currentVersion.isOlderThan(latestVersion)) {
+ logger.log(Level.WARNING, "You are using an outdated version of EntityLib. Please take a look at the Github releases page.");
+ } else if (currentVersion.isNewerThan(latestVersion)) {
+ logger.log(Level.INFO, "No EntityLib updates found.");
+ }
+ } catch (Exception ex) {
+ logger.warning("Failed to check for updates: " + ex.getMessage());
}
- throw new IOException("Could not find name attribute in github api fetch");
+ });
}
+ @Blocking
+ private PEVersion getLatestVersion() throws IOException {
+ URL url = new URL("https://api.github.com/repos/" + org + "/" + repo + "/releases/latest");
+ URLConnection connection = url.openConnection();
+ connection.addRequestProperty("User-Agent", "Mozilla/5.0");
+ InputStreamReader isr = new InputStreamReader(connection.getInputStream());
+ BufferedReader reader = new BufferedReader(isr);
+ String response = reader.readLine();
+ JsonObject json = AdventureSerializer.getGsonSerializer().serializer().fromJson(response, JsonObject.class);
+
+ reader.close();
+ isr.close();
+
+ if (json.has("tag_name")) {
+ return PEVersion.fromString(json.get("tag_name").getAsString().replaceFirst("^[vV]", ""));
+ }
+ throw new IOException("Could not find name attribute in github api fetch");
+ }
+
+ @Deprecated
public String getCurrentVersion() {
- return currentVersion;
+ return currentVersion.toString();
}
public String getOrg() {
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 925667e..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,66 +0,0 @@
-plugins {
- id 'java'
- id 'java-library'
- id 'maven-publish'
-}
-allprojects {
-
- project.ext.adventureVersion = '4.15.0'
- project.ext.adventureDependencies = ["net.kyori:adventure-api:${adventureVersion}",
- "net.kyori:adventure-text-serializer-gson:${adventureVersion}",
- "net.kyori:adventure-text-serializer-legacy:${adventureVersion}",
- "net.kyori:adventure-nbt:${adventureVersion}"]
-
- project.ext.peVersion = '2.4.0'
-
- apply plugin: 'java'
- apply plugin: 'java-library'
- apply plugin: 'maven-publish'
-
- group = 'me.tofaa.entitylib'
- version = '2.4.1-SNAPSHOT'
-
- java.sourceCompatibility = JavaVersion.VERSION_1_8
- java.targetCompatibility = JavaVersion.VERSION_1_8
- java {
- withSourcesJar()
- withJavadocJar()
- }
-
-
- repositories {
- mavenCentral()
- maven {
- url = 'https://jitpack.io/'
- }
- maven {
- name = 'papermc'
- url = 'https://repo.papermc.io/repository/maven-public/'
- }
- maven {
- name = 'codemc-repo'
- url = 'https://repo.codemc.io/repository/maven-releases/'
- }
- maven {
- url = "https://oss.sonatype.org/content/groups/public/"
- }
- maven { url = "https://repo.codemc.org/repository/maven-public/" }
- }
-
- publishing {
- publications {
- maven(MavenPublication) {
- groupId project.group
- artifactId project.name
- version project.version
- from components.java
- }
- }
- }
-}
-
-
-dependencies {
- compileOnlyApi 'com.github.retrooper:packetevents-spigot:${project.ext.peVersion}'
-}
-
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..177f4d3
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,27 @@
+import java.io.ByteArrayOutputStream
+
+plugins {
+ entitylib.`library-conventions`
+}
+
+group = "me.tofaa.entitylib"
+description = rootProject.name
+val fullVersion = "2.4.1"
+val snapshot = true
+
+fun getVersionMeta(): String {
+ if (!snapshot) {
+ return ""
+ }
+ var commitHash = ""
+ if (file(".git").isDirectory) {
+ val stdout = ByteArrayOutputStream()
+ exec {
+ commandLine("git", "rev-parse", "--short", "HEAD")
+ standardOutput = stdout
+ }
+ commitHash = "+${stdout.toString().trim()}"
+ }
+ return "$commitHash-SNAPSHOT"
+}
+version = "$fullVersion${getVersionMeta()}"
\ No newline at end of file
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
new file mode 100644
index 0000000..6bdb120
--- /dev/null
+++ b/buildSrc/build.gradle.kts
@@ -0,0 +1,18 @@
+plugins {
+ `kotlin-dsl`
+}
+
+kotlin {
+ compilerOptions {
+ jvmToolchain(8)
+ }
+}
+
+repositories {
+ gradlePluginPortal()
+ mavenCentral()
+}
+
+dependencies {
+ implementation(libs.shadow)
+}
\ No newline at end of file
diff --git a/buildSrc/libs.versions.toml b/buildSrc/libs.versions.toml
new file mode 100644
index 0000000..4407c6d
--- /dev/null
+++ b/buildSrc/libs.versions.toml
@@ -0,0 +1,5 @@
+[versions]
+shadow = "8.1.8"
+
+[libraries]
+shadow = { group = "io.github.goooler.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" }
\ No newline at end of file
diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts
new file mode 100644
index 0000000..71b8251
--- /dev/null
+++ b/buildSrc/settings.gradle.kts
@@ -0,0 +1,7 @@
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("libs.versions.toml"))
+ }
+ }
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts b/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts
new file mode 100644
index 0000000..e4718a2
--- /dev/null
+++ b/buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts
@@ -0,0 +1,50 @@
+plugins {
+ `java-library`
+ `maven-publish`
+}
+
+group = rootProject.group
+version = rootProject.version
+description = project.description
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+ maven("https://repo.codemc.io/repository/maven-releases/")
+ maven("https://repo.codemc.io/repository/maven-snapshots/")
+}
+
+java {
+ withSourcesJar()
+ withJavadocJar()
+ disableAutoTargetJvm()
+
+ toolchain.languageVersion = JavaLanguageVersion.of(21)
+}
+
+tasks {
+ processResources {
+ inputs.property("version", project.version)
+ filesMatching(listOf("plugin.yml", "velocity-plugin.json")) {
+ expand("version" to project.version)
+ }
+ }
+
+ withType {
+ options.encoding = Charsets.UTF_8.name()
+ options.release = 8
+ }
+
+ publishing {
+ publications {
+ create("maven") {
+ groupId = project.group.toString()
+ artifactId = project.name
+ version = project.version.toString()
+ from(components["java"])
+ }
+ }
+ }
+
+ defaultTasks("build")
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts b/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts
new file mode 100644
index 0000000..00d91ac
--- /dev/null
+++ b/buildSrc/src/main/kotlin/entitylib.shadow-conventions.gradle.kts
@@ -0,0 +1,19 @@
+plugins {
+ java
+ io.github.goooler.shadow
+}
+
+tasks {
+ shadowJar {
+ archiveFileName = "EntityLib-${project.name}-${project.version}.jar"
+ archiveClassifier = null
+
+ mergeServiceFiles()
+ }
+
+ assemble {
+ dependsOn(shadowJar)
+ }
+}
+
+configurations.implementation.get().extendsFrom(configurations.shadow.get())
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionPlugin.kt b/buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionPlugin.kt
new file mode 100644
index 0000000..0e5ab27
--- /dev/null
+++ b/buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionPlugin.kt
@@ -0,0 +1,31 @@
+package me.tofaa.entitylib.version
+
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.tasks.SourceSet
+import org.gradle.api.tasks.SourceSetContainer
+import org.gradle.kotlin.dsl.getByName
+import org.gradle.kotlin.dsl.register
+
+class ELVersionPlugin : Plugin {
+
+ override fun apply(target: Project) {
+ val task = target.tasks.register(ELVersionTask.TASK_NAME) {
+ group = target.rootProject.name.toString()
+
+ version = target.version.toString()
+ outputDir = target.layout.buildDirectory.dir("generated/sources/src/java/main")
+ }
+
+ target.afterEvaluate {
+ val sourceSets = target.extensions.getByName("sourceSets")
+
+ sequenceOf(SourceSet.MAIN_SOURCE_SET_NAME, SourceSet.TEST_SOURCE_SET_NAME).forEach {
+ sourceSets.getByName(it).java.srcDir(task.flatMap { it.outputDir })
+ }
+
+ task.get().generate()
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionTask.kt b/buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionTask.kt
new file mode 100644
index 0000000..c01ef12
--- /dev/null
+++ b/buildSrc/src/main/kotlin/me/tofaa/entitylib/version/ELVersionTask.kt
@@ -0,0 +1,80 @@
+package me.tofaa.entitylib.version
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.file.Directory
+import org.gradle.api.provider.Provider
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.TaskAction
+
+abstract class ELVersionTask : DefaultTask() {
+
+ companion object {
+ const val TASK_NAME = "generateVersionsFile"
+ }
+
+ @get:Input
+ abstract var packageName: String
+
+ @get:Input
+ abstract var version: String
+
+ @get:OutputDirectory
+ abstract var outputDir: Provider
+
+ @TaskAction
+ fun generate() {
+ val dir = outputDir.get().dir(packageName.replace('.', '/'))
+ dir.asFile.mkdirs()
+
+ val file = dir.file("ELVersions.java").asFile
+ if (!file.exists()) {
+ file.createNewFile()
+ }
+
+ val ver = Version.fromString(version)
+ logger.info("Generating ELVersions.java with version $ver")
+
+ file.writeText("""
+ /**
+ * This file is generated by the auto-version task. Modifying it will have no effect.
+ */
+ package $packageName;
+
+ import com.github.retrooper.packetevents.util.PEVersion;
+
+ public final class ELVersions {
+
+ public static final String RAW = "$version";
+ public static final PEVersion CURRENT = new PEVersion(${ver.major}, ${ver.minor}, ${ver.patch}, ${ver.snapShot});
+ public static final PEVersion UNKNOWN = new PEVersion(0, 0, 0);
+
+ private ELVersions() {
+ throw new IllegalStateException();
+ }
+ }
+ """.trimIndent())
+ }
+
+ private data class Version(
+ val major: Int,
+ val minor: Int,
+ val patch: Int,
+ val snapShot: Boolean
+ ) {
+ companion object {
+ private val REGEX = Regex("""(\d+)\.(\d+)\.(\d+)(?:\+[0-9a-f]+)?(-SNAPSHOT)?""")
+
+ fun fromString(version: String): Version {
+ val match = REGEX.matchEntire(version) ?: throw IllegalArgumentException("Invalid version: $version")
+ return Version(
+ match.groupValues[1].toInt(),
+ match.groupValues[2].toInt(),
+ match.groupValues[3].toInt(),
+ match.groupValues[4].isNotEmpty()
+ )
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/el-version.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/el-version.properties
new file mode 100644
index 0000000..095e231
--- /dev/null
+++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/el-version.properties
@@ -0,0 +1 @@
+implementation-class=me.tofaa.entitylib.version.ELVersionPlugin
\ No newline at end of file
diff --git a/code-gen/build.gradle b/code-gen/build.gradle
deleted file mode 100644
index 30cb78d..0000000
--- a/code-gen/build.gradle
+++ /dev/null
@@ -1,7 +0,0 @@
-
-dependencies {
- implementation 'com.google.code.gson:gson:2.10.1'
- implementation 'com.squareup:javapoet:1.13.0'
- implementation 'com.github.retrooper.packetevents:api:2.2.0'
- implementation 'org.jetbrains:annotations:24.0.0'
-}
diff --git a/code-gen/build.gradle.kts b/code-gen/build.gradle.kts
new file mode 100644
index 0000000..cde7c53
--- /dev/null
+++ b/code-gen/build.gradle.kts
@@ -0,0 +1,11 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+}
+
+dependencies {
+ implementation(libs.gson)
+ implementation(libs.javapoet)
+ implementation(libs.packetevents.api)
+ implementation(libs.jetbrains.annotations)
+}
diff --git a/common/build.gradle b/common/build.gradle
deleted file mode 100644
index 3647b1a..0000000
--- a/common/build.gradle
+++ /dev/null
@@ -1,4 +0,0 @@
-
-dependencies {
- api(project(":api"))
-}
diff --git a/common/build.gradle.kts b/common/build.gradle.kts
new file mode 100644
index 0000000..e8b8cb1
--- /dev/null
+++ b/common/build.gradle.kts
@@ -0,0 +1,8 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+}
+
+dependencies {
+ api(project(":api"))
+}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ea829b1..086d5c7 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Mon Nov 27 02:38:48 TRT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/libs.versions.toml b/libs.versions.toml
new file mode 100644
index 0000000..745095a
--- /dev/null
+++ b/libs.versions.toml
@@ -0,0 +1,31 @@
+[versions]
+adventure = "4.16.0"
+jetbrains-annotations = "24.0.0"
+gson = "2.11.0"
+packetevents = "2.4.1-SNAPSHOT"
+paper = "1.21-R0.1-SNAPSHOT"
+velocity = "3.3.0-SNAPSHOT"
+run-paper = "2.3.0"
+javapoet = "1.13.0"
+
+[libraries]
+adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
+adventure-text-serializer-gson = { group = "net.kyori", name = "adventure-text-serializer-gson", version.ref = "adventure" }
+adventure-text-serializer-legacy = { group = "net.kyori", name = "adventure-text-serializer-legacy", version.ref = "adventure" }
+adventure-text-serializer-gson-legacy = { group = "net.kyori", name = "adventure-text-serializer-gson-legacy-impl", version.ref = "adventure" }
+adventure-nbt = { group = "net.kyori", name = "adventure-nbt", version.ref = "adventure" }
+jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }
+gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
+packetevents-api = { group = "com.github.retrooper", name = "packetevents-api", version.ref = "packetevents" }
+packetevents-spigot = { group = "com.github.retrooper", name = "packetevents-spigot", version.ref = "packetevents" }
+packetevents-velocity = { group = "com.github.retrooper", name = "packetevents-velocity", version.ref = "packetevents" }
+paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
+velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
+javapoet = { group = "com.squareup", name = "javapoet", version.ref = "javapoet" }
+
+[bundles]
+adventure = ["adventure-api", "adventure-text-serializer-gson", "adventure-text-serializer-legacy", "adventure-nbt"]
+
+[plugins]
+run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" }
+run-velocity = { id = "xyz.jpenilla.run-velocity", version.ref = "run-paper" }
\ No newline at end of file
diff --git a/model-engine-addon/build.gradle b/model-engine-addon/build.gradle
deleted file mode 100644
index 4488d2f..0000000
--- a/model-engine-addon/build.gradle
+++ /dev/null
@@ -1,8 +0,0 @@
-repositories {
- maven { url 'https://mvn.lumine.io/repository/maven-public/' }
-}
-
-dependencies {
-// compileOnly 'com.ticxo.modelengine:ModelEngine:R4.0.4'
- api(project(":api"))
-}
diff --git a/model-engine-addon/build.gradle.kts b/model-engine-addon/build.gradle.kts
new file mode 100644
index 0000000..e5436d9
--- /dev/null
+++ b/model-engine-addon/build.gradle.kts
@@ -0,0 +1,15 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+}
+
+repositories {
+ maven {
+ url = uri("https://mvn.lumine.io/repository/maven-public/")
+ }
+}
+
+dependencies {
+ // compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
+ api(project(":api"))
+}
diff --git a/platforms/spigot/build.gradle b/platforms/spigot/build.gradle
deleted file mode 100644
index ae6b4d3..0000000
--- a/platforms/spigot/build.gradle
+++ /dev/null
@@ -1,6 +0,0 @@
-
-dependencies {
- api(project(":common"))
- compileOnly('com.github.retrooper:packetevents-spigot:' + peVersion)
- compileOnly('org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT')
-}
diff --git a/platforms/spigot/build.gradle.kts b/platforms/spigot/build.gradle.kts
new file mode 100644
index 0000000..e52a692
--- /dev/null
+++ b/platforms/spigot/build.gradle.kts
@@ -0,0 +1,14 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+}
+
+repositories {
+ maven("https://repo.papermc.io/repository/maven-public/")
+}
+
+dependencies {
+ api(project(":common"))
+ compileOnly(libs.paper)
+ compileOnly(libs.packetevents.spigot)
+}
diff --git a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java
index ffe81e5..7aaa98e 100644
--- a/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java
+++ b/platforms/spigot/src/main/java/me/tofaa/entitylib/spigot/SpigotEntityLibPlatform.java
@@ -45,8 +45,9 @@ public class SpigotEntityLibPlatform extends AbstractPlatform {
if (settings.shouldUseBstats()) {
PacketEventsAPI pe = (PacketEventsAPI)api.getPacketEvents();
Metrics metrics = new Metrics((JavaPlugin) pe.getPlugin(), 21916);
- metrics.addCustomChart(new Metrics.SimplePie("entitylib-version", EntityLib::getVersion));
+ metrics.addCustomChart(new Metrics.SimplePie("entitylib-version", () -> EntityLib.getVersion().toString()));
}
+
}
diff --git a/platforms/standalone/build.gradle b/platforms/standalone/build.gradle
deleted file mode 100644
index 9dec5ae..0000000
--- a/platforms/standalone/build.gradle
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-dependencies {
- api(project(":common"))
- compileOnly('com.github.retrooper.packetevents:api:2.3.0')
-}
diff --git a/platforms/standalone/build.gradle.kts b/platforms/standalone/build.gradle.kts
new file mode 100644
index 0000000..b414df6
--- /dev/null
+++ b/platforms/standalone/build.gradle.kts
@@ -0,0 +1,9 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+}
+
+dependencies {
+ api(project(":common"))
+ compileOnly(libs.packetevents.api)
+}
diff --git a/platforms/velocity/build.gradle b/platforms/velocity/build.gradle
deleted file mode 100644
index 689b917..0000000
--- a/platforms/velocity/build.gradle
+++ /dev/null
@@ -1,20 +0,0 @@
-
-repositories {
- maven {
- name = 'papermc'
- url = 'https://repo.papermc.io/repository/maven-public/'
- }
-}
-tasks {
- compileJava {
- options.release.set(17)
- }
-}
-java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
-
-
-dependencies {
- api(project(":common"))
- compileOnly('com.github.retrooper.packetevents:velocity:' + peVersion)
- compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
-}
diff --git a/platforms/velocity/build.gradle.kts b/platforms/velocity/build.gradle.kts
new file mode 100644
index 0000000..71fc835
--- /dev/null
+++ b/platforms/velocity/build.gradle.kts
@@ -0,0 +1,22 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+}
+
+repositories {
+ maven("https://repo.papermc.io/repository/maven-public/")
+}
+
+dependencies {
+ api(project(":common"))
+ compileOnly(libs.velocity)
+ compileOnly(libs.packetevents.velocity)
+ annotationProcessor(libs.velocity)
+}
+
+tasks {
+ withType {
+ options.encoding = Charsets.UTF_8.name()
+ options.release = 17
+ }
+}
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index 020ecc3..0000000
--- a/settings.gradle
+++ /dev/null
@@ -1,21 +0,0 @@
-plugins {
- id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
-}
-rootProject.name = 'EntityLib'
-//include 'test-plugin'
-include 'api'
-include 'platforms:spigot'
-findProject(':platforms:spigot')?.name = 'spigot'
-include 'common'
-
-if (!Boolean.parseBoolean(System.getenv("JITPACK"))) {
- include 'code-gen'
- include 'test-plugin'
- include 'model-engine-addon'
-}
-include 'platforms:velocity'
-findProject(':platforms:velocity')?.name = 'velocity'
-
-include 'platforms:standalone'
-findProject(':platforms:standalone')?.name = 'standalone'
-
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 0000000..d823582
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1,41 @@
+pluginManagement {
+ repositories {
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+
+plugins {
+ id("org.gradle.toolchains.foojay-resolver") version "0.8.0"
+}
+
+toolchainManagement {
+ jvm {
+ javaRepositories {
+ repository("foojay") {
+ resolverClass.set(org.gradle.toolchains.foojay.FoojayToolchainResolver::class.java)
+ }
+ }
+ }
+}
+
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("libs.versions.toml"))
+ }
+ }
+}
+
+rootProject.name = "EntityLib"
+include(":common")
+include(":api")
+include(":platforms:spigot")
+include(":platforms:velocity")
+include(":platforms:standalone")
+
+if (!System.getenv("JITPACK").toBoolean()) {
+ include(":code-gen")
+ include(":test-plugin")
+ include(":model-engine-addon")
+}
diff --git a/test-plugin/build.gradle b/test-plugin/build.gradle
deleted file mode 100644
index c2843f1..0000000
--- a/test-plugin/build.gradle
+++ /dev/null
@@ -1,46 +0,0 @@
-plugins {
- id 'java'
- id 'com.github.johnrengelman.shadow' version '7.1.2'
- //id("io.papermc.paperweight.userdev") version "1.5.11"
- id 'xyz.jpenilla.run-paper' version '2.2.2'
-}
-
-group = 'me.tofaa.peentitymeta'
-version = '1.0-SNAPSHOT'
-// java 21
-java {
- toolchain {
- languageVersion.set(JavaLanguageVersion.of(21))
- }
-}
-
-repositories {
- mavenCentral()
- maven {
- name = 'papermc'
- url = 'https://repo.papermc.io/repository/maven-public/'
- }
- maven {
- name = 'codemc-repo'
- url = 'https://repo.codemc.io/repository/maven-releases/'
- }
- maven {
- url = "https://oss.sonatype.org/content/groups/public/"
- }
- maven { url = "https://repo.codemc.org/repository/maven-public/" }
-}
-
-dependencies {
- compileOnly('org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT')
- compileOnly('com.github.retrooper:packetevents-spigot:' + peVersion)
-// implementation(project(":platforms:spigot"))
- implementation(project(":platforms:spigot"))
-}
-
-
-runServer {
- minecraftVersion("1.21")
- downloadPlugins {
- modrinth("packetevents", "MfD5eOYA")
- }
-}
\ No newline at end of file
diff --git a/test-plugin/build.gradle.kts b/test-plugin/build.gradle.kts
new file mode 100644
index 0000000..1b4c6cb
--- /dev/null
+++ b/test-plugin/build.gradle.kts
@@ -0,0 +1,62 @@
+plugins {
+ entitylib.`library-conventions`
+ entitylib.`shadow-conventions`
+ alias(libs.plugins.run.paper)
+}
+
+repositories {
+ maven("https://repo.papermc.io/repository/maven-public/")
+}
+
+dependencies {
+ compileOnly(libs.paper)
+ compileOnly(libs.packetevents.spigot)
+ implementation(project(":platforms:spigot"))
+}
+
+tasks {
+ // 1.8.8 - 1.16.5 = Java 8
+ // 1.17 = Java 16
+ // 1.18 - 1.20.4 = Java 17
+ // 1-20.5+ = Java 21
+ val version = "1.21"
+ val javaVersion = JavaLanguageVersion.of(21)
+
+ val jvmArgsExternal = listOf(
+ "-Dcom.mojang.eula.agree=true"
+ )
+
+ val sharedBukkitPlugins = runPaper.downloadPluginsSpec {
+ modrinth("packetevents", "MfD5eOYA")
+ }
+
+ runServer {
+ minecraftVersion(version)
+ runDirectory = rootDir.resolve("run/paper/$version")
+
+ javaLauncher = project.javaToolchains.launcherFor {
+ languageVersion = javaVersion
+ }
+
+ downloadPlugins {
+ from(sharedBukkitPlugins)
+ }
+
+ jvmArgs = jvmArgsExternal
+ }
+
+ runPaper.folia.registerTask {
+ minecraftVersion(version)
+ runDirectory = rootDir.resolve("run/folia/$version")
+
+ javaLauncher = project.javaToolchains.launcherFor {
+ languageVersion = javaVersion
+ }
+
+ downloadPlugins {
+ from(sharedBukkitPlugins)
+ }
+
+ jvmArgs = jvmArgsExternal
+ }
+}
\ No newline at end of file
diff --git a/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java b/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java
index 291fbf9..f5946c4 100644
--- a/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java
+++ b/test-plugin/src/main/java/me/tofaa/testentitylib/TestEntityLibPlugin.java
@@ -30,6 +30,7 @@ public class TestEntityLibPlugin extends JavaPlugin {
SpigotEntityLibPlatform platform = new SpigotEntityLibPlatform(this);
APIConfig settings = new APIConfig(PacketEvents.getAPI())
.debugMode()
+ .checkForUpdates()
.tickTickables()
.trackPlatformEntities()
.useBstats()
diff --git a/test-plugin/src/main/resources/plugin.yml b/test-plugin/src/main/resources/plugin.yml
index 2c7deb1..1e9762b 100644
--- a/test-plugin/src/main/resources/plugin.yml
+++ b/test-plugin/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: EntityLibPlugin
-version: 1.0.0
+version: ${version}
depend:
- packetevents
main: me.tofaa.testentitylib.TestEntityLibPlugin