From 42a3967f1994b8c2806e1ff3abd3de92be653c4d Mon Sep 17 00:00:00 2001 From: Aizistral Date: Sat, 18 Jun 2022 18:06:33 +0200 Subject: I figured it out --- .github/workflows/build.yml | 39 +++ .gitignore | 57 +++-- README.md | 9 + build.gradle | 266 ++++--------------- docs/META-INF/mods.toml | 27 -- docs/README.md | 9 - docs/changelog.html | 6 - gradle.properties | 40 +-- gradle/wrapper/gradle-wrapper.jar | Bin 54708 -> 59536 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 282 +++++++++++++-------- gradlew.bat | 43 ++-- settings.gradle | 10 + .../aizistral/nochatreports/MixinConnector.java | 13 - .../com/aizistral/nochatreports/NoChatReports.java | 79 ++---- .../nochatreports/NoChatReportsClient.java | 35 +++ .../nochatreports/handlers/NoReportsConfig.java | 6 +- .../network/ClientChannelHandler.java | 26 ++ .../network/ServerChannelHandler.java | 22 ++ src/main/resources/META-INF/MANIFEST.MF | 1 - src/main/resources/META-INF/mods.toml | 12 - .../resources/assets/nochatreports/lang/en_us.json | 4 +- src/main/resources/fabric.mod.json | 39 +++ src/main/resources/pack.mcmeta | 6 - 24 files changed, 501 insertions(+), 532 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 README.md delete mode 100644 docs/META-INF/mods.toml delete mode 100644 docs/README.md delete mode 100644 docs/changelog.html create mode 100644 settings.gradle delete mode 100644 src/main/java/com/aizistral/nochatreports/MixinConnector.java create mode 100644 src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java create mode 100644 src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java create mode 100644 src/main/java/com/aizistral/nochatreports/network/ServerChannelHandler.java delete mode 100644 src/main/resources/META-INF/MANIFEST.MF delete mode 100644 src/main/resources/META-INF/mods.toml create mode 100644 src/main/resources/fabric.mod.json delete mode 100644 src/main/resources/pack.mcmeta diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1fc365f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [ + 17, # Current Java LTS & minimum supported by Minecraft + ] + # and run on both Linux and Windows + os: [ubuntu-20.04, windows-2022] + runs-on: ${{ matrix.os }} + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs/ diff --git a/.gitignore b/.gitignore index 4981644..4765959 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,37 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + # eclipse -bin + *.launch -.settings -.metadata -.classpath -.project # idea -out + +.idea/ +*.iml *.ipr *.iws -*.iml -.idea -# gradle -build -.gradle - -# other -eclipse -run - -# Aizistral -.apt_generated -logs -omniconfig_first -*works -Users -.factorypath -deps/Soulbound* -multiuser_args.txt -old_enigmatic_desc.txt -**/TestEventHandler* \ No newline at end of file +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# Because shenanigans +gradlew.bat +gradlew diff --git a/README.md b/README.md new file mode 100644 index 0000000..92fe8f4 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# No Chat Reports + +**Current Version:** 1.19-v1.0.0 + +**Minecraft Version:** 1.19.x + +**Forge Version:** 41.0.0 or later. + +Strips cryptographic signatures from player messages, making it impossible to track and associate them with your Mojang/Microsoft account, as well as use Player Chat Reporting feature. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2af6f08..b027b04 100644 --- a/build.gradle +++ b/build.gradle @@ -1,243 +1,77 @@ -buildscript { - repositories { - mavenLocal() - maven { url = 'https://maven.minecraftforge.net' } - maven { url = 'https://dist.creeper.host/Sponge/maven' } - maven { url 'https://plugins.gradle.org/m2/' } - mavenCentral() - maven { - url = 'https://repo.spongepowered.org/repository/maven-public/' - content { includeGroup "org.spongepowered" } - } - maven { - name "Gradle Plugin Portal" - url 'https://plugins.gradle.org/m2/' - content { - includeGroup "gradle.plugin.com.matthewprenger" - includeGroup "com.modrinth" - } - } - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0' - classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT' - } -} - plugins { - id "com.modrinth.minotaur" version "2.+" + id 'fabric-loom' version '0.12-SNAPSHOT' + id 'maven-publish' } -println("Applying plugins...") - -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' -apply plugin: 'com.matthewprenger.cursegradle' -apply plugin: 'org.spongepowered.mixin' - -println("Specifying project version/group/archivesBaseName...") -version = "${mod_version}" -group = "${mod_group}" -archivesBaseName = "${mod_archives_name}" - - -println("Specifying Java compatibility...") -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -println("Java Installation Data:") -println(" - Java Version: " + System.getProperty('java.version')) -println(" - JVM Version: " + System.getProperty('java.vm.version')) -println(" - Vendor: " + System.getProperty('java.vendor')) -println(" - OS Archetype: " + System.getProperty('os.arch')) - -mixin { - println("Specifying refmaps for Mixin...") - - add sourceSets.main, "nochatreports.refmap.json" -} +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 -minecraft { - println("Specifying MCP mappings...") - mappings channel: 'official', version: '1.19' - println("Specifying Access Transformer configuration...") - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - runs { - client { - properties 'org.gradle.jvmargs': '-Xms4G -Xmx4G' - properties 'fml.earlyprogresswindow': 'false' - properties 'mixin.env.disableRefMap': 'true' - workingDirectory project.file('run') - - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - - mods { - nochatreports { - source sourceSets.main - } - } - } - - server { - properties 'mixin.env.disableRefMap': 'true' - workingDirectory project.file('run') - - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - - mods { - nochatreports { - source sourceSets.main - } - } - } - } -} - -sourceSets.main.resources { - // NO-OP -} +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group repositories { - println("Specifying repositories...") - flatDir { dirs 'deps' } - maven { url = "https://maven.theillusivec4.top/" } // curios - maven { url = "https://maven.blamejared.com/" } // patchouli - maven { url = "https://repo.spongepowered.org/maven" } // mixin - maven { url "https://dvs1.progwml6.com/files/maven/" } // no idea + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. } dependencies { - println("Processing dependencies...") - - // Minecraft & Forge - minecraft "net.minecraftforge:forge:${version_forge}" - - annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' - annotationProcessor 'com.google.code.gson:gson:2.8.0' - annotationProcessor 'com.google.guava:guava:21.0' - annotationProcessor 'org.ow2.asm:asm-tree:7.2' - annotationProcessor 'org.ow2.asm:asm-commons:7.2' - annotationProcessor 'org.ow2.asm:asm-util:7.2' -} + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings loom.officialMojangMappings() + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" -jar { - println("Processing manifest...") + // Uncomment the following line to enable the deprecated Fabric API modules. + // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. - manifest { - attributes([ - "Specification-Title": "${mod_name}", - "Specification-Vendor": "${mod_author}", - "Specification-Version": "${mod_version}", - "Implementation-Title": "${mod_name}", - "Implementation-Version": "${mod_version}", - "Implementation-Vendor" :"${mod_author}", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - "MixinConnector": "${project.group}.MixinConnector" - ]) - } + // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" } processResources { - println("Processing resources...") - - exclude 'META-INF/mods.toml' - - from("${project.projectDir}/docs/META-INF") { - println("Inflating mods.toml...") - - // Replace properties in mods.toml with ones derived from settings.gradle - include 'mods.toml' - expand 'mod_license': mod_license, - 'mod_version': project.version, - 'mod_id' : mod_id, - 'mod_name': mod_name, - 'mod_url': mod_url, - 'mod_author': mod_author, - 'mod_description': mod_description, - 'mod_icon': mod_icon, - 'issue_tracker_url': issue_tracker_url, - 'mod_credits': mod_credits, - 'dep_forge': dep_forge, - 'dep_minecraft': dep_minecraft - into 'META-INF' - } + inputs.property "version", project.version - from("${project.projectDir}/docs") { - include 'changelog.html' - } - - from("${project.projectDir}") { - include 'LICENSE' + filesMatching("fabric.mod.json") { + expand "version": project.version } } -curseforge { - - project { - println("Pushing CurseGradle specifications for project ID: ${curse_id}") - - // Specified as cmd argument - apiKey = findProperty('curseKey') ?: 0 - - id = "${curse_id}" - releaseType = "${curse_release}" - changelogType = 'html' - changelog = file('docs/changelog.html') - - addGameVersion '1.19' - - //addArtifact(sourcesJar) - //addArtifact(apiJar) - } -} - -modrinth { - token = findProperty('modrinthKey') ?: 0 - projectId = "qQyHxfxd" - versionNumber = project.version - versionName = "No Chat Reports" + project.version - versionType = "release" - changelog = rootProject.file("docs/changelog.html").text - uploadFile = jar - gameVersions = ["1.19"] - - //syncBodyFrom = rootProject.file("docs/README.md").text +tasks.withType(JavaCompile).configureEach { + // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. + it.options.release = 17 } -task upload { - dependsOn('modrinth') - dependsOn('curseforge') +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + // withSourcesJar() } - -task updateResources() { - // NO-OP -} - -tasks.updateResources.dependsOn processResources - -tasks.withType(JavaCompile) { - options.failOnError(true) +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } } -jar.finalizedBy('reobfJar') -//publish.dependsOn('reobfJar') - +// configure the maven publication publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { - url "file:///${project.projectDir}/mcmodsrepo" - } - } -} \ No newline at end of file + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} diff --git a/docs/META-INF/mods.toml b/docs/META-INF/mods.toml deleted file mode 100644 index c8d50fb..0000000 --- a/docs/META-INF/mods.toml +++ /dev/null @@ -1,27 +0,0 @@ -license="${mod_license}" -modLoader="javafml" -loaderVersion="[31,)" -issueTrackerURL="${issue_tracker_url}" -[[mods]] -modId="${mod_id}" -version="${mod_version}" -displayName="${mod_name}" -displayURL="${mod_url}" -logoFile="${mod_icon}" -credits="${mod_credits}" -authors="${mod_author}" -description=''' -${mod_description} -''' -[[dependencies.${mod_id}]] - modId="forge" - mandatory=true - versionRange="${dep_forge}" - ordering="NONE" - side="BOTH" -[[dependencies.${mod_id}]] - modId="minecraft" - mandatory=true - versionRange="${dep_minecraft}" - ordering="NONE" - side="BOTH" diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 92fe8f4..0000000 --- a/docs/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# No Chat Reports - -**Current Version:** 1.19-v1.0.0 - -**Minecraft Version:** 1.19.x - -**Forge Version:** 41.0.0 or later. - -Strips cryptographic signatures from player messages, making it impossible to track and associate them with your Mojang/Microsoft account, as well as use Player Chat Reporting feature. \ No newline at end of file diff --git a/docs/changelog.html b/docs/changelog.html deleted file mode 100644 index bd11633..0000000 --- a/docs/changelog.html +++ /dev/null @@ -1,6 +0,0 @@ -
- - Initial release. -
diff --git a/gradle.properties b/gradle.properties index 821928e..eb4ea09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,32 +1,18 @@ -# Gradle -org.gradle.jvmargs=-Xmx4G +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx2G org.gradle.daemon=false -# Mod -mod_version=1.19-v1.0.0 -mod_group=com.aizistral.nochatreports -mod_id=nochatreports -mod_name=No Chat Reports -mod_archives_name=NoChatReports-FORGE -mod_url=https://www.curseforge.com/minecraft/mc-mods/no-chat-reports -issue_tracker_url=https://github.com/Aizistral-Studious/No-Chat-Reports/issues -mod_author=Aizistral -mod_description=Simple mod that disables chat reports. -mod_credits=Me, for making such an amazing mod. +# Fabric Properties + # check these on https://fabricmc.net/develop + minecraft_version=1.19 + yarn_mappings=1.19+build.4 + loader_version=0.14.8 -mod_icon=NCR_logo.png -mod_license=WTFPL +# Mod Properties + mod_version=FABRIC-v1.0.0 + maven_group=com.aizistral.nochatreports + archives_base_name=NoChatReports -# Dependency specifications for mods.toml -dep_forge=[37,) -dep_minecraft=[1.19,1.19.1) - -# Dependencies specifications for build.gradle -version_mc=1.19 -version_forge=1.19-41.0.35 -version_mcp=1.19 - -# CurseGradle -curse_id=634062 -curse_release=release \ No newline at end of file +# Dependencies + fabric_version=0.56.0+1.19 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e7fa367..41dfb87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..c53aefa 100644 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (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 +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..b02216b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} diff --git a/src/main/java/com/aizistral/nochatreports/MixinConnector.java b/src/main/java/com/aizistral/nochatreports/MixinConnector.java deleted file mode 100644 index dc2b9a6..0000000 --- a/src/main/java/com/aizistral/nochatreports/MixinConnector.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.aizistral.nochatreports; - -import org.spongepowered.asm.mixin.Mixins; -import org.spongepowered.asm.mixin.connect.IMixinConnector; - -public class MixinConnector implements IMixinConnector { - - @Override - public void connect() { - Mixins.addConfigurations("nochatreports.mixins.json"); - } - -} diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReports.java b/src/main/java/com/aizistral/nochatreports/NoChatReports.java index adaf08b..d45c5e8 100644 --- a/src/main/java/com/aizistral/nochatreports/NoChatReports.java +++ b/src/main/java/com/aizistral/nochatreports/NoChatReports.java @@ -1,70 +1,41 @@ package com.aizistral.nochatreports; -import java.util.function.Predicate; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.aizistral.nochatreports.handlers.NoReportsConfig; - +import com.aizistral.nochatreports.network.ServerChannelHandler; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.networking.v1.PacketSender; +import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.network.NetworkRegistry; -import net.minecraftforge.network.simple.SimpleChannel; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; -@Mod(NoChatReports.MODID) -public class NoChatReports { - public static final String MODID = "nochatreports"; +public class NoChatReports implements ModInitializer { public static final Logger LOGGER = LogManager.getLogger(); - private static final String PTC_VERSION = "1"; - private static final Predicate