diff --git a/build.gradle b/build.gradle index 464a6257..9a2f2683 100644 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,10 @@ repositories { name 'minecraft' url 'https://libraries.minecraft.net/' } + maven { + name 'gtnh' + url 'https://nexus.gtnewhorizons.com/repository/public/' + } } minecraft { @@ -57,6 +61,7 @@ minecraft { 'https://github.com/juanmuscaria/maven/raw/master', 'https://maven.minecraftforge.net/', 'https://oss.sonatype.org/content/repositories/snapshots/', + 'https://nexus.gtnewhorizons.com/repository/public/', 'https://libraries.minecraft.net/' ] } @@ -81,13 +86,16 @@ configurations { dependencies { // New java stuff + libraries('com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7') { + exclude group: 'org.apache.logging.log4j' + } libraries 'org.apache.commons:commons-lang3:3.12.0' libraries 'org.apache.commons:commons-compress:1.21' - libraries 'org.ow2.asm:asm:9.5' - libraries 'org.ow2.asm:asm-commons:9.5' - libraries 'org.ow2.asm:asm-tree:9.5' - libraries 'org.ow2.asm:asm-analysis:9.5' - libraries 'org.ow2.asm:asm-util:9.5' + libraries 'org.ow2.asm:asm:9.7.1' + libraries 'org.ow2.asm:asm-commons:9.7.1' + libraries 'org.ow2.asm:asm-tree:9.7.1' + libraries 'org.ow2.asm:asm-analysis:9.7.1' + libraries 'org.ow2.asm:asm-util:9.7.1' libraries 'org.ow2.asm:asm-deprecated:7.1' libraries 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.1' libraries "javax.servlet:javax.servlet-api:4.0.1" diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 8f3c8af6..b032666a 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -16,8 +16,8 @@ repositories { dependencies { // TODO? figure a way to use the runtime dependencies of FG? - implementation("org.ow2.asm:asm:9.6") - implementation("org.ow2.asm:asm-tree:9.6") + implementation("org.ow2.asm:asm:9.7.1") + implementation("org.ow2.asm:asm-tree:9.7.1") implementation("com.google.guava:guava:31.1-jre") implementation("com.opencsv:opencsv:5.7.0") implementation("com.cloudbees:diff4j:1.3") @@ -33,7 +33,7 @@ dependencies { implementation("de.oceanlabs.mcp:mcinjector:3.2-SNAPSHOT") implementation("net.minecraftforge:Srg2Source:4.2.7") - api("com.anatawa12.forge:ForgeGradle:1.2-1.1.0") + api("com.anatawa12.forge:ForgeGradle:1.2-1.1.1") testImplementation(platform("org.junit:junit-bom:5.9.1")) testImplementation("org.junit.jupiter:junit-jupiter") diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf0..a4b76b95 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 da1db5f0..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 83f2acfd..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# 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. @@ -15,80 +15,116 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## 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/HEAD/platforms/jvm/plugins-application/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_NAME="Gradle" -APP_BASE_NAME=`basename "$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='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # 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 @@ -97,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - 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. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + 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 location of your Java installation." + fi 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*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + 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" = "true" -o "$msys" = "true" ] ; 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 +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # 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" +# 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"' -# 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")" +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + 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. +# +# 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 9618d8d9..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +27,14 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused 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="-Xmx64m" "-Xms64m" @@ -37,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -51,48 +57,36 @@ 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% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 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 -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/patches/cpw/mods/fml/relauncher/ServerLaunchWrapper.java.patch b/patches/cpw/mods/fml/relauncher/ServerLaunchWrapper.java.patch index 1b058c76..ad258390 100644 --- a/patches/cpw/mods/fml/relauncher/ServerLaunchWrapper.java.patch +++ b/patches/cpw/mods/fml/relauncher/ServerLaunchWrapper.java.patch @@ -19,3 +19,12 @@ new ServerLaunchWrapper().run(args); } +@@ -22,7 +25,7 @@ + Class launchwrapper = null; + try + { +- launchwrapper = Class.forName("net.minecraft.launchwrapper.Launch",true,getClass().getClassLoader()); ++ launchwrapper = Class.forName("com.gtnewhorizons.retrofuturabootstrap.Main",true,getClass().getClassLoader()); + Class.forName("org.objectweb.asm.Type",true,getClass().getClassLoader()); + } + catch (Exception e) diff --git a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch index bafcdcd8..3422e49f 100644 --- a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -976,7 +976,7 @@ + // Spigot Start + if (org.spigotmc.SpigotConfig.logCommands) + { -+ this.logger.info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit ++ this.logger.info("{} issued server command: {}", event.getPlayer().getName(), event.getMessage()); // CraftBukkit + } + + // Spigot end diff --git a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch index fb00694a..9bc44167 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -77,7 +77,7 @@ { private static final String __OBFID = "CL_00001787"; { -@@ -82,31 +100,102 @@ +@@ -82,31 +100,54 @@ }; } @@ -111,7 +111,7 @@ - DedicatedServer.this.addPendingCommand(s4, DedicatedServer.this); + if (useJline) + { -+ s = bufferedreader.readLine(">", null); ++ s = bufferedreader.readLine("", null); + } + else + { @@ -135,59 +135,11 @@ }; thread.setDaemon(true); thread.start(); -+ // CraftBukkit start - TODO: handle command-line logging arguments -+ java.util.logging.Logger global = java.util.logging.Logger.getLogger(""); -+ global.setUseParentHandlers(false); -+ -+ for (java.util.logging.Handler handler : global.getHandlers()) -+ { -+ global.removeHandler(handler); -+ } -+ -+ global.addHandler(new ForwardLogHandler()); -+ -+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()); -+ -+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) -+ { -+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) -+ { -+ logger.removeAppender(appender); -+ } -+ } -+ -+ // Crucible start - go nuclear on all other loggers -+ try { -+ LoggerContext ctx = (LoggerContext) FMLRelaunchLog.log.ctx; -+ Field loggersField = LoggerContext.class.getDeclaredField("loggers"); -+ loggersField.setAccessible(true); -+ @SuppressWarnings("unchecked") -+ ConcurrentMap loggers = -+ (ConcurrentMap) loggersField.get(ctx); -+ for (org.apache.logging.log4j.core.Logger loggerToHack : loggers.values()) { -+ for (org.apache.logging.log4j.core.Appender appender : loggerToHack.getAppenders().values()) -+ { -+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) -+ { -+ loggerToHack.removeAppender(appender); -+ } -+ } -+ } -+ } catch (Throwable e) { -+ System.out.println("[Crucible] Unable to hack other loggers, expect broken and chaotic logs."); -+ e.printStackTrace(); -+ } -+ // Crucible end -+ -+ CrucibleServerMainHook.restoreStreams(); // Crucible - Restores the original streams so System.out does not log to forge logger -+ new Thread(new TerminalConsoleWriterThread(System.out, this.reader)).start(); -+ System.setOut(new PrintStream(new CrucibleTracingLoggerOutputStream(LogManager.getLogger("STDOUT"), Level.INFO), true)); -+ System.setErr(new PrintStream(new CrucibleTracingLoggerOutputStream(LogManager.getLogger("STDERR"), Level.WARN), true)); + // CraftBukkit end field_155771_h.info("Starting minecraft server version 1.7.10"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) -@@ -117,7 +206,7 @@ +@@ -117,7 +158,7 @@ FMLCommonHandler.instance().onServerStart(this); field_155771_h.info("Loading properties"); @@ -196,7 +148,7 @@ this.field_154332_n = new ServerEula(new File("eula.txt")); if (!this.field_154332_n.func_154346_a()) -@@ -172,6 +261,18 @@ +@@ -172,6 +213,18 @@ this.setServerPort(this.settings.getIntProperty("server-port", 25565)); } @@ -215,7 +167,7 @@ field_155771_h.info("Generating keypair"); this.setKeyPair(CryptManager.createNewKeyPair()); field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort()); -@@ -180,7 +281,7 @@ +@@ -180,7 +233,7 @@ { this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort()); } @@ -224,7 +176,7 @@ { field_155771_h.warn("**** FAILED TO BIND TO PORT!"); field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()}); -@@ -196,10 +297,17 @@ +@@ -196,10 +249,17 @@ field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); } @@ -244,7 +196,7 @@ if (!PreYggdrasilConverter.func_152714_a(this.settings)) { -@@ -208,7 +316,8 @@ +@@ -208,7 +268,8 @@ else { FMLCommonHandler.instance().onServerStarted(); @@ -254,7 +206,7 @@ long j = System.nanoTime(); if (this.getFolderName() == null) -@@ -274,11 +383,30 @@ +@@ -274,11 +335,30 @@ this.theRConThreadMain.startThread(); } @@ -285,7 +237,7 @@ public boolean canStructuresSpawn() { return this.canSpawnStructures; -@@ -364,11 +492,19 @@ +@@ -364,11 +444,19 @@ public void executePendingCommands() { diff --git a/patches/org/bukkit/plugin/PluginLogger.java.patch b/patches/org/bukkit/plugin/PluginLogger.java.patch index d19b24a9..7d5d34e1 100644 --- a/patches/org/bukkit/plugin/PluginLogger.java.patch +++ b/patches/org/bukkit/plugin/PluginLogger.java.patch @@ -1,25 +1,42 @@ --- ../src-base/minecraft/org/bukkit/plugin/PluginLogger.java +++ ../src-work/minecraft/org/bukkit/plugin/PluginLogger.java -@@ -22,14 +22,20 @@ +@@ -1,5 +1,7 @@ + package org.bukkit.plugin; + ++import io.github.crucible.JulLogManager; ++ + import java.util.logging.Level; + import java.util.logging.LogRecord; + import java.util.logging.Logger; +@@ -11,8 +13,7 @@ + * + * @see Logger + */ +-public class PluginLogger extends Logger { +- private String pluginName; ++public class PluginLogger extends JulLogManager.JulToLog4jLogger { + + /** + * Creates a new PluginLogger that extracts the name from a plugin. +@@ -20,17 +21,12 @@ + * @param context A reference to the plugin + */ public PluginLogger(Plugin context) { - super(context.getClass().getCanonicalName(), null); - String prefix = context.getDescription().getPrefix(); +- super(context.getClass().getCanonicalName(), null); +- String prefix = context.getDescription().getPrefix(); - pluginName = prefix != null ? new StringBuilder().append("[").append(prefix).append("] ").toString() : "[" + context.getDescription().getName() + "] "; -+ // Crucible start - give plugins a proper prefix for log4j -+ //pluginName = prefix != null ? new StringBuilder().append("[").append(prefix).append("] ").toString() : "[" + context.getDescription().getName() + "] "; -+ pluginName = prefix != null ? prefix : context.getDescription().getName(); -+ // Crucible end - setParent(context.getServer().getLogger()); +- setParent(context.getServer().getLogger()); ++ super(getLoggerName(context)); setLevel(Level.ALL); } - @Override - public void log(LogRecord logRecord) { +- @Override +- public void log(LogRecord logRecord) { - logRecord.setMessage(pluginName + logRecord.getMessage()); -+ // Crucible start - fix log4j prefix -+ //logRecord.setMessage(pluginName + logRecord.getMessage()); -+ logRecord.setLoggerName(pluginName); -+ // Crucible end - super.log(logRecord); +- super.log(logRecord); ++ private static String getLoggerName(Plugin context) { ++ String prefix = context.getDescription().getPrefix(); ++ return prefix != null ? prefix : context.getDescription().getName(); } - +- + } diff --git a/patches/org/bukkit/plugin/java/PluginClassLoader.java.patch b/patches/org/bukkit/plugin/java/PluginClassLoader.java.patch index da70520d..32d14f05 100644 --- a/patches/org/bukkit/plugin/java/PluginClassLoader.java.patch +++ b/patches/org/bukkit/plugin/java/PluginClassLoader.java.patch @@ -1,20 +1,27 @@ --- ../src-base/minecraft/org/bukkit/plugin/java/PluginClassLoader.java +++ ../src-work/minecraft/org/bukkit/plugin/java/PluginClassLoader.java -@@ -1,5 +1,23 @@ +@@ -1,5 +1,30 @@ package org.bukkit.plugin.java; +// Cauldron start ++import com.gtnewhorizons.retrofuturabootstrap.Main; ++import com.gtnewhorizons.retrofuturabootstrap.URLClassLoaderBase; ++import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer; +import net.md_5.specialsource.provider.ClassLoaderProvider; +import net.md_5.specialsource.transformer.MavenShade; +//import org.bouncycastle.util.io.Streams; +import net.md_5.specialsource.*; +import net.md_5.specialsource.repo.*; ++import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.cauldron.CauldronUtils; + +import org.bukkit.craftbukkit.v1_7_R4.CraftServer; +import org.bukkit.plugin.PluginDescriptionFile; +import java.io.*; ++import java.lang.invoke.MethodHandle; ++import java.lang.invoke.MethodHandles; ++import java.lang.reflect.Method; +import java.net.JarURLConnection; +import java.security.CodeSigner; +import java.security.CodeSource; @@ -24,7 +31,11 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; -@@ -10,21 +28,46 @@ +@@ -7,24 +32,68 @@ + import java.util.HashMap; + import java.util.Map; + import java.util.Set; ++import java.util.jar.Manifest; import org.apache.commons.lang.Validate; import org.bukkit.plugin.InvalidPluginException; @@ -35,6 +46,22 @@ */ -final class PluginClassLoader extends URLClassLoader { +public class PluginClassLoader extends URLClassLoader { ++ private static final LaunchClassLoader launchClassLoader = (LaunchClassLoader) PluginClassLoader.class.getClassLoader(); ++ private static final MethodHandle runTransformersMH; ++ ++ static { ++ MethodHandle runTransformersMHTmp; ++ try { ++ Method method = LaunchClassLoader.class.getDeclaredMethod("runTransformers", String.class, String.class, byte[].class); ++ method.setAccessible(true); ++ runTransformersMHTmp = MethodHandles.lookup().unreflect(method); ++ } catch (NoSuchMethodException | IllegalAccessException e) { ++ e.printStackTrace(); ++ runTransformersMHTmp = null; ++ } ++ runTransformersMH = runTransformersMHTmp; ++ } ++ + public JavaPlugin getPlugin() { return plugin; } // Spigot private final JavaPluginLoader loader; - private final Map> classes = new HashMap>(); @@ -51,6 +78,8 @@ + private RemapperProcessor remapperProcessor; // secondary; for inheritance & remapping reflection + private boolean debug; // classloader debugging + private int remapFlags = -1; ++ private boolean runRfbTransformers; ++ private boolean runLwTransformers; + private static ConcurrentMap jarMappings = new ConcurrentHashMap(); + private static final int F_GLOBAL_INHERIT = 1 << 1; @@ -75,7 +104,7 @@ PluginClassLoader(final JavaPluginLoader loader, final ClassLoader parent, final PluginDescriptionFile description, final File dataFolder, final File file) throws InvalidPluginException, MalformedURLException { super(new URL[] {file.toURI().toURL()}, parent); Validate.notNull(loader, "Loader cannot be null"); -@@ -34,6 +77,116 @@ +@@ -34,6 +103,119 @@ this.dataFolder = dataFolder; this.file = file; @@ -104,6 +133,8 @@ + boolean reflectClass = MinecraftServer.cauldronConfig.getBoolean("plugin-settings.default.remap-reflect-class", true); + boolean allowFuture = MinecraftServer.cauldronConfig.getBoolean("plugin-settings.default.remap-allow-future", false); + boolean remapGuava = MinecraftServer.cauldronConfig.getBoolean("plugin-settings.default.remap-guava", true); ++ runRfbTransformers = MinecraftServer.cauldronConfig.getBoolean("plugin-settings.default.rfb-transformers", true); ++ runLwTransformers = MinecraftServer.cauldronConfig.getBoolean("plugin-settings.default.lw-transformers", false); + + // plugin-specific overrides + useCustomClassLoader = MinecraftServer.cauldronConfig.getBoolean("plugin-settings."+pluginName+".custom-class-loader", useCustomClassLoader, false); @@ -126,73 +157,74 @@ + reflectClass = MinecraftServer.cauldronConfig.getBoolean("plugin-settings."+pluginName+".remap-reflect-class", reflectClass, false); + allowFuture = MinecraftServer.cauldronConfig.getBoolean("plugin-settings."+pluginName+".remap-allow-future", allowFuture, false); + remapGuava = MinecraftServer.cauldronConfig.getBoolean("plugin-settings."+pluginName+".remap-guava", remapGuava, false); ++ runRfbTransformers = MinecraftServer.cauldronConfig.getBoolean("plugin-settings."+pluginName+".rfb-transformers", runRfbTransformers, false); ++ runLwTransformers = MinecraftServer.cauldronConfig.getBoolean("plugin-settings."+pluginName+".lw-transformers", runLwTransformers, false); + + if (debug) { + System.out.println("PluginClassLoader debugging enabled for "+pluginName); + } + -+ if (!useCustomClassLoader) { -+ remapper = null; -+ return; -+ } -+ -+ int flags = 0; -+ if (remapNMS1710) flags |= F_REMAP_NMS1710; -+ if (remapNMS179) flags |= F_REMAP_NMS179; -+ if (remapNMS172) flags |= F_REMAP_NMS172; -+ if (remapNMS164) flags |= F_REMAP_NMS164; -+ if (remapNMS152) flags |= F_REMAP_NMS152; -+ if (!remapNMSPre.equals("false")) { -+ if (remapNMSPre.equals("1.7.10")) flags |= 0x17100000; -+ else if (remapNMSPre.equals("1.7.9")) flags |= 0x01790000; -+ else if (remapNMSPre.equals("1.7.2")) flags |= 0x01720000; -+ else if (remapNMSPre.equals("1.6.4")) flags |= 0x01640000; -+ else if (remapNMSPre.equals("1.5.2")) flags |= 0x01520000; -+ else { -+ System.out.println("Unsupported nms-remap-pre version '"+remapNMSPre+"', disabling"); ++ if (useCustomClassLoader) { ++ int flags = 0; ++ if (remapNMS1710) flags |= F_REMAP_NMS1710; ++ if (remapNMS179) flags |= F_REMAP_NMS179; ++ if (remapNMS172) flags |= F_REMAP_NMS172; ++ if (remapNMS164) flags |= F_REMAP_NMS164; ++ if (remapNMS152) flags |= F_REMAP_NMS152; ++ if (!remapNMSPre.equals("false")) { ++ if (remapNMSPre.equals("1.7.10")) flags |= 0x17100000; ++ else if (remapNMSPre.equals("1.7.9")) flags |= 0x01790000; ++ else if (remapNMSPre.equals("1.7.2")) flags |= 0x01720000; ++ else if (remapNMSPre.equals("1.6.4")) flags |= 0x01640000; ++ else if (remapNMSPre.equals("1.5.2")) flags |= 0x01520000; ++ else { ++ System.out.println("Unsupported nms-remap-pre version '"+remapNMSPre+"', disabling"); ++ } + } -+ } -+ if (remapOBC1710) flags |= F_REMAP_OBC1710; -+ if (remapOBC179) flags |= F_REMAP_OBC179; -+ if (remapOBC172) flags |= F_REMAP_OBC172; -+ if (remapOBC164) flags |= F_REMAP_OBC164; -+ if (remapOBC152) flags |= F_REMAP_OBC152; -+ if (remapOBCPre) flags |= F_REMAP_OBCPRE; -+ if (remapGuava) flags |= F_REMAP_GUAVA; -+ if (globalInherit) flags |= F_GLOBAL_INHERIT; -+ -+ remapFlags = flags; // used in findClass0 -+ JarMapping jarMapping = getJarMapping(flags); -+ -+ // Load inheritance map -+ if ((flags & F_GLOBAL_INHERIT) != 0) { -+ if (debug) { -+ System.out.println("Enabling global inheritance remapping"); -+ //ClassLoaderProvider.verbose = debug; // TODO: changed in https://github.com/md-5/SpecialSource/commit/132584eda4f0860c9d14f4c142e684a027a128b8#L3L48 ++ if (remapOBC1710) flags |= F_REMAP_OBC1710; ++ if (remapOBC179) flags |= F_REMAP_OBC179; ++ if (remapOBC172) flags |= F_REMAP_OBC172; ++ if (remapOBC164) flags |= F_REMAP_OBC164; ++ if (remapOBC152) flags |= F_REMAP_OBC152; ++ if (remapOBCPre) flags |= F_REMAP_OBCPRE; ++ if (remapGuava) flags |= F_REMAP_GUAVA; ++ if (globalInherit) flags |= F_GLOBAL_INHERIT; ++ ++ remapFlags = flags; // used in findClass0 ++ JarMapping jarMapping = getJarMapping(flags); ++ ++ // Load inheritance map ++ if ((flags & F_GLOBAL_INHERIT) != 0) { ++ if (debug) { ++ System.out.println("Enabling global inheritance remapping"); ++ //ClassLoaderProvider.verbose = debug; // TODO: changed in https://github.com/md-5/SpecialSource/commit/132584eda4f0860c9d14f4c142e684a027a128b8#L3L48 ++ } ++ jarMapping.setInheritanceMap(loader.getGlobalInheritanceMap()); ++ jarMapping.setFallbackInheritanceProvider(new ClassLoaderProvider(this)); + } -+ jarMapping.setInheritanceMap(loader.getGlobalInheritanceMap()); -+ jarMapping.setFallbackInheritanceProvider(new ClassLoaderProvider(this)); -+ } + -+ remapper = new thermos.ThermosRemapper(jarMapping); ++ remapper = new thermos.ThermosRemapper(jarMapping); + -+ if (pluginInherit || reflectFields || reflectClass) { -+ remapperProcessor = new RemapperProcessor( -+ pluginInherit ? loader.getGlobalInheritanceMap() : null, -+ (reflectFields || reflectClass) ? jarMapping : null); ++ if (pluginInherit || reflectFields || reflectClass) { ++ remapperProcessor = new RemapperProcessor( ++ pluginInherit ? loader.getGlobalInheritanceMap() : null, ++ (reflectFields || reflectClass) ? jarMapping : null); + -+ remapperProcessor.setRemapReflectField(reflectFields); -+ remapperProcessor.setRemapReflectClass(reflectClass); -+ remapperProcessor.debug = debug; -+ } else { -+ remapperProcessor = null; ++ remapperProcessor.setRemapReflectField(reflectFields); ++ remapperProcessor.setRemapReflectClass(reflectClass); ++ remapperProcessor.debug = debug; ++ } else { ++ remapperProcessor = null; ++ } + } ++ ++ + // Cauldron end + try { Class jarClass; try { -@@ -58,34 +211,288 @@ +@@ -58,34 +240,313 @@ } @Override @@ -378,9 +410,22 @@ + if (name.startsWith("net.minecraft.")) + { + JarMapping jarMapping = this.getJarMapping(remapFlags); // grab from SpecialSource -+ String remappedClass = jarMapping.classes.get(name.replaceAll("\\.", "\\/")); // get remapped pkgmcp class name -+ Class clazz = ((net.minecraft.launchwrapper.LaunchClassLoader)MinecraftServer.getServer().getClass().getClassLoader()).findClass(remappedClass); -+ return clazz; ++ String remappedClass = jarMapping.classes.get(name.replace('.', '/')); // get remapped pkgmcp class name ++ if(remappedClass == null) { ++ throw new ClassNotFoundException(name); ++ } ++ try { ++ Class clazz = ((net.minecraft.launchwrapper.LaunchClassLoader)MinecraftServer.getServer().getClass().getClassLoader()).findClass(remappedClass); ++ if(debug) { ++ System.out.printf("Found class %s (remapped to %s, found %s)\n", name, remappedClass, clazz.getName()); ++ } ++ return clazz; ++ } catch (Throwable e) { ++ if(debug) { ++ System.out.printf("Not found class %s (remapped %s)\n", name, remappedClass); ++ } ++ throw e; ++ } + } + if (name.startsWith("org.bukkit.")) { + if (debug) { @@ -399,7 +444,7 @@ + } + if (result == null) { -+ if (remapper == null) { ++ if (remapper == null && !runRfbTransformers && !runLwTransformers) { + result = super.findClass(name); + } else { + result = remappedFindClass(name); @@ -442,13 +487,28 @@ + bytecode = remapperProcessor.process(stream); + if (bytecode == null) stream = url.openStream(); + } ++ JarURLConnection jarURLConnection = (JarURLConnection) url.openConnection(); // parses only ++ URL jarURL = jarURLConnection.getJarFileURL(); ++ CodeSource codeSource = new CodeSource(jarURL, new CodeSigner[0]); ++ Manifest manifest = jarURLConnection.getManifest(); + -+ /*if (bytecode == null) { -+ bytecode = Streams.readAll(stream); -+ }*/ ++ if (bytecode == null) { ++ bytecode = URLClassLoaderBase.readAllBytes(stream, null); ++ } + + // Remap the classes -+ byte[] remappedBytecode = remapper.remapClassFile(bytecode, RuntimeRepo.getInstance()); ++ byte[] remappedBytecode = bytecode; ++ if(remapper != null) { ++ remappedBytecode = remapper.remapClassFile(bytecode, RuntimeRepo.getInstance()); ++ } ++ if(runLwTransformers) { ++ remappedBytecode = (byte[]) runTransformersMH.invoke(launchClassLoader, name, name, remappedBytecode); ++ } ++ if(runRfbTransformers) { ++ remappedBytecode = launchClassLoader.runRfbTransformers( ++ Main.getRfbTransformers(), runLwTransformers ? RfbClassTransformer.Context.LCL_WITH_TRANSFORMS : RfbClassTransformer.Context.LCL_NO_TRANSFORMS, ++ manifest, name, remappedBytecode); ++ } + + if (debug) { + File file = new File("remapped-plugin-classes/"+name+".class"); @@ -462,15 +522,12 @@ + } + } + ++ + // Define (create) the class using the modified byte code + // The top-child class loader is used for this to prevent access violations + // Set the codesource to the jar, not within the jar, for compatibility with + // plugins that do new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI())) + // instead of using getResourceAsStream - see https://github.com/MinecraftPortCentral/Cauldron-Plus/issues/75 -+ JarURLConnection jarURLConnection = (JarURLConnection) url.openConnection(); // parses only -+ URL jarURL = jarURLConnection.getJarFileURL(); -+ CodeSource codeSource = new CodeSource(jarURL, new CodeSigner[0]); -+ + result = this.defineClass(name, remappedBytecode, 0, remappedBytecode.length, codeSource); + if (result != null) { + // Resolve it - sets the class loader of the class diff --git a/src/main/java/io/github/crucible/JulLogManager.java b/src/main/java/io/github/crucible/JulLogManager.java new file mode 100644 index 00000000..8a61ac4f --- /dev/null +++ b/src/main/java/io/github/crucible/JulLogManager.java @@ -0,0 +1,247 @@ +package io.github.crucible; + +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.message.MessageFactory; + +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +/** + * Backport and simplify log4j2-jul + */ +public class JulLogManager extends LogManager { + + @Override + public boolean addLogger(Logger logger) { + return false; + } + + @Override + public Logger getLogger(String name) { + try { + return new JulToLog4jLogger(name); + } catch (Throwable e) { + return new JulNoopLogger(name); + } + } + + public static class JulNoopLogger extends Logger { + + protected JulNoopLogger(String name) { + super(name, null); + } + } + + public static class JulToLog4jLogger extends Logger { + private final org.apache.logging.log4j.Logger logger; + + public JulToLog4jLogger(String name) { + super(name, null); + this.logger = org.apache.logging.log4j.LogManager.getLogger(name); + } + + @Override + public void log(LogRecord record) { + final org.apache.logging.log4j.Level level = convertLevel(record.getLevel()); + final Object[] parameters = record.getParameters(); + final MessageFactory messageFactory = logger.getMessageFactory(); + final Message message = parameters == null + ? messageFactory.newMessage(record.getMessage()) + : messageFactory.newMessage(record.getMessage(), parameters); + final Throwable thrown = record.getThrown(); + logger.log(level, null, message, thrown); + } + + @Override + public boolean isLoggable(Level level) { + return logger.isEnabled(convertLevel(level)); + } + + @Override + public String getName() { + return super.getName(); + } + + @Override + public Level getLevel() { + return super.getLevel(); + } + + @Override + public void setLevel(Level newLevel) throws SecurityException { + super.setLevel(newLevel); + } + + public org.apache.logging.log4j.Level convertLevel(Level level) { + if(level == Level.ALL) { + return org.apache.logging.log4j.Level.ALL; + } + if(level == Level.FINEST || level == Level.FINER) { + return org.apache.logging.log4j.Level.TRACE; + } + if(level == Level.FINE) { + return org.apache.logging.log4j.Level.DEBUG; + } + if(level == Level.INFO) { + return org.apache.logging.log4j.Level.INFO; + } + if(level == Level.WARNING) { + return org.apache.logging.log4j.Level.WARN; + } + if(level == Level.SEVERE) { + return org.apache.logging.log4j.Level.ERROR; + } + return org.apache.logging.log4j.Level.TRACE; + } + + @Override + public void setParent(final Logger parent) { + logger.warn("Logger.setParent() not supported by jul-to-log4j LogManager. Logs may be broken"); + } + + @Override + public Logger getParent() { + final org.apache.logging.log4j.core.Logger parent = ((org.apache.logging.log4j.core.Logger)logger).getParent(); + return parent == null ? null : Logger.getLogger(parent.getName()); + } + + @Override + public void log(final Level level, final String msg) { + logger.log(convertLevel(level), msg); + } + + @Override + public void log(final Level level, final String msg, final Object param1) { + logger.log(convertLevel(level), msg, param1); + } + + @Override + public void log(final Level level, final String msg, final Object[] params) { + logger.log(convertLevel(level), msg, params); + } + + @Override + public void log(final Level level, final String msg, final Throwable thrown) { + logger.log(convertLevel(level), msg, thrown); + } + + @Override + public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg) { + log(level, msg); + } + + @Override + public void logp( + final Level level, + final String sourceClass, + final String sourceMethod, + final String msg, + final Object param1) { + log(level, msg, param1); + } + + @Override + public void logp( + final Level level, + final String sourceClass, + final String sourceMethod, + final String msg, + final Object[] params) { + log(level, msg, params); + } + + @Override + public void logp( + final Level level, + final String sourceClass, + final String sourceMethod, + final String msg, + final Throwable thrown) { + log(level, msg, thrown); + } + + @Override + public void logrb( + final Level level, + final String sourceClass, + final String sourceMethod, + final String bundleName, + final String msg) { + log(level, msg); + } + + @Override + public void logrb( + final Level level, + final String sourceClass, + final String sourceMethod, + final String bundleName, + final String msg, + final Object param1) { + log(level, msg, param1); + } + + @Override + public void logrb( + final Level level, + final String sourceClass, + final String sourceMethod, + final String bundleName, + final String msg, + final Object[] params) { + log(level, msg, params); + } + + @Override + public void logrb( + final Level level, + final String sourceClass, + final String sourceMethod, + final String bundleName, + final String msg, + final Throwable thrown) { + log(level, msg, thrown); + } + + @Override + public void throwing(final String sourceClass, final String sourceMethod, final Throwable thrown) { + logger.throwing(thrown); + } + + @Override + public void severe(final String msg) { + logger.log(org.apache.logging.log4j.Level.ERROR, null, msg); + } + + @Override + public void warning(final String msg) { + logger.log(org.apache.logging.log4j.Level.WARN, null, msg); + } + + @Override + public void info(final String msg) { + logger.log(org.apache.logging.log4j.Level.INFO, null, msg); + } + + @Override + public void config(final String msg) { + logger.log(org.apache.logging.log4j.Level.INFO, null, msg); + } + + @Override + public void fine(final String msg) { + logger.log(org.apache.logging.log4j.Level.DEBUG, null, msg); + } + + @Override + public void finer(final String msg) { + logger.log(org.apache.logging.log4j.Level.TRACE, null, msg); + } + + @Override + public void finest(final String msg) { + logger.log(org.apache.logging.log4j.Level.TRACE, null, msg); + } + } +} diff --git a/src/main/java/io/github/crucible/bootstrap/CrucibleServerMainHook.java b/src/main/java/io/github/crucible/bootstrap/CrucibleServerMainHook.java index 05c1fdc9..87d6d167 100644 --- a/src/main/java/io/github/crucible/bootstrap/CrucibleServerMainHook.java +++ b/src/main/java/io/github/crucible/bootstrap/CrucibleServerMainHook.java @@ -21,7 +21,8 @@ public class CrucibleServerMainHook { "https://github.com/juanmuscaria/maven/raw/master/ThermosLibs/", "https://maven.minecraftforge.net/", "https://libraries.minecraft.net/", - "https://repo.maven.apache.org/maven2/" + "https://repo.maven.apache.org/maven2/", + "https://nexus.gtnewhorizons.com/repository/public/" }; private static final Path LIBRARY_ROOT = Paths.get("libraries").toAbsolutePath(); public static final PrintStream originalOut = System.out; @@ -54,6 +55,11 @@ public static void relaunchMain(String[] args) throws Exception { Lwjgl3ifyGlue.checkJava(); + if(System.getProperty("java.class.loader") == null) { + System.setProperty("rfb.skipClassLoaderCheck", "true"); + } + System.setProperty("java.util.logging.manager", "io.github.crucible.JulLogManager"); + if (!verifyLibraries()) { setupLibraries(); System.out.println("[Crucible] Crucible installed! A restart is required to be able to boot."); diff --git a/src/main/java/org/bukkit/craftbukkit/v1_7_R4/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/v1_7_R4/util/TerminalConsoleWriterThread.java index bacb52ae..e1e3422a 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_7_R4/util/TerminalConsoleWriterThread.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_7_R4/util/TerminalConsoleWriterThread.java @@ -26,7 +26,7 @@ public TerminalConsoleWriterThread(OutputStream output, ConsoleReader reader) { @SuppressWarnings("unchecked") Map> instance = (Map>) queues.get(null); instance.get("TerminalConsole").clear(); - } catch (ReflectiveOperationException e) { + } catch (ReflectiveOperationException | NullPointerException e) { e.printStackTrace(); } // Crucible end