big bang
This commit is contained in:
commit
48c2fd2977
23 changed files with 1293 additions and 0 deletions
203
build.gradle.kts
Normal file
203
build.gradle.kts
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
import org.jetbrains.gradle.ext.ProjectSettings
|
||||||
|
import org.jetbrains.gradle.ext.TaskTriggersConfig
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
kotlin("plugin.serialization")
|
||||||
|
id("fabric-loom")
|
||||||
|
`maven-publish`
|
||||||
|
eclipse
|
||||||
|
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||||
|
}
|
||||||
|
|
||||||
|
val mavenVersion = System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } ?: "0.0.0-SNAPSHOT"
|
||||||
|
val modId: String by project
|
||||||
|
val modName: String by project
|
||||||
|
|
||||||
|
val mavenGroup: String by project
|
||||||
|
val mavenArtifact: String by project
|
||||||
|
|
||||||
|
val minecraftVersion = project.ext["minecraft.version"] as String
|
||||||
|
val yarnMappings = project.ext["yarn.version"] as String
|
||||||
|
val fabricLoaderVersion = project.ext["fabric.loader.version"] as String
|
||||||
|
|
||||||
|
val fabricApiVersion = project.ext["fabric.api.version"] as String
|
||||||
|
val fabricKotlinVersion = project.ext["fabric.kotlin.version"] as String
|
||||||
|
val serializationVersion = project.ext["kotlinx.serialization.version"] as String
|
||||||
|
val configlibVersion = project.ext["configlib.version"] as String
|
||||||
|
|
||||||
|
version = mavenVersion
|
||||||
|
group = mavenGroup
|
||||||
|
project.base.archivesName.set(mavenArtifact)
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "HuebCraftGitlab"
|
||||||
|
url = uri("https://gitlab.huebcraft.net/api/v4/groups/48/-/packages/maven")
|
||||||
|
authentication {
|
||||||
|
create("header", HttpHeaderAuthentication::class.java) {
|
||||||
|
if (System.getenv("CI_JOB_TOKEN") != null) {
|
||||||
|
credentials(HttpHeaderCredentials::class) {
|
||||||
|
name = "Job-Token"
|
||||||
|
value = System.getenv("CI_JOB_TOKEN")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
credentials(HttpHeaderCredentials::class) {
|
||||||
|
name = "Private-Token"
|
||||||
|
value = project.ext["huebcraftGitlabToken"] as String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maven(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// To change the versions see the gradle.properties file
|
||||||
|
minecraft("com.mojang:minecraft:$minecraftVersion")
|
||||||
|
mappings("net.fabricmc:yarn:$yarnMappings:v2")
|
||||||
|
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
|
||||||
|
|
||||||
|
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion")
|
||||||
|
modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion")
|
||||||
|
|
||||||
|
modImplementation("de.huebcraft.mod-libs:configlib:$configlibVersion")
|
||||||
|
implementation("com.mashape.unirest:unirest-java:1.4.9")
|
||||||
|
implementation("com.formdev:flatlaf:3.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
val targetJavaVersion = 17
|
||||||
|
val templateSrc = project.rootDir.resolve("src/main/templates")
|
||||||
|
val templateDest = project.buildDir.resolve("generated/templates")
|
||||||
|
val datagenDest = project.rootDir.resolve("src/main/generated")
|
||||||
|
val templateProps = mapOf(
|
||||||
|
"modVersion" to project.version as String,
|
||||||
|
"modId" to modId,
|
||||||
|
"modName" to modName,
|
||||||
|
"minecraftVersion" to minecraftVersion,
|
||||||
|
"fabricLoaderVersion" to fabricLoaderVersion,
|
||||||
|
"configlibVersion" to configlibVersion,
|
||||||
|
"fabricKotlinVersion" to fabricKotlinVersion,
|
||||||
|
)
|
||||||
|
|
||||||
|
loom {
|
||||||
|
accessWidenerPath.set(file("src/main/resources/$modId.accesswidener"))
|
||||||
|
runs {
|
||||||
|
register("datagenClient") {
|
||||||
|
client()
|
||||||
|
name("Data Generation")
|
||||||
|
vmArg("-Dfabric-api.datagen")
|
||||||
|
vmArg("-Dfabric-api.datagen.output-dir=$datagenDest")
|
||||||
|
vmArg("-Dfabric-api.datagen.modid=$modId")
|
||||||
|
|
||||||
|
runDir("build/datagen")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
withType<ProcessResources> {
|
||||||
|
filteringCharset = "UTF-8"
|
||||||
|
|
||||||
|
inputs.properties(templateProps)
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand(templateProps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
create<Copy>("generateTemplates") {
|
||||||
|
filteringCharset = "UTF-8"
|
||||||
|
|
||||||
|
inputs.properties(templateProps)
|
||||||
|
from(templateSrc)
|
||||||
|
expand(templateProps)
|
||||||
|
into(templateDest)
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<JavaCompile> {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible) {
|
||||||
|
options.release.set(targetJavaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependsOn("generateTemplates", "processResources")
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = targetJavaVersion.toString()
|
||||||
|
|
||||||
|
dependsOn("generateTemplates", "processResources")
|
||||||
|
}
|
||||||
|
withType<Jar> {
|
||||||
|
from("LICENSE") {
|
||||||
|
rename { "${it}_${project.base.archivesName.get()}" }
|
||||||
|
}
|
||||||
|
|
||||||
|
archiveBaseName.set(mavenArtifact)
|
||||||
|
|
||||||
|
dependsOn("generateTemplates", "processResources")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
java {
|
||||||
|
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||||
|
if (JavaVersion.current() < javaVersion) {
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
|
||||||
|
}
|
||||||
|
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
srcDir(templateDest)
|
||||||
|
}
|
||||||
|
resources {
|
||||||
|
srcDir(datagenDest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("mavenJava") {
|
||||||
|
version = project.version as String
|
||||||
|
artifactId = mavenArtifact
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
if (System.getenv("CI_JOB_TOKEN") != null) {
|
||||||
|
maven {
|
||||||
|
name = "GitLab"
|
||||||
|
val projectId = System.getenv("CI_PROJECT_ID")
|
||||||
|
val apiV4 = System.getenv("CI_API_V4_URL")
|
||||||
|
url = uri("$apiV4/projects/$projectId/packages/maven")
|
||||||
|
authentication {
|
||||||
|
create("token", HttpHeaderAuthentication::class.java) {
|
||||||
|
credentials(HttpHeaderCredentials::class.java) {
|
||||||
|
name = "Job-Token"
|
||||||
|
value = System.getenv("CI_JOB_TOKEN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.idea.project {
|
||||||
|
this as ExtensionAware
|
||||||
|
configure<ProjectSettings> {
|
||||||
|
this as ExtensionAware
|
||||||
|
configure<TaskTriggersConfig> {
|
||||||
|
afterSync(tasks["generateTemplates"], tasks["processResources"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.eclipse.synchronizationTasks("generateTemplates", "processResources")
|
18
gradle.properties
Normal file
18
gradle.properties
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#Generated by fabric-mod-template
|
||||||
|
#Fri Apr 05 14:48:18 CEST 2024
|
||||||
|
fabric.loom.version=1.4.6
|
||||||
|
kotlin.version=1.9.22
|
||||||
|
fabric.api.version=0.77.0+1.19.2
|
||||||
|
yarn.version=1.19.2+build.28
|
||||||
|
configlib.version=3.0.0-beta
|
||||||
|
idea-ext.version=1.1.6
|
||||||
|
org.gradle.jvmargs=-Xmx2G
|
||||||
|
modId=quickcrashreports
|
||||||
|
kotlinx.serialization.version=1.6.2
|
||||||
|
fabric.kotlin.version=1.10.19+kotlin.1.9.23
|
||||||
|
mavenGroup=net.moonleay
|
||||||
|
kotlin.code.style=official
|
||||||
|
minecraft.version=1.19.2
|
||||||
|
modName=QuickCrashReports
|
||||||
|
fabric.loader.version=0.15.9
|
||||||
|
mavenArtifact=QuickCrashReports
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
249
gradlew
vendored
Executable file
249
gradlew
vendored
Executable file
|
@ -0,0 +1,249 @@
|
||||||
|
#!/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 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/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
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
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 ;; #(
|
||||||
|
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
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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" && ! "$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
|
||||||
|
|
||||||
|
# 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" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
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
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# 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"'
|
||||||
|
|
||||||
|
# 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" "$@"
|
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
@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
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
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"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
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.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
: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 %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
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!
|
||||||
|
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
|
||||||
|
|
||||||
|
:omega
|
15
settings.gradle.kts
Normal file
15
settings.gradle.kts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Fabric"
|
||||||
|
url = uri("https://maven.fabricmc.net/")
|
||||||
|
}
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm") version extra["kotlin.version"] as String
|
||||||
|
kotlin("plugin.serialization") version extra["kotlin.version"] as String
|
||||||
|
id("fabric-loom") version extra["fabric.loom.version"] as String
|
||||||
|
id("org.jetbrains.gradle.plugin.idea-ext") version extra["idea-ext.version"] as String
|
||||||
|
}
|
||||||
|
}
|
13
src/main/java/net/moonleay/quickcrashreports/Main.kt
Normal file
13
src/main/java/net/moonleay/quickcrashreports/Main.kt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package net.moonleay.quickcrashreports
|
||||||
|
|
||||||
|
import net.moonleay.quickcrashreports.build.BuildConstants
|
||||||
|
import net.fabricmc.api.ModInitializer
|
||||||
|
import org.apache.logging.log4j.LogManager
|
||||||
|
|
||||||
|
internal object Main : ModInitializer {
|
||||||
|
internal val LOGGER = LogManager.getLogger(BuildConstants.modName)
|
||||||
|
|
||||||
|
override fun onInitialize() {
|
||||||
|
LOGGER.info("Main has been initialized")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package net.moonleay.quickcrashreports.client
|
||||||
|
|
||||||
|
import net.moonleay.quickcrashreports.build.BuildConstants
|
||||||
|
import net.fabricmc.api.ClientModInitializer
|
||||||
|
import org.apache.logging.log4j.LogManager
|
||||||
|
|
||||||
|
internal object ClientMain : ClientModInitializer {
|
||||||
|
internal val LOGGER = LogManager.getLogger(BuildConstants.modName)
|
||||||
|
|
||||||
|
override fun onInitializeClient() {
|
||||||
|
LOGGER.info("ClientMain has been initialized")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package net.moonleay.quickcrashreports.client.ui
|
||||||
|
|
||||||
|
import java.awt.GridLayout
|
||||||
|
import javax.swing.JLabel
|
||||||
|
import javax.swing.JPanel
|
||||||
|
import javax.swing.JSeparator
|
||||||
|
import javax.swing.border.EmptyBorder
|
||||||
|
|
||||||
|
class BottomBar : JPanel() {
|
||||||
|
init {
|
||||||
|
this.layout = GridLayout(2, 4)
|
||||||
|
this.border = EmptyBorder(0, 10, 10, 10)
|
||||||
|
|
||||||
|
val label = JLabel("(c) 2024 moonleay, Licensed under GPL-3.0")
|
||||||
|
|
||||||
|
this.add(JSeparator())
|
||||||
|
this.add(label)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package net.moonleay.quickcrashreports.client.ui
|
||||||
|
|
||||||
|
import com.formdev.flatlaf.FlatDarculaLaf
|
||||||
|
import com.mashape.unirest.http.Unirest
|
||||||
|
import com.mashape.unirest.http.exceptions.UnirestException
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
object CrashUi {
|
||||||
|
fun start (crashReport: String) {
|
||||||
|
println("Launching gui")
|
||||||
|
FlatDarculaLaf.setup()
|
||||||
|
JustCrashedGUI()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(IOException::class, InterruptedException::class, UnirestException::class)
|
||||||
|
private fun sendPaste(text: String, burnAfterReading: Boolean): String {
|
||||||
|
val body = StringBuilder("{\"text\": \"")
|
||||||
|
body.append(text.replace("[\\u-0001-\\u001F]", "<br>")).append("\",\n")
|
||||||
|
body.append("\"\"").append("\",\n")
|
||||||
|
body.append("\"burn_after_reading\": ").append(burnAfterReading)
|
||||||
|
body.append("}")
|
||||||
|
|
||||||
|
Unirest.setTimeouts(-1, 0)
|
||||||
|
val response = Unirest.post("https://bin.moonleay.net/")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.body(body.toString())
|
||||||
|
.asString()
|
||||||
|
return response.body
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package net.moonleay.quickcrashreports.client.ui
|
||||||
|
|
||||||
|
import net.moonleay.quickcrashreports.build.BuildConstants
|
||||||
|
import java.awt.BorderLayout
|
||||||
|
import javax.swing.JFrame
|
||||||
|
import javax.swing.WindowConstants
|
||||||
|
|
||||||
|
class JustCrashedGUI : JFrame("QuickCrashReports " + BuildConstants.modVersion) {
|
||||||
|
init {
|
||||||
|
this.isResizable = false
|
||||||
|
this.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
|
||||||
|
|
||||||
|
val contentPane = this.contentPane
|
||||||
|
contentPane.layout = BorderLayout()
|
||||||
|
|
||||||
|
// contentPane.add(MainPanel, BorderLayout.CENTER)
|
||||||
|
contentPane.add(BottomBar(), BorderLayout.SOUTH)
|
||||||
|
|
||||||
|
this.pack()
|
||||||
|
this.setLocationRelativeTo(null)
|
||||||
|
this.isVisible = true
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.moonleay.quickcrashreports.client.ui;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class LaunchGui {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
System.err.println("Missing crash report path argument");
|
||||||
|
System.exit(255);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final var report = Files.readString(Path.of(args[0]));
|
||||||
|
System.out.println(report);
|
||||||
|
// TODO: Add GUI
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package net.moonleay.quickcrashreports.client.ui
|
||||||
|
|
||||||
|
import java.awt.BorderLayout
|
||||||
|
import java.awt.FlowLayout
|
||||||
|
import java.awt.GridLayout
|
||||||
|
import javax.swing.*
|
||||||
|
import javax.swing.border.EmptyBorder
|
||||||
|
|
||||||
|
object MainPanel : JPanel() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
// val layout = GridLayout(6, 1)
|
||||||
|
//
|
||||||
|
// this.layout = layout
|
||||||
|
// border = EmptyBorder(10, 10, 10, 10)
|
||||||
|
//
|
||||||
|
// val info = JLabel("Modpack Installer")
|
||||||
|
// info.horizontalAlignment = SwingConstants.CENTER
|
||||||
|
// info.font = Font(font.name, font.style, font.size + 6)
|
||||||
|
// this.add(info, BorderLayout.NORTH)
|
||||||
|
//
|
||||||
|
// val flayout = FlowLayout()
|
||||||
|
// flayout.hgap = 10
|
||||||
|
// flayout.alignment = SwingConstants.VERTICAL
|
||||||
|
//
|
||||||
|
// fabricLabel = JLabel("Fabric mod loader")
|
||||||
|
// modpackLabel = JLabel("Modpack")
|
||||||
|
//
|
||||||
|
// this.add(fabricLabel)
|
||||||
|
// this.add(modpackLabel)
|
||||||
|
//
|
||||||
|
// dotMcLocationBar = JTextField(dotMcLocation)
|
||||||
|
// dotMcLocationBar.isEditable = false
|
||||||
|
// this.add(dotMcLocationBar)
|
||||||
|
//
|
||||||
|
// val openFileChooser = JButton("Select .minecraft Folder")
|
||||||
|
// openFileChooser.addActionListener {
|
||||||
|
// dotMcLocation = promptForFolder(openFileChooser)
|
||||||
|
// dotMcLocationBar.text = dotMcLocation
|
||||||
|
// }
|
||||||
|
// this.add(openFileChooser)
|
||||||
|
// generatorButton.addActionListener {
|
||||||
|
// val dotMcMods = File(dotMcLocation + File.separator + "mods")
|
||||||
|
// if (dotMcMods.exists()) {
|
||||||
|
// val bool = PopupFactory.getYesOrNoError(
|
||||||
|
// "Warning! .minecraft/mods folder found",
|
||||||
|
// "This installer will clear your mods folder in order to install the right Modpack."
|
||||||
|
// )
|
||||||
|
// if (bool) {
|
||||||
|
// generatorButton.isEnabled = false
|
||||||
|
// Manager.startDownloadAndInstall(dotMcLocation)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// generatorButton.isEnabled = false
|
||||||
|
// Manager.startDownloadAndInstall(dotMcLocation)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// this.add(generatorButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
// private fun promptForFolder(parent: Component?): String {
|
||||||
|
// val fc = JFileChooser()
|
||||||
|
// fc.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
|
||||||
|
// return if (fc.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
// fc.selectedFile.absolutePath
|
||||||
|
// } else "Error"
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fun updateFabricModloader(tx: String) {
|
||||||
|
// fabricLabel.text = "Fabric mod loader $tx"
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fun updateModpack(tx: String) {
|
||||||
|
// modpackLabel.text = "Modpack $tx"
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Code by mostlymagic
|
||||||
|
* src: https://github.com/mostlymagic/hacking-java
|
||||||
|
* */
|
||||||
|
package net.moonleay.quickcrashreports.client.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public final class CompilationResult {
|
||||||
|
|
||||||
|
private final boolean success;
|
||||||
|
private final List<String> warnings;
|
||||||
|
private final List<String> errors;
|
||||||
|
|
||||||
|
public boolean isSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getWarnings() {
|
||||||
|
return Collections.unmodifiableList(warnings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getErrors() {
|
||||||
|
return Collections.unmodifiableList(errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompilationResult(final boolean success, final List<String> warnings, final List<String> errors) {
|
||||||
|
this.success = success;
|
||||||
|
this.warnings = new ArrayList<>(warnings);
|
||||||
|
this.errors = new ArrayList<>(errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(success, warnings, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj == null || getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CompilationResult other = (CompilationResult) obj;
|
||||||
|
return Objects.equals(this.success, other.success) && Objects.equals(this.warnings, other.warnings)
|
||||||
|
&& Objects.equals(this.errors, other.errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CompilationResult{" + "success=" + success + ", warnings=" + warnings + ", errors=" + errors + '}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,287 @@
|
||||||
|
/*
|
||||||
|
* Code by mostlymagic
|
||||||
|
* src: https://github.com/mostlymagic/hacking-java
|
||||||
|
* */
|
||||||
|
|
||||||
|
package net.moonleay.quickcrashreports.client.util;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Lists.newArrayList;
|
||||||
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
|
import static com.google.common.collect.Sets.newLinkedHashSet;
|
||||||
|
import static java.lang.String.format;
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class encapsulates a call to the {@code java} executable (or optionally {@code javac}) in a separate, forked
|
||||||
|
* process, with the classpath copied from the local process. Additionally, it allows you to move classpath entries to
|
||||||
|
* the bootclasspath, in order to overwrite default JDK functionality. This class is stateful and not thread safe.
|
||||||
|
*/
|
||||||
|
public final class ForkedRun {
|
||||||
|
private static final Joiner SEP_JOINER;
|
||||||
|
private static final String MAVEN_REPO;
|
||||||
|
// private static final String ROOT_PROJECT_PATH;
|
||||||
|
|
||||||
|
// by default, all classpath elements that come either from inside the project root or the local maven repository
|
||||||
|
// are included in the forked classpath
|
||||||
|
private final Set<JarPredicate> jarFilePredicates = EnumSet.of(
|
||||||
|
JarPredicate.IN_LOCAL_MAVEN_REPO);
|
||||||
|
private boolean useJavaC;
|
||||||
|
private boolean outputCommand;
|
||||||
|
|
||||||
|
private final Set<String> bootClassPathMatchers = newHashSet();
|
||||||
|
private final List<String> vmArgs = newArrayList();
|
||||||
|
private final List<String> args = newArrayList();
|
||||||
|
private final ClassLoader referenceClassLoader;
|
||||||
|
private final Set<ClassLoader> additionalClassLoaders = newHashSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activate the flag to output the full command line statement to standard out before executing it.
|
||||||
|
*/
|
||||||
|
public ForkedRun printCommand() {
|
||||||
|
this.outputCommand = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly add the tools.jar / classes.jar to the forked classpath. Since JDK 8, these are already present on the
|
||||||
|
* classpath by default.
|
||||||
|
*/
|
||||||
|
public ForkedRun withToolsJar() {
|
||||||
|
jarFilePredicates.add(JarPredicate.TOOLS_JAR);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activate the flag to use javac instead of java as target executable.
|
||||||
|
*/
|
||||||
|
public ForkedRun withJavaC() {
|
||||||
|
this.useJavaC = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a temporary directory and store its full path as command line argument.
|
||||||
|
*/
|
||||||
|
public ForkedRun tempDirAsArg() {
|
||||||
|
this.args.add(Files.createTempDir().getAbsolutePath());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activate debugging in the forked process, with the specified port.
|
||||||
|
*/
|
||||||
|
public ForkedRun withDebugPort(final int port) {
|
||||||
|
vmArgs.addAll(
|
||||||
|
asList("-Xdebug", "-Xnoagent",
|
||||||
|
format("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%d", port)));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a vm argument in the forked process.
|
||||||
|
*/
|
||||||
|
public ForkedRun withArg(final String arg) {
|
||||||
|
args.add(arg);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a command line argument in the forked process.
|
||||||
|
*/
|
||||||
|
public ForkedRun withArg(final Class<?> arg) {
|
||||||
|
args.add(arg.getName());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert all class path elements that contain this partial path signature to bootclasspath elements. The
|
||||||
|
* individual arguments should be parts of the directory path, usually Maven groupId and artifactId, e.g. "org",
|
||||||
|
* "springframework", "spring-aop".
|
||||||
|
*/
|
||||||
|
public ForkedRun withBootClassPathMatcher(final String pathElement, final String... morePathElements) {
|
||||||
|
bootClassPathMatchers.add(Joiner.on(File.separatorChar).join(Lists.asList(pathElement, morePathElements)));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all classpath elements from the ClassLoader owning the referenced class.
|
||||||
|
*/
|
||||||
|
public ForkedRun withAdditionalClassLoaderFromClass(final Class<?> referenceClass) {
|
||||||
|
return withAdditionalClassLoader(referenceClass.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all classpath elements from the referenced ClassLoader.
|
||||||
|
*/
|
||||||
|
public ForkedRun withAdditionalClassLoader(final ClassLoader additional) {
|
||||||
|
additionalClassLoaders.add(additional);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate with reference ClassLoader.
|
||||||
|
*/
|
||||||
|
public ForkedRun(final ClassLoader referenceClassLoader) {
|
||||||
|
if (referenceClassLoader instanceof URLClassLoader) {
|
||||||
|
final URLClassLoader urlClassLoader = (URLClassLoader) referenceClassLoader;
|
||||||
|
this.referenceClassLoader = urlClassLoader;
|
||||||
|
} else throw new IllegalArgumentException("Unsupported ClassLoader: " + referenceClassLoader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate with ClassLoader from reference class.
|
||||||
|
*/
|
||||||
|
public ForkedRun(final Class<?> referenceClass) {
|
||||||
|
this(referenceClass.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the actual forked process and create a CompilationResult object. This method should only be called once!
|
||||||
|
*/
|
||||||
|
public final CompilationResult run() {
|
||||||
|
final Set<String> classPathElements = new LinkedHashSet<>();
|
||||||
|
final Set<String> bootPathElements = new LinkedHashSet<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
dispatchClassPath(classPathElements, bootPathElements);
|
||||||
|
final String javaExe = getExecutable();
|
||||||
|
final List<String> commands = buildCommands(classPathElements, bootPathElements, javaExe);
|
||||||
|
final ProcessBuilder processBuilder = new ProcessBuilder().command(commands);
|
||||||
|
if (outputCommand) System.out.println(Joiner.on(' ').join(commands));
|
||||||
|
processBuilder.directory(Files.createTempDir());
|
||||||
|
final Process proc = processBuilder.start();
|
||||||
|
final List<String> errorMessages = gatherOutput(proc);
|
||||||
|
final int statusCode = proc.waitFor();
|
||||||
|
return new CompilationResult(statusCode == 0, Collections.<String>emptyList(), errorMessages);
|
||||||
|
|
||||||
|
} catch (InterruptedException | IOException | URISyntaxException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchClassPath(final Set<String> classPathElements, final Set<String> bootPathElements)
|
||||||
|
throws URISyntaxException {
|
||||||
|
for (final URL url : getUrLs()) {
|
||||||
|
final File jarFile = new File(url.toURI());
|
||||||
|
if (!jarFilePredicates.stream().anyMatch((it) -> it.test(jarFile))) continue;
|
||||||
|
final String absolutePath = jarFile.getAbsolutePath();
|
||||||
|
if (bootClassPathMatchers.stream().anyMatch((it) -> {
|
||||||
|
return absolutePath.contains(it);
|
||||||
|
})) bootPathElements.add(absolutePath);
|
||||||
|
else classPathElements.add(absolutePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect all URLs from all ClassLoaders
|
||||||
|
private Iterable<URL> getUrLs() {
|
||||||
|
final Set<URL> urls = newLinkedHashSet();
|
||||||
|
for (final ClassLoader referenceClassLoader : Lists.asList(this.referenceClassLoader,
|
||||||
|
additionalClassLoaders.toArray(new ClassLoader[additionalClassLoaders.size()]))) {
|
||||||
|
|
||||||
|
ClassLoader current = referenceClassLoader;
|
||||||
|
while (current != null) {
|
||||||
|
if (current instanceof URLClassLoader) {
|
||||||
|
final URLClassLoader urlClassLoader = (URLClassLoader) current;
|
||||||
|
urls.addAll(asList(urlClassLoader.getURLs()));
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Bad ClassLoader: " + current);
|
||||||
|
}
|
||||||
|
current = current.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getExecutable() {
|
||||||
|
return new File(
|
||||||
|
System.getProperty("java.home"),
|
||||||
|
useJavaC ? "../bin/javac" : "bin/java"
|
||||||
|
).getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> buildCommands(final Set<String> classPathElements, final Set<String> bootPathElements,
|
||||||
|
final String javaExe) {
|
||||||
|
final List<String> commands = newArrayList();
|
||||||
|
if (!bootPathElements.isEmpty()) {
|
||||||
|
vmArgs.add("-Xbootclasspath/p:" + SEP_JOINER.join(bootPathElements));
|
||||||
|
}
|
||||||
|
commands.add(javaExe);
|
||||||
|
commands.addAll(vmArgs);
|
||||||
|
if (!classPathElements.isEmpty()) {
|
||||||
|
commands.add("-cp");
|
||||||
|
commands.add(SEP_JOINER.join(classPathElements));
|
||||||
|
}
|
||||||
|
commands.addAll(args);
|
||||||
|
return ImmutableList.copyOf(commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> gatherOutput(final Process proc) throws IOException {
|
||||||
|
try (BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||||
|
final BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()))) {
|
||||||
|
final List<String> errorMessages = newArrayList();
|
||||||
|
String line = null;
|
||||||
|
while ((line = stdInput.readLine()) != null) {
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
while ((line = stdError.readLine()) != null) {
|
||||||
|
errorMessages.add(line);
|
||||||
|
}
|
||||||
|
return errorMessages;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
SEP_JOINER = Joiner.on(File.pathSeparatorChar);
|
||||||
|
MAVEN_REPO = new File(System.getProperty("user.home"), ".m2/repository").getAbsolutePath();
|
||||||
|
// ROOT_PROJECT_PATH = calculateProjectRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String calculateProjectRoot() {
|
||||||
|
File current = new File(System.getProperty("user.dir"));
|
||||||
|
while (current != null) {
|
||||||
|
if (new File(current, "x_common").isDirectory())
|
||||||
|
return current.getAbsolutePath();
|
||||||
|
current = current.getParentFile();
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Couldn't detect project root. Please fix this hacky logic");
|
||||||
|
}
|
||||||
|
|
||||||
|
enum JarPredicate implements Predicate<File> {
|
||||||
|
IN_LOCAL_MAVEN_REPO {
|
||||||
|
@Override public boolean test(final File file) {
|
||||||
|
return file.getAbsolutePath().startsWith(MAVEN_REPO);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// IN_PROJECT_DIR {
|
||||||
|
// @Override public boolean test(final File file) {
|
||||||
|
// return file.getAbsolutePath().startsWith(ROOT_PROJECT_PATH);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
TOOLS_JAR {
|
||||||
|
final Set<String> supportedNames = ImmutableSet.of("tools.jar", "classes.jar");
|
||||||
|
|
||||||
|
@Override public boolean test(final File file) {
|
||||||
|
return supportedNames.contains(file.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package net.moonleay.quickcrashreports.client.util
|
||||||
|
|
||||||
|
object RunJavaProcess {
|
||||||
|
@JvmStatic
|
||||||
|
fun runInNewProcess(clazz: Class<*>, vararg args: String) {
|
||||||
|
try {
|
||||||
|
clazz.getDeclaredMethod("main", Array<String>::class.java)
|
||||||
|
} catch (e: NoSuchMethodException) {
|
||||||
|
error("Class ${clazz.name} has no main method")
|
||||||
|
}
|
||||||
|
|
||||||
|
ForkedRun(clazz.classLoader).withArg(clazz).apply {
|
||||||
|
args.forEach(::withArg)
|
||||||
|
}.run()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package net.moonleay.quickcrashreports.datagen
|
||||||
|
|
||||||
|
import net.moonleay.quickcrashreports.build.BuildConstants
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
|
||||||
|
import org.apache.logging.log4j.LogManager
|
||||||
|
|
||||||
|
internal class DataGenerator : DataGeneratorEntrypoint {
|
||||||
|
private val LOGGER = LogManager.getLogger(BuildConstants.modName)
|
||||||
|
|
||||||
|
override fun onInitializeDataGenerator(fabricDataGenerator: FabricDataGenerator) {
|
||||||
|
LOGGER.info("Starting Data Generation")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package net.moonleay.quickcrashreports.mixin;
|
||||||
|
|
||||||
|
import com.mashape.unirest.http.HttpResponse;
|
||||||
|
import com.mashape.unirest.http.Unirest;
|
||||||
|
import com.mashape.unirest.http.exceptions.UnirestException;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.util.Session;
|
||||||
|
import net.minecraft.util.crash.CrashReport;
|
||||||
|
import net.moonleay.quickcrashreports.client.ui.LaunchGui;
|
||||||
|
import net.moonleay.quickcrashreports.client.util.RunJavaProcess;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Mixin(MinecraftClient.class)
|
||||||
|
public class IJustCrashedMixin {
|
||||||
|
|
||||||
|
/* {
|
||||||
|
"text": "<paste content>",
|
||||||
|
"extension": "<file extension, optional>",
|
||||||
|
"expires": <number of seconds from now, optional>,
|
||||||
|
"burn_after_reading": <true/false, optional>
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@Inject(method = "printCrashReport", at = @At("HEAD"), cancellable = false)
|
||||||
|
private static void POSTCrashReportToWastebin(CrashReport report, CallbackInfo ci) {
|
||||||
|
System.out.println("[QCR] Your game crashed!!");
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("== Game crashed! ==\n");
|
||||||
|
sb.append("Details:\n");
|
||||||
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
|
Session currentSession = mc.getSession();
|
||||||
|
GameProfile profile = currentSession.getProfile();
|
||||||
|
sb.append("User: ").append(profile.getName()).append(", UUID: ").append(profile.getId().toString());
|
||||||
|
sb.append("\nCrash Reason: ").append(report.getMessage());
|
||||||
|
sb.append("\nComplete report:\n").append(report.asString());
|
||||||
|
|
||||||
|
RunJavaProcess.runInNewProcess(LaunchGui.class, sb.toString());
|
||||||
|
|
||||||
|
String response = null;
|
||||||
|
try {
|
||||||
|
response = sendPaste(sb.toString(), true);
|
||||||
|
} catch (IOException | InterruptedException | UnirestException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
if (response == null)
|
||||||
|
return;
|
||||||
|
// String id = response.replaceAll("{\"path\":\"", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private static String sendPaste(String text, boolean burnAfterReading) throws IOException, InterruptedException, UnirestException {
|
||||||
|
StringBuilder body = new StringBuilder("{\"text\": \"");
|
||||||
|
body.append(text.replaceAll("[\\u0000-\\u001F]", "<br>")).append("\",\n");
|
||||||
|
// body.append("\"\"").append("\",\n");
|
||||||
|
body.append("\"burn_after_reading\": ").append(burnAfterReading);
|
||||||
|
body.append("}");
|
||||||
|
|
||||||
|
Unirest.setTimeouts(0, 0);
|
||||||
|
HttpResponse<String> response = Unirest.post("https://bin.moonleay.net/")
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.body(body.toString())
|
||||||
|
.asString();
|
||||||
|
return response.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
src/main/resources/fabric.mod.json
Normal file
38
src/main/resources/fabric.mod.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "${modId}",
|
||||||
|
"version": "${modVersion}",
|
||||||
|
"name": "${modName}",
|
||||||
|
"description": "Lets the user quickly upload crash reports to a wastebin instance.",
|
||||||
|
"authors": [
|
||||||
|
"The HuebCraft Team"
|
||||||
|
],
|
||||||
|
"contact": {},
|
||||||
|
"license": "All rights reserved",
|
||||||
|
"environment": "*",
|
||||||
|
"entrypoints": {
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"adapter": "kotlin",
|
||||||
|
"value": "net.moonleay.quickcrashreports.client.ClientMain"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": [
|
||||||
|
{
|
||||||
|
"adapter": "kotlin",
|
||||||
|
"value": "net.moonleay.quickcrashreports.Main"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mixins": [
|
||||||
|
"${modId}.mixins.json"
|
||||||
|
],
|
||||||
|
"depends": {
|
||||||
|
"fabricloader": ">=${fabricLoaderVersion}",
|
||||||
|
"fabric": "*",
|
||||||
|
"fabric-language-kotlin": ">=${fabricKotlinVersion}",
|
||||||
|
"huebcraftconfiglib": "${configlibVersion}",
|
||||||
|
"minecraft": "${minecraftVersion}"
|
||||||
|
},
|
||||||
|
"accessWidener": "${modId}.accesswidener"
|
||||||
|
}
|
2
src/main/resources/quickcrashreports.accesswidener
Normal file
2
src/main/resources/quickcrashreports.accesswidener
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
accessWidener v2 named
|
||||||
|
|
14
src/main/resources/quickcrashreports.mixins.json
Normal file
14
src/main/resources/quickcrashreports.mixins.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "net.moonleay.quickcrashreports.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"mixins": [
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"IJustCrashedMixin"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package net.moonleay.quickcrashreports.build
|
||||||
|
|
||||||
|
internal object BuildConstants {
|
||||||
|
const val modId = "${modId}"
|
||||||
|
const val modName = "${modName}"
|
||||||
|
const val modVersion = "${modVersion}"
|
||||||
|
}
|
Loading…
Reference in a new issue