diff --git a/build.gradle b/build.gradle index b6391d1..5d9d733 100644 --- a/build.gradle +++ b/build.gradle @@ -23,88 +23,83 @@ plugins { id 'java-library' id 'com.github.johnrengelman.shadow' version '7.0.0' - id 'org.spongepowered.gradle.vanilla' version '0.2' + id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' } -group 'net.smoofyuniverse' +allprojects { + apply plugin: 'java-library' -java { - toolchain { - languageVersion = JavaLanguageVersion.of(8) - } -} - -tasks.withType(JavaCompile).configureEach { - options.encoding = "utf-8" -} + group 'net.smoofyuniverse' -repositories { - mavenCentral() - maven { - name = 'sponge' - url = 'https://repo.spongepowered.org/repository/maven-public/' + java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } } -} -configurations { - spongevanilla - spongeforge -} - -dependencies { - implementation 'org.spongepowered:sponge:1.16.5-8.1.0-SNAPSHOT:dev' - implementation 'org.spongepowered:mixin:0.8.4' - implementation 'org.ow2.asm:asm-util:9.2' + tasks.withType(JavaCompile).configureEach { + options.encoding = "utf-8" + } - implementation 'net.smoofyuniverse:oreupdater:1.1.1' - implementation 'net.smoofyuniverse:worldmap:1.1.0' + repositories { + mavenCentral() + maven { + name = 'sponge' + url = 'https://repo.spongepowered.org/repository/maven-public/' + } + } - spongevanilla 'org.spongepowered:spongevanilla:1.16.5-8.1.0-RC1185:universal' - spongeforge 'org.spongepowered:spongeforge:1.16.5-36.2.5-8.1.0-RC1185:universal' -} + configurations { + provided + shade -minecraft { - version("1.16.5") -} + provided.extendsFrom shade + implementation.extendsFrom provided + } -jar { - classifier 'base' - manifest { - attributes( - 'MixinConfigs': 'mixins.superpiston.json' - ) + jar { + classifier 'base' } } -shadowJar { - classifier '' +subprojects { + apply plugin: 'com.github.johnrengelman.shadow' - dependencies { - include dependency('net.smoofyuniverse:oreapi') - include dependency('net.smoofyuniverse:oreupdater') - include dependency('net.smoofyuniverse:worldmap') - } + shadowJar { + classifier 'shadow' + configurations = [project.configurations.shade] - relocate 'net.smoofyuniverse.ore', 'net.smoofyuniverse.superpiston.ore' - relocate 'net.smoofyuniverse.map', 'net.smoofyuniverse.superpiston.map' -} + dependencies { + include project(':') + include dependency('net.smoofyuniverse:oreapi') + include dependency('net.smoofyuniverse:oreupdater') + include dependency('net.smoofyuniverse:worldmap') + } -task setupVanillaServer(type: Copy) { - into 'run/vanilla' + relocate 'net.smoofyuniverse.ore', 'net.smoofyuniverse.superpiston.ore' + relocate 'net.smoofyuniverse.map', 'net.smoofyuniverse.superpiston.map' - from configurations.spongevanilla - rename('spongevanilla-(.*).jar', 'spongevanilla.jar') + manifest { + attributes('MixinConfigs': 'mixins.superpiston.json') + } + } - into('mods') { - from shadowJar + dependencies { + provided project(path: ':', configuration: 'provided') + shade project(path: ':', transitive: false) + shade project(path: ':', configuration: 'shade') } } -task setupForgeServer(type: Copy) { - into 'run/forge/mods' +dependencies { + provided 'org.spongepowered:sponge:1.16.5-8.1.0-SNAPSHOT:dev' + provided 'org.spongepowered:mixin:0.8.4' + provided 'org.ow2.asm:asm-util:9.2' - from configurations.spongeforge - rename('spongeforge-(.*).jar', 'spongeforge.jar') + shade 'net.smoofyuniverse:oreupdater:1.1.2' + shade 'net.smoofyuniverse:worldmap:1.1.0' +} - from shadowJar +minecraft { + version '1.16.5' } diff --git a/forge/build.gradle b/forge/build.gradle new file mode 100644 index 0000000..070bf2c --- /dev/null +++ b/forge/build.gradle @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2022 Hugo Dupanloup (Yeregorix) + * + * 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. + */ +plugins { + id "net.smoofyuniverse.loom" version "0.12.0-SNAPSHOT" +} + +archivesBaseName = 'SuperPiston-forge' + +loom { + silentMojangMappingsLicense() + + mixin { + useLegacyMixinAp = false + } +} + +configurations { + spongeforge +} + +dependencies { + minecraft 'com.mojang:minecraft:1.16.5' + forge 'net.minecraftforge:forge:1.16.5-36.2.5' + mappings loom.officialMojangMappings() + + spongeforge 'org.spongepowered:spongeforge:1.16.5-36.2.5-8.1.0-RC1185:universal' +} + +remapJar { + inputFile.set shadowJar.archiveFile + dependsOn shadowJar +} + +build.dependsOn remapJar + +task setupServer(type: Copy) { + into 'run/mods' + + from configurations.spongeforge + rename('spongeforge-(.*).jar', 'spongeforge.jar') + + from remapJar +} diff --git a/forge/gradle.properties b/forge/gradle.properties new file mode 100644 index 0000000..8242585 --- /dev/null +++ b/forge/gradle.properties @@ -0,0 +1 @@ +loom.platform=forge diff --git a/forge/src/main/resources/META-INF/sponge_plugins.json b/forge/src/main/resources/META-INF/sponge_plugins.json new file mode 100644 index 0000000..898b98e --- /dev/null +++ b/forge/src/main/resources/META-INF/sponge_plugins.json @@ -0,0 +1,41 @@ +{ + "loader": { + "name": "java_plain", + "version": "1.0" + }, + "license": "MIT", + "plugins": [ + { + "id": "superpiston", + "name": "SuperPiston", + "version": "1.1.1-forge", + "entrypoint": "net.smoofyuniverse.superpiston.SuperPiston", + "description": "Configurable piston behavior", + "links": { + "homepage": "https://ore.spongepowered.org/Yeregorix/SuperPiston", + "source": "https://github.com/Yeregorix/SuperPiston/", + "issues": "https://github.com/Yeregorix/SuperPiston/issues" + }, + "contributors": [ + { + "name": "Yeregorix", + "description": "Lead Developer" + } + ], + "dependencies": [ + { + "id": "spongeapi", + "version": "8.1.0", + "load-order": "AFTER", + "optional": false + }, + { + "id": "spongeforge", + "version": "8.1.0", + "load-order": "AFTER", + "optional": false + } + ] + } + ] +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..4687f10 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx2G diff --git a/settings.gradle b/settings.gradle index 234057c..0d4bc24 100644 --- a/settings.gradle +++ b/settings.gradle @@ -19,6 +19,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +pluginManagement { + repositories { + maven { url "https://repo.spongepowered.org/repository/maven-public" } + maven { url "https://maven.architectury.dev/" } + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + gradlePluginPortal() + } +} rootProject.name = 'SuperPiston' +include ':forge' +include ':vanilla' diff --git a/src/main/java/net/smoofyuniverse/superpiston/SuperPiston.java b/src/main/java/net/smoofyuniverse/superpiston/SuperPiston.java index c7cd660..ac2be3c 100644 --- a/src/main/java/net/smoofyuniverse/superpiston/SuperPiston.java +++ b/src/main/java/net/smoofyuniverse/superpiston/SuperPiston.java @@ -33,6 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.spongepowered.api.Game; +import org.spongepowered.api.Platform; import org.spongepowered.api.Server; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.event.Listener; @@ -105,8 +106,10 @@ public void onServerStarting(StartingEngineEvent e) { this.game.eventManager().registerListeners(this.container, new PistonListener(this)); + String platformId = this.game.platform().container(Platform.Component.IMPLEMENTATION).metadata().id(); + this.game.eventManager().registerListeners(this.container, new UpdateChecker(LOGGER, this.container, - createConfigLoader(this.configDir.resolve("update.conf")), "Yeregorix", "SuperPiston")); + createConfigLoader(this.configDir.resolve("update.conf")), "Yeregorix", "SuperPiston", platformId)); } private void loadConfigs() { diff --git a/src/main/resources/META-INF/sponge_plugins.json b/src/main/resources/META-INF/sponge_plugins.json deleted file mode 100644 index a92d347..0000000 --- a/src/main/resources/META-INF/sponge_plugins.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "loader": { - "name": "java_plain", - "version": "1.0" - }, - "license": "MIT", - "plugins": [ - { - "id": "superpiston", - "name": "SuperPiston", - "version": "1.1.1", - "entrypoint": "net.smoofyuniverse.superpiston.SuperPiston", - "description": "Configurable piston behavior", - "links": { - "homepage": "https://ore.spongepowered.org/Yeregorix/SuperPiston", - "source": "https://github.com/Yeregorix/SuperPiston/", - "issues": "https://github.com/Yeregorix/SuperPiston/issues" - }, - "contributors": [ - { - "name": "Yeregorix", - "description": "Lead Developer" - } - ], - "dependencies": [ - { - "id": "spongeapi", - "version": "8.0.0", - "load-order": "AFTER", - "optional": false - } - ] - } - ] -} diff --git a/vanilla/build.gradle b/vanilla/build.gradle new file mode 100644 index 0000000..d5dc225 --- /dev/null +++ b/vanilla/build.gradle @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018-2022 Hugo Dupanloup (Yeregorix) + * + * 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. + */ +archivesBaseName = 'SuperPiston-vanilla' + +configurations { + spongevanilla +} + +dependencies { + spongevanilla 'org.spongepowered:spongevanilla:1.16.5-8.1.0-RC1185:universal' +} + +shadowJar { + classifier '' +} + +build.dependsOn shadowJar + +task setupServer(type: Copy) { + into 'run' + + from configurations.spongevanilla + rename('spongevanilla-(.*).jar', 'spongevanilla.jar') + + into('mods') { + from shadowJar + } +} diff --git a/vanilla/src/main/resources/META-INF/sponge_plugins.json b/vanilla/src/main/resources/META-INF/sponge_plugins.json new file mode 100644 index 0000000..802cf27 --- /dev/null +++ b/vanilla/src/main/resources/META-INF/sponge_plugins.json @@ -0,0 +1,41 @@ +{ + "loader": { + "name": "java_plain", + "version": "1.0" + }, + "license": "MIT", + "plugins": [ + { + "id": "superpiston", + "name": "SuperPiston", + "version": "1.1.1-vanilla", + "entrypoint": "net.smoofyuniverse.superpiston.SuperPiston", + "description": "Configurable piston behavior", + "links": { + "homepage": "https://ore.spongepowered.org/Yeregorix/SuperPiston", + "source": "https://github.com/Yeregorix/SuperPiston/", + "issues": "https://github.com/Yeregorix/SuperPiston/issues" + }, + "contributors": [ + { + "name": "Yeregorix", + "description": "Lead Developer" + } + ], + "dependencies": [ + { + "id": "spongeapi", + "version": "8.1.0", + "load-order": "AFTER", + "optional": false + }, + { + "id": "spongevanilla", + "version": "8.1.0", + "load-order": "AFTER", + "optional": false + } + ] + } + ] +}