diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..83ec3ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,144 @@ +# Created by .ignore support plugin (hsz.mobi) +### Minecraft template +# Don't sync the run folder! +/run/ +### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +### Gradle template +.gradle +/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties +### Eclipse template + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e8bbc01 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/MIT.xml b/.idea/copyright/MIT.xml new file mode 100644 index 0000000..111f110 --- /dev/null +++ b/.idea/copyright/MIT.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..c3ba54a --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..d821048 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..4f642cd --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..1c24f9a --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..da46dcb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5ba4511 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/DebugServerInfo.iml b/.idea/modules/DebugServerInfo.iml new file mode 100644 index 0000000..9affd70 --- /dev/null +++ b/.idea/modules/DebugServerInfo.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/DebugServerInfo_main.iml b/.idea/modules/DebugServerInfo_main.iml new file mode 100644 index 0000000..7b1b4c3 --- /dev/null +++ b/.idea/modules/DebugServerInfo_main.iml @@ -0,0 +1,130 @@ + + + + + + + FORGE + MCP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DebugServerInfo.iml b/DebugServerInfo.iml new file mode 100644 index 0000000..d532ce8 --- /dev/null +++ b/DebugServerInfo.iml @@ -0,0 +1,736 @@ + + + + + + + FORGE + MCP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DebugServerInfo.ipr b/DebugServerInfo.ipr new file mode 100644 index 0000000..531856f --- /dev/null +++ b/DebugServerInfo.ipr @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.6 + + + + + + + + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c578623 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Dries K. aka Dries007 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..36d6c5d --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# DebugServerInfo + +This is a Minecraft (1.10.2 +) mod that adds some server debug info to the client debug screen. + +Suggestions & bug reports are always welcome, but please make sure there isn't a similar Github issue already. + +[**Available for download from CurseForge here.**](https://minecraft.curseforge.com/projects/debugserverinfo) + + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..4a0fb36 --- /dev/null +++ b/build.gradle @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +buildscript { + repositories { + jcenter() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } + } + dependencies { + classpath "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT" + } +} + +apply plugin: "net.minecraftforge.gradle.forge" + +sourceCompatibility = targetCompatibility = "1.7" + +version = modVersion +group = modGroup +archivesBaseName = modBaseName + +minecraft { + version = project.forgeVersion + runDir = "run" + + // the mappings can be changed at any time, and must be in the following format. + // snapshot_YYYYMMDD snapshot are built nightly. + // stable_# stables are built at the discretion of the MCP team. + // Use non-default mappings at your own risk. they may not always work. + // simply re-run your setup task after changing the mappings to update your workspace. + mappings = project.mcpVersion + // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. +} + +repositories { + mavenCentral() +} + +dependencies { +} + +processResources { + // this will ensure that this task is redone when the versions change. + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include "mcmod.info" + + // replace version and mcversion + expand "version": project.version, "mcversion": project.minecraft.version + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude "mcmod.info" + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..a4f8fe1 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,27 @@ +# +# Copyright (c) 2017 Dries K. aka Dries007 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +modGroup=net.dries007.dsi +modVersion=1.0.0 +modBaseName=DebugServerInfo +forgeVersion=1.10.2-12.18.3.2185 +mcpVersion=stable_29 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..59109b0 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..147a332 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Apr 07 14:34:57 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4453cce --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/run/eula.txt b/run/eula.txt new file mode 100644 index 0000000..02cdd7a --- /dev/null +++ b/run/eula.txt @@ -0,0 +1,3 @@ +#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula). +#Thu Oct 13 20:20:34 CEST 2016 +eula=true diff --git a/run/server.properties b/run/server.properties new file mode 100644 index 0000000..cb92e81 --- /dev/null +++ b/run/server.properties @@ -0,0 +1,55 @@ +# +# Copyright (c) 2017 Dries K. aka Dries007 +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +#Minecraft server properties +#Fri Apr 07 14:28:43 CEST 2017 +generator-settings= +use-native-transport=true +op-permission-level=4 +level-name=world +allow-flight=false +announce-player-achievements=true +server-port=25565 +level-type=DEFAULT +level-seed= +force-gamemode=false +server-ip= +network-compression-threshold=256 +max-build-height=256 +spawn-npcs=true +white-list=false +spawn-animals=true +snooper-enabled=false +resource-pack-sha1= +online-mode=false +resource-pack= +pvp=true +difficulty=1 +enable-command-block=true +gamemode=0 +player-idle-timeout=0 +max-players=5 +max-tick-time=-1 +view-distance=10 +generate-structures=true +spawn-protection=0 +motd=test server please ignore diff --git a/run/servers.dat b/run/servers.dat new file mode 100644 index 0000000..3d521a4 Binary files /dev/null and b/run/servers.dat differ diff --git a/src/main/java/net/dries007/dsi/CommonProxy.java b/src/main/java/net/dries007/dsi/CommonProxy.java new file mode 100644 index 0000000..d33d80b --- /dev/null +++ b/src/main/java/net/dries007/dsi/CommonProxy.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi; + +import net.minecraftforge.common.config.Configuration; + +import java.util.Map; + +/** + * @author Dries007 + */ +public class CommonProxy +{ + public void init() {} + + public void preInit() + { + + } + + public void config(Configuration config) + { + + } + + public void handleData(double meanTickTime, Map map, int free, int total, int max) + { + + } +} diff --git a/src/main/java/net/dries007/dsi/DebugServerInfo.java b/src/main/java/net/dries007/dsi/DebugServerInfo.java new file mode 100644 index 0000000..8f74a8a --- /dev/null +++ b/src/main/java/net/dries007/dsi/DebugServerInfo.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi; + +import net.dries007.dsi.network.Data; +import net.dries007.dsi.network.Request; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import net.minecraftforge.fml.relauncher.Side; +import org.apache.logging.log4j.Logger; + +@Mod( + modid = DebugServerInfo.MOD_ID, + name = DebugServerInfo.MOD_NAME, + version = DebugServerInfo.VERSION, + acceptableRemoteVersions = "*", + guiFactory = "net.dries007.dsi.client.ConfigGuiFactory" +) +public class DebugServerInfo +{ + public static final String MOD_ID = "debugserverinfo"; + public static final String MOD_NAME = "DebugServerInfo"; + public static final String VERSION = "1.0.0"; + public static final String NBT_COUNTER = MOD_ID + "Count"; + + @Mod.Instance + private static DebugServerInfo instance; + + @SidedProxy(clientSide = "net.dries007.dsi.client.ClientProxy", serverSide = "net.dries007.dsi.CommonProxy") + private static CommonProxy proxy; + private Logger logger; + private SimpleNetworkWrapper snw; + + private Configuration config; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) + { + logger = event.getModLog(); + + config = new Configuration(event.getSuggestedConfigurationFile()); + doConfig(); + + int id = 1; // Don't use 0, more easy debug. + snw = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID); + + snw.registerMessage(Request.Handler.class, Request.class, id++, Side.SERVER); + snw.registerMessage(Data.Handler.class, Data.class, id++, Side.CLIENT); + + proxy.preInit(); + } + + @SubscribeEvent + public void updateConfig(ConfigChangedEvent.OnConfigChangedEvent event) + { + if (event.getModID().equals(MOD_ID)) doConfig(); + } + + private void doConfig() + { + proxy.config(config); + + if (config.hasChanged()) config.save(); + } + + @EventHandler + public void init(FMLInitializationEvent event) + { + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(proxy); + MinecraftForge.EVENT_BUS.register(ServerHelper.I); + + proxy.init(); + } + + public static Logger getLogger() + { + return instance.logger; + } + + public static SimpleNetworkWrapper getSnw() + { + return instance.snw; + } + + public static CommonProxy getProxy() + { + return proxy; + } +} diff --git a/src/main/java/net/dries007/dsi/ServerHelper.java b/src/main/java/net/dries007/dsi/ServerHelper.java new file mode 100644 index 0000000..91a26c9 --- /dev/null +++ b/src/main/java/net/dries007/dsi/ServerHelper.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi; + +import gnu.trove.map.TIntDoubleMap; +import gnu.trove.map.hash.TIntDoubleHashMap; +import net.dries007.dsi.network.Data; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import static net.dries007.dsi.DebugServerInfo.NBT_COUNTER; + +/** + * @author Dries007 + */ +public class ServerHelper +{ + public static final ServerHelper I = new ServerHelper(); + + private static Data data; + + private ServerHelper() + { + } + + private static long mean(long[] values) + { + long sum = 0; + for (long v : values) sum += v; + return sum / values.length; + } + + public static Data getData() + { + if (data != null) return data; + + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + + Integer[] dimsObj = DimensionManager.getIDs(); + TIntDoubleMap map = new TIntDoubleHashMap(dimsObj.length); + + for (Integer dim : dimsObj) + { + map.put(dim, mean(server.worldTickTimes.get(dim)) * 1.0E-6D); + } + + double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D; + + int total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024); + int max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024); + int free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024); + + data = new Data(meanTickTime, map, free, total, max); + return data; + } + + @SubscribeEvent + public void onTickServerTick(TickEvent.ServerTickEvent event) + { + if (event.phase != TickEvent.Phase.START) return; + data = null; + } + + @SubscribeEvent + public void onTickPlayerTick(TickEvent.PlayerTickEvent event) + { + if (event.side.isClient() || event.phase != TickEvent.Phase.START) return; + int count = event.player.getEntityData().getInteger(NBT_COUNTER); + if (count <= 0) return; + event.player.getEntityData().setInteger(NBT_COUNTER, count - 1); + Data data = ServerHelper.getData(); + if (data != null) DebugServerInfo.getSnw().sendTo(data, (EntityPlayerMP) event.player); + } +} diff --git a/src/main/java/net/dries007/dsi/client/ClientProxy.java b/src/main/java/net/dries007/dsi/client/ClientProxy.java new file mode 100644 index 0000000..857f077 --- /dev/null +++ b/src/main/java/net/dries007/dsi/client/ClientProxy.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi.client; + +import net.dries007.dsi.CommonProxy; +import net.dries007.dsi.DebugServerInfo; +import net.dries007.dsi.network.Request; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.text.DecimalFormat; +import java.util.*; + +/** + * @author Dries007 + */ +@SideOnly(Side.CLIENT) +public class ClientProxy extends CommonProxy +{ + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("########0.000"); + + static Configuration config; + + private Minecraft mc; + + private boolean cfgLeft; + private boolean cfgAlways; + + private int counter; + private int cfgMaxDims; + + private double meanTickTime; + private Map dims; + private int free; + private int total; + private int max; + + @Override + public void preInit() + { + mc = Minecraft.getMinecraft(); + + super.preInit(); + } + + @Override + public void config(Configuration config) + { + ClientProxy.config = config; + + cfgLeft = config.getBoolean("left", Configuration.CATEGORY_CLIENT, false, "Display on the left instead the right"); + cfgAlways = config.getBoolean("always", Configuration.CATEGORY_CLIENT, false, "Always display the tps & mem, even when not in F3"); + cfgMaxDims = config.getInt("maxDims", Configuration.CATEGORY_CLIENT, 10, 0, Integer.MAX_VALUE, "The max amount of dims to display. If 0, only total is shown."); + + super.config(config); + } + + @Override + public void init() + { + super.init(); + } + + @Override + public void handleData(double meanTickTime, Map map, int free, int total, int max) + { + this.meanTickTime = meanTickTime; + this.free = free; + this.total = total; + this.max = max; + + List> list = new LinkedList<>(map.entrySet()); + Collections.sort(list, new Comparator>() + { + @Override + public int compare(Map.Entry o1, Map.Entry o2) + { + return o2.getValue().compareTo(o1.getValue()); // REVERSED ordering + } + }); + Map dims = new LinkedHashMap<>(Math.max(list.size(), cfgMaxDims)); + for (Map.Entry entry : list) + { + if (dims.size() >= cfgMaxDims) break; + dims.put(entry.getKey(), entry.getValue()); + } + this.dims = dims; + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) + { + dims = null; + } + + @SubscribeEvent + public void clientTick(TickEvent.ClientTickEvent event) + { + if (event.phase != TickEvent.Phase.END) return; + if (mc.world == null) return; + if ((cfgAlways || mc.gameSettings.showDebugInfo) && --counter < 0) + { + counter = 20; + DebugServerInfo.getSnw().sendToServer(new Request(counter)); + } + } + + @SubscribeEvent + public void drawTextEvent(RenderGameOverlayEvent.Text event) + { + if (cfgAlways && !mc.gameSettings.showDebugInfo) + draw(cfgLeft ? event.getLeft() : event.getRight(), Side.CLIENT); + if (cfgAlways || mc.gameSettings.showDebugInfo) draw(cfgLeft ? event.getLeft() : event.getRight(), Side.SERVER); + } + + private void draw(ArrayList list, Side side) + { + int max = this.max; + int total = this.total; + int free = this.free; + if (side.isClient()) + { + if (list.isEmpty()) list.add("Client"); + max = (int) (Runtime.getRuntime().maxMemory() / 1024 / 1024); + total = (int) (Runtime.getRuntime().totalMemory() / 1024 / 1024); + free = (int) (Runtime.getRuntime().freeMemory() / 1024 / 1024); + if (!mc.gameSettings.showDebugInfo) list.add(String.format("%d FPS", Minecraft.getDebugFPS())); + } + else + { + if (dims == null) + { + list.add("No server data :("); + return; + } + if (!list.isEmpty()) list.add("Server"); + } + + int diff = total - free; + list.add(String.format("Mem: % 2d%% %03d/%03dMB", diff * 100 / max, diff, max)); + list.add(String.format("Allocated: % 2d%% %03dMB", total * 100 / max, total)); + if (side.isClient()) return; + + list.add(String.format("Ticktime Overall: %sms (%d TPS)", DECIMAL_FORMAT.format(meanTickTime), (int) Math.min(1000.0 / meanTickTime, 20))); + for (Map.Entry entry : dims.entrySet()) + { + list.add(String.format("Dim %d: %sms (%d TPS)", entry.getKey(), DECIMAL_FORMAT.format(entry.getValue()), (int) Math.min(1000.0 / entry.getValue(), 20))); + } + } +} diff --git a/src/main/java/net/dries007/dsi/client/ConfigGuiFactory.java b/src/main/java/net/dries007/dsi/client/ConfigGuiFactory.java new file mode 100644 index 0000000..4405e4a --- /dev/null +++ b/src/main/java/net/dries007/dsi/client/ConfigGuiFactory.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi.client; + +import net.dries007.dsi.DebugServerInfo; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author Dries007 + */ +@SideOnly(Side.CLIENT) +public class ConfigGuiFactory implements IModGuiFactory +{ + @Override + public void initialize(Minecraft minecraftInstance) + { + + } + + @Override + public Class mainConfigGuiClass() + { + return ConfigGuiScreen.class; + } + + @Override + public Set runtimeGuiCategories() + { + return null; + } + + @SuppressWarnings("deprecation") + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) + { + return null; + } + + public static class ConfigGuiScreen extends GuiConfig + { + public ConfigGuiScreen(GuiScreen parentScreen) + { + super(parentScreen, getConfigElements(), DebugServerInfo.MOD_ID, false, false, DebugServerInfo.MOD_NAME); + } + + private static List getConfigElements() + { + Configuration c = ClientProxy.config; + if (c.getCategoryNames().size() == 1) + { + //noinspection LoopStatementThatDoesntLoop + for (String k : c.getCategoryNames()) + { + // Let forge do the work, for loop abused to avoid other strange constructs + return new ConfigElement(c.getCategory(k)).getChildElements(); + } + } + + List list = new ArrayList<>(); + for (String k : c.getCategoryNames()) + { + list.add(new ConfigElement(c.getCategory(k))); + } + return list; + } + } +} diff --git a/src/main/java/net/dries007/dsi/network/Data.java b/src/main/java/net/dries007/dsi/network/Data.java new file mode 100644 index 0000000..ea2be49 --- /dev/null +++ b/src/main/java/net/dries007/dsi/network/Data.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi.network; + +import gnu.trove.iterator.TIntDoubleIterator; +import gnu.trove.map.TIntDoubleMap; +import io.netty.buffer.ByteBuf; +import net.dries007.dsi.DebugServerInfo; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Dries007 + */ +public class Data implements IMessage +{ + private double meanTickTime; + private double meanTPS; + private TIntDoubleMap tMap; + private Map jMap; + private int free; + private int total; + private int max; + + @SuppressWarnings("unused") + public Data() + { + + } + + public Data(double meanTickTime, TIntDoubleMap map, int free, int total, int max) + { + this.meanTickTime = meanTickTime; + this.tMap = map; + this.free = free; + this.total = total; + this.max = max; + } + + @Override + public void fromBytes(ByteBuf buf) + { + meanTickTime = buf.readDouble(); + int len = buf.readInt(); + jMap = new HashMap<>(len); + while (len-- != 0) + { + jMap.put(buf.readInt(), buf.readDouble()); + } + free = buf.readInt(); + total = buf.readInt(); + max = buf.readInt(); + } + + @Override + public void toBytes(final ByteBuf buf) + { + buf.writeDouble(meanTickTime); + buf.writeInt(tMap.size()); + TIntDoubleIterator i = tMap.iterator(); + while (i.hasNext()) + { + i.advance(); + buf.writeInt(i.key()); + buf.writeDouble(i.value()); + } + buf.writeInt(free); + buf.writeInt(total); + buf.writeInt(max); + } + + public static class Handler implements IMessageHandler + { + @Override + public IMessage onMessage(Data message, MessageContext ctx) + { +// DebugServerInfo.getLogger().info("Got data packet"); + DebugServerInfo.getProxy().handleData(message.meanTickTime, message.jMap, message.free, message.total, message.max); + return null; + } + } +} diff --git a/src/main/java/net/dries007/dsi/network/Request.java b/src/main/java/net/dries007/dsi/network/Request.java new file mode 100644 index 0000000..5c959e1 --- /dev/null +++ b/src/main/java/net/dries007/dsi/network/Request.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017 Dries K. aka Dries007 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.dries007.dsi.network; + +import io.netty.buffer.ByteBuf; +import net.dries007.dsi.ServerHelper; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; + +import static net.dries007.dsi.DebugServerInfo.NBT_COUNTER; + +/** + * @author Dries007 + */ +public class Request implements IMessage +{ + private int time; + + public Request(int time) + { + this.time = time; + } + + @SuppressWarnings("unused") + public Request() + { + + } + + @Override + public void fromBytes(ByteBuf buf) + { + time = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(time); + } + + public static class Handler implements IMessageHandler + { + @Override + public Data onMessage(Request message, MessageContext ctx) + { +// DebugServerInfo.getLogger().info("Request"); + ctx.getServerHandler().playerEntity.getEntityData().setInteger(NBT_COUNTER, message.time); + return ServerHelper.getData(); + } + } +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..86398ba --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,20 @@ +[ + { + "modid": "debugserverinfo", + "name": "DebugServerInfo", + "description": "Display some server info in the F3 debug info", + "version": "${version}", + "mcversion": "${mcversion}", + "url": "https://mc.dries007.net/DebugServerInfo", + "updateUrl": "https://mc.dries007.net/DebugServerInfo/update.json", + "authorList": [ + "Dries007" + ], + "credits": "", + "logoFile": "", + "screenshots": [], + "dependencies": [ + "forge" + ] + } +]