diff --git a/.gitignore b/.gitignore index 9d0620d..02f7876 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,6 @@ hs_err_pid* # Project files /.idea/* !/.idea/copyright/ -/.gradle/ -/build/ -/out/ +.gradle/ +build/ +out/ diff --git a/README.md b/README.md index fc73e2a..32e024b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # ViaAprilFools ViaVersion addon to add support for some notable Minecraft snapshots. -ViaAprilFools is not usable by itself as a standalone software, as it is an addon for ViaVersion which adds more protocol translators. -ViaAprilFools is intended to be implemented in a ViaVersion based protocol translator. +ViaAprilFools itself runs on Paper and Velocity servers and can be implemented in any other platform which supports ViaVersion. If you are looking to implement ViaAprilFools in your own software you can start by reading the [Usage](#usage) section. If you just want to use ViaAprilFools yourself you can check out some projects which implement it in the [Projects](#projects-implementing-viaaprilfools) section. @@ -19,6 +18,7 @@ If you just want to use ViaAprilFools yourself you can check out some projects w ### Projects implementing ViaAprilFools - [ViaProxy](https://github.com/ViaVersion/ViaProxy): Standalone proxy which uses ViaVersion to translate between Minecraft versions. Allows Minecraft 1.7+ clients to join to any version server. - [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus): Fabric mod for the latest Minecraft version with QoL fixes and enhancements to the gameplay. +- [ViaFabric](https://github.com/ViaVersion/ViaFabric): Client-side and server-side ViaVersion implementation for Fabric ## Releases ### Gradle/Maven diff --git a/build-logic/build.gradle b/build-logic/build.gradle new file mode 100644 index 0000000..abe72b3 --- /dev/null +++ b/build-logic/build.gradle @@ -0,0 +1,7 @@ +plugins { + id "groovy-gradle-plugin" +} + +repositories { + gradlePluginPortal() +} \ No newline at end of file diff --git a/build-logic/src/main/groovy/vaf.base-conventions.gradle b/build-logic/src/main/groovy/vaf.base-conventions.gradle new file mode 100644 index 0000000..1fddc38 --- /dev/null +++ b/build-logic/src/main/groovy/vaf.base-conventions.gradle @@ -0,0 +1,89 @@ +plugins { + id "java-library" + id "maven-publish" + id "idea" +} + +repositories { + mavenCentral() + maven { + name = "ViaVersion" + url "https://repo.viaversion.com" + } + maven { + name = "SpigotMC" + url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" + } + maven { + name = "SpongePowered" + url "https://repo.spongepowered.org/repository/maven-public/" + } + maven { + name = "VelocityPowered" + url "https://nexus.velocitypowered.com/repository/maven-public/" + } +} + +base { + java.toolchain.languageVersion = JavaLanguageVersion.of(17) + compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8" + + archivesName = project.name + group = rootProject.maven_group + version = rootProject.maven_version + + description = "ViaVersion addon to add support for some notable Minecraft snapshots" +} + +dependencies { + compileOnly "com.viaversion:viaversion-common:5.0.0" + compileOnly "com.viaversion:viabackwards-common:5.0.0" +} + +publishing { + repositories { + maven { + name = "Via" + url = "https://repo.viaversion.com/" + + credentials(PasswordCredentials) + authentication { + basic(BasicAuthentication) + } + } + } + publications { + maven(MavenPublication) { + groupId = project.maven_group + artifactId = project.name + version = project.maven_version + + from components.java + + pom { + name = "ViaAprilFools" + description = project.description + url = "https://github.com/ViaVersion/ViaAprilFools" + licenses { + license { + name = "GPL-3.0 License" + url = "https://github.com/ViaVersion/ViaAprilFools/blob/main/LICENSE" + } + } + developers { + developer { + id = "RK_01" + } + developer { + id = "FlorianMichael/EnZaXD" + } + } + scm { + connection = "scm:git:git://github.com/ViaVersion/ViaAprilFools.git" + developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaAprilFools.git" + url = "https://github.com/ViaVersion/ViaAprilFools.git" + } + } + } + } +} diff --git a/build-logic/src/main/groovy/vaf.platform-conventions.gradle b/build-logic/src/main/groovy/vaf.platform-conventions.gradle new file mode 100644 index 0000000..e731e7b --- /dev/null +++ b/build-logic/src/main/groovy/vaf.platform-conventions.gradle @@ -0,0 +1,7 @@ +plugins { + id "vaf.base-conventions" +} + +dependencies { + compileOnly project(":viaaprilfools-common") +} diff --git a/build.gradle b/build.gradle index 69d45ff..cf0e142 100644 --- a/build.gradle +++ b/build.gradle @@ -1,99 +1,50 @@ plugins { - id "java-library" - id "maven-publish" - id "idea" - id "net.raphimc.class-token-replacer" version "1.1.2" + id "vaf.base-conventions" + + id "io.papermc.hangar-publish-plugin" version "0.1.2" + id "com.modrinth.minotaur" version "2.+" } base { - java.toolchain.languageVersion = JavaLanguageVersion.of(17) - compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8" - - group = project.maven_group ?: rootProject.maven_group - archivesName = project.maven_name ?: rootProject.maven_name - version = project.maven_version ?: rootProject.maven_version + archivesName = "ViaAprilFools" } -repositories { - mavenCentral() - maven { - name = "ViaVersion" - url "https://repo.viaversion.com" - } +configurations { + publishInclude } dependencies { - compileOnly "com.viaversion:viaversion-common:5.0.0" - compileOnly "com.viaversion:viabackwards-common:5.0.0" - compileOnly "org.yaml:snakeyaml:2.2" - compileOnly "com.google.guava:guava:33.2.1-jre" - compileOnly "io.netty:netty-handler:4.1.111.Final" -} - -sourceSets { - main { - classTokenReplacer { - property("\${version}", project.version) - property("\${impl_version}", "git-${project.name}-${project.version}:${project.latestCommitHash()}") - } - } + publishInclude project(":viaaprilfools-common") + publishInclude project(":viaaprilfools-bukkit") + publishInclude project(":viaaprilfools-fabric") + publishInclude project(":viaaprilfools-velocity") } java { withSourcesJar() + withJavadocJar() } jar { + dependsOn configurations.publishInclude + from { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + configurations.publishInclude.collect { + zipTree(it) + } + } { + exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA" + } + manifest { + attributes( + "paperweight-mappings-namespace": "mojang" + ) + } from("LICENSE") { rename { "${it}_${project.name ?: rootProject.name}" } } } -publishing { - repositories { - maven { - name = "Via" - url = "https://repo.viaversion.com/" - - credentials(PasswordCredentials) - authentication { - basic(BasicAuthentication) - } - } - } - publications { - maven(MavenPublication) { - groupId = project.maven_group - artifactId = project.maven_name - version = project.maven_version - - from components.java - - pom { - name = "ViaAprilFools" - description = "ViaVersion addon to add support for some notable Minecraft snapshots" - url = "https://github.com/ViaVersion/ViaAprilFools" - licenses { - license { - name = "GPL-3.0 License" - url = "https://github.com/ViaVersion/ViaAprilFools/blob/main/LICENSE" - } - } - developers { - developer { - id = "RK_01" - } - } - scm { - connection = "scm:git:git://github.com/ViaVersion/ViaAprilFools.git" - developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaAprilFools.git" - url = "https://github.com/ViaVersion/ViaAprilFools.git" - } - } - } - } -} - idea { module { ["run"].each { @@ -102,11 +53,102 @@ idea { } } -String latestCommitHash() { - def stdout = new ByteArrayOutputStream() +// ----------------------------------------------------- +// Publishing + +def latestCommitHash() { + def byteOut = new ByteArrayOutputStream() exec { - commandLine "git", "rev-parse", "--short", "HEAD" - standardOutput = stdout + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = byteOut } - return stdout.toString().trim() + return byteOut.toString('UTF-8').trim() } + +def latestCommitMessage() { + def byteOut = new ByteArrayOutputStream() + exec { + commandLine 'git', 'log', '-1', '--pretty=%B' + standardOutput = byteOut + } + return byteOut.toString('UTF-8').trim() +} + +def branchName() { + def byteOut = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' + standardOutput = byteOut + } + return byteOut.toString('UTF-8').trim() +} + +def branch = branchName() +def baseVersion = project.maven_version +def isRelease = !baseVersion.contains('-') +if (!isRelease) { // Only publish releases from the main branch + def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER") + def commitHash = latestCommitHash() + def changelogContent = "[${commitHash}](https://github.com/ViaVersion/ViaAprilFools/commit/${commitHash}) ${latestCommitMessage()}" + modrinth { + def mcVersions = project.mcVersions + .split(',') + .collect { it.trim() } + + token.set(System.getenv("MODRINTH_TOKEN")) + projectId.set("viaaprilfools") + versionType.set(isRelease ? "release" : "beta") + versionNumber.set(suffixedVersion) + versionName.set(suffixedVersion) + changelog.set(changelogContent) + uploadFile.set(jar.archiveFile) + gameVersions.set(mcVersions) + loaders.add("fabric") + loaders.add("paper") + loaders.add("folia") + loaders.add("velocity") + autoAddDependsOn.set(false) + detectLoaders.set(false) + dependencies { + required.project("viaversion") + required.project("viabackwards") + optional.project("viafabric") + } + } + + hangarPublish { + publications.register("plugin") { + version = suffixedVersion + id = "ViaAprilFools" + channel = isRelease ? "Release" : "Snapshot" + changelog = changelogContent + apiKey = System.getenv("HANGAR_TOKEN") + platforms { + PAPER { + jar = project.jar.archiveFile + platformVersions = [property('mcVersionRange') as String] + dependencies { + hangar("ViaVersion") { + required = true + } + hangar("ViaBackwards") { + required = true + } + } + } + VELOCITY { + jar = project.jar.archiveFile + platformVersions = [property("velocityVersion") as String] + dependencies { + hangar("ViaVersion") { + required = true + } + hangar("ViaBackwards") { + required = true + } + } + } + } + } + } +} \ No newline at end of file diff --git a/bukkit/build.gradle b/bukkit/build.gradle new file mode 100644 index 0000000..84afc0f --- /dev/null +++ b/bukkit/build.gradle @@ -0,0 +1,13 @@ +plugins { + id "vaf.platform-conventions" +} + +dependencies { + compileOnly(annotationProcessor("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")) +} + +processResources { + filesMatching("plugin.yml") { + expand("version": project.version, "description": project.description) + } +} diff --git a/bukkit/src/main/java/net/raphimc/viaaprilfools/BukkitPlugin.java b/bukkit/src/main/java/net/raphimc/viaaprilfools/BukkitPlugin.java new file mode 100644 index 0000000..e88771c --- /dev/null +++ b/bukkit/src/main/java/net/raphimc/viaaprilfools/BukkitPlugin.java @@ -0,0 +1,32 @@ +/* + * This file is part of ViaAprilFools - https://github.com/RaphiMC/ViaAprilFools + * Copyright (C) 2021-2024 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaaprilfools; + +import com.viaversion.viaversion.api.Via; +import net.raphimc.viaaprilfools.platform.ViaAprilFoolsPlatform; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; + +public class BukkitPlugin extends JavaPlugin implements ViaAprilFoolsPlatform { + + public BukkitPlugin() { + Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml"))); + } + +} diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml new file mode 100644 index 0000000..4e0c049 --- /dev/null +++ b/bukkit/src/main/resources/plugin.yml @@ -0,0 +1,10 @@ +name: ViaAprilFools +main: net.raphimc.viaaprilfools.BukkitPlugin +authors: [RK_01, FlorianMichael/EnZaXD] +version: ${version} +description: ${description} +website: https://viaversion.com/aprilfools +api-version: 1.13 +folia-supported: true +load: STARTUP +depend: [ViaVersion, ViaBackwards] \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..d20d333 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,29 @@ +plugins { + id "vaf.base-conventions" + + id "net.raphimc.class-token-replacer" version "1.1.2" +} + +dependencies { + compileOnly "org.yaml:snakeyaml:2.2" + compileOnly "com.google.guava:guava:33.2.1-jre" + compileOnly "io.netty:netty-handler:4.1.111.Final" +} + +sourceSets { + main { + classTokenReplacer { + property("\${version}", project.version) + property("\${impl_version}", "git-${rootProject.name}-${project.version}:${project.latestCommitHash()}") + } + } +} + +String latestCommitHash() { + def stdout = new ByteArrayOutputStream() + exec { + commandLine "git", "rev-parse", "--short", "HEAD" + standardOutput = stdout + } + return stdout.toString().trim() +} diff --git a/src/main/java/net/raphimc/viaaprilfools/ViaAprilFools.java b/common/src/main/java/net/raphimc/viaaprilfools/ViaAprilFools.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/ViaAprilFools.java rename to common/src/main/java/net/raphimc/viaaprilfools/ViaAprilFools.java diff --git a/src/main/java/net/raphimc/viaaprilfools/ViaAprilFoolsConfig.java b/common/src/main/java/net/raphimc/viaaprilfools/ViaAprilFoolsConfig.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/ViaAprilFoolsConfig.java rename to common/src/main/java/net/raphimc/viaaprilfools/ViaAprilFoolsConfig.java diff --git a/src/main/java/net/raphimc/viaaprilfools/api/AprilFoolsProtocolVersion.java b/common/src/main/java/net/raphimc/viaaprilfools/api/AprilFoolsProtocolVersion.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/api/AprilFoolsProtocolVersion.java rename to common/src/main/java/net/raphimc/viaaprilfools/api/AprilFoolsProtocolVersion.java diff --git a/src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingData.java b/common/src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingData.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingData.java rename to common/src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingData.java diff --git a/src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingDataLoader.java b/common/src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingDataLoader.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingDataLoader.java rename to common/src/main/java/net/raphimc/viaaprilfools/api/data/AprilFoolsMappingDataLoader.java diff --git a/src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsConfig.java b/common/src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsConfig.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsConfig.java rename to common/src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsConfig.java diff --git a/src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsPlatform.java b/common/src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsPlatform.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsPlatform.java rename to common/src/main/java/net/raphimc/viaaprilfools/platform/ViaAprilFoolsPlatform.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/Protocol20w14infiniteTo1_16.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/Protocol20w14infiniteTo1_16.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/Protocol20w14infiniteTo1_16.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/Protocol20w14infiniteTo1_16.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/data/BiomeData20w14infinite.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/data/BiomeData20w14infinite.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/data/BiomeData20w14infinite.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/data/BiomeData20w14infinite.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ClientboundPackets20w14infinite.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ClientboundPackets20w14infinite.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ClientboundPackets20w14infinite.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ClientboundPackets20w14infinite.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ServerboundPackets20w14infinite.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ServerboundPackets20w14infinite.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ServerboundPackets20w14infinite.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/packet/ServerboundPackets20w14infinite.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/BlockItemPacketRewriter20w14infinite.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/BlockItemPacketRewriter20w14infinite.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/BlockItemPacketRewriter20w14infinite.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/BlockItemPacketRewriter20w14infinite.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/EntityPacketRewriter20w14infinite.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/EntityPacketRewriter20w14infinite.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/EntityPacketRewriter20w14infinite.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s20w14infinitetov1_16/rewriter/EntityPacketRewriter20w14infinite.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/Protocol3D_SharewareTo1_14.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/Protocol3D_SharewareTo1_14.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/Protocol3D_SharewareTo1_14.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/Protocol3D_SharewareTo1_14.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ClientboundPackets3D_Shareware.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ClientboundPackets3D_Shareware.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ClientboundPackets3D_Shareware.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ClientboundPackets3D_Shareware.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ServerboundPackets3D_Shareware.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ServerboundPackets3D_Shareware.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ServerboundPackets3D_Shareware.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/packet/ServerboundPackets3D_Shareware.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/BlockItemPacketRewriter3D_Shareware.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/BlockItemPacketRewriter3D_Shareware.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/BlockItemPacketRewriter3D_Shareware.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/BlockItemPacketRewriter3D_Shareware.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/EntityPacketRewriter3D_Shareware.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/EntityPacketRewriter3D_Shareware.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/EntityPacketRewriter3D_Shareware.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/rewriter/EntityPacketRewriter3D_Shareware.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/storage/ChunkCenterTracker3D_Shareware.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/storage/ChunkCenterTracker3D_Shareware.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/storage/ChunkCenterTracker3D_Shareware.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/s3d_sharewaretov1_14/storage/ChunkCenterTracker3D_Shareware.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/scombattest8ctov1_16_2/ProtocolCombatTest8cTo1_16_2.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/scombattest8ctov1_16_2/ProtocolCombatTest8cTo1_16_2.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/scombattest8ctov1_16_2/ProtocolCombatTest8cTo1_16_2.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/scombattest8ctov1_16_2/ProtocolCombatTest8cTo1_16_2.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/v1_14tos3d_shareware/Protocol1_14To3D_Shareware.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/v1_14tos3d_shareware/Protocol1_14To3D_Shareware.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/v1_14tos3d_shareware/Protocol1_14To3D_Shareware.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/v1_14tos3d_shareware/Protocol1_14To3D_Shareware.java diff --git a/src/main/java/net/raphimc/viaaprilfools/protocol/v1_16_2toscombattest8c/Protocol1_16_2ToCombatTest8c.java b/common/src/main/java/net/raphimc/viaaprilfools/protocol/v1_16_2toscombattest8c/Protocol1_16_2ToCombatTest8c.java similarity index 100% rename from src/main/java/net/raphimc/viaaprilfools/protocol/v1_16_2toscombattest8c/Protocol1_16_2ToCombatTest8c.java rename to common/src/main/java/net/raphimc/viaaprilfools/protocol/v1_16_2toscombattest8c/Protocol1_16_2ToCombatTest8c.java diff --git a/src/main/resources/assets/viaaprilfools/data/identifiers-20w14infinite.nbt b/common/src/main/resources/assets/viaaprilfools/data/identifiers-20w14infinite.nbt similarity index 100% rename from src/main/resources/assets/viaaprilfools/data/identifiers-20w14infinite.nbt rename to common/src/main/resources/assets/viaaprilfools/data/identifiers-20w14infinite.nbt diff --git a/src/main/resources/assets/viaaprilfools/data/identifiers-3D_Shareware.nbt b/common/src/main/resources/assets/viaaprilfools/data/identifiers-3D_Shareware.nbt similarity index 100% rename from src/main/resources/assets/viaaprilfools/data/identifiers-3D_Shareware.nbt rename to common/src/main/resources/assets/viaaprilfools/data/identifiers-3D_Shareware.nbt diff --git a/src/main/resources/assets/viaaprilfools/data/mappings-20w14infiniteto1.16.nbt b/common/src/main/resources/assets/viaaprilfools/data/mappings-20w14infiniteto1.16.nbt similarity index 100% rename from src/main/resources/assets/viaaprilfools/data/mappings-20w14infiniteto1.16.nbt rename to common/src/main/resources/assets/viaaprilfools/data/mappings-20w14infiniteto1.16.nbt diff --git a/src/main/resources/assets/viaaprilfools/data/mappings-3D_Sharewareto1.14.nbt b/common/src/main/resources/assets/viaaprilfools/data/mappings-3D_Sharewareto1.14.nbt similarity index 100% rename from src/main/resources/assets/viaaprilfools/data/mappings-3D_Sharewareto1.14.nbt rename to common/src/main/resources/assets/viaaprilfools/data/mappings-3D_Sharewareto1.14.nbt diff --git a/src/main/resources/assets/viaaprilfools/viaaprilfools.yml b/common/src/main/resources/assets/viaaprilfools/viaaprilfools.yml similarity index 100% rename from src/main/resources/assets/viaaprilfools/viaaprilfools.yml rename to common/src/main/resources/assets/viaaprilfools/viaaprilfools.yml diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..6462f7f --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,14 @@ +plugins { + id "vaf.platform-conventions" +} + +dependencies { + compileOnly(annotationProcessor("net.fabricmc:fabric-loader:0.11.3")) + compileOnly(annotationProcessor("org.apache.logging.log4j:log4j-api:2.17.1")) +} + +processResources { + filesMatching("fabric.mod.json") { + expand("version": project.version, "description": project.description) + } +} diff --git a/fabric/src/main/java/net/raphimc/viaaprilfools/ViaFabricAddon.java b/fabric/src/main/java/net/raphimc/viaaprilfools/ViaFabricAddon.java new file mode 100644 index 0000000..95f31a1 --- /dev/null +++ b/fabric/src/main/java/net/raphimc/viaaprilfools/ViaFabricAddon.java @@ -0,0 +1,51 @@ +/* + * This file is part of ViaAprilFools - https://github.com/RaphiMC/ViaAprilFools + * Copyright (C) 2021-2024 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaaprilfools; + +import net.fabricmc.loader.api.FabricLoader; +import net.raphimc.viaaprilfools.fabric.util.LoggerWrapper; +import net.raphimc.viaaprilfools.platform.ViaAprilFoolsPlatform; +import org.apache.logging.log4j.LogManager; + +import java.io.File; +import java.nio.file.Path; +import java.util.logging.Logger; + +public class ViaFabricAddon implements ViaAprilFoolsPlatform, Runnable { + + private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaRewind")); + private File configDir; + + @Override + public void run() { + final Path configDirPath = FabricLoader.getInstance().getConfigDir().resolve("ViaAprilFools"); + this.configDir = configDirPath.toFile(); + this.init(new File(getDataFolder(), "config.yml")); + } + + @Override + public File getDataFolder() { + return this.configDir; + } + + @Override + public Logger getLogger() { + return this.logger; + } + +} diff --git a/fabric/src/main/java/net/raphimc/viaaprilfools/fabric/util/LoggerWrapper.java b/fabric/src/main/java/net/raphimc/viaaprilfools/fabric/util/LoggerWrapper.java new file mode 100644 index 0000000..32313e6 --- /dev/null +++ b/fabric/src/main/java/net/raphimc/viaaprilfools/fabric/util/LoggerWrapper.java @@ -0,0 +1,91 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2018-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaaprilfools.fabric.util; + +import java.text.MessageFormat; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class LoggerWrapper extends Logger { + + private final org.apache.logging.log4j.Logger base; + + public LoggerWrapper(org.apache.logging.log4j.Logger logger) { + super("logger", null); + this.base = logger; + } + + @Override + public void log(LogRecord record) { + this.log(record.getLevel(), record.getMessage()); + } + + @Override + public void log(Level level, String msg) { + if (level == Level.FINE) { + this.base.debug(msg); + } else if (level == Level.WARNING) { + this.base.warn(msg); + } else if (level == Level.SEVERE) { + this.base.error(msg); + } else if (level == Level.INFO) { + this.base.info(msg); + } else { + this.base.trace(msg); + } + + } + + @Override + public void log(Level level, String msg, Object param1) { + if (level == Level.FINE) { + this.base.debug(msg, param1); + } else if (level == Level.WARNING) { + this.base.warn(msg, param1); + } else if (level == Level.SEVERE) { + this.base.error(msg, param1); + } else if (level == Level.INFO) { + this.base.info(msg, param1); + } else { + this.base.trace(msg, param1); + } + + } + + @Override + public void log(Level level, String msg, Object[] params) { + log(level, MessageFormat.format(msg, params)); + } + + @Override + public void log(Level level, String msg, Throwable params) { + if (level == Level.FINE) { + this.base.debug(msg, params); + } else if (level == Level.WARNING) { + this.base.warn(msg, params); + } else if (level == Level.SEVERE) { + this.base.error(msg, params); + } else if (level == Level.INFO) { + this.base.info(msg, params); + } else { + this.base.trace(msg, params); + } + } + +} \ No newline at end of file diff --git a/fabric/src/main/resources/assets/viaaprilfools/textures/icon.png b/fabric/src/main/resources/assets/viaaprilfools/textures/icon.png new file mode 100644 index 0000000..7fff9b9 Binary files /dev/null and b/fabric/src/main/resources/assets/viaaprilfools/textures/icon.png differ diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..b2a08bc --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,36 @@ +{ + "schemaVersion": 1, + "id": "viaaprilfools", + "name": "ViaAprilFools", + "version": "${version}", + "description": "${description}", + "license": "GPL-3.0", + "contact": { + "homepage": "https://viaversion.com/aprilfools", + "issues": "https://github.com/ViaVersion/ViaAprilFools/issues", + "sources": "https://github.com/ViaVersion/ViaAprilFools" + }, + "icon": "assets/viaaprilfools/textures/icon.png", + "environment": "*", + "authors": [ + "RK_01", + "FlorianMichael/EnZaXD" + ], + "entrypoints": { + "viafabric:via_api_initialized": [ + "net.raphimc.viaaprilfools.ViaFabricAddon" + ] + }, + "depends": { + "fabricloader": ">=0.14.0", + "viafabric": ">=0.4.10", + "viabackwards": ">=5.0.0" + }, + "custom": { + "modmenu:api": true, + "modmenu": { + "badges": [ "library" ], + "parent": "viafabric" + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 298aeb2..ee2a033 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,3 +5,8 @@ org.gradle.configureondemand=true maven_group=net.raphimc maven_name=ViaAprilFools maven_version=3.0.1-SNAPSHOT + +# Smile emoji +mcVersions=1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9, 1.8.8 +mcVersionRange=1.8-1.21 +velocityVersion=3.3 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 17041f0..91cd0ca 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,4 +9,18 @@ plugins { id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0" } -rootProject.name = "ViaAprilFools" +rootProject.name = "viaaprilfools" + +includeBuild("build-logic") + +setupViaSubproject("common") +setupViaSubproject("bukkit") +setupViaSubproject("fabric") +setupViaSubproject("velocity") + +void setupViaSubproject(String name) { + var pName = "viaaprilfools-" + name + + include pName + project(":" + pName).projectDir = file(name) +} diff --git a/velocity/build.gradle b/velocity/build.gradle new file mode 100644 index 0000000..276dc48 --- /dev/null +++ b/velocity/build.gradle @@ -0,0 +1,8 @@ +plugins { + id "vaf.platform-conventions" +} + +dependencies { + compileOnly("com.viaversion:viaversion-velocity:5.0.0") // Needed for logger wrapper + compileOnly(annotationProcessor("com.velocitypowered:velocity-api:3.1.1")) +} diff --git a/velocity/src/main/java/net/raphimc/viaaprilfools/VelocityPlugin.java b/velocity/src/main/java/net/raphimc/viaaprilfools/VelocityPlugin.java new file mode 100644 index 0000000..ff4cfc1 --- /dev/null +++ b/velocity/src/main/java/net/raphimc/viaaprilfools/VelocityPlugin.java @@ -0,0 +1,72 @@ +/* + * This file is part of ViaAprilFools - https://github.com/RaphiMC/ViaAprilFools + * Copyright (C) 2021-2024 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaaprilfools; + +import com.google.inject.Inject; +import com.velocitypowered.api.event.PostOrder; +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; +import com.velocitypowered.api.plugin.Dependency; +import com.velocitypowered.api.plugin.Plugin; +import com.velocitypowered.api.plugin.annotation.DataDirectory; +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.velocity.util.LoggerWrapper; +import net.raphimc.viaaprilfools.platform.ViaAprilFoolsPlatform; + +import java.io.File; +import java.nio.file.Path; +import java.util.logging.Logger; + +@Plugin(id = "viaaprilfools", + name = "ViaAprilFools", + version = ViaAprilFools.VERSION, + authors = {"RK_01", "FlorianMichael/EnZaXD"}, + description = "ViaVersion addon to add support for some notable Minecraft snapshots", + dependencies = { + @Dependency(id = "viaversion"), + @Dependency(id = "viabackwards") + }, + url = "https://viaversion.com/aprilfools" +) +public class VelocityPlugin implements ViaAprilFoolsPlatform { + + private Logger logger; + + @Inject + private org.slf4j.Logger loggerSlf4j; + + @Inject + @DataDirectory + private Path configPath; + + @Subscribe(order = PostOrder.LATE) + public void onProxyStart(ProxyInitializeEvent e) { + this.logger = new LoggerWrapper(loggerSlf4j); + Via.getManager().addEnableListener(() -> this.init(new File(getDataFolder(), "config.yml"))); + } + + @Override + public File getDataFolder() { + return configPath.toFile(); + } + + @Override + public Logger getLogger() { + return this.logger; + } +}