rewrite template for ignite 1.0.0
This commit is contained in:
parent
285e53cbb9
commit
ec138cc92b
21 changed files with 210 additions and 316 deletions
|
@ -2,17 +2,27 @@ plugins {
|
||||||
`kotlin-dsl`
|
`kotlin-dsl`
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
dependencies {
|
||||||
gradlePluginPortal()
|
implementation(libs.build.paperweight)
|
||||||
maven {
|
implementation(libs.build.shadow)
|
||||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
implementation(libs.build.spotless)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val indraVersion = "3.0.1"
|
compileOnly(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||||
implementation("net.kyori", "indra-common", indraVersion)
|
}
|
||||||
implementation("net.kyori", "indra-licenser-spotless", indraVersion)
|
|
||||||
implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2")
|
java {
|
||||||
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.5.0")
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
target {
|
||||||
|
compilations.configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
14
build-logic/settings.gradle.kts
Normal file
14
build-logic/settings.gradle.kts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
rootProject.name = "ignite-template-build-logic"
|
||||||
|
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
}
|
||||||
|
|
||||||
|
versionCatalogs {
|
||||||
|
register("libs") {
|
||||||
|
from(files("../gradle/libs.versions.toml")) // include from parent project
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
build-logic/src/main/kotlin/extensions.kt
Normal file
6
build-logic/src/main/kotlin/extensions.kt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
|
||||||
|
fun JavaPluginExtension.javaTarget(version: Int) {
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(version))
|
||||||
|
}
|
|
@ -1,60 +1,87 @@
|
||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.diffplug.gradle.spotless.FormatExtension
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("net.kyori.indra")
|
`java-library`
|
||||||
id("net.kyori.indra.licenser.spotless")
|
id("com.diffplug.spotless")
|
||||||
|
|
||||||
id("com.github.johnrengelman.shadow")
|
id("com.github.johnrengelman.shadow")
|
||||||
id("io.papermc.paperweight.userdev")
|
id("io.papermc.paperweight.userdev")
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
// Expose version catalog
|
||||||
val shadeApi = create("shadeApi")
|
val libs = extensions.getByType(org.gradle.accessors.dm.LibrariesForLibs::class)
|
||||||
val shadeImplementation = create("shadeImplementation")
|
|
||||||
|
|
||||||
api { extendsFrom(shadeApi) }
|
java {
|
||||||
implementation { extendsFrom(shadeImplementation) }
|
javaTarget(17)
|
||||||
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven("https://oss.sonatype.org/content/groups/public/")
|
||||||
url = uri("https://oss.sonatype.org/content/groups/public/")
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
}
|
maven("https://repo.spongepowered.org/maven/")
|
||||||
maven {
|
|
||||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url = uri("https://repo.spongepowered.org/maven/")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
indra {
|
dependencies {
|
||||||
javaVersions {
|
compileOnlyApi(libs.jetbrains.annotations)
|
||||||
target(17)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mitLicense()
|
spotless {
|
||||||
|
fun FormatExtension.applyCommon() {
|
||||||
|
trimTrailingWhitespace()
|
||||||
|
endWithNewline()
|
||||||
|
indentWithSpaces(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
val jar = tasks.named<Jar>("jar")
|
fun formatLicense(): String {
|
||||||
|
val splitPattern = Pattern.compile("\r?\n")
|
||||||
|
val lineSeparator = System.lineSeparator()
|
||||||
|
val headerPrefix = "/*$lineSeparator"
|
||||||
|
val linePrefix = " * "
|
||||||
|
val headerSuffix = "$lineSeparator */"
|
||||||
|
|
||||||
val shadowJar = tasks.named<ShadowJar>("shadowJar") {
|
val headerText = String(Files.readAllBytes(rootProject.file("license_header.txt").toPath()), StandardCharsets.UTF_8)
|
||||||
configurations = listOf(project.configurations.named("shadeApi").get(), project.configurations.named("shadeImplementation").get())
|
|
||||||
|
|
||||||
from(jar)
|
return splitPattern.splitAsStream(headerText)
|
||||||
|
.map {
|
||||||
|
StringBuilder(it.length + 4)
|
||||||
|
.append(linePrefix)
|
||||||
|
.append(it)
|
||||||
|
.toString()
|
||||||
|
}
|
||||||
|
.collect(Collectors.joining(
|
||||||
|
lineSeparator,
|
||||||
|
headerPrefix,
|
||||||
|
headerSuffix
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
java {
|
||||||
|
licenseHeader(formatLicense())
|
||||||
|
applyCommon()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
applyCommon()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
build {
|
jar {
|
||||||
dependsOn(reobfJar)
|
archiveClassifier.set("dev")
|
||||||
}
|
}
|
||||||
|
|
||||||
reobfJar {
|
reobfJar {
|
||||||
remapperArgs.add("--mixin")
|
remapperArgs.add("--mixin")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
build {
|
||||||
archives(shadowJar)
|
dependsOn(reobfJar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@ plugins {
|
||||||
id("mod.base-conventions")
|
id("mod.base-conventions")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.example"
|
|
||||||
version = "1.0.0-SNAPSHOT"
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.ignite)
|
compileOnly(libs.ignite)
|
||||||
implementation(libs.mixin)
|
compileOnly(libs.mixin)
|
||||||
|
|
||||||
paperweight.paperDevBundle("1.19.3-R0.1-SNAPSHOT")
|
paperweight.paperDevBundle(libs.versions.paper)
|
||||||
}
|
}
|
||||||
|
|
5
gradle.properties
Normal file
5
gradle.properties
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
group=com.example
|
||||||
|
version=1.0.0-SNAPSHOT
|
||||||
|
description=Example mod for Ignite
|
||||||
|
|
||||||
|
org.gradle.parallel=true
|
|
@ -2,12 +2,20 @@ metadata.format.version = "1.1"
|
||||||
|
|
||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
ignite = "0.8.0"
|
jetbrains = "24.1.0"
|
||||||
|
ignite = "1.0.0-SNAPSHOT"
|
||||||
mixin = "0.8.5"
|
mixin = "0.8.5"
|
||||||
|
paperweight = "1.5.11"
|
||||||
|
shadow = "8.1.1"
|
||||||
|
spotless = "6.23.3"
|
||||||
|
paper = "1.20.4-R0.1-SNAPSHOT"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains" }
|
||||||
|
|
||||||
ignite = { group = "space.vectrix.ignite", name = "ignite-api", version.ref = "ignite" }
|
ignite = { group = "space.vectrix.ignite", name = "ignite-api", version.ref = "ignite" }
|
||||||
mixin = { group = "org.spongepowered", name = "mixin", version.ref = "mixin" }
|
mixin = { group = "org.spongepowered", name = "mixin", version.ref = "mixin" }
|
||||||
|
|
||||||
|
build-paperweight = { module = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin", version.ref = "paperweight" }
|
||||||
|
build-shadow = { module = "com.github.johnrengelman:shadow", version.ref = "shadow" }
|
||||||
|
build-spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
18
gradlew
vendored
18
gradlew
vendored
|
@ -55,7 +55,7 @@
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
@ -80,10 +80,10 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
@ -143,12 +143,16 @@ fi
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
@ -205,6 +209,12 @@ set -- \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|
11
gradlew.bat
vendored
11
gradlew.bat
vendored
|
@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
|
||||||
enableFeaturePreview("VERSION_CATALOGS")
|
|
||||||
|
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
|
includeBuild("build-logic")
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "ignite-mod-template"
|
plugins {
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
||||||
|
}
|
||||||
|
|
||||||
includeBuild("build-logic")
|
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||||
|
|
||||||
|
rootProject.name = "ignite-mod-template"
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Ignite, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) vectrix.space <https://vectrix.space/>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.example;
|
|
||||||
|
|
||||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
|
||||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|
||||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
|
||||||
|
|
||||||
@ConfigSerializable
|
|
||||||
public final class ExampleConfig {
|
|
||||||
@Setting(value = "test")
|
|
||||||
@Comment(value = "Test configuration property.")
|
|
||||||
private boolean test;
|
|
||||||
|
|
||||||
@Setting(value = "container")
|
|
||||||
@Comment(value = "A test container.")
|
|
||||||
private TestContainer container;
|
|
||||||
|
|
||||||
public boolean test() {
|
|
||||||
return this.test;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestContainer container() {
|
|
||||||
return this.container;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigSerializable
|
|
||||||
public static class TestContainer {
|
|
||||||
@Setting(value = "foo")
|
|
||||||
@Comment(value = "A test boolean in a container.")
|
|
||||||
private boolean foo;
|
|
||||||
|
|
||||||
public boolean foo() {
|
|
||||||
return this.foo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Ignite, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) vectrix.space <https://vectrix.space/>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.example;
|
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
import space.vectrix.ignite.api.Blackboard;
|
|
||||||
import space.vectrix.ignite.api.config.Configuration;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public final class ExampleInfo {
|
|
||||||
private static final @MonotonicNonNull Path CONFIGS_PATH = Blackboard.getProperty(Blackboard.CONFIG_DIRECTORY_PATH);
|
|
||||||
|
|
||||||
private static @MonotonicNonNull Path EXAMPLE_PATH;
|
|
||||||
private static Configuration.@MonotonicNonNull Key<ExampleConfig> EXAMPLE_CONFIG;
|
|
||||||
|
|
||||||
public static @MonotonicNonNull Path getExamplePath() {
|
|
||||||
if (ExampleInfo.EXAMPLE_PATH != null) return ExampleInfo.EXAMPLE_PATH;
|
|
||||||
if (ExampleInfo.CONFIGS_PATH == null) return null;
|
|
||||||
|
|
||||||
return ExampleInfo.EXAMPLE_PATH = ExampleInfo.CONFIGS_PATH.resolve("example");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Configuration.@NonNull Key<ExampleConfig> getExampleConfig() {
|
|
||||||
if (ExampleInfo.EXAMPLE_CONFIG != null) return ExampleInfo.EXAMPLE_CONFIG;
|
|
||||||
|
|
||||||
final Path examplePath = ExampleInfo.getExamplePath();
|
|
||||||
if (examplePath == null) throw new IllegalStateException("Unable to locate example path.");
|
|
||||||
|
|
||||||
return ExampleInfo.EXAMPLE_CONFIG = Configuration.key(ExampleConfig.class, examplePath.resolve("example.conf"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Ignite, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) vectrix.space <https://vectrix.space/>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.example;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
|
||||||
import space.vectrix.ignite.api.Platform;
|
|
||||||
import space.vectrix.ignite.api.config.Configuration;
|
|
||||||
import space.vectrix.ignite.api.config.Configurations;
|
|
||||||
import space.vectrix.ignite.api.event.Subscribe;
|
|
||||||
import space.vectrix.ignite.api.event.platform.PlatformInitializeEvent;
|
|
||||||
|
|
||||||
public final class ExampleMod {
|
|
||||||
private final Logger logger;
|
|
||||||
private final Platform platform;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public ExampleMod(final Logger logger,
|
|
||||||
final Platform platform) {
|
|
||||||
this.logger = logger;
|
|
||||||
this.platform = platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onInitialize(final @NonNull PlatformInitializeEvent event) {
|
|
||||||
this.logger.info("Hello Example!");
|
|
||||||
|
|
||||||
final Configuration<ExampleConfig, CommentedConfigurationNode> configWrapper = Configurations.getOrCreate(Configurations.HOCON_LOADER, ExampleInfo.getExampleConfig());
|
|
||||||
final ExampleConfig config = configWrapper.instance();
|
|
||||||
if (config != null) {
|
|
||||||
this.logger.info("Foo is set to: " + (config.container().foo() ? "Enabled" : "Disabled"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,15 +24,14 @@
|
||||||
*/
|
*/
|
||||||
package com.example.mixin.core;
|
package com.example.mixin.core;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
import java.util.logging.Logger;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
@Mixin(value = CraftServer.class)
|
@Mixin(value = CraftServer.class)
|
||||||
public abstract class MixinCraftServer {
|
public abstract class MixinCraftServer {
|
||||||
@Shadow public abstract Logger getLogger();
|
@Shadow public abstract Logger getLogger();
|
||||||
|
|
|
@ -24,23 +24,17 @@
|
||||||
*/
|
*/
|
||||||
package com.example.mixin.plugins;
|
package com.example.mixin.plugins;
|
||||||
|
|
||||||
import com.example.ExampleConfig;
|
import java.util.List;
|
||||||
import com.example.ExampleInfo;
|
import java.util.Set;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
|
||||||
import space.vectrix.ignite.api.config.Configuration;
|
|
||||||
import space.vectrix.ignite.api.config.Configurations;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public final class CorePlugin implements IMixinConfigPlugin {
|
public final class CorePlugin implements IMixinConfigPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onLoad(final @NonNull String mixinPackage) {
|
public void onLoad(final @NotNull String mixinPackage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,18 +43,12 @@ public final class CorePlugin implements IMixinConfigPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldApplyMixin(final @NonNull String targetClassName, final @NonNull String mixinClassName) {
|
public boolean shouldApplyMixin(final @NotNull String targetClassName, final @NotNull String mixinClassName) {
|
||||||
final Configuration<ExampleConfig, CommentedConfigurationNode> configWrapper = Configurations.getOrCreate(Configurations.HOCON_LOADER, ExampleInfo.getExampleConfig());
|
return true;
|
||||||
final ExampleConfig config = configWrapper.instance();
|
|
||||||
if (config != null) {
|
|
||||||
return config.test();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void acceptTargets(final @NonNull Set<String> myTargets, final @NonNull Set<String> otherTargets) {
|
public void acceptTargets(final @NotNull Set<String> myTargets, final @NotNull Set<String> otherTargets) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,10 +57,10 @@ public final class CorePlugin implements IMixinConfigPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preApply(final @NonNull String targetClassName, final @NonNull ClassNode targetClass, final @NonNull String mixinClassName, final @NonNull IMixinInfo mixinInfo) {
|
public void preApply(final @NotNull String targetClassName, final @NotNull ClassNode targetClass, final @NotNull String mixinClassName, final @NotNull IMixinInfo mixinInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postApply(final @NonNull String targetClassName, final @NonNull ClassNode targetClass, final @NonNull String mixinClassName, final @NonNull IMixinInfo mixinInfo) {
|
public void postApply(final @NotNull String targetClassName, final @NotNull ClassNode targetClass, final @NotNull String mixinClassName, final @NotNull IMixinInfo mixinInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
{
|
{
|
||||||
"id": "example",
|
"id": "example",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"entry": "com.example.ExampleMod",
|
|
||||||
"dependencies": [
|
|
||||||
"ignite"
|
|
||||||
],
|
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"mixins.example.core.json"
|
"mixins.example.core.json"
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"package": "com.example.mixin.core",
|
"package": "com.example.mixin.core",
|
||||||
"plugin": "com.example.mixin.plugins.CorePlugin",
|
"plugin": "com.example.mixin.plugins.CorePlugin",
|
||||||
"target": "@env(DEFAULT)",
|
"target": "@env(DEFAULT)",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"server": [
|
"server": [
|
||||||
"MixinCraftServer",
|
"MixinCraftServer",
|
||||||
"MixinSimpleCommandMap"
|
"MixinSimpleCommandMap"
|
||||||
|
|
Loading…
Reference in a new issue