Really, needed to add repo earlier
This commit is contained in:
commit
9f5b4ec40e
13 changed files with 646 additions and 0 deletions
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# eclipse
|
||||||
|
bin
|
||||||
|
*.launch
|
||||||
|
.settings
|
||||||
|
.metadata
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
|
||||||
|
# idea
|
||||||
|
out
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# gradle
|
||||||
|
build
|
||||||
|
.gradle
|
||||||
|
|
||||||
|
# other
|
||||||
|
eclipse
|
||||||
|
run
|
||||||
|
|
||||||
|
# Files from Forge MDK
|
||||||
|
forge*changelog.txt
|
||||||
73
build.gradle
Normal file
73
build.gradle
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven { url = 'https://files.minecraftforge.net/maven' }
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
|
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||||
|
apply plugin: 'eclipse'
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
|
version = '1.0'
|
||||||
|
group = 'xyz.nuark.mcmodlistdumper'
|
||||||
|
archivesBaseName = 'mcmodlistdumper'
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
mappings channel: 'snapshot', version: '20171003-1.12'
|
||||||
|
|
||||||
|
runs {
|
||||||
|
client {
|
||||||
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||||
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||||
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest {
|
||||||
|
attributes([
|
||||||
|
"Specification-Title": "mcmodlistdumper",
|
||||||
|
"Specification-Vendor": "nuark",
|
||||||
|
"Specification-Version": "1",
|
||||||
|
"Implementation-Title": project.name,
|
||||||
|
"Implementation-Version": "${version}",
|
||||||
|
"Implementation-Vendor" :"nuark",
|
||||||
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jar.finalizedBy('reobfJar')
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
artifact jar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url "file:///${project.projectDir}/mcmodsrepo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||||
172
gradlew
vendored
Normal file
172
gradlew
vendored
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# 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
|
||||||
|
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=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
;;
|
||||||
|
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"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
84
gradlew.bat
vendored
Normal file
84
gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
@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=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@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=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
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 init
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
: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%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="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
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
33
src/main/java/xyz/nuark/mcmodlistdumper/MCMLDMod.java
Normal file
33
src/main/java/xyz/nuark/mcmodlistdumper/MCMLDMod.java
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package xyz.nuark.mcmodlistdumper;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import xyz.nuark.mcmodlistdumper.utils.Dumper;
|
||||||
|
|
||||||
|
@Mod(modid = MCMLDMod.MODID, name = MCMLDMod.NAME, version = MCMLDMod.VERSION, clientSideOnly = true)
|
||||||
|
public class MCMLDMod {
|
||||||
|
public static final String MODID = "mcmodlistdumper";
|
||||||
|
public static final String NAME = "MC Mod List Dumper";
|
||||||
|
public static final String VERSION = "1.0";
|
||||||
|
public static final String AUTHOR = "nuark";
|
||||||
|
|
||||||
|
private static Logger logger;
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
|
logger = event.getModLog();
|
||||||
|
Dumper.setMCFolder(event.getModConfigurationDirectory().getParent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void init(FMLInitializationEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Logger getLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/main/java/xyz/nuark/mcmodlistdumper/ModEventHandler.java
Normal file
35
src/main/java/xyz/nuark/mcmodlistdumper/ModEventHandler.java
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
package xyz.nuark.mcmodlistdumper;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import xyz.nuark.mcmodlistdumper.gui.ButtonDumper;
|
||||||
|
|
||||||
|
import static net.minecraftforge.fml.relauncher.Side.CLIENT;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(CLIENT)
|
||||||
|
public class ModEventHandler {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onInitGuiEvent(final GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
|
final GuiScreen gui = event.getGui();
|
||||||
|
if (gui instanceof GuiMainMenu) {
|
||||||
|
GuiButton ref_btn = null; // It will always be exit button
|
||||||
|
for (GuiButton btn : event.getButtonList()) {
|
||||||
|
if (btn.id == 4) {
|
||||||
|
ref_btn = btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ref_btn == null) {
|
||||||
|
MCMLDMod.getLogger().warn("Cannot find reference button!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getButtonList().add(new ButtonDumper(gui, ref_btn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package xyz.nuark.mcmodlistdumper.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import xyz.nuark.mcmodlistdumper.utils.Dumper;
|
||||||
|
|
||||||
|
public class ButtonDumper extends GuiButton {
|
||||||
|
public ButtonDumper(GuiScreen parent, GuiButton reference) {
|
||||||
|
super(4356789, reference.x + reference.width + 8, reference.y, "Dump mods");
|
||||||
|
this.width = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(int mouseX, int mouseY) {
|
||||||
|
String title = "Mods dump saved";
|
||||||
|
String message = "Location: ";
|
||||||
|
|
||||||
|
try {
|
||||||
|
String location = Dumper.dump();
|
||||||
|
message += location;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.fillInStackTrace();
|
||||||
|
title = "Cannot save mods dump";
|
||||||
|
message = e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
Minecraft.getMinecraft().displayGuiScreen(new GuiOk(title, message));
|
||||||
|
super.mouseReleased(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/main/java/xyz/nuark/mcmodlistdumper/gui/GuiOk.java
Normal file
45
src/main/java/xyz/nuark/mcmodlistdumper/gui/GuiOk.java
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
package xyz.nuark.mcmodlistdumper.gui;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiOk extends GuiScreen {
|
||||||
|
protected String messageTitle;
|
||||||
|
private final String messageThereIsFile;
|
||||||
|
private final List<String> listLines = Lists.newArrayList();
|
||||||
|
// protected String confirmButtonText; // TODO: I need to get to know how to close current menu!
|
||||||
|
|
||||||
|
public GuiOk(String messageTitle, String messageThereIsFile) {
|
||||||
|
this.messageTitle = messageTitle;
|
||||||
|
this.messageThereIsFile = messageThereIsFile;
|
||||||
|
// this.confirmButtonText = "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
// this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 6 + 96, this.confirmButtonText));
|
||||||
|
this.listLines.clear();
|
||||||
|
this.listLines.addAll(this.fontRenderer.listFormattedStringToWidth(this.messageThereIsFile, this.width - 50));
|
||||||
|
this.listLines.addAll(this.fontRenderer.listFormattedStringToWidth("Press ESC to exit", this.width - 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
this.drawCenteredString(this.fontRenderer, this.messageTitle, this.width / 2, 70, 16777215);
|
||||||
|
int i = 90;
|
||||||
|
|
||||||
|
for (String s : this.listLines) {
|
||||||
|
this.drawCenteredString(this.fontRenderer, s, this.width / 2, i, 16777215);
|
||||||
|
i += this.fontRenderer.FONT_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/main/java/xyz/nuark/mcmodlistdumper/utils/Dumper.java
Normal file
70
src/main/java/xyz/nuark/mcmodlistdumper/utils/Dumper.java
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
package xyz.nuark.mcmodlistdumper.utils;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import xyz.nuark.mcmodlistdumper.MCMLDMod;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Dumper {
|
||||||
|
private static String _mcFolder = "";
|
||||||
|
|
||||||
|
private static String readTemplateFromAssets() throws IOException {
|
||||||
|
InputStream stream = MCMLDMod.class.getClassLoader().getResourceAsStream(String.format("assets/%s/report_tpl.html", MCMLDMod.MODID));
|
||||||
|
return IOUtils.toString(Objects.requireNonNull(stream), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String dump() throws Exception {
|
||||||
|
if (_mcFolder.isEmpty()) {
|
||||||
|
throw new Exception("Did not received MC root folder!");
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder mods = new StringBuilder();
|
||||||
|
Loader.instance().getIndexedModList().forEach((name, container) -> {
|
||||||
|
String modId = container.getModId();
|
||||||
|
String modName = container.getName();
|
||||||
|
String modDisplayVersion = container.getDisplayVersion();
|
||||||
|
String modAuthors = container.getMetadata().getAuthorList();
|
||||||
|
String modDescription = container.getMetadata().description;
|
||||||
|
|
||||||
|
mods.append(String.format(
|
||||||
|
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
|
||||||
|
modId, modName, modDescription, modDisplayVersion, modAuthors
|
||||||
|
));
|
||||||
|
});
|
||||||
|
|
||||||
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
Path folderPath = Paths.get(Dumper._mcFolder, "mod_lists");
|
||||||
|
if (Files.notExists(folderPath) || !Files.isDirectory(folderPath)) {
|
||||||
|
Files.createDirectories(folderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Path filePath = Paths.get(
|
||||||
|
folderPath.toAbsolutePath().toString(),
|
||||||
|
String.format("dump-%s.html", dtf.format(LocalDateTime.now()))
|
||||||
|
);
|
||||||
|
|
||||||
|
String template = Dumper.readTemplateFromAssets();
|
||||||
|
try (PrintWriter out = new PrintWriter(filePath.toAbsolutePath().toString())) {
|
||||||
|
out.println(MessageFormat.format(template, MCMLDMod.NAME, MCMLDMod.VERSION, MCMLDMod.AUTHOR, mods));
|
||||||
|
}
|
||||||
|
|
||||||
|
Desktop.getDesktop().open(filePath.toFile());
|
||||||
|
return filePath.toAbsolutePath().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMCFolder(String _mcFolder) {
|
||||||
|
Dumper._mcFolder = _mcFolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
63
src/main/resources/assets/mcmodlistdumper/report_tpl.html
Normal file
63
src/main/resources/assets/mcmodlistdumper/report_tpl.html
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="EN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>{0} report</title>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
|
||||||
|
<script type='text/javascript' src='https://ko-fi.com/widgets/widget_2.js'></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() '{'
|
||||||
|
$("#report_table").DataTable();
|
||||||
|
'}');
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
* '{'
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
'}'
|
||||||
|
.main '{'
|
||||||
|
padding: 20px;
|
||||||
|
'}'
|
||||||
|
</style>
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="main">
|
||||||
|
<h4>Report generated with {0} v{1} by {2}</h4>
|
||||||
|
<p>Thanks for choosing me!</p>
|
||||||
|
<br>
|
||||||
|
<script type='text/javascript'>kofiwidget2.init("Support my creator on Ko-fi", "#29abe0", "I2I222JQH");kofiwidget2.draw();</script>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<table id="report_table" class="display compact">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ModID</th>
|
||||||
|
<th>Mod name</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Display ver.</th>
|
||||||
|
<th>Authors</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{3}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th>ModID</th>
|
||||||
|
<th>Mod name</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Display ver.</th>
|
||||||
|
<th>Authors</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
9
src/main/resources/mcmod.info
Normal file
9
src/main/resources/mcmod.info
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[{
|
||||||
|
"modid": "mcmodlistdumper",
|
||||||
|
"name": "MC Mod List Dumper",
|
||||||
|
"description": "Dumps list of your mods and creates nice-looking report",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"mcversion": "1.12.2",
|
||||||
|
"url": "nuark.xyz/",
|
||||||
|
"authorList": ["nuark"],
|
||||||
|
}]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue