Commit c15092b2a462c27877e0cf2c4f155a9853516ffb
1 parent
2953b223
merging 1.7.2 development branch into trunk
Showing
35 changed files
with
1917 additions
and
743 deletions
Too many changes to show.
To preserve performance only 35 of 129 files are displayed.
.classpath
@@ -6,15 +6,17 @@ | @@ -6,15 +6,17 @@ | ||
6 | <classpathentry combineaccessrules="false" exported="true" kind="src" path="/Client"/> | 6 | <classpathentry combineaccessrules="false" exported="true" kind="src" path="/Client"/> |
7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | 7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
8 | <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar"/> | 8 | <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar"/> |
9 | - <classpathentry kind="lib" path="/Client/jars/libraries/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar"/> | ||
10 | - <classpathentry kind="lib" path="/Client/jars/libraries/com/google/guava/guava/14.0/guava-14.0.jar"/> | 9 | + <classpathentry kind="lib" path="/Client/jars/libraries/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar"/> |
10 | + <classpathentry kind="lib" path="/Client/jars/libraries/com/google/guava/guava/15.0/guava-15.0.jar"/> | ||
11 | <classpathentry kind="lib" path="/Client/jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar"/> | 11 | <classpathentry kind="lib" path="/Client/jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar"/> |
12 | - <classpathentry exported="true" kind="lib" path="lib/launchwrapper-1.8.jar"/> | 12 | + <classpathentry exported="true" kind="lib" path="lib/launchwrapper-1.9.jar" sourcepath="externals/launchwrapper/src"/> |
13 | <classpathentry exported="true" kind="lib" path="lib/asm-debug-all-4.1.jar"/> | 13 | <classpathentry exported="true" kind="lib" path="lib/asm-debug-all-4.1.jar"/> |
14 | - <classpathentry exported="true" kind="lib" path="lib/authlib-1.3.jar" sourcepath="/AuthLib/java"/> | ||
15 | <classpathentry kind="lib" path="/Client/jars/libraries/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar"/> | 14 | <classpathentry kind="lib" path="/Client/jars/libraries/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar"/> |
16 | - <classpathentry exported="true" kind="lib" path="lib/log4j-api-2.0-beta9.jar"/> | ||
17 | - <classpathentry exported="true" kind="lib" path="lib/log4j-core-2.0-beta9.jar"/> | ||
18 | <classpathentry kind="lib" path="/Client/jars/libraries/net/sf/jopt-simple/jopt-simple/4.5/jopt-simple-4.5.jar"/> | 15 | <classpathentry kind="lib" path="/Client/jars/libraries/net/sf/jopt-simple/jopt-simple/4.5/jopt-simple-4.5.jar"/> |
16 | + <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/io/netty/netty-all/4.0.10.Final/netty-all-4.0.10.Final.jar"/> | ||
17 | + <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/com/mojang/authlib/1.3/authlib-1.3.jar"/> | ||
18 | + <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/apache/logging/log4j/log4j-api/2.0-beta9/log4j-api-2.0-beta9.jar"/> | ||
19 | + <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/apache/logging/log4j/log4j-core/2.0-beta9/log4j-core-2.0-beta9.jar"/> | ||
20 | + <classpathentry kind="lib" path="/Client/jars/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar"/> | ||
19 | <classpathentry kind="output" path="bin"/> | 21 | <classpathentry kind="output" path="bin"/> |
20 | </classpath> | 22 | </classpath> |
.settings/org.eclipse.core.resources.prefs
0 → 100644
.settings/org.eclipse.jdt.ui.prefs
ant/build_liteloader.xml
1 | <?xml version="1.0" encoding="UTF-8" ?> | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | -<project name="liteloader" basedir="." default="rebuild"> | 2 | +<project name="liteloader" basedir="." default="development"> |
3 | 3 | ||
4 | <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="tasks/ant-contrib.jar" /> | 4 | <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="tasks/ant-contrib.jar" /> |
5 | 5 | ||
6 | <!-- Versions !!IMPORTANT --> | 6 | <!-- Versions !!IMPORTANT --> |
7 | - <property name="version" value="1.6.4_02" /> | ||
8 | - <property name="mcversion" value="1.6.4" /> | 7 | + <property name="version" value="1.7.2_02" /> |
8 | + <property name="mcversion" value="1.7.2" /> | ||
9 | <property name="author" value="Mumfrey" /> | 9 | <property name="author" value="Mumfrey" /> |
10 | 10 | ||
11 | <!-- Project definitions and dependencies --> | 11 | <!-- Project definitions and dependencies --> |
@@ -28,41 +28,51 @@ | @@ -28,41 +28,51 @@ | ||
28 | 28 | ||
29 | <property name="python" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" /> | 29 | <property name="python" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" /> |
30 | 30 | ||
31 | - <target name="findmcp"> | ||
32 | - <echo level="info" message="Searching for clean MCP source..." /> | ||
33 | - <condition property="mcpsrc.exists"> | ||
34 | - <available file="${mcp.dir}/src/mcp" type="dir"/> | ||
35 | - </condition> | ||
36 | - </target> | ||
37 | - | 31 | + <target name="findmcp"> |
32 | + <echo level="info" message="Searching for clean MCP source..." /> | ||
33 | + <condition property="mcpsrc.exists"> | ||
34 | + <available file="${mcp.dir}/src/mcp" type="dir"/> | ||
35 | + </condition> | ||
36 | + </target> | ||
37 | + | ||
38 | + <target name="setup_development"> | ||
39 | + <property name="skipremoval" value="DEV" /> | ||
40 | + </target> | ||
41 | + | ||
42 | + <target name="setup_production"> | ||
43 | + <property name="skipremoval" value="" /> | ||
44 | + </target> | ||
45 | + | ||
38 | <!-- Main target --> | 46 | <!-- Main target --> |
39 | - <target name="rebuild" depends="findmcp, setdirsold, setdirsnew, build" description="Entry point" /> | 47 | + <target name="development" depends="setup_development, findmcp, setdirsold, setdirsnew, build" description="Entry point for MCP and upstream builds" /> |
48 | + | ||
49 | + <target name="production" depends="setup_production, findmcp, setdirsold, setdirsnew, build" description="Entry point for production builds" /> | ||
40 | 50 | ||
41 | <target name="setdirsnew" description="Set the MCP source directories for the new layout" unless="mcpsrc.exists"> | 51 | <target name="setdirsnew" description="Set the MCP source directories for the new layout" unless="mcpsrc.exists"> |
42 | <echo level="info" message="Setting MCP source directories for NEW configuration" /> | 52 | <echo level="info" message="Setting MCP source directories for NEW configuration" /> |
43 | - <property name="src" location="${build}/src"/> | ||
44 | - <property name="mc.src" location="${mcp.dir}/src/minecraft" /> | 53 | + <property name="src" location="${build}/src"/> |
54 | + <property name="mc.src" location="${mcp.dir}/src/minecraft" /> | ||
45 | <echo append="false" file="${temp}/build.cfg" message="[OUTPUT]
SrcClient = build/src" /> | 55 | <echo append="false" file="${temp}/build.cfg" message="[OUTPUT]
SrcClient = build/src" /> |
46 | - </target> | 56 | + </target> |
47 | 57 | ||
48 | <target name="setdirsold" description="Set the MCP source directories for the old layout" if="mcpsrc.exists"> | 58 | <target name="setdirsold" description="Set the MCP source directories for the old layout" if="mcpsrc.exists"> |
49 | - <echo level="warning" message="--------------------------------------------------------------------------------" /> | ||
50 | - <echo level="warning" message=" " /> | ||
51 | - <echo level="warning" message=" Setting MCP source directories for OLD configuration!" /> | ||
52 | - <echo level="warning" message=" " /> | ||
53 | - <echo level="warning" message=" Renaming the MCP 'src' directory is no longer required and support for this" /> | ||
54 | - <echo level="warning" message=" be removed in a future version." /> | ||
55 | - <echo level="warning" message=" " /> | ||
56 | - <echo level="warning" message="--------------------------------------------------------------------------------" /> | ||
57 | - <property name="src" location="${mcp.dir}/src/minecraft"/> | ||
58 | - <property name="mc.src" location="${mcp.dir}/src/mcp" /> | ||
59 | - </target> | 59 | + <echo level="warning" message="--------------------------------------------------------------------------------" /> |
60 | + <echo level="warning" message=" " /> | ||
61 | + <echo level="warning" message=" Setting MCP source directories for OLD configuration!" /> | ||
62 | + <echo level="warning" message=" " /> | ||
63 | + <echo level="warning" message=" Renaming the MCP 'src' directory is no longer required and support for this" /> | ||
64 | + <echo level="warning" message=" be removed in a future version." /> | ||
65 | + <echo level="warning" message=" " /> | ||
66 | + <echo level="warning" message="--------------------------------------------------------------------------------" /> | ||
67 | + <property name="src" location="${mcp.dir}/src/minecraft"/> | ||
68 | + <property name="mc.src" location="${mcp.dir}/src/mcp" /> | ||
69 | + </target> | ||
60 | 70 | ||
61 | <target name="build" description="Perform all tasks for a build" depends="init, recompile, reobfuscate, savemd5, stage, zip" > | 71 | <target name="build" description="Perform all tasks for a build" depends="init, recompile, reobfuscate, savemd5, stage, zip" > |
62 | </target> | 72 | </target> |
63 | 73 | ||
64 | <target name="clean"> | 74 | <target name="clean"> |
65 | - <echo level="info" message="Cleaning output directories" /> | 75 | + <echo level="info" message="Cleaning output directories" /> |
66 | 76 | ||
67 | <delete dir="${src}" /> | 77 | <delete dir="${src}" /> |
68 | <delete dir="${mcp.dir}/reobf" /> | 78 | <delete dir="${mcp.dir}/reobf" /> |
@@ -76,41 +86,46 @@ | @@ -76,41 +86,46 @@ | ||
76 | <exclude name="**/debug/*.java" /> | 86 | <exclude name="**/debug/*.java" /> |
77 | </fileset> | 87 | </fileset> |
78 | <fileset dir="${eclipse}/${lib}/src" /> | 88 | <fileset dir="${eclipse}/${lib}/src" /> |
89 | + <filterchain> | ||
90 | + <linecontains negate="true"> | ||
91 | + <contains value="@MCPONLY${skipremoval}" /> | ||
92 | + </linecontains> | ||
93 | + </filterchain> | ||
79 | </copy> | 94 | </copy> |
80 | </target> | 95 | </target> |
81 | 96 | ||
82 | <target name="contributeresources" description="Contribute resources to the staging path"> | 97 | <target name="contributeresources" description="Contribute resources to the staging path"> |
83 | <echo level="info" message="Contributing project resources for ${lib}" /> | 98 | <echo level="info" message="Contributing project resources for ${lib}" /> |
84 | <copy todir="${stage.dir}" verbose="false" failonerror="false"> | 99 | <copy todir="${stage.dir}" verbose="false" failonerror="false"> |
85 | - <fileset dir="${eclipse}/${lib}/resources" excludes=".svn/**"> | ||
86 | - <exclude name="**/Thumbs.db" /> | ||
87 | - <exclude name="**/minecraft.key" /> | ||
88 | - </fileset> | 100 | + <fileset dir="${eclipse}/${lib}/resources" excludes=".svn/**"> |
101 | + <exclude name="**/Thumbs.db" /> | ||
102 | + <exclude name="**/minecraft.key" /> | ||
103 | + </fileset> | ||
89 | </copy> | 104 | </copy> |
90 | </target> | 105 | </target> |
91 | 106 | ||
92 | <target name="findmd5dir"> | 107 | <target name="findmd5dir"> |
93 | - <echo level="info" message="Searching for existing MD5 directory..." /> | 108 | + <echo level="info" message="Searching for existing MD5 directory..." /> |
94 | <condition property="md5dir.exists"> | 109 | <condition property="md5dir.exists"> |
95 | <available file="${md5.dir}" type="dir"/> | 110 | <available file="${md5.dir}" type="dir"/> |
96 | </condition> | 111 | </condition> |
97 | </target> | 112 | </target> |
98 | 113 | ||
99 | <target name="findmd5" depends="findmd5dir"> | 114 | <target name="findmd5" depends="findmd5dir"> |
100 | - <echo level="info" message="Searching for existing MD5 sets..." /> | ||
101 | - <condition property="md5set.exists"> | ||
102 | - <available file="${md5.dir}/client_${md5set}.md5" type="file"/> | ||
103 | - </condition> | 115 | + <echo level="info" message="Searching for existing MD5 sets..." /> |
116 | + <condition property="md5set.exists"> | ||
117 | + <available file="${md5.dir}/client_${md5set}.md5" type="file"/> | ||
118 | + </condition> | ||
104 | </target> | 119 | </target> |
105 | 120 | ||
106 | <target name="seedmd5" depends="findmd5" unless="md5set.exists"> | 121 | <target name="seedmd5" depends="findmd5" unless="md5set.exists"> |
107 | - <echo level="info" message="MD5 sets not found, seeding..." /> | 122 | + <echo level="info" message="MD5 sets not found, seeding..." /> |
108 | <ant target="genmd5" antfile="seed_md5.xml" inheritall="true" /> | 123 | <ant target="genmd5" antfile="seed_md5.xml" inheritall="true" /> |
109 | </target> | 124 | </target> |
110 | 125 | ||
111 | - <target name="notifymd5ok" depends="findmd5" if="md5set.exists"> | ||
112 | - <echo level="info" message="MD5 sets already exist, skipping MD5 set seeding" /> | ||
113 | - </target> | 126 | + <target name="notifymd5ok" depends="findmd5" if="md5set.exists"> |
127 | + <echo level="info" message="MD5 sets already exist, skipping MD5 set seeding" /> | ||
128 | + </target> | ||
114 | 129 | ||
115 | <target name="preparemd5" description="Copy patched MD5 to the temp directory" depends="seedmd5, notifymd5ok, clean"> | 130 | <target name="preparemd5" description="Copy patched MD5 to the temp directory" depends="seedmd5, notifymd5ok, clean"> |
116 | <echo level="info" message="Prepare exclusion MD5s, using exclusion set "${md5set}"" /> | 131 | <echo level="info" message="Prepare exclusion MD5s, using exclusion set "${md5set}"" /> |
@@ -186,7 +201,8 @@ | @@ -186,7 +201,8 @@ | ||
186 | 201 | ||
187 | <copy todir="${stage.dir}"> | 202 | <copy todir="${stage.dir}"> |
188 | <fileset dir="${mcp.dir}/reobf/minecraft" excludes=".svn/**, *.txt"> | 203 | <fileset dir="${mcp.dir}/reobf/minecraft" excludes=".svn/**, *.txt"> |
189 | - <exclude name="/*.class" /> | 204 | + <exclude name="/*.class" /> |
205 | + <exclude name="/com/mumfrey/liteloader/core/gen/**" /> | ||
190 | </fileset> | 206 | </fileset> |
191 | </copy> | 207 | </copy> |
192 | 208 | ||
@@ -220,7 +236,7 @@ | @@ -220,7 +236,7 @@ | ||
220 | 236 | ||
221 | <property environment="env" /> | 237 | <property environment="env" /> |
222 | 238 | ||
223 | - <target name="deploy" depends="rebuild" description="Deploy artifact to local minecraft installation in APPDATA"> | 239 | + <target name="deploy" depends="production" description="Deploy artifact to local minecraft installation in APPDATA"> |
224 | <mkdir dir="${env.APPDATA}/.minecraft/libraries/com/mumfrey/liteloader/1.7.2"/> | 240 | <mkdir dir="${env.APPDATA}/.minecraft/libraries/com/mumfrey/liteloader/1.7.2"/> |
225 | <copy todir="${env.APPDATA}/.minecraft/libraries/com/mumfrey/liteloader/1.7.2" file="${dist.dir}/${ant.project.name}-${mcversion}.${filetype}" failonerror="false" overwrite="true" /> | 241 | <copy todir="${env.APPDATA}/.minecraft/libraries/com/mumfrey/liteloader/1.7.2" file="${dist.dir}/${ant.project.name}-${mcversion}.${filetype}" failonerror="false" overwrite="true" /> |
226 | </target> | 242 | </target> |
ant/seed_md5.xml
1 | <?xml version="1.0" encoding="UTF-8" ?> | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | <project name="mcp" basedir="." default="genmd5"> | 2 | <project name="mcp" basedir="." default="genmd5"> |
3 | 3 | ||
4 | - <!-- ========================================================================== --> | ||
5 | - <!-- DO NOT RUN THIS SCRIPT DIRECTLY --> | ||
6 | - <!-- ========================================================================== --> | ||
7 | - | ||
8 | - <!-- This script is called by the LiteLoader build script if the initial MD5s --> | ||
9 | - <!-- are missing. If you want to fire this script then delete the 'md5' folder --> | ||
10 | - <!-- before running the LiteLoader build. --> | ||
11 | - | ||
12 | - <target name="genmd5" description="Seed the initial MCP md5 set"> | ||
13 | - <echo level="info" message="MCP md5set was not found, making a clean compile" /> | ||
14 | - <antcall target="clean" /> | ||
15 | - <antcall target="init" /> | ||
16 | - <antcall target="recompile" /> | ||
17 | - <antcall target="reobfuscate" /> | ||
18 | - <antcall target="savemd5" /> | 4 | + <!-- ========================================================================== --> |
5 | + <!-- DO NOT RUN THIS SCRIPT DIRECTLY --> | ||
6 | + <!-- ========================================================================== --> | ||
7 | + | ||
8 | + <!-- This script is called by the LiteLoader build script if the initial MD5s --> | ||
9 | + <!-- are missing. If you want to fire this script then delete the 'md5' folder --> | ||
10 | + <!-- before running the LiteLoader build. --> | ||
11 | + | ||
12 | + <target name="genmd5" description="Seed the initial MCP md5 set"> | ||
13 | + <echo level="info" message="MCP md5set was not found, making a clean compile" /> | ||
14 | + <antcall target="clean" /> | ||
15 | + <antcall target="init" /> | ||
16 | + <antcall target="recompile" /> | ||
17 | + <antcall target="reobfuscate" /> | ||
18 | + <antcall target="savemd5" /> | ||
19 | </target> | 19 | </target> |
20 | 20 | ||
21 | <target name="clean"> | 21 | <target name="clean"> |
22 | - <echo level="info" message="Cleaning output directories" /> | 22 | + <echo level="info" message="Cleaning output directories" /> |
23 | 23 | ||
24 | - <delete dir="${src}" /> | ||
25 | - <delete dir="${mcp.dir}/reobf" /> | ||
26 | - </target> | 24 | + <delete dir="${src}" /> |
25 | + <delete dir="${mcp.dir}/reobf" /> | ||
26 | + </target> | ||
27 | 27 | ||
28 | <target name="init" description="Initialize environment"> | 28 | <target name="init" description="Initialize environment"> |
29 | - <echo level="info" message="Initialising environment" /> | 29 | + <echo level="info" message="Initialising environment" /> |
30 | 30 | ||
31 | - <mkdir dir="${md5.dir}" /> | 31 | + <mkdir dir="${md5.dir}" /> |
32 | 32 | ||
33 | - <copy todir="${src}" verbose="false" overwrite="true"> | ||
34 | - <fileset dir="${mc.src}" /> | ||
35 | - </copy> | 33 | + <copy todir="${src}" verbose="false" overwrite="true"> |
34 | + <fileset dir="${mc.src}" /> | ||
35 | + </copy> | ||
36 | </target> | 36 | </target> |
37 | 37 | ||
38 | <target name="recompile" description="MCP recompile"> | 38 | <target name="recompile" description="MCP recompile"> |
39 | - <echo level="info" message="Compiling MCP sources" /> | 39 | + <echo level="info" message="Compiling MCP sources" /> |
40 | 40 | ||
41 | <exec executable="${python}" dir="${mcp.dir}"> | 41 | <exec executable="${python}" dir="${mcp.dir}"> |
42 | <arg value="runtime/recompile.py" /> | 42 | <arg value="runtime/recompile.py" /> |
@@ -46,17 +46,17 @@ | @@ -46,17 +46,17 @@ | ||
46 | </target> | 46 | </target> |
47 | 47 | ||
48 | <target name="reobfuscate" description="MCP reobfuscate"> | 48 | <target name="reobfuscate" description="MCP reobfuscate"> |
49 | - <echo level="info" message="Obfuscating classes" /> | 49 | + <echo level="info" message="Obfuscating classes" /> |
50 | 50 | ||
51 | <exec executable="${python}" dir="${mcp.dir}"> | 51 | <exec executable="${python}" dir="${mcp.dir}"> |
52 | <arg value="runtime/reobfuscate.py" /> | 52 | <arg value="runtime/reobfuscate.py" /> |
53 | - <arg value="--client" /> | 53 | + <arg value="--client" /> |
54 | <arg value="%*" /> | 54 | <arg value="%*" /> |
55 | </exec> | 55 | </exec> |
56 | </target> | 56 | </target> |
57 | 57 | ||
58 | - <target name="savemd5" description="Put post-obfuscation MD5 to stored md5 set" if="outmd5set"> | ||
59 | - <echo level="info" message="Storing obfuscated MD5s" /> | 58 | + <target name="savemd5" description="Put post-obfuscation MD5 to stored md5 set" if="outmd5set"> |
59 | + <echo level="info" message="Storing obfuscated MD5s" /> | ||
60 | 60 | ||
61 | <copy file="${temp}/client_reobf.md5" tofile="${md5.dir}/client_mcp.md5" overwrite="true" verbose="true" /> | 61 | <copy file="${temp}/client_reobf.md5" tofile="${md5.dir}/client_mcp.md5" overwrite="true" verbose="true" /> |
62 | </target> | 62 | </target> |
debug/com/mumfrey/liteloader/debug/LoginManager.java
@@ -8,7 +8,6 @@ import java.net.Proxy; | @@ -8,7 +8,6 @@ import java.net.Proxy; | ||
8 | import java.util.HashMap; | 8 | import java.util.HashMap; |
9 | import java.util.Map; | 9 | import java.util.Map; |
10 | import java.util.UUID; | 10 | import java.util.UUID; |
11 | -import java.util.logging.Logger; | ||
12 | 11 | ||
13 | import javax.swing.JOptionPane; | 12 | import javax.swing.JOptionPane; |
14 | 13 | ||
@@ -22,6 +21,7 @@ import com.mojang.authlib.exceptions.AuthenticationException; | @@ -22,6 +21,7 @@ import com.mojang.authlib.exceptions.AuthenticationException; | ||
22 | import com.mojang.authlib.exceptions.InvalidCredentialsException; | 21 | import com.mojang.authlib.exceptions.InvalidCredentialsException; |
23 | import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; | 22 | import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; |
24 | import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; | 23 | import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; |
24 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Manages login requests against Yggdrasil for use in MCP | 27 | * Manages login requests against Yggdrasil for use in MCP |
@@ -31,11 +31,6 @@ import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; | @@ -31,11 +31,6 @@ import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; | ||
31 | public class LoginManager | 31 | public class LoginManager |
32 | { | 32 | { |
33 | /** | 33 | /** |
34 | - * Logger instance | ||
35 | - */ | ||
36 | - private static Logger logger = Logger.getLogger("liteloader"); | ||
37 | - | ||
38 | - /** | ||
39 | * Gson instance for serialising and deserialising the authentication data | 34 | * Gson instance for serialising and deserialising the authentication data |
40 | */ | 35 | */ |
41 | private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); | 36 | private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); |
@@ -120,7 +115,7 @@ public class LoginManager | @@ -120,7 +115,7 @@ public class LoginManager | ||
120 | 115 | ||
121 | if (authData != null && authData.validate()) | 116 | if (authData != null && authData.validate()) |
122 | { | 117 | { |
123 | - this.logInfo("Initialising Yggdrasil authentication service with client token: %s", authData.getClientToken()); | 118 | + LiteLoaderLogger.info("Initialising Yggdrasil authentication service with client token: %s", authData.getClientToken()); |
124 | this.authService = new YggdrasilAuthenticationService(Proxy.NO_PROXY, authData.getClientToken()); | 119 | this.authService = new YggdrasilAuthenticationService(Proxy.NO_PROXY, authData.getClientToken()); |
125 | this.authentication = new YggdrasilUserAuthentication(this.authService, Agent.MINECRAFT); | 120 | this.authentication = new YggdrasilUserAuthentication(this.authService, Agent.MINECRAFT); |
126 | authData.loadFromStorage(this.authentication); | 121 | authData.loadFromStorage(this.authentication); |
@@ -187,30 +182,30 @@ public class LoginManager | @@ -187,30 +182,30 @@ public class LoginManager | ||
187 | { | 182 | { |
188 | if (this.offline || remainingTries == 0) | 183 | if (this.offline || remainingTries == 0) |
189 | { | 184 | { |
190 | - this.logInfo("LoginManager is set to work offline, skipping login"); | 185 | + LiteLoaderLogger.info("LoginManager is set to work offline, skipping login"); |
191 | return false; | 186 | return false; |
192 | } | 187 | } |
193 | 188 | ||
194 | - this.logInfo("Remaining login tries: %s", remainingTries > 0 ? remainingTries : "unlimited"); | 189 | + LiteLoaderLogger.info("Remaining login tries: %s", remainingTries > 0 ? remainingTries : "unlimited"); |
195 | 190 | ||
196 | try | 191 | try |
197 | { | 192 | { |
198 | - this.logInfo("Attempting login, contacting Mojang auth servers..."); | 193 | + LiteLoaderLogger.info("Attempting login, contacting Mojang auth servers..."); |
199 | 194 | ||
200 | this.authentication.logIn(); | 195 | this.authentication.logIn(); |
201 | 196 | ||
202 | if (this.authentication.isLoggedIn()) | 197 | if (this.authentication.isLoggedIn()) |
203 | { | 198 | { |
204 | - this.logInfo("LoginManager logged in successfully. Can play online = %s", this.authentication.canPlayOnline()); | 199 | + LiteLoaderLogger.info("LoginManager logged in successfully. Can play online = %s", this.authentication.canPlayOnline()); |
205 | this.save(); | 200 | this.save(); |
206 | return true; | 201 | return true; |
207 | } | 202 | } |
208 | 203 | ||
209 | - this.logInfo("LoginManager failed to log in, unspecified status."); | 204 | + LiteLoaderLogger.info("LoginManager failed to log in, unspecified status."); |
210 | } | 205 | } |
211 | catch (InvalidCredentialsException ex) | 206 | catch (InvalidCredentialsException ex) |
212 | { | 207 | { |
213 | - this.logInfo("Authentication agent reported invalid credentials: %s", ex.getMessage()); | 208 | + LiteLoaderLogger.info("Authentication agent reported invalid credentials: %s", ex.getMessage()); |
214 | this.resetAuth(); | 209 | this.resetAuth(); |
215 | 210 | ||
216 | if (remainingTries > 1) | 211 | if (remainingTries > 1) |
@@ -229,7 +224,7 @@ public class LoginManager | @@ -229,7 +224,7 @@ public class LoginManager | ||
229 | 224 | ||
230 | if (!dialogResult) | 225 | if (!dialogResult) |
231 | { | 226 | { |
232 | - this.logInfo("User cancelled login dialog"); | 227 | + LiteLoaderLogger.info("User cancelled login dialog"); |
233 | return false; | 228 | return false; |
234 | } | 229 | } |
235 | 230 | ||
@@ -292,6 +287,15 @@ public class LoginManager | @@ -292,6 +287,15 @@ public class LoginManager | ||
292 | } | 287 | } |
293 | 288 | ||
294 | /** | 289 | /** |
290 | + * Get the profile name (minecraft player name) from login | ||
291 | + */ | ||
292 | + public String getUUID() | ||
293 | + { | ||
294 | + GameProfile selectedProfile = this.authentication.getSelectedProfile(); | ||
295 | + return selectedProfile != null ? selectedProfile.getId() : this.defaultDisplayName; | ||
296 | + } | ||
297 | + | ||
298 | + /** | ||
295 | * Get the session token | 299 | * Get the session token |
296 | */ | 300 | */ |
297 | public String getAuthenticatedToken() | 301 | public String getAuthenticatedToken() |
@@ -300,11 +304,6 @@ public class LoginManager | @@ -300,11 +304,6 @@ public class LoginManager | ||
300 | return accessToken != null ? accessToken : "-"; | 304 | return accessToken != null ? accessToken : "-"; |
301 | } | 305 | } |
302 | 306 | ||
303 | - private void logInfo(String message, Object... params) | ||
304 | - { | ||
305 | - LoginManager.logger.info(String.format(message, params)); | ||
306 | - } | ||
307 | - | ||
308 | /** | 307 | /** |
309 | * Struct for Gson serialisation of authenticaion settings | 308 | * Struct for Gson serialisation of authenticaion settings |
310 | * | 309 | * |
debug/com/mumfrey/liteloader/debug/LoginPanel.java
1 | package com.mumfrey.liteloader.debug; | 1 | package com.mumfrey.liteloader.debug; |
2 | 2 | ||
3 | -import javax.swing.JPanel; | ||
4 | - | ||
5 | -import java.awt.Color; | ||
6 | -import java.awt.Dimension; | ||
7 | -import java.awt.BorderLayout; | ||
8 | - | ||
9 | -import javax.swing.JLabel; | ||
10 | - | ||
11 | -import java.awt.Font; | ||
12 | - | ||
13 | -import javax.swing.border.EmptyBorder; | ||
14 | -import javax.swing.border.TitledBorder; | ||
15 | -import javax.swing.JDialog; | ||
16 | -import javax.swing.UIManager; | ||
17 | -import javax.swing.JCheckBox; | ||
18 | - | ||
19 | -import java.awt.Component; | ||
20 | -import java.awt.Container; | ||
21 | -import java.awt.FlowLayout; | ||
22 | -import java.awt.FocusTraversalPolicy; | ||
23 | -import java.awt.TextField; | ||
24 | -import java.awt.GridBagLayout; | ||
25 | -import java.awt.GridBagConstraints; | ||
26 | -import java.awt.Insets; | 3 | +import static javax.swing.WindowConstants.*; |
27 | 4 | ||
28 | -import javax.swing.JButton; | ||
29 | - | ||
30 | -import java.awt.event.ActionListener; | 5 | +import java.awt.*; |
31 | import java.awt.event.ActionEvent; | 6 | import java.awt.event.ActionEvent; |
7 | +import java.awt.event.ActionListener; | ||
32 | import java.awt.event.WindowAdapter; | 8 | import java.awt.event.WindowAdapter; |
33 | import java.awt.event.WindowEvent; | 9 | import java.awt.event.WindowEvent; |
34 | import java.util.ArrayList; | 10 | import java.util.ArrayList; |
35 | import java.util.List; | 11 | import java.util.List; |
36 | 12 | ||
37 | -import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; | 13 | +import javax.swing.JButton; |
14 | +import javax.swing.JCheckBox; | ||
15 | +import javax.swing.JDialog; | ||
16 | +import javax.swing.JLabel; | ||
17 | +import javax.swing.JPanel; | ||
18 | +import javax.swing.UIManager; | ||
19 | +import javax.swing.border.EmptyBorder; | ||
20 | +import javax.swing.border.TitledBorder; | ||
38 | 21 | ||
39 | /** | 22 | /** |
40 | * JPanel displayed in a JDialog to prompt the user for login credentials for minecraft | 23 | * JPanel displayed in a JDialog to prompt the user for login credentials for minecraft |
debug/com/mumfrey/liteloader/debug/Start.java
1 | package com.mumfrey.liteloader.debug; | 1 | package com.mumfrey.liteloader.debug; |
2 | import java.io.File; | 2 | import java.io.File; |
3 | -import java.util.logging.ConsoleHandler; | ||
4 | -import java.util.logging.Handler; | ||
5 | -import java.util.logging.Logger; | 3 | +import java.util.ArrayList; |
4 | +import java.util.List; | ||
6 | 5 | ||
7 | import net.minecraft.launchwrapper.Launch; | 6 | import net.minecraft.launchwrapper.Launch; |
8 | 7 | ||
9 | import com.mumfrey.liteloader.launch.LiteLoaderTweaker; | 8 | import com.mumfrey.liteloader.launch.LiteLoaderTweaker; |
10 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogFormatter; | 9 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
11 | 10 | ||
12 | /** | 11 | /** |
13 | * Wrapper class for LaunchWrapper Main class, which logs into minecraft.net first so that online shizzle can be tested | 12 | * Wrapper class for LaunchWrapper Main class, which logs into minecraft.net first so that online shizzle can be tested |
14 | * | 13 | * |
15 | * @author Adam Mummery-Smith | 14 | * @author Adam Mummery-Smith |
16 | - * @version 0.6 | 15 | + * @version 0.6.2 |
17 | */ | 16 | */ |
18 | public abstract class Start | 17 | public abstract class Start |
19 | { | 18 | { |
20 | - private static Logger logger = Logger.getLogger("liteloader"); | 19 | + private static final String FML_TWEAKER_NAME = "cpw.mods.fml.common.launcher.FMLTweaker"; |
21 | 20 | ||
22 | /** | 21 | /** |
23 | * Entry point. | 22 | * Entry point. |
@@ -26,8 +25,21 @@ public abstract class Start | @@ -26,8 +25,21 @@ public abstract class Start | ||
26 | */ | 25 | */ |
27 | public static void main(String[] args) | 26 | public static void main(String[] args) |
28 | { | 27 | { |
29 | - Start.prepareLogger(); | 28 | + System.setProperty("mcpenv", "true"); |
30 | 29 | ||
30 | + boolean fmlDetected = false; | ||
31 | + List<String> argsList = new ArrayList<String>(); | ||
32 | + | ||
33 | + // Detect the FML tweaker specified on the command line, this likely means someone has pulled us | ||
34 | + // into a Forge MCP workspace | ||
35 | + for (String arg : args) fmlDetected |= FML_TWEAKER_NAME.equals(arg); | ||
36 | + | ||
37 | + if (fmlDetected) | ||
38 | + { | ||
39 | + args = new String[0]; | ||
40 | + argsList.add("--tweakClass");argsList.add(FML_TWEAKER_NAME); | ||
41 | + } | ||
42 | + | ||
31 | String usernameFromCmdLine = (args.length > 0) ? args[0] : null; | 43 | String usernameFromCmdLine = (args.length > 0) ? args[0] : null; |
32 | String passwordFromCmdLine = (args.length > 1) ? args[1] : null; | 44 | String passwordFromCmdLine = (args.length > 1) ? args[1] : null; |
33 | 45 | ||
@@ -35,31 +47,19 @@ public abstract class Start | @@ -35,31 +47,19 @@ public abstract class Start | ||
35 | LoginManager loginManager = new LoginManager(loginJson); | 47 | LoginManager loginManager = new LoginManager(loginJson); |
36 | loginManager.login(usernameFromCmdLine, passwordFromCmdLine, 5); | 48 | loginManager.login(usernameFromCmdLine, passwordFromCmdLine, 5); |
37 | 49 | ||
38 | - Start.logger.info(String.format("Launching game as %s", loginManager.getProfileName())); | 50 | + LiteLoaderLogger.info("Launching game as %s", loginManager.getProfileName()); |
39 | 51 | ||
40 | File gameDir = new File(System.getProperty("user.dir")); | 52 | File gameDir = new File(System.getProperty("user.dir")); |
41 | - File assetsDir = new File(gameDir, "assets"); | ||
42 | - | ||
43 | - args = new String[] { | ||
44 | - "--tweakClass", LiteLoaderTweaker.class.getName(), | ||
45 | - "--username", loginManager.getProfileName(), | ||
46 | - "--session", loginManager.getAuthenticatedToken(), | ||
47 | - "--version", "mcp", | ||
48 | - "--gameDir", gameDir.getAbsolutePath(), | ||
49 | - "--assetsDir", assetsDir.getAbsolutePath() | ||
50 | - }; | ||
51 | - | ||
52 | - Launch.main(args); | ||
53 | - } | ||
54 | - | ||
55 | - private static void prepareLogger() | ||
56 | - { | ||
57 | - System.setProperty("liteloaderFormatLog", "true"); | 53 | + File assetsDir = new File(gameDir, "assets/virtual/legacy"); |
54 | + | ||
55 | + argsList.add("--tweakClass"); argsList.add(LiteLoaderTweaker.class.getName()); | ||
56 | + argsList.add("--username"); argsList.add(loginManager.getProfileName()); | ||
57 | + argsList.add("--uuid"); argsList.add(loginManager.getUUID()); | ||
58 | + argsList.add("--accessToken"); argsList.add(loginManager.getAuthenticatedToken()); | ||
59 | + argsList.add("--version"); argsList.add("mcp"); | ||
60 | + argsList.add("--gameDir"); argsList.add(gameDir.getAbsolutePath()); | ||
61 | + argsList.add("--assetsDir"); argsList.add(assetsDir.getAbsolutePath()); | ||
58 | 62 | ||
59 | - for (Handler handler : Start.logger.getParent().getHandlers()) | ||
60 | - { | ||
61 | - if (handler instanceof ConsoleHandler) | ||
62 | - handler.setFormatter(new LiteLoaderLogFormatter(false)); | ||
63 | - } | 63 | + Launch.main(argsList.toArray(args)); |
64 | } | 64 | } |
65 | } | 65 | } |
java/com/mumfrey/liteloader/ChatFilter.java
1 | package com.mumfrey.liteloader; | 1 | package com.mumfrey.liteloader; |
2 | 2 | ||
3 | -import net.minecraft.src.ChatMessageComponent; | ||
4 | -import net.minecraft.src.Packet3Chat; | 3 | +import net.minecraft.network.play.server.S02PacketChat; |
4 | +import net.minecraft.util.IChatComponent; | ||
5 | + | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * Interface for mods which can filter inbound chat | 8 | * Interface for mods which can filter inbound chat |
@@ -18,5 +19,5 @@ public interface ChatFilter extends LiteMod | @@ -18,5 +19,5 @@ public interface ChatFilter extends LiteMod | ||
18 | * @param message Chat message parsed from the chat message component | 19 | * @param message Chat message parsed from the chat message component |
19 | * @return True to keep the packet, false to discard | 20 | * @return True to keep the packet, false to discard |
20 | */ | 21 | */ |
21 | - public abstract boolean onChat(Packet3Chat chatPacket, ChatMessageComponent chat, String message); | 22 | + public abstract boolean onChat(S02PacketChat chatPacket, IChatComponent chat, String message); |
22 | } | 23 | } |
java/com/mumfrey/liteloader/ChatListener.java
1 | package com.mumfrey.liteloader; | 1 | package com.mumfrey.liteloader; |
2 | 2 | ||
3 | -import net.minecraft.src.ChatMessageComponent; | 3 | +import net.minecraft.util.IChatComponent; |
4 | + | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * Interface for mods which receive inbound chat | 7 | * Interface for mods which receive inbound chat |
@@ -15,5 +16,5 @@ public interface ChatListener extends LiteMod | @@ -15,5 +16,5 @@ public interface ChatListener extends LiteMod | ||
15 | * @param chat ChatMessageComponent parsed from the chat packet | 16 | * @param chat ChatMessageComponent parsed from the chat packet |
16 | * @param message Chat message parsed from the chat message component | 17 | * @param message Chat message parsed from the chat message component |
17 | */ | 18 | */ |
18 | - public abstract void onChat(ChatMessageComponent chat, String message); | 19 | + public abstract void onChat(IChatComponent chat, String message); |
19 | } | 20 | } |
java/com/mumfrey/liteloader/ChatRenderListener.java
java/com/mumfrey/liteloader/GameLoopListener.java
1 | package com.mumfrey.liteloader; | 1 | package com.mumfrey.liteloader; |
2 | 2 | ||
3 | -import net.minecraft.src.Minecraft; | 3 | +import net.minecraft.client.Minecraft; |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * Interface for mods which want a frame notification every single game loop | 6 | * Interface for mods which want a frame notification every single game loop |
java/com/mumfrey/liteloader/InitCompleteListener.java
java/com/mumfrey/liteloader/PreLoginListener.java renamed to java/com/mumfrey/liteloader/JoinGameListener.java
1 | package com.mumfrey.liteloader; | 1 | package com.mumfrey.liteloader; |
2 | 2 | ||
3 | -import net.minecraft.src.NetHandler; | ||
4 | -import net.minecraft.src.Packet1Login; | 3 | +import net.minecraft.network.INetHandler; |
4 | +import net.minecraft.network.play.server.S01PacketJoinGame; | ||
5 | + | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * Interface for mods which wish to be notified when the player connects to a server (or local game) | 8 | * Interface for mods which wish to be notified when the player connects to a server (or local game) |
8 | * | 9 | * |
9 | * @author Adam Mummery-Smith | 10 | * @author Adam Mummery-Smith |
10 | */ | 11 | */ |
11 | -public interface PreLoginListener extends LiteMod | 12 | +public interface JoinGameListener extends LiteMod |
12 | { | 13 | { |
13 | /** | 14 | /** |
14 | - * Called on login | 15 | + * Called on join game |
15 | * | 16 | * |
16 | * @param netHandler Net handler | 17 | * @param netHandler Net handler |
17 | - * @param loginPacket Login packet | 18 | + * @param joinGamePacket Join game packet |
18 | */ | 19 | */ |
19 | - public abstract boolean onPreLogin(NetHandler netHandler, Packet1Login loginPacket); | 20 | + public abstract void onJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket); |
20 | } | 21 | } |
java/com/mumfrey/liteloader/OutboundChatListener.java
0 → 100644
1 | +package com.mumfrey.liteloader; | ||
2 | + | ||
3 | +import net.minecraft.network.play.client.C01PacketChatMessage; | ||
4 | + | ||
5 | +/** | ||
6 | + * Interface for mods which want to monitor outbound chat | ||
7 | + * | ||
8 | + * @author Adam Mummery-Smith | ||
9 | + */ | ||
10 | +public interface OutboundChatListener extends LiteMod | ||
11 | +{ | ||
12 | + /** | ||
13 | + * Raised when a new chat packet is created (not necessarily transmitted, something could be trolling us) | ||
14 | + * | ||
15 | + * @param packet | ||
16 | + * @param message | ||
17 | + */ | ||
18 | + public abstract void onSendChatMessage(C01PacketChatMessage packet, String message); | ||
19 | +} |
java/com/mumfrey/liteloader/PluginChannelListener.java
1 | package com.mumfrey.liteloader; | 1 | package com.mumfrey.liteloader; |
2 | 2 | ||
3 | -import java.util.List; | 3 | +import com.mumfrey.liteloader.core.CommonPluginChannelListener; |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * Interface for mods which want to use plugin channels | 6 | * Interface for mods which want to use plugin channels |
7 | * | 7 | * |
8 | * @author Adam Mummery-Smith | 8 | * @author Adam Mummery-Smith |
9 | */ | 9 | */ |
10 | -public interface PluginChannelListener extends LoginListener | 10 | +public interface PluginChannelListener extends CommonPluginChannelListener, JoinGameListener |
11 | { | 11 | { |
12 | /** | 12 | /** |
13 | - * Return a list of the plugin channels the mod wants to register | ||
14 | - * | ||
15 | - * @return | ||
16 | - */ | ||
17 | - public abstract List<String> getChannels(); | ||
18 | - | ||
19 | - /** | ||
20 | * Called when a custom payload packet arrives on a channel this mod has registered | 13 | * Called when a custom payload packet arrives on a channel this mod has registered |
21 | * | 14 | * |
22 | * @param channel Channel on which the custom payload was received | 15 | * @param channel Channel on which the custom payload was received |
java/com/mumfrey/liteloader/PostLoginListener.java
0 → 100644
1 | +package com.mumfrey.liteloader; | ||
2 | + | ||
3 | +import net.minecraft.network.login.INetHandlerLoginClient; | ||
4 | +import net.minecraft.network.login.server.S02PacketLoginSuccess; | ||
5 | + | ||
6 | +/** | ||
7 | + * | ||
8 | + * @author Adam Mummery-Smith | ||
9 | + */ | ||
10 | +public interface PostLoginListener extends LiteMod | ||
11 | +{ | ||
12 | + public abstract void onPostLogin(INetHandlerLoginClient netHandler, S02PacketLoginSuccess packet); | ||
13 | +} |
java/com/mumfrey/liteloader/LoginListener.java renamed to java/com/mumfrey/liteloader/PreJoinGameListener.java
1 | package com.mumfrey.liteloader; | 1 | package com.mumfrey.liteloader; |
2 | 2 | ||
3 | -import net.minecraft.src.NetHandler; | ||
4 | -import net.minecraft.src.Packet1Login; | 3 | +import net.minecraft.network.INetHandler; |
4 | +import net.minecraft.network.play.server.S01PacketJoinGame; | ||
5 | + | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * Interface for mods which wish to be notified when the player connects to a server (or local game) | 8 | * Interface for mods which wish to be notified when the player connects to a server (or local game) |
8 | * | 9 | * |
9 | * @author Adam Mummery-Smith | 10 | * @author Adam Mummery-Smith |
10 | */ | 11 | */ |
11 | -public interface LoginListener extends LiteMod | 12 | +public interface PreJoinGameListener extends LiteMod |
12 | { | 13 | { |
13 | /** | 14 | /** |
14 | * Called on login | 15 | * Called on login |
15 | * | 16 | * |
16 | * @param netHandler Net handler | 17 | * @param netHandler Net handler |
17 | - * @param loginPacket Login packet | 18 | + * @param joinGamePacket Join game packet |
18 | */ | 19 | */ |
19 | - public abstract void onLogin(NetHandler netHandler, Packet1Login loginPacket); | 20 | + public abstract boolean onPreJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket); |
20 | } | 21 | } |
java/com/mumfrey/liteloader/RenderListener.java
java/com/mumfrey/liteloader/ServerChatFilter.java
0 → 100644
1 | +package com.mumfrey.liteloader; | ||
2 | + | ||
3 | +import net.minecraft.entity.player.EntityPlayerMP; | ||
4 | +import net.minecraft.network.play.client.C01PacketChatMessage; | ||
5 | + | ||
6 | +/** | ||
7 | + * Interface for mods which can filter inbound chat | ||
8 | + * | ||
9 | + * @author Adam Mummery-Smith | ||
10 | + */ | ||
11 | +public interface ServerChatFilter extends LiteMod | ||
12 | +{ | ||
13 | + /** | ||
14 | + * Chat filter function, return false to filter this packet, true to pass the packet | ||
15 | + * | ||
16 | + * @param chatPacket Chat packet to examine | ||
17 | + * @param message Chat message | ||
18 | + * @return True to keep the packet, false to discard | ||
19 | + */ | ||
20 | + public abstract boolean onChat(EntityPlayerMP player, C01PacketChatMessage chatPacket, String message); | ||
21 | +} |
java/com/mumfrey/liteloader/ServerCommandProvider.java
0 → 100644
1 | +package com.mumfrey.liteloader; | ||
2 | + | ||
3 | +import net.minecraft.command.ServerCommandManager; | ||
4 | + | ||
5 | + | ||
6 | +/** | ||
7 | + * Interface for mods which provide commands to the local integrated server | ||
8 | + * | ||
9 | + * @author Adam Mummery-Smith | ||
10 | + */ | ||
11 | +public interface ServerCommandProvider extends LiteMod | ||
12 | +{ | ||
13 | + /** | ||
14 | + * Allows the mod to provide commands to the server command manager my invoking commandManager.registerCommand() to | ||
15 | + * provide new commands for single player and lan worlds | ||
16 | + * | ||
17 | + * @param commandManager | ||
18 | + */ | ||
19 | + public abstract void provideCommands(ServerCommandManager commandManager); | ||
20 | +} |
java/com/mumfrey/liteloader/ServerPlayerListener.java
0 → 100644
1 | +package com.mumfrey.liteloader; | ||
2 | + | ||
3 | +import net.minecraft.entity.player.EntityPlayerMP; | ||
4 | + | ||
5 | +import com.mojang.authlib.GameProfile; | ||
6 | + | ||
7 | +/** | ||
8 | + * Interface for mods which want to handle players joining and leaving a LAN game (or single player game) | ||
9 | + * | ||
10 | + * @author Adam Mummery-Smith | ||
11 | + */ | ||
12 | +public interface ServerPlayerListener extends LiteMod | ||
13 | +{ | ||
14 | + /** | ||
15 | + * Called when a player connects to the server and the EntityPlayerMP instance is created, the player has not logged | ||
16 | + * in at this point and may be disconnected if login fails | ||
17 | + * | ||
18 | + * @param player Player attempting to connect | ||
19 | + * @param profile Player's GameProfile from the authentication service | ||
20 | + */ | ||
21 | + public abstract void onPlayerConnect(EntityPlayerMP player, GameProfile profile); | ||
22 | + | ||
23 | + /** | ||
24 | + * Called once the player has successfully logged in and all player variables are initialised and replicated | ||
25 | + * | ||
26 | + * @param player Player connected | ||
27 | + */ | ||
28 | + public abstract void onPlayerLoggedIn(EntityPlayerMP player); | ||
29 | + | ||
30 | + /** | ||
31 | + * Called when a player respawns. This event is raised when a player respawns after dying or conquers the end | ||
32 | + * | ||
33 | + * @param player New player instance | ||
34 | + * @param oldPlayer Old player instance being discarded | ||
35 | + * @param newDimension Dimension the player is respawning in | ||
36 | + * @param playerWonTheGame True if the player conquered the end (this respawn is NOT as the result of a death) | ||
37 | + */ | ||
38 | + public abstract void onPlayerRespawn(EntityPlayerMP player, EntityPlayerMP oldPlayer, int newDimension, boolean playerWonTheGame); | ||
39 | + | ||
40 | + /** | ||
41 | + * Called when a player disconnects from the game | ||
42 | + * | ||
43 | + * @param player Player disconnecting | ||
44 | + */ | ||
45 | + public abstract void onPlayerLogout(EntityPlayerMP player); | ||
46 | +} |
java/com/mumfrey/liteloader/ServerPluginChannelListener.java
0 → 100644
1 | +package com.mumfrey.liteloader; | ||
2 | + | ||
3 | +import net.minecraft.entity.player.EntityPlayerMP; | ||
4 | + | ||
5 | +import com.mumfrey.liteloader.core.CommonPluginChannelListener; | ||
6 | + | ||
7 | +/** | ||
8 | + * Interface for mods which want to use plugin channels on the (integrated) server side | ||
9 | + * | ||
10 | + * @author Adam Mummery-Smith | ||
11 | + */ | ||
12 | +public interface ServerPluginChannelListener extends CommonPluginChannelListener | ||
13 | +{ | ||
14 | + /** | ||
15 | + * Called when a custom payload packet arrives on a channel this mod has registered | ||
16 | + * | ||
17 | + * @param channel Channel on which the custom payload was received | ||
18 | + * @param length Length of the custom payload data | ||
19 | + * @param data Custom payload data | ||
20 | + */ | ||
21 | + public abstract void onCustomPayload(EntityPlayerMP sender, String channel, int length, byte[] data); | ||
22 | +} |
java/com/mumfrey/liteloader/Tickable.java
java/com/mumfrey/liteloader/core/ClientPluginChannels.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import net.minecraft.client.Minecraft; | ||
4 | +import net.minecraft.client.network.NetHandlerLoginClient; | ||
5 | +import net.minecraft.network.INetHandler; | ||
6 | +import net.minecraft.network.NetworkManager; | ||
7 | +import net.minecraft.network.login.INetHandlerLoginClient; | ||
8 | +import net.minecraft.network.login.server.S02PacketLoginSuccess; | ||
9 | +import net.minecraft.network.play.INetHandlerPlayClient; | ||
10 | +import net.minecraft.network.play.client.C17PacketCustomPayload; | ||
11 | +import net.minecraft.network.play.server.S01PacketJoinGame; | ||
12 | +import net.minecraft.network.play.server.S3FPacketCustomPayload; | ||
13 | + | ||
14 | +import com.mumfrey.liteloader.LiteMod; | ||
15 | +import com.mumfrey.liteloader.PluginChannelListener; | ||
16 | +import com.mumfrey.liteloader.core.exceptions.UnregisteredChannelException; | ||
17 | +import com.mumfrey.liteloader.permissions.PermissionsManagerClient; | ||
18 | +import com.mumfrey.liteloader.util.PrivateFields; | ||
19 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
20 | + | ||
21 | +/** | ||
22 | + * Handler for client plugin channels | ||
23 | + * | ||
24 | + * @author Adam Mummery-Smith | ||
25 | + */ | ||
26 | +public class ClientPluginChannels extends PluginChannels<PluginChannelListener> | ||
27 | +{ | ||
28 | + private static ClientPluginChannels instance; | ||
29 | + | ||
30 | + ClientPluginChannels() | ||
31 | + { | ||
32 | + super(); | ||
33 | + | ||
34 | + ClientPluginChannels.instance = this; | ||
35 | + } | ||
36 | + | ||
37 | + static ClientPluginChannels getInstance() | ||
38 | + { | ||
39 | + return instance; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * @param listener | ||
44 | + */ | ||
45 | + void addListener(LiteMod listener) | ||
46 | + { | ||
47 | + if (listener instanceof PluginChannelListener) | ||
48 | + { | ||
49 | + this.addPluginChannelListener((PluginChannelListener)listener); | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * @param netHandler | ||
55 | + * @param loginPacket | ||
56 | + */ | ||
57 | + void onPostLogin(INetHandlerLoginClient netHandler, S02PacketLoginSuccess loginPacket) | ||
58 | + { | ||
59 | + this.clearPluginChannels(netHandler); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * @param netHandler | ||
64 | + * @param loginPacket | ||
65 | + */ | ||
66 | + void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) | ||
67 | + { | ||
68 | + this.sendRegisteredPluginChannels(netHandler); | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * Callback for the plugin channel hook | ||
73 | + * | ||
74 | + * @param customPayload | ||
75 | + */ | ||
76 | + public void onPluginChannelMessage(S3FPacketCustomPayload customPayload) | ||
77 | + { | ||
78 | + if (customPayload != null && customPayload.func_149169_c() != null) // getChannel | ||
79 | + { | ||
80 | + String channel = customPayload.func_149169_c(); // getChannel | ||
81 | + byte[] data = customPayload.func_149168_d(); // getData | ||
82 | + | ||
83 | + if (PluginChannels.CHANNEL_REGISTER.equals(channel)) | ||
84 | + { | ||
85 | + this.onRegisterPacketReceived(data); | ||
86 | + } | ||
87 | + else if (this.pluginChannels.containsKey(channel)) | ||
88 | + { | ||
89 | + try | ||
90 | + { | ||
91 | + PermissionsManagerClient permissionsManager = LiteLoader.getPermissionsManager(); | ||
92 | + if (permissionsManager != null) | ||
93 | + { | ||
94 | + permissionsManager.onCustomPayload(channel, data.length, data); | ||
95 | + } | ||
96 | + } | ||
97 | + catch (Exception ex) {} | ||
98 | + | ||
99 | + this.onModPacketReceived(channel, data, data.length); | ||
100 | + } | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * @param channel | ||
106 | + * @param data | ||
107 | + * @param length | ||
108 | + */ | ||
109 | + protected void onModPacketReceived(String channel, byte[] data, int length) | ||
110 | + { | ||
111 | + for (PluginChannelListener pluginChannelListener : this.pluginChannels.get(channel)) | ||
112 | + { | ||
113 | + try | ||
114 | + { | ||
115 | + pluginChannelListener.onCustomPayload(channel, length, data); | ||
116 | + throw new RuntimeException(); | ||
117 | + } | ||
118 | + catch (Exception ex) | ||
119 | + { | ||
120 | + int failCount = 1; | ||
121 | + if (this.faultingPluginChannelListeners.containsKey(pluginChannelListener)) | ||
122 | + failCount = this.faultingPluginChannelListeners.get(pluginChannelListener).intValue() + 1; | ||
123 | + | ||
124 | + if (failCount >= PluginChannels.WARN_FAULT_THRESHOLD) | ||
125 | + { | ||
126 | + LiteLoaderLogger.warning("Plugin channel listener %s exceeded fault threshold on channel %s with %s", pluginChannelListener.getName(), channel, ex.getClass().getSimpleName()); | ||
127 | + this.faultingPluginChannelListeners.remove(pluginChannelListener); | ||
128 | + } | ||
129 | + else | ||
130 | + { | ||
131 | + this.faultingPluginChannelListeners.put(pluginChannelListener, Integer.valueOf(failCount)); | ||
132 | + } | ||
133 | + } | ||
134 | + } | ||
135 | + } | ||
136 | + | ||
137 | + protected void sendRegisteredPluginChannels(INetHandler netHandler) | ||
138 | + { | ||
139 | + // Add the permissions manager channels | ||
140 | + this.addPluginChannelsFor(LiteLoader.getPermissionsManager()); | ||
141 | + | ||
142 | + try | ||
143 | + { | ||
144 | + byte[] registrationData = this.getRegistrationData(); | ||
145 | + if (registrationData != null) | ||
146 | + { | ||
147 | + this.sendRegistrationData(netHandler, registrationData); | ||
148 | + } | ||
149 | + } | ||
150 | + catch (Exception ex) | ||
151 | + { | ||
152 | + LiteLoaderLogger.warning(ex, "Error dispatching REGISTER packet to server %s", ex.getClass().getSimpleName()); | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + /** | ||
157 | + * @param netHandler | ||
158 | + * @param registrationData | ||
159 | + */ | ||
160 | + protected void sendRegistrationData(INetHandler netHandler, byte[] registrationData) | ||
161 | + { | ||
162 | + if (netHandler instanceof INetHandlerLoginClient) | ||
163 | + { | ||
164 | + NetworkManager networkManager = PrivateFields.netManager.get(((NetHandlerLoginClient)netHandler)); | ||
165 | + networkManager.scheduleOutboundPacket(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); | ||
166 | + } | ||
167 | + else if (netHandler instanceof INetHandlerPlayClient) | ||
168 | + { | ||
169 | + ClientPluginChannels.dispatch(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); | ||
170 | + } | ||
171 | + } | ||
172 | + | ||
173 | + /** | ||
174 | + * @param channel | ||
175 | + * @param data | ||
176 | + */ | ||
177 | + static boolean dispatch(C17PacketCustomPayload payload) | ||
178 | + { | ||
179 | + try | ||
180 | + { | ||
181 | + Minecraft minecraft = Minecraft.getMinecraft(); | ||
182 | + | ||
183 | + if (minecraft.thePlayer != null && minecraft.thePlayer.sendQueue != null) | ||
184 | + { | ||
185 | + minecraft.thePlayer.sendQueue.addToSendQueue(payload); | ||
186 | + return true; | ||
187 | + } | ||
188 | + } | ||
189 | + catch (Exception ex) {} | ||
190 | + | ||
191 | + return false; | ||
192 | + } | ||
193 | + | ||
194 | + /** | ||
195 | + * Send a message to the server on a plugin channel | ||
196 | + * | ||
197 | + * @param channel Channel to send, must not be a reserved channel name | ||
198 | + * @param data | ||
199 | + */ | ||
200 | + public static boolean sendMessage(String channel, byte[] data, ChannelPolicy policy) | ||
201 | + { | ||
202 | + if (!policy.allows(ClientPluginChannels.getInstance(), channel)) | ||
203 | + { | ||
204 | + if (policy.isSilent()) return false; | ||
205 | + throw new UnregisteredChannelException(channel); | ||
206 | + } | ||
207 | + | ||
208 | + if (channel == null || channel.length() > 16 || CHANNEL_REGISTER.equals(channel) || CHANNEL_UNREGISTER.equals(channel)) | ||
209 | + throw new RuntimeException("Invalid channel name specified"); | ||
210 | + | ||
211 | + C17PacketCustomPayload payload = new C17PacketCustomPayload(channel, data); | ||
212 | + return ClientPluginChannels.dispatch(payload); | ||
213 | + } | ||
214 | +} |
java/com/mumfrey/liteloader/core/CommonPluginChannelListener.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import com.mumfrey.liteloader.LiteMod; | ||
6 | + | ||
7 | +/** | ||
8 | + * Common interface for the client/server plugin channel listeners. DO NOT IMPLEMENT THIS INTERFACE DIRECTLY, nothing will happen! | ||
9 | + * | ||
10 | + * @author Adam Mummery-Smith | ||
11 | + */ | ||
12 | +public interface CommonPluginChannelListener extends LiteMod | ||
13 | +{ | ||
14 | + /** | ||
15 | + * Return a list of the plugin channels the mod wants to register | ||
16 | + * | ||
17 | + * @return | ||
18 | + */ | ||
19 | + public abstract List<String> getChannels(); | ||
20 | +} |
java/com/mumfrey/liteloader/core/EnabledModsList.java
@@ -54,33 +54,33 @@ public class EnabledModsList | @@ -54,33 +54,33 @@ public class EnabledModsList | ||
54 | * Check whether a particular mod is enabled | 54 | * Check whether a particular mod is enabled |
55 | * | 55 | * |
56 | * @param profileName | 56 | * @param profileName |
57 | - * @param name | 57 | + * @param identifier |
58 | * @return | 58 | * @return |
59 | */ | 59 | */ |
60 | - public boolean isEnabled(String profileName, String name) | 60 | + public boolean isEnabled(String profileName, String identifier) |
61 | { | 61 | { |
62 | Map<String, Boolean> profile = this.getProfile(profileName); | 62 | Map<String, Boolean> profile = this.getProfile(profileName); |
63 | - name = name.toLowerCase().trim(); | 63 | + identifier = identifier.toLowerCase().trim(); |
64 | 64 | ||
65 | - if (!profile.containsKey(name)) | 65 | + if (!profile.containsKey(identifier)) |
66 | { | 66 | { |
67 | - profile.put(name, this.defaultEnabledValue); | 67 | + profile.put(identifier, this.defaultEnabledValue); |
68 | } | 68 | } |
69 | 69 | ||
70 | - return profile.get(name); | 70 | + return profile.get(identifier); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Set the enablement state of a mod in the specified profile | 74 | * Set the enablement state of a mod in the specified profile |
75 | * | 75 | * |
76 | * @param profileName | 76 | * @param profileName |
77 | - * @param name | 77 | + * @param identifier |
78 | * @param enabled | 78 | * @param enabled |
79 | */ | 79 | */ |
80 | - public void setEnabled(String profileName, String name, boolean enabled) | 80 | + public void setEnabled(String profileName, String identifier, boolean enabled) |
81 | { | 81 | { |
82 | Map<String, Boolean> profile = this.getProfile(profileName); | 82 | Map<String, Boolean> profile = this.getProfile(profileName); |
83 | - profile.put(name.toLowerCase().trim(), Boolean.valueOf(enabled)); | 83 | + profile.put(identifier.toLowerCase().trim(), Boolean.valueOf(enabled)); |
84 | 84 | ||
85 | this.allowSave = true; | 85 | this.allowSave = true; |
86 | } | 86 | } |
java/com/mumfrey/liteloader/core/EnumeratorModule.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import net.minecraft.launchwrapper.LaunchClassLoader; | ||
4 | + | ||
5 | +/** | ||
6 | + * Interface for objects which can enumerate mods in places | ||
7 | + * | ||
8 | + * @author Adam Mummery-Smith | ||
9 | + * | ||
10 | + * @param <T> | ||
11 | + */ | ||
12 | +public interface EnumeratorModule<T> | ||
13 | +{ | ||
14 | + /** | ||
15 | + * @param enumerator | ||
16 | + */ | ||
17 | + public abstract void init(PluggableEnumerator enumerator); | ||
18 | + | ||
19 | + /** | ||
20 | + * @param enumerator | ||
21 | + */ | ||
22 | + public abstract void writeSettings(PluggableEnumerator enumerator); | ||
23 | + | ||
24 | + /** | ||
25 | + * Find loadable mods in this enumerator's domain | ||
26 | + * | ||
27 | + * @param enumerator | ||
28 | + * @param enabledModsList | ||
29 | + * @param profile | ||
30 | + */ | ||
31 | + public abstract void enumerate(PluggableEnumerator enumerator, EnabledModsList enabledModsList, String profile); | ||
32 | + | ||
33 | + /** | ||
34 | + * @param enumerator | ||
35 | + * @param classLoader | ||
36 | + * @param enabledModsList | ||
37 | + * @param profile | ||
38 | + */ | ||
39 | + public abstract void injectIntoClassLoader(PluggableEnumerator enumerator, LaunchClassLoader classLoader, EnabledModsList enabledModsList, String profile); | ||
40 | + | ||
41 | + /** | ||
42 | + * @param enumerator | ||
43 | + * @param classLoader | ||
44 | + */ | ||
45 | + public abstract void registerMods(PluggableEnumerator enumerator, LaunchClassLoader classLoader); | ||
46 | +} | ||
0 | \ No newline at end of file | 47 | \ No newline at end of file |
java/com/mumfrey/liteloader/core/EnumeratorModuleClassPath.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import java.io.File; | ||
4 | +import java.util.ArrayList; | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +import net.minecraft.launchwrapper.LaunchClassLoader; | ||
8 | + | ||
9 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
10 | + | ||
11 | +/** | ||
12 | + * Enumerator module which searches for mods on the classpath | ||
13 | + * | ||
14 | + * @author Adam Mummery-Smith | ||
15 | + */ | ||
16 | +public class EnumeratorModuleClassPath implements EnumeratorModule<File> | ||
17 | +{ | ||
18 | + /** | ||
19 | + * Array of class path entries specified to the JVM instance | ||
20 | + */ | ||
21 | + private final String[] classPathEntries; | ||
22 | + | ||
23 | + /** | ||
24 | + * URLs to add once init is completed | ||
25 | + */ | ||
26 | + private final List<LoadableMod<File>> loadableMods = new ArrayList<LoadableMod<File>>(); | ||
27 | + | ||
28 | + private boolean loadTweaks; | ||
29 | + | ||
30 | + /** | ||
31 | + * @param parent | ||
32 | + * @param searchProtectionDomain | ||
33 | + * @param searchClassPath | ||
34 | + * @param loadTweaks | ||
35 | + */ | ||
36 | + public EnumeratorModuleClassPath(boolean loadTweaks) | ||
37 | + { | ||
38 | + // Read the JVM class path into the local array | ||
39 | + this.classPathEntries = this.readClassPath(); | ||
40 | + | ||
41 | + this.loadTweaks = loadTweaks; | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public String toString() | ||
46 | + { | ||
47 | + return "<Java Class Path>"; | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public void init(PluggableEnumerator enumerator) | ||
52 | + { | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public void writeSettings(PluggableEnumerator enumerator) | ||
57 | + { | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * Reads the class path entries that were supplied to the JVM and returns them as an array | ||
62 | + */ | ||
63 | + private String[] readClassPath() | ||
64 | + { | ||
65 | + LiteLoaderLogger.info("Enumerating class path..."); | ||
66 | + | ||
67 | + String classPath = System.getProperty("java.class.path"); | ||
68 | + String classPathSeparator = System.getProperty("path.separator"); | ||
69 | + String[] classPathEntries = classPath.split(classPathSeparator); | ||
70 | + | ||
71 | + LiteLoaderLogger.info("Class path separator=\"%s\"", classPathSeparator); | ||
72 | + LiteLoaderLogger.info("Class path entries=(\n classpathEntry=%s\n)", classPath.replace(classPathSeparator, "\n classpathEntry=")); | ||
73 | + return classPathEntries; | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public void enumerate(PluggableEnumerator enumerator, EnabledModsList enabledModsList, String profile) | ||
78 | + { | ||
79 | + if (this.loadTweaks) | ||
80 | + { | ||
81 | + LiteLoaderLogger.info("Discovering tweaks on class path..."); | ||
82 | + | ||
83 | + for (String classPathPart : this.classPathEntries) | ||
84 | + { | ||
85 | + File packagePath = new File(classPathPart); | ||
86 | + if (packagePath.exists()) | ||
87 | + { | ||
88 | + LoadableModClassPath classPathMod = new LoadableModClassPath(packagePath); | ||
89 | + if (enumerator.isContainerEnabled(classPathMod)) | ||
90 | + { | ||
91 | + this.loadableMods.add(classPathMod); | ||
92 | + if (classPathMod.hasTweakClass() || classPathMod.hasClassTransformers()) | ||
93 | + { | ||
94 | + enumerator.registerTweakContainer(classPathMod); | ||
95 | + } | ||
96 | + } | ||
97 | + else | ||
98 | + { | ||
99 | + LiteLoaderLogger.info("Mod %s is disabled or missing a required dependency, not injecting tranformers", classPathMod.getIdentifier()); | ||
100 | + } | ||
101 | + } | ||
102 | + } | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public void injectIntoClassLoader(PluggableEnumerator enumerator, LaunchClassLoader classLoader, EnabledModsList enabledModsList, String profile) | ||
108 | + { | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * @param classLoader | ||
113 | + */ | ||
114 | + @Override | ||
115 | + public void registerMods(PluggableEnumerator enumerator, LaunchClassLoader classLoader) | ||
116 | + { | ||
117 | + LiteLoaderLogger.info("Discovering mods on class path..."); | ||
118 | + | ||
119 | + for (LoadableMod<File> classPathMod : this.loadableMods) | ||
120 | + { | ||
121 | + LiteLoaderLogger.info("Searching %s...", classPathMod); | ||
122 | + enumerator.registerModsFrom(classPathMod, true); | ||
123 | + } | ||
124 | + } | ||
125 | +} |
java/com/mumfrey/liteloader/core/EnumeratorModuleFolder.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import java.io.File; | ||
4 | +import java.io.FilenameFilter; | ||
5 | +import java.io.IOException; | ||
6 | +import java.net.MalformedURLException; | ||
7 | +import java.util.ArrayList; | ||
8 | +import java.util.HashMap; | ||
9 | +import java.util.List; | ||
10 | +import java.util.Map; | ||
11 | +import java.util.TreeSet; | ||
12 | +import java.util.Map.Entry; | ||
13 | +import java.util.zip.ZipEntry; | ||
14 | +import java.util.zip.ZipFile; | ||
15 | + | ||
16 | +import net.minecraft.launchwrapper.LaunchClassLoader; | ||
17 | + | ||
18 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
19 | + | ||
20 | +/** | ||
21 | + * Enumerator module which searches for mods and tweaks in a folder | ||
22 | + * | ||
23 | + * @author Adam Mummery-Smith | ||
24 | + */ | ||
25 | +public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule<File> | ||
26 | +{ | ||
27 | + private static final String OPTION_SEARCH_ZIPFILES = "search.zipfiles"; | ||
28 | + private static final String OPTION_SEARCH_JARFILES = "search.jarfiles"; | ||
29 | + | ||
30 | + /** | ||
31 | + * Ordered sets used to sort mods by version/revision | ||
32 | + */ | ||
33 | + private final Map<String, TreeSet<LoadableMod<File>>> versionOrderingSets = new HashMap<String, TreeSet<LoadableMod<File>>>(); | ||
34 | + | ||
35 | + /** | ||
36 | + * Mods to add once init is completed | ||
37 | + */ | ||
38 | + private final List<LoadableMod<File>> loadableMods = new ArrayList<LoadableMod<File>>(); | ||
39 | + | ||
40 | + private File directory; | ||
41 | + | ||
42 | + private boolean readZipFiles; | ||
43 | + private boolean readJarFiles; | ||
44 | + private boolean loadTweaks; | ||
45 | + | ||
46 | + /** | ||
47 | + * True if this is a general, unversioned folder and the enumerator should only add files which have valid version metadata | ||
48 | + */ | ||
49 | + private final boolean requireMetaData; | ||
50 | + | ||
51 | + public EnumeratorModuleFolder(File directory, boolean loadTweaks, boolean requireMetaData) | ||
52 | + { | ||
53 | + this.directory = directory; | ||
54 | + this.loadTweaks = loadTweaks; | ||
55 | + this.requireMetaData = requireMetaData; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public void init(PluggableEnumerator enumerator) | ||
60 | + { | ||
61 | + this.readZipFiles = enumerator.getAndStoreBooleanProperty(OPTION_SEARCH_ZIPFILES, false); | ||
62 | + this.readJarFiles = enumerator.getAndStoreBooleanProperty(OPTION_SEARCH_JARFILES, true); | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Write settings | ||
67 | + */ | ||
68 | + @Override | ||
69 | + public void writeSettings(PluggableEnumerator enumerator) | ||
70 | + { | ||
71 | + enumerator.setBooleanProperty(OPTION_SEARCH_ZIPFILES, this.readZipFiles); | ||
72 | + enumerator.setBooleanProperty(OPTION_SEARCH_JARFILES, this.readJarFiles); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public String toString() | ||
77 | + { | ||
78 | + return this.directory.getAbsolutePath(); | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * @return | ||
83 | + */ | ||
84 | + public File getDirectory() | ||
85 | + { | ||
86 | + return this.directory; | ||
87 | + } | ||
88 | + | ||
89 | + /* (non-Javadoc) | ||
90 | + * @see com.mumfrey.liteloader.core.Enumerator#getLoadableMods() | ||
91 | + */ | ||
92 | + public List<LoadableMod<File>> getLoadableMods() | ||
93 | + { | ||
94 | + return this.loadableMods; | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * For FilenameFilter interface | ||
99 | + * | ||
100 | + * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) | ||
101 | + */ | ||
102 | + @Override | ||
103 | + public boolean accept(File dir, String fileName) | ||
104 | + { | ||
105 | + fileName = fileName.toLowerCase(); | ||
106 | + return fileName.endsWith(".litemod") | ||
107 | + || (this.readZipFiles && fileName.endsWith(".zip")) | ||
108 | + || (this.readJarFiles && fileName.endsWith(".jar")); | ||
109 | + } | ||
110 | + | ||
111 | + /* (non-Javadoc) | ||
112 | + * @see com.mumfrey.liteloader.core.Enumerator#enumerate(com.mumfrey.liteloader.core.EnabledModsList, java.lang.String) | ||
113 | + */ | ||
114 | + @Override | ||
115 | + public void enumerate(PluggableEnumerator enumerator, EnabledModsList enabledModsList, String profile) | ||
116 | + { | ||
117 | + if (this.directory.exists() && this.directory.isDirectory()) | ||
118 | + { | ||
119 | + LiteLoaderLogger.info("Discovering valid mod files in folder %s", this.directory.getPath()); | ||
120 | + | ||
121 | + this.findValidFiles(enumerator, enabledModsList, profile); | ||
122 | + this.sortAndAllocateFiles(enumerator, enabledModsList, profile); | ||
123 | + this.versionOrderingSets.clear(); | ||
124 | + } | ||
125 | + } | ||
126 | + | ||
127 | + /** | ||
128 | + * @param enabledModsList | ||
129 | + * @param profile | ||
130 | + */ | ||
131 | + private void findValidFiles(PluggableEnumerator enumerator, EnabledModsList enabledModsList, String profile) | ||
132 | + { | ||
133 | + for (File candidateFile : this.directory.listFiles(this)) | ||
134 | + { | ||
135 | + ZipFile candidateZip = null; | ||
136 | + | ||
137 | + try | ||
138 | + { | ||
139 | + candidateZip = new ZipFile(candidateFile); | ||
140 | + ZipEntry versionEntry = candidateZip.getEntry(LoadableMod.METADATA_FILENAME); | ||
141 | + ZipEntry legacyVersionEntry = candidateZip.getEntry(LoadableMod.LEGACY_METADATA_FILENAME); | ||
142 | + | ||
143 | + // Check for a version file | ||
144 | + if (versionEntry != null) | ||
145 | + { | ||
146 | + String strVersion = null; | ||
147 | + try | ||
148 | + { | ||
149 | + strVersion = LoadableModFile.zipEntryToString(candidateZip, versionEntry); | ||
150 | + } | ||
151 | + catch (IOException ex) | ||
152 | + { | ||
153 | + LiteLoaderLogger.warning("Error reading version data from %s", candidateZip.getName()); | ||
154 | + } | ||
155 | + | ||
156 | + if (strVersion != null) | ||
157 | + { | ||
158 | + this.addModFile(candidateFile, strVersion); | ||
159 | + } | ||
160 | + } | ||
161 | + else if (legacyVersionEntry != null) | ||
162 | + { | ||
163 | + LiteLoaderLogger.warning("%s is no longer supported, ignoring outdated mod file: %s", LoadableMod.LEGACY_METADATA_FILENAME, candidateFile.getAbsolutePath()); | ||
164 | + } | ||
165 | + else if (!this.requireMetaData && this.loadTweaks && this.readJarFiles && candidateFile.getName().toLowerCase().endsWith(".jar")) | ||
166 | + { | ||
167 | + LoadableFile container = new LoadableFile(candidateFile); | ||
168 | + enumerator.registerTweakContainer(container); | ||
169 | + } | ||
170 | + } | ||
171 | + catch (Exception ex) | ||
172 | + { | ||
173 | + LiteLoaderLogger.info("Error enumerating '%s': Invalid zip file or error reading file", candidateFile.getAbsolutePath()); | ||
174 | + } | ||
175 | + finally | ||
176 | + { | ||
177 | + if (candidateZip != null) | ||
178 | + { | ||
179 | + try | ||
180 | + { | ||
181 | + candidateZip.close(); | ||
182 | + } | ||
183 | + catch (IOException ex) {} | ||
184 | + } | ||
185 | + } | ||
186 | + } | ||
187 | + } | ||
188 | + | ||
189 | + /** | ||
190 | + * @param candidateFile | ||
191 | + * @param strVersion | ||
192 | + */ | ||
193 | + private void addModFile(File candidateFile, String strVersion) | ||
194 | + { | ||
195 | + LoadableModFile modFile = new LoadableModFile(candidateFile, strVersion); | ||
196 | + | ||
197 | + if (modFile.hasValidMetaData()) | ||
198 | + { | ||
199 | + // Only add the mod if the version matches, we add candidates to the versionOrderingSets in | ||
200 | + // order to determine the most recent version available. | ||
201 | + if (LiteLoaderVersion.CURRENT.isVersionSupported(modFile.getTargetVersion())) | ||
202 | + { | ||
203 | + if (!this.versionOrderingSets.containsKey(modFile.getName())) | ||
204 | + { | ||
205 | + this.versionOrderingSets.put(modFile.getModName(), new TreeSet<LoadableMod<File>>()); | ||
206 | + } | ||
207 | + | ||
208 | + LiteLoaderLogger.info("Considering valid mod file: %s", modFile.getAbsolutePath()); | ||
209 | + this.versionOrderingSets.get(modFile.getModName()).add(modFile); | ||
210 | + } | ||
211 | + else | ||
212 | + { | ||
213 | + LiteLoaderLogger.info("Not adding invalid or outdated mod file: %s", candidateFile.getAbsolutePath()); | ||
214 | + } | ||
215 | + } | ||
216 | + } | ||
217 | + | ||
218 | + /** | ||
219 | + * @param enumerator | ||
220 | + * @param enabledModsList | ||
221 | + * @param enabledModsList | ||
222 | + * @param profile | ||
223 | + * @param profile | ||
224 | + */ | ||
225 | + @SuppressWarnings("unchecked") | ||
226 | + private void sortAndAllocateFiles(PluggableEnumerator enumerator, EnabledModsList enabledModsList, String profile) | ||
227 | + { | ||
228 | + // Copy the first entry in every version set into the modfiles list | ||
229 | + for (Entry<String, TreeSet<LoadableMod<File>>> modFileEntry : this.versionOrderingSets.entrySet()) | ||
230 | + { | ||
231 | + LoadableMod<File> newestVersion = modFileEntry.getValue().iterator().next(); | ||
232 | + | ||
233 | + if (enumerator.isContainerEnabled(newestVersion)) | ||
234 | + { | ||
235 | + LiteLoaderLogger.info("Adding newest valid mod file '%s' at revision %.4f", newestVersion.getLocation(), newestVersion.getRevision()); | ||
236 | + this.loadableMods.add(newestVersion); | ||
237 | + } | ||
238 | + else | ||
239 | + { | ||
240 | + LiteLoaderLogger.info("Not adding valid mod file '%s', the specified mod is disabled or missing a required dependency", newestVersion.getLocation()); | ||
241 | + } | ||
242 | + | ||
243 | + if (this.loadTweaks) | ||
244 | + { | ||
245 | + try | ||
246 | + { | ||
247 | + if (newestVersion instanceof TweakContainer) | ||
248 | + { | ||
249 | + enumerator.registerTweakContainer((TweakContainer<File>)newestVersion); | ||
250 | + } | ||
251 | + } | ||
252 | + catch (Throwable th) | ||
253 | + { | ||
254 | + LiteLoaderLogger.warning("Error adding tweaks from '%s'", newestVersion.getLocation()); | ||
255 | + } | ||
256 | + } | ||
257 | + } | ||
258 | + } | ||
259 | + | ||
260 | + @Override | ||
261 | + public void injectIntoClassLoader(PluggableEnumerator enumerator, LaunchClassLoader classLoader, EnabledModsList enabledModsList, String profile) | ||
262 | + { | ||
263 | + LiteLoaderLogger.info("Injecting external mods into class path..."); | ||
264 | + | ||
265 | + for (LoadableMod<?> loadableMod : this.loadableMods) | ||
266 | + { | ||
267 | + try | ||
268 | + { | ||
269 | + if (loadableMod.injectIntoClassPath(classLoader, false)) | ||
270 | + { | ||
271 | + LiteLoaderLogger.info("Successfully injected mod file '%s' into classpath", loadableMod.getLocation()); | ||
272 | + } | ||
273 | + } | ||
274 | + catch (MalformedURLException ex) | ||
275 | + { | ||
276 | + LiteLoaderLogger.warning("Error injecting '%s' into classPath. The mod will not be loaded", loadableMod.getLocation()); | ||
277 | + } | ||
278 | + } | ||
279 | + } | ||
280 | + | ||
281 | + @Override | ||
282 | + public void registerMods(PluggableEnumerator enumerator, LaunchClassLoader classLoader) | ||
283 | + { | ||
284 | + LiteLoaderLogger.info("Discovering mods in valid mod files..."); | ||
285 | + | ||
286 | + for (LoadableMod<?> modFile : this.loadableMods) | ||
287 | + { | ||
288 | + LiteLoaderLogger.info("Searching %s...", modFile.getLocation()); | ||
289 | + enumerator.registerModsFrom(modFile, true); | ||
290 | + } | ||
291 | + } | ||
292 | +} |
java/com/mumfrey/liteloader/core/EnumeratorModuleProtectionDomain.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import java.io.File; | ||
4 | +import java.net.URL; | ||
5 | +import java.net.URLDecoder; | ||
6 | + | ||
7 | +import net.minecraft.launchwrapper.LaunchClassLoader; | ||
8 | + | ||
9 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
10 | + | ||
11 | +/** | ||
12 | + * Enumerator module which searches for mods on the classpath | ||
13 | + * | ||
14 | + * @author Adam Mummery-Smith | ||
15 | + */ | ||
16 | +public class EnumeratorModuleProtectionDomain implements EnumeratorModule<File> | ||
17 | +{ | ||
18 | + private LoadableMod<File> codeSource; | ||
19 | + | ||
20 | + /** | ||
21 | + * @param parent | ||
22 | + * @param searchProtectionDomain | ||
23 | + * @param searchClassPath | ||
24 | + * @param loadTweaks | ||
25 | + */ | ||
26 | + public EnumeratorModuleProtectionDomain(boolean loadTweaks) | ||
27 | + { | ||
28 | + this.initPackagePath(); | ||
29 | + } | ||
30 | + | ||
31 | + @Override | ||
32 | + public String toString() | ||
33 | + { | ||
34 | + return this.codeSource != null ? this.codeSource.getName() : "<None>"; | ||
35 | + } | ||
36 | + | ||
37 | + private void initPackagePath() | ||
38 | + { | ||
39 | + try | ||
40 | + { | ||
41 | + URL protectionDomainLocation = EnumeratorModuleProtectionDomain.class.getProtectionDomain().getCodeSource().getLocation(); | ||
42 | + if (protectionDomainLocation != null) | ||
43 | + { | ||
44 | + LiteLoaderLogger.info("Determining code source using protection domain"); | ||
45 | + if (protectionDomainLocation.toString().indexOf('!') > -1 && protectionDomainLocation.toString().startsWith("jar:")) | ||
46 | + { | ||
47 | + LiteLoaderLogger.info("Protection domain references a jar file"); | ||
48 | + protectionDomainLocation = new URL(protectionDomainLocation.toString().substring(4, protectionDomainLocation.toString().indexOf('!'))); | ||
49 | + } | ||
50 | + | ||
51 | + File packagePath = new File(protectionDomainLocation.toURI()); | ||
52 | + if (packagePath.isFile() && packagePath.getName().endsWith(".class")) | ||
53 | + { | ||
54 | + packagePath = packagePath.getParentFile(); | ||
55 | + } | ||
56 | + | ||
57 | + this.codeSource = new LoadableModClassPath(packagePath); | ||
58 | + } | ||
59 | + else | ||
60 | + { | ||
61 | + LiteLoaderLogger.info("Determining code source using resource"); | ||
62 | + String reflectionClassPath = EnumeratorModuleProtectionDomain.class.getResource("/net/minecraft/client/main/Main.class").getPath(); | ||
63 | + | ||
64 | + if (reflectionClassPath.indexOf('!') > -1) | ||
65 | + { | ||
66 | + reflectionClassPath = URLDecoder.decode(reflectionClassPath, "UTF-8"); | ||
67 | + this.codeSource = new LoadableModClassPath(new File(reflectionClassPath.substring(5, reflectionClassPath.indexOf('!')))); | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + catch (Throwable th) | ||
72 | + { | ||
73 | + LiteLoaderLogger.warning("Error determining local protection domain: %s", th.getMessage()); | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public void init(PluggableEnumerator enumerator) | ||
79 | + { | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void writeSettings(PluggableEnumerator enumerator) | ||
84 | + { | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + public void enumerate(PluggableEnumerator enumerator, EnabledModsList enabledModsList, String profile) | ||
89 | + { | ||
90 | + } | ||
91 | + | ||
92 | + @Override | ||
93 | + public void injectIntoClassLoader(PluggableEnumerator enumerator, LaunchClassLoader classLoader, EnabledModsList enabledModsList, String profile) | ||
94 | + { | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * @param classLoader | ||
99 | + */ | ||
100 | + @Override | ||
101 | + public void registerMods(PluggableEnumerator enumerator, LaunchClassLoader classLoader) | ||
102 | + { | ||
103 | + LiteLoaderLogger.info("Discovering mods in protection domain..."); | ||
104 | + | ||
105 | + try | ||
106 | + { | ||
107 | + if (this.codeSource != null) | ||
108 | + { | ||
109 | + enumerator.registerModsFrom(this.codeSource, false); | ||
110 | + } | ||
111 | + } | ||
112 | + catch (Throwable th) | ||
113 | + { | ||
114 | + LiteLoaderLogger.warning("Error loading from local class path: %s", th.getMessage()); | ||
115 | + } | ||
116 | + } | ||
117 | +} |
java/com/mumfrey/liteloader/core/Events.java
1 | package com.mumfrey.liteloader.core; | 1 | package com.mumfrey.liteloader.core; |
2 | 2 | ||
3 | import java.util.LinkedList; | 3 | import java.util.LinkedList; |
4 | -import java.util.logging.Level; | ||
5 | 4 | ||
6 | -import org.lwjgl.input.Mouse; | 5 | +import net.minecraft.client.Minecraft; |
6 | +import net.minecraft.client.gui.GuiNewChat; | ||
7 | +import net.minecraft.client.gui.ScaledResolution; | ||
8 | +import net.minecraft.command.ICommandManager; | ||
9 | +import net.minecraft.command.ServerCommandManager; | ||
10 | +import net.minecraft.entity.player.EntityPlayerMP; | ||
11 | +import net.minecraft.network.INetHandler; | ||
12 | +import net.minecraft.network.NetHandlerPlayServer; | ||
13 | +import net.minecraft.network.NetworkManager; | ||
14 | +import net.minecraft.network.login.INetHandlerLoginClient; | ||
15 | +import net.minecraft.network.login.server.S02PacketLoginSuccess; | ||
16 | +import net.minecraft.network.play.INetHandlerPlayServer; | ||
17 | +import net.minecraft.network.play.client.C01PacketChatMessage; | ||
18 | +import net.minecraft.network.play.server.S01PacketJoinGame; | ||
19 | +import net.minecraft.network.play.server.S02PacketChat; | ||
20 | +import net.minecraft.profiler.Profiler; | ||
21 | +import net.minecraft.server.integrated.IntegratedServer; | ||
22 | +import net.minecraft.server.management.ServerConfigurationManager; | ||
23 | +import net.minecraft.util.IChatComponent; | ||
24 | +import net.minecraft.util.Timer; | ||
25 | +import net.minecraft.world.WorldSettings; | ||
7 | 26 | ||
8 | -import net.minecraft.src.*; | 27 | +import org.lwjgl.input.Mouse; |
9 | 28 | ||
29 | +import com.mojang.authlib.GameProfile; | ||
10 | import com.mumfrey.liteloader.*; | 30 | import com.mumfrey.liteloader.*; |
11 | -import com.mumfrey.liteloader.Tickable; | ||
12 | -import com.mumfrey.liteloader.core.hooks.HookProfiler; | 31 | +import com.mumfrey.liteloader.core.gen.GenProfiler; |
32 | +import com.mumfrey.liteloader.core.overlays.IMinecraft; | ||
13 | import com.mumfrey.liteloader.util.PrivateFields; | 33 | import com.mumfrey.liteloader.util.PrivateFields; |
34 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
14 | 35 | ||
15 | /** | 36 | /** |
16 | * | 37 | * |
17 | * @author Adam Mummery-Smith | 38 | * @author Adam Mummery-Smith |
18 | */ | 39 | */ |
19 | -public class Events implements IPlayerUsage | 40 | +public class Events |
20 | { | 41 | { |
21 | /** | 42 | /** |
22 | * Reference to the loader instance | 43 | * Reference to the loader instance |
@@ -29,9 +50,14 @@ public class Events implements IPlayerUsage | @@ -29,9 +50,14 @@ public class Events implements IPlayerUsage | ||
29 | private final Minecraft minecraft; | 50 | private final Minecraft minecraft; |
30 | 51 | ||
31 | /** | 52 | /** |
32 | - * Plugin channel manager | 53 | + * Client plugin channel manager |
54 | + */ | ||
55 | + private final ClientPluginChannels clientPluginChannels; | ||
56 | + | ||
57 | + /** | ||
58 | + * Server plugin channel manager | ||
33 | */ | 59 | */ |
34 | - private final PluginChannels pluginChannels; | 60 | + private final ServerPluginChannels serverPluginChannels; |
35 | 61 | ||
36 | /** | 62 | /** |
37 | * Reference to the minecraft timer | 63 | * Reference to the minecraft timer |
@@ -41,12 +67,12 @@ public class Events implements IPlayerUsage | @@ -41,12 +67,12 @@ public class Events implements IPlayerUsage | ||
41 | /** | 67 | /** |
42 | * Flags which keep track of whether hooks have been applied | 68 | * Flags which keep track of whether hooks have been applied |
43 | */ | 69 | */ |
44 | - private boolean hookInitDone, lateInitDone, tickHooked; | 70 | + private boolean hookInitDone, lateInitDone, profilerHooked; |
45 | 71 | ||
46 | /** | 72 | /** |
47 | * Profiler hook objects | 73 | * Profiler hook objects |
48 | */ | 74 | */ |
49 | - private final HookProfiler profilerHook = new HookProfiler(this); | 75 | + private Profiler genProfiler = null; |
50 | 76 | ||
51 | /** | 77 | /** |
52 | * ScaledResolution used by the pre-chat and post-chat render callbacks | 78 | * ScaledResolution used by the pre-chat and post-chat render callbacks |
@@ -117,16 +143,41 @@ public class Events implements IPlayerUsage | @@ -117,16 +143,41 @@ public class Events implements IPlayerUsage | ||
117 | private LinkedList<ChatFilter> chatFilters = new LinkedList<ChatFilter>(); | 143 | private LinkedList<ChatFilter> chatFilters = new LinkedList<ChatFilter>(); |
118 | 144 | ||
119 | /** | 145 | /** |
146 | + * List of mods which implement PostLoginListener and want to be notified post login | ||
147 | + */ | ||
148 | + private LinkedList<PostLoginListener> postLoginListeners = new LinkedList<PostLoginListener>(); | ||
149 | + | ||
150 | + /** | ||
120 | * List of mods which implement LoginListener interface and will receive | 151 | * List of mods which implement LoginListener interface and will receive |
121 | * client login events | 152 | * client login events |
122 | */ | 153 | */ |
123 | - private LinkedList<LoginListener> loginListeners = new LinkedList<LoginListener>(); | 154 | + private LinkedList<JoinGameListener> joinGameListeners = new LinkedList<JoinGameListener>(); |
124 | 155 | ||
125 | /** | 156 | /** |
126 | * List of mods which implement LoginListener interface and will receive | 157 | * List of mods which implement LoginListener interface and will receive |
127 | * client login events | 158 | * client login events |
128 | */ | 159 | */ |
129 | - private LinkedList<PreLoginListener> preLoginListeners = new LinkedList<PreLoginListener>(); | 160 | + private LinkedList<PreJoinGameListener> preJoinGameListeners = new LinkedList<PreJoinGameListener>(); |
161 | + | ||
162 | + /** | ||
163 | + * List of mods which can filter server chat | ||
164 | + */ | ||
165 | + private LinkedList<ServerChatFilter> serverChatFilters = new LinkedList<ServerChatFilter>(); | ||
166 | + | ||
167 | + /** | ||
168 | + * List of mods which provide server commands | ||
169 | + */ | ||
170 | + private LinkedList<ServerCommandProvider> serverCommandProviders = new LinkedList<ServerCommandProvider>(); | ||
171 | + | ||
172 | + /** | ||
173 | + * List of mods which monitor server player events | ||
174 | + */ | ||
175 | + private LinkedList<ServerPlayerListener> serverPlayerListeners = new LinkedList<ServerPlayerListener>(); | ||
176 | + | ||
177 | + /** | ||
178 | + * List of mods which monitor outbound chat | ||
179 | + */ | ||
180 | + private LinkedList<OutboundChatListener> outboundChatListeners = new LinkedList<OutboundChatListener>(); | ||
130 | 181 | ||
131 | /** | 182 | /** |
132 | * Hash code of the current world. We don't store the world reference here because we don't want | 183 | * Hash code of the current world. We don't store the world reference here because we don't want |
@@ -141,11 +192,23 @@ public class Events implements IPlayerUsage | @@ -141,11 +192,23 @@ public class Events implements IPlayerUsage | ||
141 | * @param minecraft | 192 | * @param minecraft |
142 | * @param pluginChannels | 193 | * @param pluginChannels |
143 | */ | 194 | */ |
144 | - Events(LiteLoader loader, Minecraft minecraft, PluginChannels pluginChannels) | 195 | + Events(LiteLoader loader, Minecraft minecraft, ClientPluginChannels pluginChannels, ServerPluginChannels serverPluginChannels, boolean genMappings) |
145 | { | 196 | { |
146 | this.loader = loader; | 197 | this.loader = loader; |
147 | this.minecraft = minecraft; | 198 | this.minecraft = minecraft; |
148 | - this.pluginChannels = pluginChannels; | 199 | + this.clientPluginChannels = pluginChannels; |
200 | + this.serverPluginChannels = serverPluginChannels; | ||
201 | + try | ||
202 | + { | ||
203 | + if (genMappings) | ||
204 | + { | ||
205 | + this.genProfiler = GenProfiler.class.newInstance(); | ||
206 | + } | ||
207 | + } | ||
208 | + catch (Throwable th) | ||
209 | + { | ||
210 | +// th.printStackTrace(); | ||
211 | + } | ||
149 | } | 212 | } |
150 | 213 | ||
151 | /** | 214 | /** |
@@ -189,7 +252,7 @@ public class Events implements IPlayerUsage | @@ -189,7 +252,7 @@ public class Events implements IPlayerUsage | ||
189 | { | 252 | { |
190 | if (listener instanceof ChatFilter) | 253 | if (listener instanceof ChatFilter) |
191 | { | 254 | { |
192 | - LiteLoader.getLogger().warning(String.format("Interface error initialising mod '%1s'. A mod implementing ChatFilter and ChatListener is not supported! Remove one of these interfaces", listener.getName())); | 255 | + LiteLoaderLogger.warning("Interface error initialising mod '%1s'. A mod implementing ChatFilter and ChatListener is not supported! Remove one of these interfaces", listener.getName()); |
193 | } | 256 | } |
194 | else | 257 | else |
195 | { | 258 | { |
@@ -207,47 +270,69 @@ public class Events implements IPlayerUsage | @@ -207,47 +270,69 @@ public class Events implements IPlayerUsage | ||
207 | this.addHUDRenderListener((HUDRenderListener)listener); | 270 | this.addHUDRenderListener((HUDRenderListener)listener); |
208 | } | 271 | } |
209 | 272 | ||
210 | - if (listener instanceof PreLoginListener) | 273 | + if (listener instanceof PreJoinGameListener) |
274 | + { | ||
275 | + this.addPreJoinGameListener((PreJoinGameListener)listener); | ||
276 | + } | ||
277 | + | ||
278 | + if (listener instanceof JoinGameListener) | ||
211 | { | 279 | { |
212 | - this.addPreLoginListener((PreLoginListener)listener); | 280 | + this.addJoinGameListener((JoinGameListener)listener); |
213 | } | 281 | } |
214 | 282 | ||
215 | - if (listener instanceof LoginListener) | 283 | + if (listener instanceof ServerChatFilter) |
216 | { | 284 | { |
217 | - this.addLoginListener((LoginListener)listener); | 285 | + this.addServerChatFilter((ServerChatFilter)listener); |
218 | } | 286 | } |
219 | 287 | ||
220 | - if (listener instanceof PluginChannelListener) | 288 | + if (listener instanceof ServerCommandProvider) |
221 | { | 289 | { |
222 | - this.pluginChannels.addPluginChannelListener((PluginChannelListener)listener); | 290 | + this.addServerCommandProvider((ServerCommandProvider)listener); |
291 | + } | ||
292 | + | ||
293 | + if (listener instanceof ServerPlayerListener) | ||
294 | + { | ||
295 | + this.addServerPlayerListener((ServerPlayerListener)listener); | ||
296 | + } | ||
297 | + | ||
298 | + if (listener instanceof OutboundChatListener) | ||
299 | + { | ||
300 | + this.addOutboundChatListener((OutboundChatListener)listener); | ||
301 | + } | ||
302 | + | ||
303 | + this.clientPluginChannels.addListener(listener); | ||
304 | + this.serverPluginChannels.addListener(listener); | ||
305 | + | ||
306 | + if (listener instanceof CommonPluginChannelListener && !(listener instanceof PluginChannelListener) && !(listener instanceof ServerPluginChannelListener)) | ||
307 | + { | ||
308 | + LiteLoaderLogger.warning("Interface error for mod '%1s'. Implementing CommonPluginChannelListener has no effect! Use PluginChannelListener or ServerPluginChannelListener instead", listener.getName()); | ||
223 | } | 309 | } |
224 | } | 310 | } |
225 | 311 | ||
226 | /** | 312 | /** |
227 | - * Initialise mod hooks | 313 | + * Initialise hooks |
228 | */ | 314 | */ |
229 | public void initHooks() | 315 | public void initHooks() |
230 | { | 316 | { |
231 | - try | 317 | + if (this.genProfiler != null) |
232 | { | 318 | { |
233 | - LiteLoader.getLogger().info("Event manager is registering hooks"); | ||
234 | - | ||
235 | - // Tick hook | ||
236 | - if (!this.tickHooked) | 319 | + try |
237 | { | 320 | { |
238 | - this.tickHooked = true; | ||
239 | - PrivateFields.minecraftProfiler.setFinal(this.minecraft, this.profilerHook); | 321 | + LiteLoaderLogger.info("Event manager is registering the mapping generator hook"); |
322 | + | ||
323 | + // Tick hook | ||
324 | + if (!this.profilerHooked) | ||
325 | + { | ||
326 | + this.profilerHooked = true; | ||
327 | + PrivateFields.minecraftProfiler.setFinal(this.minecraft, this.genProfiler); | ||
328 | + } | ||
240 | } | 329 | } |
241 | - | ||
242 | - // Sanity hook | ||
243 | - PlayerUsageSnooper snooper = this.minecraft.getPlayerUsageSnooper(); | ||
244 | - PrivateFields.playerStatsCollector.setFinal(snooper, this); | ||
245 | - } | ||
246 | - catch (Exception ex) | ||
247 | - { | ||
248 | - LiteLoader.getLogger().log(Level.WARNING, "Error creating hooks", ex); | ||
249 | - ex.printStackTrace(); | ||
250 | - } | 330 | + catch (Exception ex) |
331 | + { | ||
332 | + LiteLoaderLogger.warning(ex, "Error creating hook"); | ||
333 | + ex.printStackTrace(); | ||
334 | + } | ||
335 | + } | ||
251 | 336 | ||
252 | this.hookInitDone = true; | 337 | this.hookInitDone = true; |
253 | } | 338 | } |
@@ -325,8 +410,6 @@ public class Events implements IPlayerUsage | @@ -325,8 +410,6 @@ public class Events implements IPlayerUsage | ||
325 | if (!this.chatFilters.contains(chatFilter)) | 410 | if (!this.chatFilters.contains(chatFilter)) |
326 | { | 411 | { |
327 | this.chatFilters.add(chatFilter); | 412 | this.chatFilters.add(chatFilter); |
328 | - if (this.hookInitDone) | ||
329 | - this.initHooks(); | ||
330 | } | 413 | } |
331 | } | 414 | } |
332 | 415 | ||
@@ -338,8 +421,6 @@ public class Events implements IPlayerUsage | @@ -338,8 +421,6 @@ public class Events implements IPlayerUsage | ||
338 | if (!this.chatListeners.contains(chatListener)) | 421 | if (!this.chatListeners.contains(chatListener)) |
339 | { | 422 | { |
340 | this.chatListeners.add(chatListener); | 423 | this.chatListeners.add(chatListener); |
341 | - if (this.hookInitDone) | ||
342 | - this.initHooks(); | ||
343 | } | 424 | } |
344 | } | 425 | } |
345 | 426 | ||
@@ -370,28 +451,79 @@ public class Events implements IPlayerUsage | @@ -370,28 +451,79 @@ public class Events implements IPlayerUsage | ||
370 | } | 451 | } |
371 | 452 | ||
372 | /** | 453 | /** |
373 | - * @param loginListener | 454 | + * @param postLoginListener |
374 | */ | 455 | */ |
375 | - public void addPreLoginListener(PreLoginListener loginListener) | 456 | + public void addPreJoinGameListener(PostLoginListener postLoginListener) |
376 | { | 457 | { |
377 | - if (!this.preLoginListeners.contains(loginListener)) | 458 | + if (!this.postLoginListeners.contains(postLoginListener)) |
378 | { | 459 | { |
379 | - this.preLoginListeners.add(loginListener); | ||
380 | - if (this.hookInitDone) | ||
381 | - this.initHooks(); | 460 | + this.postLoginListeners.add(postLoginListener); |
382 | } | 461 | } |
383 | } | 462 | } |
384 | 463 | ||
385 | /** | 464 | /** |
386 | - * @param loginListener | 465 | + * @param joinGameListener |
387 | */ | 466 | */ |
388 | - public void addLoginListener(LoginListener loginListener) | 467 | + public void addPreJoinGameListener(PreJoinGameListener joinGameListener) |
389 | { | 468 | { |
390 | - if (!this.loginListeners.contains(loginListener)) | 469 | + if (!this.preJoinGameListeners.contains(joinGameListener)) |
391 | { | 470 | { |
392 | - this.loginListeners.add(loginListener); | ||
393 | - if (this.hookInitDone) | ||
394 | - this.initHooks(); | 471 | + this.preJoinGameListeners.add(joinGameListener); |
472 | + } | ||
473 | + } | ||
474 | + | ||
475 | + /** | ||
476 | + * @param joinGameListener | ||
477 | + */ | ||
478 | + public void addJoinGameListener(JoinGameListener joinGameListener) | ||
479 | + { | ||
480 | + if (!this.joinGameListeners.contains(joinGameListener)) | ||
481 | + { | ||
482 | + this.joinGameListeners.add(joinGameListener); | ||
483 | + } | ||
484 | + } | ||
485 | + | ||
486 | + /** | ||
487 | + * @param serverChatFilter | ||
488 | + */ | ||
489 | + public void addServerChatFilter(ServerChatFilter serverChatFilter) | ||
490 | + { | ||
491 | + if (!this.serverChatFilters.contains(serverChatFilter)) | ||
492 | + { | ||
493 | + this.serverChatFilters.add(serverChatFilter); | ||
494 | + } | ||
495 | + } | ||
496 | + | ||
497 | + /** | ||
498 | + * @param serverCommandProvider | ||
499 | + */ | ||
500 | + public void addServerCommandProvider(ServerCommandProvider serverCommandProvider) | ||
501 | + { | ||
502 | + if (!this.serverCommandProviders.contains(serverCommandProvider)) | ||
503 | + { | ||
504 | + this.serverCommandProviders.add(serverCommandProvider); | ||
505 | + } | ||
506 | + } | ||
507 | + | ||
508 | + /** | ||
509 | + * @param serverPlayerListener | ||
510 | + */ | ||
511 | + public void addServerPlayerListener(ServerPlayerListener serverPlayerListener) | ||
512 | + { | ||
513 | + if (!this.serverPlayerListeners.contains(serverPlayerListener)) | ||
514 | + { | ||
515 | + this.serverPlayerListeners.add(serverPlayerListener); | ||
516 | + } | ||
517 | + } | ||
518 | + | ||
519 | + /** | ||
520 | + * @param outboundChatListener | ||
521 | + */ | ||
522 | + private void addOutboundChatListener(OutboundChatListener outboundChatListener) | ||
523 | + { | ||
524 | + if (!this.outboundChatListeners.contains(outboundChatListener)) | ||
525 | + { | ||
526 | + this.outboundChatListeners.add(outboundChatListener); | ||
395 | } | 527 | } |
396 | } | 528 | } |
397 | 529 | ||
@@ -410,12 +542,12 @@ public class Events implements IPlayerUsage | @@ -410,12 +542,12 @@ public class Events implements IPlayerUsage | ||
410 | { | 542 | { |
411 | try | 543 | try |
412 | { | 544 | { |
413 | - LiteLoader.getLogger().info("Calling late init for mod " + initMod.getName()); | 545 | + LiteLoaderLogger.info("Calling late init for mod " + initMod.getName()); |
414 | initMod.onInitCompleted(this.minecraft, this.loader); | 546 | initMod.onInitCompleted(this.minecraft, this.loader); |
415 | } | 547 | } |
416 | catch (Throwable th) | 548 | catch (Throwable th) |
417 | { | 549 | { |
418 | - LiteLoader.getLogger().log(Level.WARNING, "Error initialising mod " + initMod.getName(), th); | 550 | + LiteLoaderLogger.warning(th, "Error initialising mod %s", initMod.getName()); |
419 | } | 551 | } |
420 | } | 552 | } |
421 | } | 553 | } |
@@ -432,8 +564,6 @@ public class Events implements IPlayerUsage | @@ -432,8 +564,6 @@ public class Events implements IPlayerUsage | ||
432 | this.screenWidth = this.currentResolution.getScaledWidth(); | 564 | this.screenWidth = this.currentResolution.getScaledWidth(); |
433 | this.screenHeight = this.currentResolution.getScaledHeight(); | 565 | this.screenHeight = this.currentResolution.getScaledHeight(); |
434 | 566 | ||
435 | - this.loader.onRender(); | ||
436 | - | ||
437 | for (RenderListener renderListener : this.renderListeners) | 567 | for (RenderListener renderListener : this.renderListeners) |
438 | renderListener.onRender(); | 568 | renderListener.onRender(); |
439 | } | 569 | } |
@@ -463,10 +593,13 @@ public class Events implements IPlayerUsage | @@ -463,10 +593,13 @@ public class Events implements IPlayerUsage | ||
463 | /** | 593 | /** |
464 | * Called immediately before the current GUI is rendered | 594 | * Called immediately before the current GUI is rendered |
465 | */ | 595 | */ |
466 | - public void preRenderGUI() | 596 | + public void preRenderGUI(int ref) |
467 | { | 597 | { |
468 | - for (RenderListener renderListener : this.renderListeners) | ||
469 | - renderListener.onRenderGui(this.minecraft.currentScreen); | 598 | + if (!this.minecraft.skipRenderWorld && ref == (this.minecraft.theWorld == null ? 1 : 2)) |
599 | + { | ||
600 | + for (RenderListener renderListener : this.renderListeners) | ||
601 | + renderListener.onRenderGui(this.minecraft.currentScreen); | ||
602 | + } | ||
470 | } | 603 | } |
471 | 604 | ||
472 | /** | 605 | /** |
@@ -538,15 +671,16 @@ public class Events implements IPlayerUsage | @@ -538,15 +671,16 @@ public class Events implements IPlayerUsage | ||
538 | * | 671 | * |
539 | * @param clock True if this is a new tick (otherwise it's just a new frame) | 672 | * @param clock True if this is a new tick (otherwise it's just a new frame) |
540 | */ | 673 | */ |
541 | - public void onTick(Profiler profiler, boolean clock) | 674 | + public void onTick(boolean clock) |
542 | { | 675 | { |
676 | + this.minecraft.mcProfiler.startSection("litemods"); | ||
543 | float partialTicks = 0.0F; | 677 | float partialTicks = 0.0F; |
544 | 678 | ||
545 | // Try to get the minecraft timer object and determine the value of the | 679 | // Try to get the minecraft timer object and determine the value of the |
546 | // partialTicks | 680 | // partialTicks |
547 | if (clock || this.minecraftTimer == null) | 681 | if (clock || this.minecraftTimer == null) |
548 | { | 682 | { |
549 | - this.minecraftTimer = PrivateFields.minecraftTimer.get(this.minecraft); | 683 | + this.minecraftTimer = ((IMinecraft)this.minecraft).getTimer(); |
550 | } | 684 | } |
551 | 685 | ||
552 | // Hooray, we got the timer reference | 686 | // Hooray, we got the timer reference |
@@ -559,21 +693,21 @@ public class Events implements IPlayerUsage | @@ -559,21 +693,21 @@ public class Events implements IPlayerUsage | ||
559 | // Flag indicates whether we are in game at the moment | 693 | // Flag indicates whether we are in game at the moment |
560 | boolean inGame = this.minecraft.renderViewEntity != null && this.minecraft.renderViewEntity.worldObj != null; | 694 | boolean inGame = this.minecraft.renderViewEntity != null && this.minecraft.renderViewEntity.worldObj != null; |
561 | 695 | ||
562 | - if (clock) | ||
563 | - { | ||
564 | - this.loader.onTick(partialTicks, inGame); | ||
565 | - } | 696 | + this.minecraft.mcProfiler.startSection("loader"); |
697 | + this.loader.onTick(clock, partialTicks, inGame); | ||
566 | 698 | ||
567 | int mouseX = Mouse.getX() * this.screenWidth / this.minecraft.displayWidth; | 699 | int mouseX = Mouse.getX() * this.screenWidth / this.minecraft.displayWidth; |
568 | int mouseY = this.screenHeight - Mouse.getY() * this.screenHeight / this.minecraft.displayHeight - 1; | 700 | int mouseY = this.screenHeight - Mouse.getY() * this.screenHeight / this.minecraft.displayHeight - 1; |
701 | + this.minecraft.mcProfiler.endStartSection("postrender"); | ||
569 | this.loader.postRender(mouseX, mouseY, partialTicks); | 702 | this.loader.postRender(mouseX, mouseY, partialTicks); |
703 | + this.minecraft.mcProfiler.endSection(); | ||
570 | 704 | ||
571 | // Iterate tickable mods | 705 | // Iterate tickable mods |
572 | for (Tickable tickable : this.tickListeners) | 706 | for (Tickable tickable : this.tickListeners) |
573 | { | 707 | { |
574 | - profiler.startSection(tickable.getClass().getSimpleName()); | 708 | + this.minecraft.mcProfiler.startSection(tickable.getClass().getSimpleName().toLowerCase()); |
575 | tickable.onTick(this.minecraft, partialTicks, inGame, clock); | 709 | tickable.onTick(this.minecraft, partialTicks, inGame, clock); |
576 | - profiler.endSection(); | 710 | + this.minecraft.mcProfiler.endSection(); |
577 | } | 711 | } |
578 | 712 | ||
579 | // Detected world change | 713 | // Detected world change |
@@ -590,21 +724,23 @@ public class Events implements IPlayerUsage | @@ -590,21 +724,23 @@ public class Events implements IPlayerUsage | ||
590 | this.worldHashCode = 0; | 724 | this.worldHashCode = 0; |
591 | this.loader.onWorldChanged(null); | 725 | this.loader.onWorldChanged(null); |
592 | } | 726 | } |
727 | + | ||
728 | + this.minecraft.mcProfiler.endSection(); | ||
593 | } | 729 | } |
594 | 730 | ||
595 | /** | 731 | /** |
596 | - * Callback from the reflective chat hook | 732 | + * Callback from the chat hook |
597 | * | 733 | * |
598 | * @param chatPacket | 734 | * @param chatPacket |
599 | * @return | 735 | * @return |
600 | */ | 736 | */ |
601 | - public boolean onChat(Packet3Chat chatPacket) | 737 | + public boolean onChat(S02PacketChat chatPacket) |
602 | { | 738 | { |
603 | - if (chatPacket.message == null) | 739 | + if (chatPacket.func_148915_c() == null) |
604 | return true; | 740 | return true; |
605 | 741 | ||
606 | - ChatMessageComponent chat = ChatMessageComponent.createFromJson(chatPacket.message); | ||
607 | - String message = chat.toStringWithFormatting(true); | 742 | + IChatComponent chat = chatPacket.func_148915_c(); |
743 | + String message = chat.getUnformattedText(); | ||
608 | 744 | ||
609 | // Chat filters get a stab at the chat first, if any filter returns | 745 | // Chat filters get a stab at the chat first, if any filter returns |
610 | // false the chat is discarded | 746 | // false the chat is discarded |
@@ -612,8 +748,8 @@ public class Events implements IPlayerUsage | @@ -612,8 +748,8 @@ public class Events implements IPlayerUsage | ||
612 | { | 748 | { |
613 | if (chatFilter.onChat(chatPacket, chat, message)) | 749 | if (chatFilter.onChat(chatPacket, chat, message)) |
614 | { | 750 | { |
615 | - chat = ChatMessageComponent.createFromJson(chatPacket.message); | ||
616 | - message = chat.toStringWithFormatting(true); | 751 | + chat = chatPacket.func_148915_c(); |
752 | + message = chat.getUnformattedText(); | ||
617 | } | 753 | } |
618 | else | 754 | else |
619 | { | 755 | { |
@@ -627,99 +763,157 @@ public class Events implements IPlayerUsage | @@ -627,99 +763,157 @@ public class Events implements IPlayerUsage | ||
627 | 763 | ||
628 | return true; | 764 | return true; |
629 | } | 765 | } |
766 | + | ||
767 | + /** | ||
768 | + * @param packet | ||
769 | + * @param message | ||
770 | + */ | ||
771 | + public void onSendChatMessage(C01PacketChatMessage packet, String message) | ||
772 | + { | ||
773 | + for (OutboundChatListener outboundChatListener : this.outboundChatListeners) | ||
774 | + { | ||
775 | + outboundChatListener.onSendChatMessage(packet, message); | ||
776 | + } | ||
777 | + } | ||
778 | + | ||
779 | + /** | ||
780 | + * @param netHandler | ||
781 | + * @param loginPacket | ||
782 | + */ | ||
783 | + public void onPostLogin(INetHandlerLoginClient netHandler, S02PacketLoginSuccess loginPacket) | ||
784 | + { | ||
785 | + this.clientPluginChannels.onPostLogin(netHandler, loginPacket); | ||
786 | + | ||
787 | + for (PostLoginListener loginListener : this.postLoginListeners) | ||
788 | + loginListener.onPostLogin(netHandler, loginPacket); | ||
789 | + } | ||
630 | 790 | ||
631 | /** | 791 | /** |
632 | - * Pre-login callback from the login hook | 792 | + * Pre join game callback from the login hook |
633 | * | 793 | * |
634 | * @param netHandler | 794 | * @param netHandler |
635 | * @param hookLogin | 795 | * @param hookLogin |
636 | * @return | 796 | * @return |
637 | */ | 797 | */ |
638 | - public boolean onPreLogin(NetHandler netHandler, Packet1Login loginPacket) | 798 | + public boolean onPreJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) |
639 | { | 799 | { |
640 | boolean cancelled = false; | 800 | boolean cancelled = false; |
641 | 801 | ||
642 | - for (PreLoginListener loginListener : this.preLoginListeners) | 802 | + for (PreJoinGameListener joinGameListener : this.preJoinGameListeners) |
643 | { | 803 | { |
644 | - cancelled |= !loginListener.onPreLogin(netHandler, loginPacket); | 804 | + cancelled |= !joinGameListener.onPreJoinGame(netHandler, loginPacket); |
645 | } | 805 | } |
646 | 806 | ||
647 | return !cancelled; | 807 | return !cancelled; |
648 | } | 808 | } |
649 | 809 | ||
650 | /** | 810 | /** |
651 | - * Callback from the login hook | 811 | + * Callback from the join game hook |
652 | * | 812 | * |
653 | * @param netHandler | 813 | * @param netHandler |
654 | * @param loginPacket | 814 | * @param loginPacket |
655 | */ | 815 | */ |
656 | - public void onConnectToServer(NetHandler netHandler, Packet1Login loginPacket) | 816 | + public void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) |
657 | { | 817 | { |
658 | - this.loader.onLogin(netHandler, loginPacket); | 818 | + this.loader.onJoinGame(netHandler, loginPacket); |
819 | + this.clientPluginChannels.onJoinGame(netHandler, loginPacket); | ||
659 | 820 | ||
660 | - for (LoginListener loginListener : this.loginListeners) | ||
661 | - loginListener.onLogin(netHandler, loginPacket); | ||
662 | - | ||
663 | - this.pluginChannels.onConnectToServer(netHandler, loginPacket); | 821 | + for (JoinGameListener joinGameListener : this.joinGameListeners) |
822 | + joinGameListener.onJoinGame(netHandler, loginPacket); | ||
664 | } | 823 | } |
665 | 824 | ||
666 | - /* | ||
667 | - * (non-Javadoc) | 825 | + /** |
826 | + * Callback from the chat hook | ||
827 | + * @param netHandler | ||
668 | * | 828 | * |
669 | - * @see | ||
670 | - * net.minecraft.src.IPlayerUsage#addServerStatsToSnooper(net.minecraft. | ||
671 | - * src.PlayerUsageSnooper) | 829 | + * @param chatPacket |
830 | + * @return | ||
672 | */ | 831 | */ |
673 | - @Override | ||
674 | - public void addServerStatsToSnooper(PlayerUsageSnooper var1) | 832 | + public boolean onServerChat(INetHandlerPlayServer netHandler, C01PacketChatMessage chatPacket) |
675 | { | 833 | { |
676 | - this.minecraft.addServerStatsToSnooper(var1); | 834 | + EntityPlayerMP player = netHandler instanceof NetHandlerPlayServer ? ((NetHandlerPlayServer)netHandler).playerEntity : null; |
835 | + | ||
836 | + for (ServerChatFilter chatFilter : this.serverChatFilters) | ||
837 | + { | ||
838 | + if (!chatFilter.onChat(player, chatPacket, chatPacket.func_149439_c())) | ||
839 | + { | ||
840 | + return false; | ||
841 | + } | ||
842 | + } | ||
843 | + | ||
844 | + return true; | ||
677 | } | 845 | } |
678 | - | ||
679 | - /* | ||
680 | - * (non-Javadoc) | ||
681 | - * | ||
682 | - * @see | ||
683 | - * net.minecraft.src.IPlayerUsage#addServerTypeToSnooper(net.minecraft.src | ||
684 | - * .PlayerUsageSnooper) | 846 | + |
847 | + /** | ||
848 | + * @param instance | ||
849 | + * @param folderName | ||
850 | + * @param worldName | ||
851 | + * @param worldSettings | ||
852 | + */ | ||
853 | + public void onStartIntegratedServer(IntegratedServer instance, String folderName, String worldName, WorldSettings worldSettings) | ||
854 | + { | ||
855 | + ICommandManager commandManager = instance.getCommandManager(); | ||
856 | + | ||
857 | + if (commandManager instanceof ServerCommandManager) | ||
858 | + { | ||
859 | + ServerCommandManager serverCommandManager = (ServerCommandManager)commandManager; | ||
860 | + | ||
861 | + for (ServerCommandProvider commandProvider : this.serverCommandProviders) | ||
862 | + commandProvider.provideCommands(serverCommandManager); | ||
863 | + } | ||
864 | + } | ||
865 | + | ||
866 | + /** | ||
867 | + * @param scm | ||
868 | + * @param player | ||
869 | + * @param profile | ||
685 | */ | 870 | */ |
686 | - @Override | ||
687 | - public void addServerTypeToSnooper(PlayerUsageSnooper var1) | 871 | + public void onSpawnPlayer(ServerConfigurationManager scm, EntityPlayerMP player, GameProfile profile) |
688 | { | 872 | { |
689 | - this.sanityCheck(); | ||
690 | - this.minecraft.addServerTypeToSnooper(var1); | 873 | + for (ServerPlayerListener serverPlayerListener : this.serverPlayerListeners) |
874 | + serverPlayerListener.onPlayerConnect(player, profile); | ||
691 | } | 875 | } |
692 | 876 | ||
693 | - /* | ||
694 | - * (non-Javadoc) | ||
695 | - * | ||
696 | - * @see net.minecraft.src.IPlayerUsage#isSnooperEnabled() | 877 | + /** |
878 | + * @param scm | ||
879 | + * @param player | ||
697 | */ | 880 | */ |
698 | - @Override | ||
699 | - public boolean isSnooperEnabled() | 881 | + public void onPlayerLogin(ServerConfigurationManager scm, EntityPlayerMP player) |
700 | { | 882 | { |
701 | - return this.minecraft.isSnooperEnabled(); | 883 | + this.serverPluginChannels.onPlayerJoined(player); |
702 | } | 884 | } |
703 | 885 | ||
704 | - /* | ||
705 | - * (non-Javadoc) | ||
706 | - * | ||
707 | - * @see net.minecraft.src.IPlayerUsage#getLogAgent() | 886 | + /** |
887 | + * @param scm | ||
888 | + * @param netManager | ||
889 | + * @param player | ||
708 | */ | 890 | */ |
709 | - @Override | ||
710 | - public ILogAgent getLogAgent() | 891 | + public void onInitializePlayerConnection(ServerConfigurationManager scm, NetworkManager netManager, EntityPlayerMP player) |
711 | { | 892 | { |
712 | - return this.minecraft.getLogAgent(); | 893 | + for (ServerPlayerListener serverPlayerListener : this.serverPlayerListeners) |
894 | + serverPlayerListener.onPlayerLoggedIn(player); | ||
713 | } | 895 | } |
714 | - | 896 | + |
715 | /** | 897 | /** |
716 | - * Check that the profiler hook hasn't been overridden by something else | 898 | + * @param scm |
899 | + * @param player | ||
900 | + * @param oldPlayer | ||
901 | + * @param dimension | ||
902 | + * @param copy | ||
717 | */ | 903 | */ |
718 | - private void sanityCheck() | 904 | + public void onRespawnPlayer(ServerConfigurationManager scm, EntityPlayerMP player, EntityPlayerMP oldPlayer, int dimension, boolean won) |
719 | { | 905 | { |
720 | - if (this.tickHooked && this.minecraft.mcProfiler != this.profilerHook) | ||
721 | - { | ||
722 | - PrivateFields.minecraftProfiler.setFinal(this.minecraft, this.profilerHook); | ||
723 | - } | 906 | + for (ServerPlayerListener serverPlayerListener : this.serverPlayerListeners) |
907 | + serverPlayerListener.onPlayerRespawn(player, oldPlayer, dimension, won); | ||
908 | + } | ||
909 | + | ||
910 | + /** | ||
911 | + * @param scm | ||
912 | + * @param player | ||
913 | + */ | ||
914 | + public void onPlayerLogout(ServerConfigurationManager scm, EntityPlayerMP player) | ||
915 | + { | ||
916 | + for (ServerPlayerListener serverPlayerListener : this.serverPlayerListeners) | ||
917 | + serverPlayerListener.onPlayerLogout(player); | ||
724 | } | 918 | } |
725 | } | 919 | } |
java/com/mumfrey/liteloader/core/Injectable.java
0 → 100644
1 | +package com.mumfrey.liteloader.core; | ||
2 | + | ||
3 | +import java.net.MalformedURLException; | ||
4 | +import java.net.URL; | ||
5 | + | ||
6 | +import com.mumfrey.liteloader.launch.InjectionStrategy; | ||
7 | + | ||
8 | +import net.minecraft.launchwrapper.LaunchClassLoader; | ||
9 | + | ||
10 | +/** | ||
11 | + * Interface for objects which can be injected into the classpath | ||
12 | + * | ||
13 | + * @author Adam Mummery-Smith | ||
14 | + */ | ||
15 | +public interface Injectable | ||
16 | +{ | ||
17 | + /** | ||
18 | + * Get the URL of this injectable resource | ||
19 | + * @throws MalformedURLException | ||
20 | + */ | ||
21 | + public abstract URL getURL() throws MalformedURLException; | ||
22 | + | ||
23 | + /** | ||
24 | + * Returns true if this object has been injected already | ||
25 | + */ | ||
26 | + public abstract boolean isInjected(); | ||
27 | + | ||
28 | + /** | ||
29 | + * @param classLoader | ||
30 | + * @param injectIntoParent | ||
31 | + * @return | ||
32 | + * @throws MalformedURLException | ||
33 | + */ | ||
34 | + public abstract boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException; | ||
35 | + | ||
36 | + public abstract InjectionStrategy getInjectionStrategy(); | ||
37 | +} |
java/com/mumfrey/liteloader/core/LiteLoader.java
1 | package com.mumfrey.liteloader.core; | 1 | package com.mumfrey.liteloader.core; |
2 | 2 | ||
3 | import java.io.File; | 3 | import java.io.File; |
4 | -import java.io.FileReader; | ||
5 | -import java.io.FileWriter; | ||
6 | -import java.io.IOException; | ||
7 | import java.io.PrintStream; | 4 | import java.io.PrintStream; |
8 | -import java.util.ArrayList; | ||
9 | -import java.util.Arrays; | ||
10 | -import java.util.Collections; | ||
11 | -import java.util.HashMap; | ||
12 | -import java.util.Iterator; | ||
13 | -import java.util.LinkedList; | ||
14 | -import java.util.List; | ||
15 | -import java.util.Map; | ||
16 | -import java.util.Properties; | ||
17 | -import java.util.logging.Level; | ||
18 | -import java.util.logging.Logger; | 5 | +import java.util.*; |
19 | 6 | ||
20 | import javax.activity.InvalidActivityException; | 7 | import javax.activity.InvalidActivityException; |
21 | 8 | ||
22 | -import org.lwjgl.input.Keyboard; | ||
23 | - | 9 | +import net.minecraft.client.Minecraft; |
10 | +import net.minecraft.client.gui.GuiScreen; | ||
11 | +import net.minecraft.client.resources.IResourcePack; | ||
12 | +import net.minecraft.client.resources.SimpleReloadableResourceManager; | ||
13 | +import net.minecraft.client.settings.KeyBinding; | ||
14 | +import net.minecraft.crash.CrashReport; | ||
24 | import net.minecraft.launchwrapper.LaunchClassLoader; | 15 | import net.minecraft.launchwrapper.LaunchClassLoader; |
25 | -import net.minecraft.src.CrashReport; | ||
26 | -import net.minecraft.src.GuiControls; | ||
27 | -import net.minecraft.src.GuiMainMenu; | ||
28 | -import net.minecraft.src.GuiScreen; | ||
29 | -import net.minecraft.src.KeyBinding; | ||
30 | -import net.minecraft.src.Minecraft; | ||
31 | -import net.minecraft.src.NetHandler; | ||
32 | -import net.minecraft.src.Packet1Login; | ||
33 | -import net.minecraft.src.ResourcePack; | ||
34 | -import net.minecraft.src.SimpleReloadableResourceManager; | ||
35 | -import net.minecraft.src.World; | 16 | +import net.minecraft.network.INetHandler; |
17 | +import net.minecraft.network.play.server.S01PacketJoinGame; | ||
18 | +import net.minecraft.world.World; | ||
19 | + | ||
20 | +import org.apache.logging.log4j.Logger; | ||
21 | +import org.lwjgl.input.Keyboard; | ||
36 | 22 | ||
37 | -import com.mumfrey.liteloader.*; | 23 | +import com.mumfrey.liteloader.LiteMod; |
24 | +import com.mumfrey.liteloader.core.overlays.IMinecraft; | ||
25 | +import com.mumfrey.liteloader.crashreport.CallableLaunchWrapper; | ||
38 | import com.mumfrey.liteloader.crashreport.CallableLiteLoaderBrand; | 26 | import com.mumfrey.liteloader.crashreport.CallableLiteLoaderBrand; |
39 | import com.mumfrey.liteloader.crashreport.CallableLiteLoaderMods; | 27 | import com.mumfrey.liteloader.crashreport.CallableLiteLoaderMods; |
40 | -import com.mumfrey.liteloader.gui.GuiControlsPaginated; | ||
41 | import com.mumfrey.liteloader.gui.GuiScreenModInfo; | 28 | import com.mumfrey.liteloader.gui.GuiScreenModInfo; |
42 | import com.mumfrey.liteloader.modconfig.ConfigManager; | 29 | import com.mumfrey.liteloader.modconfig.ConfigManager; |
43 | import com.mumfrey.liteloader.modconfig.Exposable; | 30 | import com.mumfrey.liteloader.modconfig.Exposable; |
44 | import com.mumfrey.liteloader.permissions.PermissionsManagerClient; | 31 | import com.mumfrey.liteloader.permissions.PermissionsManagerClient; |
45 | -import com.mumfrey.liteloader.util.PrivateFields; | 32 | +import com.mumfrey.liteloader.util.Input; |
33 | +import com.mumfrey.liteloader.resources.InternalResourcePack; | ||
34 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | ||
46 | 35 | ||
47 | /** | 36 | /** |
48 | * LiteLoader is a simple loader which loads and provides useful callbacks to | 37 | * LiteLoader is a simple loader which loads and provides useful callbacks to |
49 | * lightweight mods | 38 | * lightweight mods |
50 | * | 39 | * |
51 | * @author Adam Mummery-Smith | 40 | * @author Adam Mummery-Smith |
52 | - * @version 1.6.4_02 | 41 | + * @version 1.7.2_02 |
53 | */ | 42 | */ |
54 | public final class LiteLoader | 43 | public final class LiteLoader |
55 | { | 44 | { |
45 | + public static final String MOD_SYSTEM = "liteloader"; | ||
46 | + | ||
56 | private static final String OPTION_MOD_INFO_SCREEN = "modInfoScreen"; | 47 | private static final String OPTION_MOD_INFO_SCREEN = "modInfoScreen"; |
57 | private static final String OPTION_SOUND_MANAGER_FIX = "soundManagerFix"; | 48 | private static final String OPTION_SOUND_MANAGER_FIX = "soundManagerFix"; |
58 | - private static final String OPTION_CONTROLS_PAGES = "controls.pages"; | 49 | + private static final String OPTION_GENERATE_MAPPINGS = "genMappings"; |
59 | 50 | ||
60 | /** | 51 | /** |
61 | * LiteLoader is a singleton, this is the singleton instance | 52 | * LiteLoader is a singleton, this is the singleton instance |
@@ -65,7 +56,7 @@ public final class LiteLoader | @@ -65,7 +56,7 @@ public final class LiteLoader | ||
65 | /** | 56 | /** |
66 | * Logger for LiteLoader events | 57 | * Logger for LiteLoader events |
67 | */ | 58 | */ |
68 | - private static final Logger logger = Logger.getLogger("liteloader"); | 59 | + private static final Logger logger = LiteLoaderLogger.getLogger(); |
69 | 60 | ||
70 | /** | 61 | /** |
71 | * Tweak system class loader | 62 | * Tweak system class loader |
@@ -73,11 +64,6 @@ public final class LiteLoader | @@ -73,11 +64,6 @@ public final class LiteLoader | ||
73 | private static LaunchClassLoader classLoader; | 64 | private static LaunchClassLoader classLoader; |
74 | 65 | ||
75 | /** | 66 | /** |
76 | - * List of mods passed into the command line | ||
77 | - */ | ||
78 | - private EnabledModsList enabledModsList = null; | ||
79 | - | ||
80 | - /** | ||
81 | * Mods folder which contains mods and legacy config files | 67 | * Mods folder which contains mods and legacy config files |
82 | */ | 68 | */ |
83 | private File modsFolder; | 69 | private File modsFolder; |
@@ -99,22 +85,11 @@ public final class LiteLoader | @@ -99,22 +85,11 @@ public final class LiteLoader | ||
99 | private File versionConfigFolder; | 85 | private File versionConfigFolder; |
100 | 86 | ||
101 | /** | 87 | /** |
102 | - * JSON file containing the list of enabled/disabled mods by profile | ||
103 | - */ | ||
104 | - private File enabledModsFile; | ||
105 | - | ||
106 | - /** | ||
107 | * Reference to the Minecraft game instance | 88 | * Reference to the Minecraft game instance |
108 | */ | 89 | */ |
109 | private Minecraft minecraft; | 90 | private Minecraft minecraft; |
110 | 91 | ||
111 | /** | 92 | /** |
112 | - * Setting value, if true we will swap out the MC "Controls" GUI for our | ||
113 | - * custom, paginated one | ||
114 | - */ | ||
115 | - private boolean paginateControls = true; | ||
116 | - | ||
117 | - /** | ||
118 | * Loader Bootstrap instance | 93 | * Loader Bootstrap instance |
119 | */ | 94 | */ |
120 | private final LiteLoaderBootstrap bootstrap; | 95 | private final LiteLoaderBootstrap bootstrap; |
@@ -125,9 +100,14 @@ public final class LiteLoader | @@ -125,9 +100,14 @@ public final class LiteLoader | ||
125 | private final LiteLoaderEnumerator enumerator; | 100 | private final LiteLoaderEnumerator enumerator; |
126 | 101 | ||
127 | /** | 102 | /** |
103 | + * List of mods passed into the command line | ||
104 | + */ | ||
105 | + private final EnabledModsList enabledModsList; | ||
106 | + | ||
107 | + /** | ||
128 | * Registered resource packs | 108 | * Registered resource packs |
129 | */ | 109 | */ |
130 | - private final Map<String, ResourcePack> registeredResourcePacks = new HashMap<String, ResourcePack>(); | 110 | + private final Map<String, IResourcePack> registeredResourcePacks = new HashMap<String, IResourcePack>(); |
131 | 111 | ||
132 | /** | 112 | /** |
133 | * List of loaded mods, for crash reporting | 113 | * List of loaded mods, for crash reporting |
@@ -147,7 +127,7 @@ public final class LiteLoader | @@ -147,7 +127,7 @@ public final class LiteLoader | ||
147 | /** | 127 | /** |
148 | * Mods which are loaded but disabled | 128 | * Mods which are loaded but disabled |
149 | */ | 129 | */ |
150 | - private final LinkedList<ModFile> disabledMods = new LinkedList<ModFile>(); | 130 | + private final LinkedList<Loadable<?>> disabledMods = new LinkedList<Loadable<?>>(); |
151 | 131 | ||
152 | /** | 132 | /** |
153 | * Event manager | 133 | * Event manager |
@@ -157,7 +137,12 @@ public final class LiteLoader | @@ -157,7 +137,12 @@ public final class LiteLoader | ||
157 | /** | 137 | /** |
158 | * Plugin channel manager | 138 | * Plugin channel manager |
159 | */ | 139 | */ |
160 | - private final PluginChannels pluginChannels = new PluginChannels(); | 140 | + private final ClientPluginChannels clientPluginChannels = new ClientPluginChannels(); |
141 | + | ||
142 | + /** | ||
143 | + * Server channel manager | ||
144 | + */ | ||
145 | + private final ServerPluginChannels serverPluginChannels = new ServerPluginChannels(); | ||
161 | 146 | ||
162 | /** | 147 | /** |
163 | * Permission Manager | 148 | * Permission Manager |
@@ -170,9 +155,9 @@ public final class LiteLoader | @@ -170,9 +155,9 @@ public final class LiteLoader | ||
170 | private final ConfigManager configManager; | 155 | private final ConfigManager configManager; |
171 | 156 | ||
172 | /** | 157 | /** |
173 | - * Flag which keeps track of whether late initialisation has been done | 158 | + * Flag which keeps track of whether late initialisation has completed |
174 | */ | 159 | */ |
175 | - private boolean postInitStarted, startupComplete; | 160 | + private boolean startupComplete; |
176 | 161 | ||
177 | /** | 162 | /** |
178 | * True while initialising mods if we need to do a resource manager reload once the process is completed | 163 | * True while initialising mods if we need to do a resource manager reload once the process is completed |
@@ -187,29 +172,13 @@ public final class LiteLoader | @@ -187,29 +172,13 @@ public final class LiteLoader | ||
187 | /** | 172 | /** |
188 | * If inhibit is enabled, this object is used to reflectively inhibit the sound manager's reload process during startup by removing it from the reloadables list | 173 | * If inhibit is enabled, this object is used to reflectively inhibit the sound manager's reload process during startup by removing it from the reloadables list |
189 | */ | 174 | */ |
190 | - private SoundManagerReloadInhibitor soundManagerReloadInhibitor; | ||
191 | - | ||
192 | - /** | ||
193 | - * File in which we will store mod key mappings | ||
194 | - */ | ||
195 | - private File keyMapSettingsFile = null; | 175 | + private SoundHandlerReloadInhibitor soundHandlerReloadInhibitor; |
196 | 176 | ||
197 | /** | 177 | /** |
198 | - * Properties object which stores mod key mappings | ||
199 | - */ | ||
200 | - private Properties keyMapSettings = new Properties(); | ||
201 | - | ||
202 | - /** | ||
203 | - * List of all registered mod keys | ||
204 | - */ | ||
205 | - private List<KeyBinding> modKeyBindings = new ArrayList<KeyBinding>(); | ||
206 | - | ||
207 | - /** | ||
208 | - * Map of mod key bindings to their key codes, stored so that we don't need to cast from | ||
209 | - * string in the properties file every tick | 178 | + * |
210 | */ | 179 | */ |
211 | - private Map<KeyBinding, Integer> storedModKeyBindings = new HashMap<KeyBinding, Integer>(); | ||
212 | - | 180 | + private Input input; |
181 | + | ||
213 | /** | 182 | /** |
214 | * Setting which determines whether we show the "mod info" screen tab in the main menu | 183 | * Setting which determines whether we show the "mod info" screen tab in the main menu |
215 | */ | 184 | */ |
@@ -228,53 +197,20 @@ public final class LiteLoader | @@ -228,53 +197,20 @@ public final class LiteLoader | ||
228 | private GuiScreenModInfo modInfoScreen; | 197 | private GuiScreenModInfo modInfoScreen; |
229 | 198 | ||
230 | /** | 199 | /** |
231 | - * Pre-init routine, called using reflection by the tweaker | ||
232 | - * | ||
233 | - * @param gameDirectory Game directory passed to the tweaker | ||
234 | - * @param assetsDirectory Assets directory passed to the tweaker | ||
235 | - * @param profile Launch profile name supplied with --version parameter | ||
236 | - * @param modNameFilter List of mod names parsed from the command line | ||
237 | - * @param classLoader LaunchClassLoader | ||
238 | - */ | ||
239 | - static final void init(LiteLoaderBootstrap bootstrap, LiteLoaderEnumerator enumerator, List<String> modNameFilter, LaunchClassLoader classLoader) | ||
240 | - { | ||
241 | - if (LiteLoader.instance == null) | ||
242 | - { | ||
243 | - LiteLoader.classLoader = classLoader; | ||
244 | - | ||
245 | - LiteLoader.instance = new LiteLoader(bootstrap, enumerator, modNameFilter); | ||
246 | - LiteLoader.instance.onInit(); | ||
247 | - } | ||
248 | - } | ||
249 | - | ||
250 | - /** | ||
251 | - * Post-init routine, initialises and loads mods enumerated in preInit | ||
252 | - */ | ||
253 | - static final void postInit() | ||
254 | - { | ||
255 | - if (LiteLoader.instance != null) | ||
256 | - { | ||
257 | - final Minecraft minecraft = Minecraft.getMinecraft(); | ||
258 | - LiteLoader.instance.onPostInit(minecraft); | ||
259 | - } | ||
260 | - } | ||
261 | - | ||
262 | - /** | ||
263 | * LiteLoader constructor | 200 | * LiteLoader constructor |
264 | * @param profile | 201 | * @param profile |
265 | * @param modNameFilter | 202 | * @param modNameFilter |
266 | */ | 203 | */ |
267 | - private LiteLoader(LiteLoaderBootstrap bootstrap, LiteLoaderEnumerator enumerator, List<String> modNameFilter) | 204 | + private LiteLoader(LiteLoaderBootstrap bootstrap, LiteLoaderEnumerator enumerator, EnabledModsList enabledModsList) |
268 | { | 205 | { |
269 | this.bootstrap = bootstrap; | 206 | this.bootstrap = bootstrap; |
270 | this.enumerator = enumerator; | 207 | this.enumerator = enumerator; |
208 | + this.enabledModsList = enabledModsList; | ||
271 | 209 | ||
272 | this.setupPaths(bootstrap); | 210 | this.setupPaths(bootstrap); |
273 | 211 | ||
274 | - this.enabledModsList = EnabledModsList.createFrom(this.enabledModsFile); | ||
275 | - this.enabledModsList.processModsList(bootstrap.getProfile(), modNameFilter); | ||
276 | - | ||
277 | this.configManager = new ConfigManager(); | 212 | this.configManager = new ConfigManager(); |
213 | + this.input = new Input(new File(this.commonConfigFolder, "liteloader.keys.properties")); | ||
278 | } | 214 | } |
279 | 215 | ||
280 | /** | 216 | /** |
@@ -286,15 +222,12 @@ public final class LiteLoader | @@ -286,15 +222,12 @@ public final class LiteLoader | ||
286 | this.configBaseFolder = bootstrap.getConfigBaseFolder(); | 222 | this.configBaseFolder = bootstrap.getConfigBaseFolder(); |
287 | 223 | ||
288 | this.commonConfigFolder = new File(this.configBaseFolder, "common"); | 224 | this.commonConfigFolder = new File(this.configBaseFolder, "common"); |
289 | - this.versionConfigFolder = this.inflectVersionedConfigPath(LiteLoaderBootstrap.VERSION); | 225 | + this.versionConfigFolder = this.inflectVersionedConfigPath(LiteLoaderVersion.CURRENT); |
290 | 226 | ||
291 | if (!this.modsFolder.exists()) this.modsFolder.mkdirs(); | 227 | if (!this.modsFolder.exists()) this.modsFolder.mkdirs(); |
292 | if (!this.configBaseFolder.exists()) this.configBaseFolder.mkdirs(); | 228 | if (!this.configBaseFolder.exists()) this.configBaseFolder.mkdirs(); |
293 | if (!this.commonConfigFolder.exists()) this.commonConfigFolder.mkdirs(); | 229 | if (!this.commonConfigFolder.exists()) this.commonConfigFolder.mkdirs(); |
294 | if (!this.versionConfigFolder.exists()) this.versionConfigFolder.mkdirs(); | 230 | if (!this.versionConfigFolder.exists()) this.versionConfigFolder.mkdirs(); |
295 | - | ||
296 | - this.enabledModsFile = new File(this.configBaseFolder, "liteloader.profiles.json"); | ||
297 | - this.keyMapSettingsFile = new File(this.configBaseFolder, "liteloader.keys.properties"); | ||
298 | } | 231 | } |
299 | 232 | ||
300 | /** | 233 | /** |
@@ -310,48 +243,38 @@ public final class LiteLoader | @@ -310,48 +243,38 @@ public final class LiteLoader | ||
310 | 243 | ||
311 | return new File(this.configBaseFolder, String.format("config.%s", version.getMinecraftVersion())); | 244 | return new File(this.configBaseFolder, String.format("config.%s", version.getMinecraftVersion())); |
312 | } | 245 | } |
313 | - | ||
314 | - /** | 246 | + |
247 | + /** | ||
315 | * Set up reflection methods required by the loader | 248 | * Set up reflection methods required by the loader |
316 | */ | 249 | */ |
317 | - private boolean onInit() | 250 | + void init() |
318 | { | 251 | { |
319 | try | 252 | try |
320 | { | 253 | { |
321 | - if (this.keyMapSettingsFile.exists()) | ||
322 | - { | ||
323 | - try | ||
324 | - { | ||
325 | - this.keyMapSettings.load(new FileReader(this.keyMapSettingsFile)); | ||
326 | - } | ||
327 | - catch (Exception ex) {} | ||
328 | - } | 254 | + this.input.init(); |
329 | 255 | ||
330 | - this.paginateControls = this.bootstrap.getAndStoreBooleanProperty(OPTION_CONTROLS_PAGES, true); | ||
331 | this.inhibitSoundManagerReload = this.bootstrap.getAndStoreBooleanProperty(OPTION_SOUND_MANAGER_FIX, true); | 256 | this.inhibitSoundManagerReload = this.bootstrap.getAndStoreBooleanProperty(OPTION_SOUND_MANAGER_FIX, true); |
332 | this.displayModInfoScreenTab = this.bootstrap.getAndStoreBooleanProperty(OPTION_MOD_INFO_SCREEN, true); | 257 | this.displayModInfoScreenTab = this.bootstrap.getAndStoreBooleanProperty(OPTION_MOD_INFO_SCREEN, true); |
333 | 258 | ||
334 | this.enumerator.discoverModClasses(); | 259 | this.enumerator.discoverModClasses(); |
260 | + this.disabledMods.addAll(this.enumerator.getDisabledMods()); | ||
335 | } | 261 | } |
336 | catch (Throwable th) | 262 | catch (Throwable th) |
337 | { | 263 | { |
338 | - LiteLoader.getLogger().log(Level.SEVERE, "Error initialising LiteLoader", th); | ||
339 | - return false; | 264 | + LiteLoaderLogger.severe("Error initialising LiteLoader", th); |
340 | } | 265 | } |
341 | - | ||
342 | - return true; | ||
343 | } | 266 | } |
344 | 267 | ||
345 | - private void onPostInit(Minecraft minecraft) | 268 | + void postInit() |
346 | { | 269 | { |
347 | - if (this.postInitStarted) return; | ||
348 | - this.postInitStarted = true; | ||
349 | - | ||
350 | // Cache local minecraft reference | 270 | // Cache local minecraft reference |
351 | - this.minecraft = minecraft; | ||
352 | - | 271 | + this.minecraft = Minecraft.getMinecraft(); |
272 | + | ||
273 | + // Add self as a resource pack for texture/lang resources | ||
274 | + this.registerModResourcePack(new InternalResourcePack("LiteLoader", LiteLoader.class, "liteloader")); | ||
275 | + | ||
353 | // Create the event broker | 276 | // Create the event broker |
354 | - this.events = new Events(this, this.minecraft, this.pluginChannels); | 277 | + this.events = new Events(this, this.minecraft, this.clientPluginChannels, this.serverPluginChannels, this.bootstrap.getBooleanProperty(OPTION_GENERATE_MAPPINGS)); |
355 | 278 | ||
356 | // Spawn mod instances | 279 | // Spawn mod instances |
357 | this.loadMods(); | 280 | this.loadMods(); |
@@ -359,24 +282,27 @@ public final class LiteLoader | @@ -359,24 +282,27 @@ public final class LiteLoader | ||
359 | // Initialises enumerated mods | 282 | // Initialises enumerated mods |
360 | this.initMods(); | 283 | this.initMods(); |
361 | 284 | ||
285 | + this.updateSharedModList(); | ||
286 | + | ||
362 | // Initialises the required hooks for loaded mods | 287 | // Initialises the required hooks for loaded mods |
363 | this.events.initHooks(); | 288 | this.events.initHooks(); |
364 | this.startupComplete = true; | 289 | this.startupComplete = true; |
365 | 290 | ||
366 | - this.enabledModsList.saveTo(this.enabledModsFile); | 291 | + // Save stuff |
292 | + this.enabledModsList.save(); | ||
367 | this.bootstrap.writeProperties(); | 293 | this.bootstrap.writeProperties(); |
368 | } | 294 | } |
369 | - | 295 | + |
370 | /* (non-Javadoc) | 296 | /* (non-Javadoc) |
371 | - * @see com.mumfrey.liteloader.core.ICustomResourcePackManager#registerModResourcePack(net.minecraft.src.ResourcePack) | 297 | + * @see com.mumfrey.liteloader.core.ICustomResourcePackManager#registerModResourcePack(net.minecraft.client.resources.ResourcePack) |
372 | */ | 298 | */ |
373 | - public boolean registerModResourcePack(ResourcePack resourcePack) | 299 | + public boolean registerModResourcePack(IResourcePack resourcePack) |
374 | { | 300 | { |
375 | if (!this.registeredResourcePacks.containsKey(resourcePack.getPackName())) | 301 | if (!this.registeredResourcePacks.containsKey(resourcePack.getPackName())) |
376 | { | 302 | { |
377 | this.pendingResourceReload = true; | 303 | this.pendingResourceReload = true; |
378 | 304 | ||
379 | - List<ResourcePack> defaultResourcePacks = PrivateFields.defaultResourcePacks.get(this.minecraft); | 305 | + List<IResourcePack> defaultResourcePacks = ((IMinecraft)this.minecraft).getDefaultResourcePacks(); |
380 | if (!defaultResourcePacks.contains(resourcePack)) | 306 | if (!defaultResourcePacks.contains(resourcePack)) |
381 | { | 307 | { |
382 | defaultResourcePacks.add(resourcePack); | 308 | defaultResourcePacks.add(resourcePack); |
@@ -389,15 +315,15 @@ public final class LiteLoader | @@ -389,15 +315,15 @@ public final class LiteLoader | ||
389 | } | 315 | } |
390 | 316 | ||
391 | /* (non-Javadoc) | 317 | /* (non-Javadoc) |
392 | - * @see com.mumfrey.liteloader.core.ICustomResourcePackManager#unRegisterModResourcePack(net.minecraft.src.ResourcePack) | 318 | + * @see com.mumfrey.liteloader.core.ICustomResourcePackManager#unRegisterModResourcePack(net.minecraft.client.resources.ResourcePack) |
393 | */ | 319 | */ |
394 | - public boolean unRegisterModResourcePack(ResourcePack resourcePack) | 320 | + public boolean unRegisterModResourcePack(IResourcePack resourcePack) |
395 | { | 321 | { |
396 | if (this.registeredResourcePacks.containsValue(resourcePack)) | 322 | if (this.registeredResourcePacks.containsValue(resourcePack)) |
397 | { | 323 | { |
398 | this.pendingResourceReload = true; | 324 | this.pendingResourceReload = true; |
399 | 325 | ||
400 | - List<ResourcePack> defaultResourcePacks = PrivateFields.defaultResourcePacks.get(this.minecraft); | 326 | + List<IResourcePack> defaultResourcePacks = ((IMinecraft)this.minecraft).getDefaultResourcePacks(); |
401 | this.registeredResourcePacks.remove(resourcePack.getPackName()); | 327 | this.registeredResourcePacks.remove(resourcePack.getPackName()); |
402 | defaultResourcePacks.remove(resourcePack); | 328 | defaultResourcePacks.remove(resourcePack); |
403 | return true; | 329 | return true; |
@@ -422,7 +348,9 @@ public final class LiteLoader | @@ -422,7 +348,9 @@ public final class LiteLoader | ||
422 | * Get the LiteLoader logger object | 348 | * Get the LiteLoader logger object |
423 | * | 349 | * |
424 | * @return | 350 | * @return |
351 | + * @deprecated use LiteLoaderLogger instead | ||
425 | */ | 352 | */ |
353 | + @Deprecated | ||
426 | public static final Logger getLogger() | 354 | public static final Logger getLogger() |
427 | { | 355 | { |
428 | return LiteLoader.logger; | 356 | return LiteLoader.logger; |
@@ -441,11 +369,13 @@ public final class LiteLoader | @@ -441,11 +369,13 @@ public final class LiteLoader | ||
441 | /** | 369 | /** |
442 | * Get the output stream which we are using for console output | 370 | * Get the output stream which we are using for console output |
443 | * | 371 | * |
444 | - * @return | 372 | + * @return System.err |
373 | + * @deprecated use log4j instead | ||
445 | */ | 374 | */ |
375 | + @Deprecated | ||
446 | public static final PrintStream getConsoleStream() | 376 | public static final PrintStream getConsoleStream() |
447 | { | 377 | { |
448 | - return LiteLoaderBootstrap.getConsoleStream(); | 378 | + return System.err; |
449 | } | 379 | } |
450 | 380 | ||
451 | /** | 381 | /** |
@@ -455,7 +385,17 @@ public final class LiteLoader | @@ -455,7 +385,17 @@ public final class LiteLoader | ||
455 | */ | 385 | */ |
456 | public static final String getVersion() | 386 | public static final String getVersion() |
457 | { | 387 | { |
458 | - return LiteLoaderBootstrap.VERSION.getLoaderVersion(); | 388 | + return LiteLoaderVersion.CURRENT.getLoaderVersion(); |
389 | + } | ||
390 | + | ||
391 | + /** | ||
392 | + * Get LiteLoader version | ||
393 | + * | ||
394 | + * @return | ||
395 | + */ | ||
396 | + public static final String getVersionDisplayString() | ||
397 | + { | ||
398 | + return String.format("LiteLoader %s", LiteLoaderVersion.CURRENT.getLoaderVersion()); | ||
459 | } | 399 | } |
460 | 400 | ||
461 | /** | 401 | /** |
@@ -465,7 +405,7 @@ public final class LiteLoader | @@ -465,7 +405,7 @@ public final class LiteLoader | ||
465 | */ | 405 | */ |
466 | public static final int getRevision() | 406 | public static final int getRevision() |
467 | { | 407 | { |
468 | - return LiteLoaderBootstrap.VERSION.getLoaderRevision(); | 408 | + return LiteLoaderVersion.CURRENT.getLoaderRevision(); |
469 | } | 409 | } |
470 | 410 | ||
471 | /** | 411 | /** |
@@ -490,13 +430,43 @@ public final class LiteLoader | @@ -490,13 +430,43 @@ public final class LiteLoader | ||
490 | * Get the plugin channel manager | 430 | * Get the plugin channel manager |
491 | * | 431 | * |
492 | * @return | 432 | * @return |
433 | + * @deprecated use LiteLoader.getClientPluginChannels() | ||
493 | */ | 434 | */ |
494 | - public static PluginChannels getPluginChannels() | 435 | + @Deprecated |
436 | + public static ClientPluginChannels getPluginChannels() | ||
495 | { | 437 | { |
496 | - return LiteLoader.getInstance().pluginChannels; | 438 | + return LiteLoader.getInstance().clientPluginChannels; |
497 | } | 439 | } |
498 | 440 | ||
499 | /** | 441 | /** |
442 | + * Get the client-side plugin channel manager | ||
443 | + * | ||
444 | + * @return | ||
445 | + */ | ||
446 | + public static ClientPluginChannels getClientPluginChannels() | ||
447 | + { | ||
448 | + return LiteLoader.getInstance().clientPluginChannels; | ||
449 | + } | ||
450 | + | ||
451 | + /** | ||
452 | + * Get the server-side plugin channel manager | ||
453 | + * | ||
454 | + * @return | ||
455 | + */ | ||
456 | + public static ServerPluginChannels getServerPluginChannels() | ||
457 | + { | ||
458 | + return LiteLoader.getInstance().serverPluginChannels; | ||
459 | + } | ||
460 | + | ||
461 | + /** | ||
462 | + * Get the input manager | ||
463 | + */ | ||
464 | + public static Input getInput() | ||
465 | + { | ||
466 | + return LiteLoader.getInstance().input; | ||
467 | + } | ||
468 | + | ||
469 | + /** | ||
500 | * Get the "mods" folder | 470 | * Get the "mods" folder |
501 | */ | 471 | */ |
502 | public static File getModsFolder() | 472 | public static File getModsFolder() |
@@ -545,6 +515,24 @@ public final class LiteLoader | @@ -545,6 +515,24 @@ public final class LiteLoader | ||
545 | } | 515 | } |
546 | 516 | ||
547 | /** | 517 | /** |
518 | + * Used to get the name of the modpack being used | ||
519 | + * | ||
520 | + * @return name of the modpack in use or null if no pack | ||
521 | + */ | ||
522 | + public static String getBranding() | ||
523 | + { | ||
524 | + return LiteLoader.getInstance().bootstrap.getBranding(); | ||
525 | + } | ||
526 | + | ||
527 | + /** | ||
528 | + * @return | ||
529 | + */ | ||
530 | + public static boolean isDevelopmentEnvironment() | ||
531 | + { | ||
532 | + return "true".equals(System.getProperty("mcpenv")); | ||
533 | + } | ||
534 | + | ||
535 | + /** | ||
548 | * Used for crash reporting, returns a text list of all loaded mods | 536 | * Used for crash reporting, returns a text list of all loaded mods |
549 | * | 537 | * |
550 | * @return List of loaded mods as a string | 538 | * @return List of loaded mods as a string |
@@ -565,25 +553,22 @@ public final class LiteLoader | @@ -565,25 +553,22 @@ public final class LiteLoader | ||
565 | /** | 553 | /** |
566 | * Get a list containing all mod files which were NOT loaded | 554 | * Get a list containing all mod files which were NOT loaded |
567 | */ | 555 | */ |
568 | - public List<ModFile> getDisabledMods() | 556 | + public List<Loadable<?>> getDisabledMods() |
569 | { | 557 | { |
570 | return Collections.unmodifiableList(this.disabledMods); | 558 | return Collections.unmodifiableList(this.disabledMods); |
571 | } | 559 | } |
572 | - | ||
573 | /** | 560 | /** |
574 | - * Used to get the name of the modpack being used | ||
575 | - * | ||
576 | - * @return name of the modpack in use or null if no pack | 561 | + * Get the list of injected tweak containers |
577 | */ | 562 | */ |
578 | - public String getBranding() | 563 | + public Collection<Loadable<File>> getInjectedTweaks() |
579 | { | 564 | { |
580 | - return this.bootstrap.getBranding(); | 565 | + return Collections.unmodifiableCollection(this.enumerator.getInjectedTweaks()); |
581 | } | 566 | } |
582 | - | 567 | + |
583 | /** | 568 | /** |
584 | * Get a reference to a loaded mod, if the mod exists | 569 | * Get a reference to a loaded mod, if the mod exists |
585 | * | 570 | * |
586 | - * @param modName Mod's name, meta name or class name | 571 | + * @param modName Mod's name, identifier or class name |
587 | * @return | 572 | * @return |
588 | * @throws InvalidActivityException | 573 | * @throws InvalidActivityException |
589 | */ | 574 | */ |
@@ -602,9 +587,10 @@ public final class LiteLoader | @@ -602,9 +587,10 @@ public final class LiteLoader | ||
602 | 587 | ||
603 | for (LiteMod mod : this.mods) | 588 | for (LiteMod mod : this.mods) |
604 | { | 589 | { |
605 | - String metaName = this.getModMetaName(mod.getClass()); | 590 | + Class<? extends LiteMod> modClass = mod.getClass(); |
591 | + String modId = this.getModIdentifier(modClass); | ||
606 | 592 | ||
607 | - if (modName.equalsIgnoreCase(mod.getName()) || modName.equalsIgnoreCase(metaName) || modName.equalsIgnoreCase(mod.getClass().getSimpleName())) | 593 | + if (modName.equalsIgnoreCase(mod.getName()) || modName.equalsIgnoreCase(modId) || modName.equalsIgnoreCase(modClass.getSimpleName())) |
608 | return (T)mod; | 594 | return (T)mod; |
609 | } | 595 | } |
610 | 596 | ||
@@ -656,16 +642,16 @@ public final class LiteLoader | @@ -656,16 +642,16 @@ public final class LiteLoader | ||
656 | /** | 642 | /** |
657 | * Get a metadata value for the specified mod | 643 | * Get a metadata value for the specified mod |
658 | * | 644 | * |
659 | - * @param mod | 645 | + * @param modNameOrId |
660 | * @param metaDataKey | 646 | * @param metaDataKey |
661 | * @param defaultValue | 647 | * @param defaultValue |
662 | * @return | 648 | * @return |
663 | * @throws InvalidActivityException Thrown by getMod if init is not complete | 649 | * @throws InvalidActivityException Thrown by getMod if init is not complete |
664 | * @throws IllegalArgumentException Thrown by getMod if argument is null | 650 | * @throws IllegalArgumentException Thrown by getMod if argument is null |
665 | */ | 651 | */ |
666 | - public String getModMetaData(String mod, String metaDataKey, String defaultValue) throws InvalidActivityException, IllegalArgumentException | 652 | + public String getModMetaData(String modNameOrId, String metaDataKey, String defaultValue) throws InvalidActivityException, IllegalArgumentException |
667 | { | 653 | { |
668 | - return this.getModMetaData(this.getMod(mod), metaDataKey, defaultValue); | 654 | + return this.getModMetaData(this.getMod(modNameOrId), metaDataKey, defaultValue); |
669 | } | 655 | } |
670 | 656 | ||
671 | /** | 657 | /** |
@@ -685,40 +671,74 @@ public final class LiteLoader | @@ -685,40 +671,74 @@ public final class LiteLoader | ||
685 | /** | 671 | /** |
686 | * Get a metadata value for the specified mod | 672 | * Get a metadata value for the specified mod |
687 | * | 673 | * |
688 | - * @param modClassName | 674 | + * @param modClass |
689 | * @param metaDataKey | 675 | * @param metaDataKey |
690 | * @param defaultValue | 676 | * @param defaultValue |
691 | * @return | 677 | * @return |
692 | */ | 678 | */ |
693 | public String getModMetaData(Class<? extends LiteMod> modClass, String metaDataKey, String defaultValue) | 679 | public String getModMetaData(Class<? extends LiteMod> modClass, String metaDataKey, String defaultValue) |
694 | { | 680 | { |
681 | + if (modClass == null || metaDataKey == null) return defaultValue; | ||
695 | return this.enumerator.getModMetaData(modClass, metaDataKey, defaultValue); | 682 | return this.enumerator.getModMetaData(modClass, metaDataKey, defaultValue); |
696 | } | 683 | } |
697 | 684 | ||
698 | /** | 685 | /** |
699 | - * Get the mod "name" metadata key, this is used for versioning, exclusivity, and enablement checks | 686 | + * Get the mod identifier, this is used for versioning, exclusivity, and enablement checks |
700 | * | 687 | * |
701 | * @param modClass | 688 | * @param modClass |
702 | * @return | 689 | * @return |
703 | */ | 690 | */ |
704 | - public String getModMetaName(Class<? extends LiteMod> modClass) | 691 | + public String getModIdentifier(Class<? extends LiteMod> modClass) |
705 | { | 692 | { |
706 | - return this.enumerator.getModMetaName(modClass); | 693 | + return this.enumerator.getModIdentifier(modClass); |
707 | } | 694 | } |
708 | 695 | ||
709 | /** | 696 | /** |
710 | - * Get the mod "name" metadata key, this is used for versioning, exclusivity, and enablement checks | 697 | + * Get the mod identifier, this is used for versioning, exclusivity, and enablement checks |
711 | * | 698 | * |
712 | * @param modClass | 699 | * @param modClass |
713 | * @return | 700 | * @return |
714 | */ | 701 | */ |
715 | - public Class<? extends LiteMod> getModFromMetaName(String modName) | 702 | + public String getModIdentifier(LiteMod mod) |
716 | { | 703 | { |
717 | - if (modName == null) return null; | 704 | + return mod == null ? null : this.enumerator.getModIdentifier(mod.getClass()); |
705 | + } | ||
706 | + | ||
707 | + /** | ||
708 | + * Get the container (mod file, classpath jar or folder) for the specified mod | ||
709 | + * | ||
710 | + * @param modClass | ||
711 | + * @return | ||
712 | + */ | ||
713 | + public LoadableMod<?> getModContainer(Class<? extends LiteMod> modClass) | ||
714 | + { | ||
715 | + return this.enumerator.getModContainer(modClass); | ||
716 | + } | ||
717 | + | ||
718 | + /** | ||
719 | + * Get the container (mod file, classpath jar or folder) for the specified mod | ||
720 | + * | ||
721 | + * @param modClass | ||
722 | + * @return | ||
723 | + */ | ||
724 | + public LoadableMod<?> getModContainer(LiteMod mod) | ||
725 | + { | ||
726 | + return mod == null ? null : this.enumerator.getModContainer(mod.getClass()); | ||
727 | + } | ||
728 | + | ||
729 | + /** | ||
730 | + * Get the mod which matches the specified identifier | ||
731 | + * | ||
732 | + * @param identifier | ||
733 | + * @return | ||
734 | + */ | ||
735 | + public Class<? extends LiteMod> getModFromIdentifier(String identifier) | ||
736 | + { | ||
737 | + if (identifier == null) return null; | ||
718 | 738 | ||
719 | for (LiteMod mod : this.mods) | 739 | for (LiteMod mod : this.mods) |
720 | { | 740 | { |
721 | - if (modName.equalsIgnoreCase(this.enumerator.getModMetaName(mod.getClass()))) | 741 | + if (identifier.equalsIgnoreCase(this.enumerator.getModIdentifier(mod.getClass()))) |
722 | { | 742 | { |
723 | return mod.getClass(); | 743 | return mod.getClass(); |
724 | } | 744 | } |
@@ -728,29 +748,29 @@ public final class LiteLoader | @@ -728,29 +748,29 @@ public final class LiteLoader | ||
728 | } | 748 | } |
729 | 749 | ||
730 | /** | 750 | /** |
731 | - * @param modMetaName Mod meta name to enable | 751 | + * @param identifier Identifier of the mod to enable |
732 | */ | 752 | */ |
733 | - public void enableMod(String modMetaName) | 753 | + public void enableMod(String identifier) |
734 | { | 754 | { |
735 | - this.setModEnabled(modMetaName, true); | 755 | + this.setModEnabled(identifier, true); |
736 | } | 756 | } |
737 | 757 | ||
738 | /** | 758 | /** |
739 | - * @param modMetaName Mod meta name to disable | 759 | + * @param identifier Identifier of the mod to disable |
740 | */ | 760 | */ |
741 | - public void disableMod(String modMetaName) | 761 | + public void disableMod(String identifier) |
742 | { | 762 | { |
743 | - this.setModEnabled(modMetaName, false); | 763 | + this.setModEnabled(identifier, false); |
744 | } | 764 | } |
745 | 765 | ||
746 | /** | 766 | /** |
747 | - * @param modMetaName Mod meta name to enable/disable | 767 | + * @param identifier Identifier of the mod to enable/disable |
748 | * @param enabled | 768 | * @param enabled |
749 | */ | 769 | */ |
750 | - public void setModEnabled(String modMetaName, boolean enabled) | 770 | + public void setModEnabled(String identifier, boolean enabled) |
751 | { | 771 | { |
752 | - this.enabledModsList.setEnabled(this.bootstrap.getProfile(), modMetaName, enabled); | ||
753 | - this.enabledModsList.saveTo(this.enabledModsFile); | 772 | + this.enabledModsList.setEnabled(this.bootstrap.getProfile(), identifier, enabled); |
773 | + this.enabledModsList.save(); | ||
754 | } | 774 | } |
755 | 775 | ||
756 | /** | 776 | /** |
@@ -772,7 +792,7 @@ public final class LiteLoader | @@ -772,7 +792,7 @@ public final class LiteLoader | ||
772 | 792 | ||
773 | for (LiteMod mod : this.loadedMods) | 793 | for (LiteMod mod : this.loadedMods) |
774 | { | 794 | { |
775 | - if (modName.equalsIgnoreCase(this.enumerator.getModMetaName(mod.getClass()))) | 795 | + if (modName.equalsIgnoreCase(this.enumerator.getModIdentifier(mod.getClass()))) |
776 | { | 796 | { |
777 | return true; | 797 | return true; |
778 | } | 798 | } |
@@ -810,70 +830,79 @@ public final class LiteLoader | @@ -810,70 +830,79 @@ public final class LiteLoader | ||
810 | { | 830 | { |
811 | if (!this.enumerator.hasModsToLoad()) | 831 | if (!this.enumerator.hasModsToLoad()) |
812 | { | 832 | { |
813 | - LiteLoader.logInfo("Mod class discovery failed or no mod classes were found. Not loading any mods."); | 833 | + LiteLoaderLogger.info("Mod class discovery failed or no mod classes were found. Not loading any mods."); |
814 | return; | 834 | return; |
815 | } | 835 | } |
816 | 836 | ||
817 | - LiteLoader.logInfo("Discovered %d total mod(s)", this.enumerator.modsToLoadCount()); | 837 | + LiteLoaderLogger.info("Discovered %d total mod(s)", this.enumerator.modsToLoadCount()); |
818 | 838 | ||
819 | this.pendingResourceReload = false; | 839 | this.pendingResourceReload = false; |
820 | - this.soundManagerReloadInhibitor = new SoundManagerReloadInhibitor((SimpleReloadableResourceManager)this.minecraft.getResourceManager(), this.minecraft.sndManager); | ||
821 | - if (this.inhibitSoundManagerReload) this.soundManagerReloadInhibitor.inhibit(); | 840 | + this.soundHandlerReloadInhibitor = new SoundHandlerReloadInhibitor((SimpleReloadableResourceManager)this.minecraft.getResourceManager(), this.minecraft.getSoundHandler()); |
841 | + if (this.inhibitSoundManagerReload) this.soundHandlerReloadInhibitor.inhibit(); | ||
822 | 842 | ||
823 | for (Class<? extends LiteMod> mod : this.enumerator.getModsToLoad()) | 843 | for (Class<? extends LiteMod> mod : this.enumerator.getModsToLoad()) |
824 | { | 844 | { |
845 | + LoadableMod<?> container = this.enumerator.getModContainer(mod); | ||
846 | + | ||
825 | try | 847 | try |
826 | { | 848 | { |
827 | - String metaName = this.getModMetaName(mod); | ||
828 | - if (metaName == null || this.enabledModsList.isEnabled(this.bootstrap.getProfile(), metaName)) | 849 | + String identifier = this.getModIdentifier(mod); |
850 | + if (identifier == null || this.enabledModsList.isEnabled(this.bootstrap.getProfile(), identifier)) | ||
829 | { | 851 | { |
830 | - this.loadMod(metaName, mod); | 852 | + if (this.enumerator.checkDependencies(container)) |
853 | + { | ||
854 | + this.loadMod(identifier, mod, container); | ||
855 | + } | ||
856 | + else | ||
857 | + { | ||
858 | + LiteLoaderLogger.info("Not loading mod %s, the mod was missing a required dependency", identifier); | ||
859 | + if (container != LoadableMod.NONE && !this.disabledMods.contains(container)) this.disabledMods.add(container); | ||
860 | + } | ||
831 | } | 861 | } |
832 | else | 862 | else |
833 | { | 863 | { |
834 | - LiteLoader.logInfo("Not loading mod %s, excluded by filter", metaName); | ||
835 | - this.disabledMods.add(this.enumerator.getModFile(mod)); | 864 | + LiteLoaderLogger.info("Not loading mod %s, excluded by filter", identifier); |
865 | + if (container != LoadableMod.NONE && !this.disabledMods.contains(container)) this.disabledMods.add(container); | ||
836 | } | 866 | } |
837 | } | 867 | } |
838 | catch (Throwable th) | 868 | catch (Throwable th) |
839 | { | 869 | { |
840 | - th.printStackTrace(System.out); | ||
841 | - LiteLoader.getLogger().log(Level.WARNING, String.format("Error loading mod from %s", mod.getName()), th); | 870 | + th.printStackTrace(); |
871 | + LiteLoaderLogger.warning(th, "Error loading mod from %s", mod.getName()); | ||
872 | + if (container != LoadableMod.NONE && !this.disabledMods.contains(container)) this.disabledMods.add(container); | ||
842 | } | 873 | } |
843 | } | 874 | } |
844 | } | 875 | } |
845 | 876 | ||
846 | /** | 877 | /** |
847 | - * @param metaName | 878 | + * @param identifier |
848 | * @param mod | 879 | * @param mod |
880 | + * @param container | ||
849 | * @throws InstantiationException | 881 | * @throws InstantiationException |
850 | * @throws IllegalAccessException | 882 | * @throws IllegalAccessException |
851 | */ | 883 | */ |
852 | - protected void loadMod(String metaName, Class<? extends LiteMod> mod) throws InstantiationException, IllegalAccessException | 884 | + protected void loadMod(String identifier, Class<? extends LiteMod> mod, LoadableMod<?> container) throws InstantiationException, IllegalAccessException |
853 | { | 885 | { |
854 | - LiteLoader.logInfo("Loading mod from %s", mod.getName()); | 886 | + LiteLoaderLogger.info("Loading mod from %s", mod.getName()); |
855 | 887 | ||
856 | LiteMod newMod = mod.newInstance(); | 888 | LiteMod newMod = mod.newInstance(); |
857 | 889 | ||
858 | this.mods.add(newMod); | 890 | this.mods.add(newMod); |
859 | String modName = newMod.getName(); | 891 | String modName = newMod.getName(); |
860 | - if (modName == null && metaName != null) modName = metaName; | ||
861 | - LiteLoader.logInfo("Successfully added mod %s version %s", modName, newMod.getVersion()); | 892 | + if (modName == null && identifier != null) modName = identifier; |
893 | + LiteLoaderLogger.info("Successfully added mod %s version %s", modName, newMod.getVersion()); | ||
862 | 894 | ||
863 | - // Get the mod file and register it as a resource pack if it exists | ||
864 | - ModFile modFile = this.enumerator.getModFile(mod); | ||
865 | - if (modFile != null) | 895 | + // Register the mod as a resource pack if the container exists |
896 | + if (container != null) | ||
866 | { | 897 | { |
867 | - this.disabledMods.remove(modFile); | ||
868 | - | ||
869 | - LiteLoader.logInfo("Adding \"%s\" to active resource pack set", modFile.getAbsolutePath()); | 898 | + LiteLoaderLogger.info("Adding \"%s\" to active resource pack set", container.getLocation()); |
870 | if (modName != null) | 899 | if (modName != null) |
871 | { | 900 | { |
872 | - modFile.initResourcePack(modName); | 901 | + container.initResourcePack(modName); |
873 | 902 | ||
874 | - if (modFile.hasResourcePack() && this.registerModResourcePack((ResourcePack)modFile.getResourcePack())) | 903 | + if (container.hasResourcePack() && this.registerModResourcePack((IResourcePack)container.getResourcePack())) |
875 | { | 904 | { |
876 | - LiteLoader.logInfo("Successfully added \"%s\" to active resource pack set", modFile.getAbsolutePath()); | 905 | + LiteLoaderLogger.info("Successfully added \"%s\" to active resource pack set", container.getLocation()); |
877 | } | 906 | } |
878 | } | 907 | } |
879 | } | 908 | } |
@@ -898,7 +927,7 @@ public final class LiteLoader | @@ -898,7 +927,7 @@ public final class LiteLoader | ||
898 | } | 927 | } |
899 | catch (Throwable th) | 928 | catch (Throwable th) |
900 | { | 929 | { |
901 | - LiteLoader.getLogger().log(Level.WARNING, "Error initialising mod '" + mod.getName() + "'", th); | 930 | + LiteLoaderLogger.warning(th, "Error initialising mod '%s'", mod.getName()); |
902 | iter.remove(); | 931 | iter.remove(); |
903 | } | 932 | } |
904 | } | 933 | } |
@@ -911,7 +940,7 @@ public final class LiteLoader | @@ -911,7 +940,7 @@ public final class LiteLoader | ||
911 | */ | 940 | */ |
912 | protected void initMod(LiteMod mod) | 941 | protected void initMod(LiteMod mod) |
913 | { | 942 | { |
914 | - LiteLoader.logInfo("Initialising mod %s version %s", mod.getName(), mod.getVersion()); | 943 | + LiteLoaderLogger.info("Initialising mod %s version %s", mod.getName(), mod.getVersion()); |
915 | 944 | ||
916 | // register mod config panel if configurable | 945 | // register mod config panel if configurable |
917 | this.configManager.registerMod(mod); | 946 | this.configManager.registerMod(mod); |
@@ -922,7 +951,7 @@ public final class LiteLoader | @@ -922,7 +951,7 @@ public final class LiteLoader | ||
922 | } | 951 | } |
923 | catch (Throwable th) | 952 | catch (Throwable th) |
924 | { | 953 | { |
925 | - LiteLoader.logWarning("Error performing settings upgrade for %s. Settings may not be properly migrated", mod.getName()); | 954 | + LiteLoaderLogger.warning("Error performing settings upgrade for %s. Settings may not be properly migrated", mod.getName()); |
926 | } | 955 | } |
927 | 956 | ||
928 | // Init mod config if there is any | 957 | // Init mod config if there is any |
@@ -949,18 +978,18 @@ public final class LiteLoader | @@ -949,18 +978,18 @@ public final class LiteLoader | ||
949 | String modKey = this.getModNameForConfig(mod.getClass(), mod.getName()); | 978 | String modKey = this.getModNameForConfig(mod.getClass(), mod.getName()); |
950 | LiteLoaderVersion lastModVersion = LiteLoaderVersion.getVersionFromRevision(this.bootstrap.getLastKnownModRevision(modKey)); | 979 | LiteLoaderVersion lastModVersion = LiteLoaderVersion.getVersionFromRevision(this.bootstrap.getLastKnownModRevision(modKey)); |
951 | 980 | ||
952 | - if (LiteLoaderBootstrap.VERSION.getLoaderRevision() > lastModVersion.getLoaderRevision()) | 981 | + if (LiteLoaderVersion.CURRENT.getLoaderRevision() > lastModVersion.getLoaderRevision()) |
953 | { | 982 | { |
954 | - LiteLoader.logInfo("Performing config upgrade for mod %s. Upgrading %s to %s...", mod.getName(), lastModVersion, LiteLoaderBootstrap.VERSION); | 983 | + LiteLoaderLogger.info("Performing config upgrade for mod %s. Upgrading %s to %s...", mod.getName(), lastModVersion, LiteLoaderVersion.CURRENT); |
955 | 984 | ||
956 | // Migrate versioned config if any is present | 985 | // Migrate versioned config if any is present |
957 | this.configManager.migrateModConfig(mod, this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); | 986 | this.configManager.migrateModConfig(mod, this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); |
958 | 987 | ||
959 | // Let the mod upgrade | 988 | // Let the mod upgrade |
960 | - mod.upgradeSettings(LiteLoaderBootstrap.VERSION.getMinecraftVersion(), this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); | 989 | + mod.upgradeSettings(LiteLoaderVersion.CURRENT.getMinecraftVersion(), this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); |
961 | 990 | ||
962 | this.bootstrap.storeLastKnownModRevision(modKey); | 991 | this.bootstrap.storeLastKnownModRevision(modKey); |
963 | - LiteLoader.logInfo("Config upgrade succeeded for mod %s", mod.getName()); | 992 | + LiteLoaderLogger.info("Config upgrade succeeded for mod %s", mod.getName()); |
964 | } | 993 | } |
965 | } | 994 | } |
966 | 995 | ||
@@ -1001,9 +1030,9 @@ public final class LiteLoader | @@ -1001,9 +1030,9 @@ public final class LiteLoader | ||
1001 | // Set the loader branding in ClientBrandRetriever using reflection | 1030 | // Set the loader branding in ClientBrandRetriever using reflection |
1002 | LiteLoaderBootstrap.setBranding("LiteLoader"); | 1031 | LiteLoaderBootstrap.setBranding("LiteLoader"); |
1003 | 1032 | ||
1004 | - if (this.soundManagerReloadInhibitor != null && this.soundManagerReloadInhibitor.isInhibited()) | 1033 | + if (this.soundHandlerReloadInhibitor != null && this.soundHandlerReloadInhibitor.isInhibited()) |
1005 | { | 1034 | { |
1006 | - this.soundManagerReloadInhibitor.unInhibit(true); | 1035 | + this.soundHandlerReloadInhibitor.unInhibit(true); |
1007 | } | 1036 | } |
1008 | } | 1037 | } |
1009 | 1038 | ||
@@ -1013,9 +1042,9 @@ public final class LiteLoader | @@ -1013,9 +1042,9 @@ public final class LiteLoader | ||
1013 | * @param netHandler | 1042 | * @param netHandler |
1014 | * @param loginPacket | 1043 | * @param loginPacket |
1015 | */ | 1044 | */ |
1016 | - void onLogin(NetHandler netHandler, Packet1Login loginPacket) | 1045 | + void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) |
1017 | { | 1046 | { |
1018 | - this.permissionsManager.onLogin(netHandler, loginPacket); | 1047 | + this.permissionsManager.onJoinGame(netHandler, loginPacket); |
1019 | } | 1048 | } |
1020 | 1049 | ||
1021 | /** | 1050 | /** |
@@ -1031,37 +1060,18 @@ public final class LiteLoader | @@ -1031,37 +1060,18 @@ public final class LiteLoader | ||
1031 | this.permissionsManager.scheduleRefresh(); | 1060 | this.permissionsManager.scheduleRefresh(); |
1032 | } | 1061 | } |
1033 | } | 1062 | } |
1034 | - | ||
1035 | - /** | ||
1036 | - * On render callback | ||
1037 | - */ | ||
1038 | - void onRender() | ||
1039 | - { | ||
1040 | - if (this.paginateControls && this.minecraft.currentScreen != null && this.minecraft.currentScreen.getClass().equals(GuiControls.class)) | ||
1041 | - { | ||
1042 | - try | ||
1043 | - { | ||
1044 | - // Try to get the parent screen entry from the existing screen | ||
1045 | - GuiScreen parentScreen = PrivateFields.guiControlsParentScreen.get((GuiControls)this.minecraft.currentScreen); | ||
1046 | - this.minecraft.displayGuiScreen(new GuiControlsPaginated(parentScreen, this.minecraft.gameSettings)); | ||
1047 | - } | ||
1048 | - catch (Exception ex) | ||
1049 | - { | ||
1050 | - } | ||
1051 | - } | ||
1052 | - } | ||
1053 | 1063 | ||
1054 | /** | 1064 | /** |
1055 | * @param partialTicks | 1065 | * @param partialTicks |
1056 | */ | 1066 | */ |
1057 | void postRender(int mouseX, int mouseY, float partialTicks) | 1067 | void postRender(int mouseX, int mouseY, float partialTicks) |
1058 | { | 1068 | { |
1059 | - if (this.minecraft.currentScreen instanceof GuiMainMenu && ((this.displayModInfoScreenTab && !this.hideModInfoScreenTab) || (this.modInfoScreen != null && this.modInfoScreen.isTweeningOrOpen()))) | 1069 | + if (GuiScreenModInfo.isSupportedOnScreen(this.minecraft.currentScreen) && ((this.displayModInfoScreenTab && !this.hideModInfoScreenTab) || (this.modInfoScreen != null && this.modInfoScreen.isTweeningOrOpen()))) |
1060 | { | 1070 | { |
1061 | // If we're at the main menu, prepare the overlay | 1071 | // If we're at the main menu, prepare the overlay |
1062 | - if (this.modInfoScreen == null || this.modInfoScreen.getMenu() != this.minecraft.currentScreen) | 1072 | + if (this.modInfoScreen == null || this.modInfoScreen.getScreen() != this.minecraft.currentScreen) |
1063 | { | 1073 | { |
1064 | - this.modInfoScreen = new GuiScreenModInfo(this.minecraft, (GuiMainMenu)this.minecraft.currentScreen, this, this.enabledModsList, this.configManager, this.hideModInfoScreenTab); | 1074 | + this.modInfoScreen = new GuiScreenModInfo(this.minecraft, this.minecraft.currentScreen, this, this.enabledModsList, this.configManager, this.hideModInfoScreenTab); |
1065 | } | 1075 | } |
1066 | 1076 | ||
1067 | this.modInfoScreen.drawScreen(mouseX, mouseY, partialTicks); | 1077 | this.modInfoScreen.drawScreen(mouseX, mouseY, partialTicks); |
@@ -1072,9 +1082,9 @@ public final class LiteLoader | @@ -1072,9 +1082,9 @@ public final class LiteLoader | ||
1072 | this.modInfoScreen.release(); | 1082 | this.modInfoScreen.release(); |
1073 | this.modInfoScreen = null; | 1083 | this.modInfoScreen = null; |
1074 | } | 1084 | } |
1075 | - else if (this.minecraft.currentScreen instanceof GuiMainMenu && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_TAB)) | 1085 | + else if (GuiScreenModInfo.isSupportedOnScreen(this.minecraft.currentScreen) && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_TAB)) |
1076 | { | 1086 | { |
1077 | - this.displayModInfoScreen((GuiMainMenu)this.minecraft.currentScreen); | 1087 | + this.displayModInfoScreen(this.minecraft.currentScreen); |
1078 | } | 1088 | } |
1079 | } | 1089 | } |
1080 | 1090 | ||
@@ -1082,32 +1092,39 @@ public final class LiteLoader | @@ -1082,32 +1092,39 @@ public final class LiteLoader | ||
1082 | * @param partialTicks | 1092 | * @param partialTicks |
1083 | * @param inGame | 1093 | * @param inGame |
1084 | */ | 1094 | */ |
1085 | - void onTick(float partialTicks, boolean inGame) | 1095 | + void onTick(boolean clock, float partialTicks, boolean inGame) |
1086 | { | 1096 | { |
1087 | - // Tick the permissions manager | ||
1088 | - this.permissionsManager.onTick(this.minecraft, partialTicks, inGame); | ||
1089 | - | ||
1090 | - // Tick the config manager | ||
1091 | - this.configManager.onTick(); | ||
1092 | - | ||
1093 | - this.checkAndStoreKeyBindings(); | ||
1094 | - | ||
1095 | - if (this.modInfoScreen != null && this.minecraft.currentScreen != this.modInfoScreen) | 1097 | + if (clock) |
1096 | { | 1098 | { |
1097 | - this.modInfoScreen.updateScreen(); | ||
1098 | - } | ||
1099 | - | ||
1100 | - if (!PrivateFields.gameIsRunning.get(this.minecraft)) | ||
1101 | - { | ||
1102 | - this.onShutDown(); | 1099 | + // Tick the permissions manager |
1100 | + this.minecraft.mcProfiler.startSection("permissionsmanager"); | ||
1101 | + this.permissionsManager.onTick(this.minecraft, partialTicks, inGame); | ||
1102 | + | ||
1103 | + // Tick the config manager | ||
1104 | + this.minecraft.mcProfiler.endStartSection("configmanager"); | ||
1105 | + this.configManager.onTick(); | ||
1106 | + | ||
1107 | + if (this.modInfoScreen != null && this.minecraft.currentScreen != this.modInfoScreen) | ||
1108 | + { | ||
1109 | + this.modInfoScreen.updateScreen(); | ||
1110 | + } | ||
1111 | + | ||
1112 | + if (!((IMinecraft)this.minecraft).isRunning()) | ||
1113 | + { | ||
1114 | + this.onShutDown(); | ||
1115 | + } | ||
1103 | } | 1116 | } |
1117 | + | ||
1118 | + this.minecraft.mcProfiler.endStartSection("keybindings"); | ||
1119 | + this.input.onTick(clock); | ||
1120 | + this.minecraft.mcProfiler.endSection(); | ||
1104 | } | 1121 | } |
1105 | 1122 | ||
1106 | private void onShutDown() | 1123 | private void onShutDown() |
1107 | { | 1124 | { |
1108 | - LiteLoader.logInfo("LiteLoader is shutting down, syncing configuration"); | 1125 | + LiteLoaderLogger.info("LiteLoader is shutting down, syncing configuration"); |
1109 | 1126 | ||
1110 | - this.storeBindings(); | 1127 | + this.input.storeBindings(); |
1111 | this.configManager.syncConfig(); | 1128 | this.configManager.syncConfig(); |
1112 | } | 1129 | } |
1113 | 1130 | ||
@@ -1115,71 +1132,12 @@ public final class LiteLoader | @@ -1115,71 +1132,12 @@ public final class LiteLoader | ||
1115 | * Register a key for a mod | 1132 | * Register a key for a mod |
1116 | * | 1133 | * |
1117 | * @param binding | 1134 | * @param binding |
1135 | + * @deprecated Deprecated : use LiteLoader.getInput().registerKeyBinding() instead | ||
1118 | */ | 1136 | */ |
1137 | + @Deprecated | ||
1119 | public void registerModKey(KeyBinding binding) | 1138 | public void registerModKey(KeyBinding binding) |
1120 | { | 1139 | { |
1121 | - LinkedList<KeyBinding> keyBindings = new LinkedList<KeyBinding>(); | ||
1122 | - keyBindings.addAll(Arrays.asList(this.minecraft.gameSettings.keyBindings)); | ||
1123 | - | ||
1124 | - if (!keyBindings.contains(binding)) | ||
1125 | - { | ||
1126 | - if (this.keyMapSettings.containsKey(binding.keyDescription)) | ||
1127 | - { | ||
1128 | - try | ||
1129 | - { | ||
1130 | - binding.keyCode = Integer.parseInt(this.keyMapSettings.getProperty(binding.keyDescription, String.valueOf(binding.keyCode))); | ||
1131 | - } | ||
1132 | - catch (NumberFormatException ex) {} | ||
1133 | - } | ||
1134 | - | ||
1135 | - keyBindings.add(binding); | ||
1136 | - this.minecraft.gameSettings.keyBindings = keyBindings.toArray(new KeyBinding[0]); | ||
1137 | - this.modKeyBindings.add(binding); | ||
1138 | - | ||
1139 | - this.updateBinding(binding); | ||
1140 | - this.storeBindings(); | ||
1141 | - } | ||
1142 | - } | ||
1143 | - | ||
1144 | - /** | ||
1145 | - * Checks for changed mod keybindings and stores any that have changed | ||
1146 | - */ | ||
1147 | - private void checkAndStoreKeyBindings() | ||
1148 | - { | ||
1149 | - boolean updated = false; | ||
1150 | - | ||
1151 | - for (KeyBinding binding : this.modKeyBindings) | ||
1152 | - { | ||
1153 | - if (binding.keyCode != this.storedModKeyBindings.get(binding)) | ||
1154 | - { | ||
1155 | - this.updateBinding(binding); | ||
1156 | - updated = true; | ||
1157 | - } | ||
1158 | - } | ||
1159 | - | ||
1160 | - if (updated) | ||
1161 | - this.storeBindings(); | ||
1162 | - } | ||
1163 | - | ||
1164 | - /** | ||
1165 | - * @param binding | ||
1166 | - */ | ||
1167 | - private void updateBinding(KeyBinding binding) | ||
1168 | - { | ||
1169 | - this.keyMapSettings.setProperty(binding.keyDescription, String.valueOf(binding.keyCode)); | ||
1170 | - this.storedModKeyBindings.put(binding, Integer.valueOf(binding.keyCode)); | ||
1171 | - } | ||
1172 | - | ||
1173 | - /** | ||
1174 | - * Writes mod bindings to disk | ||
1175 | - */ | ||
1176 | - private void storeBindings() | ||
1177 | - { | ||
1178 | - try | ||
1179 | - { | ||
1180 | - this.keyMapSettings.store(new FileWriter(this.keyMapSettingsFile), "Mod key mappings for LiteLoader mods, stored here to avoid losing settings stored in options.txt"); | ||
1181 | - } | ||
1182 | - catch (IOException ex) {} | 1140 | + this.input.registerKeyBinding(binding); |
1183 | } | 1141 | } |
1184 | 1142 | ||
1185 | /** | 1143 | /** |
@@ -1209,24 +1167,17 @@ public final class LiteLoader | @@ -1209,24 +1167,17 @@ public final class LiteLoader | ||
1209 | } | 1167 | } |
1210 | 1168 | ||
1211 | /** | 1169 | /** |
1212 | - * Display the "mod info" overlay over the specified main menu GUI | 1170 | + * Display the "mod info" overlay over the specified GUI |
1213 | * | 1171 | * |
1214 | * @param parentScreen | 1172 | * @param parentScreen |
1215 | */ | 1173 | */ |
1216 | - public void displayModInfoScreen(GuiMainMenu parentScreen) | ||
1217 | - { | ||
1218 | - this.modInfoScreen = new GuiScreenModInfo(this.minecraft, parentScreen, this, this.enabledModsList, this.configManager, this.hideModInfoScreenTab); | ||
1219 | - this.minecraft.displayGuiScreen(this.modInfoScreen); | ||
1220 | - } | ||
1221 | - | ||
1222 | - private static void logInfo(String string, Object... args) | 1174 | + public void displayModInfoScreen(GuiScreen parentScreen) |
1223 | { | 1175 | { |
1224 | - LiteLoader.logger.info(String.format(string, args)); | ||
1225 | - } | ||
1226 | - | ||
1227 | - private static void logWarning(String string, Object... args) | ||
1228 | - { | ||
1229 | - LiteLoader.logger.warning(String.format(string, args)); | 1176 | + if (GuiScreenModInfo.isSupportedOnScreen(parentScreen)) |
1177 | + { | ||
1178 | + this.modInfoScreen = new GuiScreenModInfo(this.minecraft, parentScreen, this, this.enabledModsList, this.configManager, this.hideModInfoScreenTab); | ||
1179 | + this.minecraft.displayGuiScreen(this.modInfoScreen); | ||
1180 | + } | ||
1230 | } | 1181 | } |
1231 | 1182 | ||
1232 | /** | 1183 | /** |
@@ -1239,6 +1190,46 @@ public final class LiteLoader | @@ -1239,6 +1190,46 @@ public final class LiteLoader | ||
1239 | CrashReport crashReport = (CrashReport)objCrashReport; | 1190 | CrashReport crashReport = (CrashReport)objCrashReport; |
1240 | crashReport.getCategory().addCrashSectionCallable("Mod Pack", new CallableLiteLoaderBrand(crashReport)); | 1191 | crashReport.getCategory().addCrashSectionCallable("Mod Pack", new CallableLiteLoaderBrand(crashReport)); |
1241 | crashReport.getCategory().addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(crashReport)); | 1192 | crashReport.getCategory().addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(crashReport)); |
1193 | + crashReport.getCategory().addCrashSectionCallable("LaunchWrapper", new CallableLaunchWrapper(crashReport)); | ||
1242 | } | 1194 | } |
1243 | } | 1195 | } |
1196 | + | ||
1197 | + static final void init(LiteLoaderBootstrap bootstrap, LiteLoaderEnumerator enumerator, EnabledModsList enabledModsList, LaunchClassLoader classLoader) | ||
1198 | + { | ||
1199 | + if (LiteLoader.instance == null) | ||
1200 | + { | ||
1201 | + LiteLoader.classLoader = classLoader; | ||
1202 | + | ||
1203 | + LiteLoader.instance = new LiteLoader(bootstrap, enumerator, enabledModsList); | ||
1204 | + LiteLoader.instance.init(); | ||
1205 | + } | ||
1206 | + } | ||
1207 | + | ||
1208 | + private void updateSharedModList() | ||
1209 | + { | ||
1210 | + Map<String, Map<String, String>> modList = this.enumerator.getSharedModList(); | ||
1211 | + if (modList == null) return; | ||
1212 | + | ||
1213 | + for (LiteMod mod : this.mods) | ||
1214 | + { | ||
1215 | + String modKey = String.format("%s:%s", LiteLoader.MOD_SYSTEM, this.getModIdentifier(mod)); | ||
1216 | + modList.put(modKey, this.packModInfoToMap(mod)); | ||
1217 | + } | ||
1218 | + } | ||
1219 | + | ||
1220 | + private Map<String, String> packModInfoToMap(LiteMod mod) | ||
1221 | + { | ||
1222 | + Map<String, String> modInfo = new HashMap<String, String>(); | ||
1223 | + LoadableMod<?> container = this.getModContainer(mod); | ||
1224 | + | ||
1225 | + modInfo.put("modsystem", LiteLoader.MOD_SYSTEM); | ||
1226 | + modInfo.put("id", this.getModIdentifier(mod)); | ||
1227 | + modInfo.put("version", mod.getVersion()); | ||
1228 | + modInfo.put("name", mod.getName()); | ||
1229 | + modInfo.put("url", container.getMetaValue("url", "")); | ||
1230 | + modInfo.put("authors", container.getAuthor()); | ||
1231 | + modInfo.put("description", container.getDescription(LiteLoaderEnumerator.getModClassName(mod))); | ||
1232 | + | ||
1233 | + return modInfo; | ||
1234 | + } | ||
1244 | } | 1235 | } |
1245 | \ No newline at end of file | 1236 | \ No newline at end of file |
java/com/mumfrey/liteloader/core/LiteLoaderBootstrap.java
@@ -6,20 +6,21 @@ import java.io.FileNotFoundException; | @@ -6,20 +6,21 @@ import java.io.FileNotFoundException; | ||
6 | import java.io.FileWriter; | 6 | import java.io.FileWriter; |
7 | import java.io.IOException; | 7 | import java.io.IOException; |
8 | import java.io.InputStream; | 8 | import java.io.InputStream; |
9 | -import java.io.PrintStream; | 9 | +import java.io.Serializable; |
10 | import java.lang.reflect.Field; | 10 | import java.lang.reflect.Field; |
11 | import java.util.List; | 11 | import java.util.List; |
12 | import java.util.Properties; | 12 | import java.util.Properties; |
13 | -import java.util.logging.FileHandler; | ||
14 | -import java.util.logging.Level; | ||
15 | -import java.util.logging.Logger; | ||
16 | -import java.util.logging.StreamHandler; | 13 | + |
14 | +import org.apache.logging.log4j.core.Layout; | ||
15 | +import org.apache.logging.log4j.core.Logger; | ||
16 | +import org.apache.logging.log4j.core.appender.FileAppender; | ||
17 | +import org.apache.logging.log4j.core.layout.PatternLayout; | ||
17 | 18 | ||
18 | import net.minecraft.client.ClientBrandRetriever; | 19 | import net.minecraft.client.ClientBrandRetriever; |
19 | import net.minecraft.launchwrapper.LaunchClassLoader; | 20 | import net.minecraft.launchwrapper.LaunchClassLoader; |
20 | 21 | ||
21 | import com.mumfrey.liteloader.launch.ILoaderBootstrap; | 22 | import com.mumfrey.liteloader.launch.ILoaderBootstrap; |
22 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogFormatter; | 23 | +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
23 | 24 | ||
24 | /** | 25 | /** |
25 | * LiteLoaderBootstrap is a proxy class which handles the early part of the LiteLoader startup process which | 26 | * LiteLoaderBootstrap is a proxy class which handles the early part of the LiteLoader startup process which |
@@ -39,19 +40,9 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -39,19 +40,9 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
39 | /** | 40 | /** |
40 | * Liteloader version | 41 | * Liteloader version |
41 | */ | 42 | */ |
42 | - public static final LiteLoaderVersion VERSION = LiteLoaderVersion.MC_1_6_4_R2; | ||
43 | - | ||
44 | - /** | ||
45 | - * Local logger reference | ||
46 | - */ | ||
47 | - private static final Logger logger = Logger.getLogger("liteloader"); | 43 | + public static final LiteLoaderVersion VERSION = LiteLoaderVersion.CURRENT; |
48 | 44 | ||
49 | /** | 45 | /** |
50 | - * True to use stdout instead of stderr | ||
51 | - */ | ||
52 | - private static boolean useStdOut; | ||
53 | - | ||
54 | - /** | ||
55 | * Base game directory, passed in from the tweaker | 46 | * Base game directory, passed in from the tweaker |
56 | */ | 47 | */ |
57 | private final File gameDirectory; | 48 | private final File gameDirectory; |
@@ -72,6 +63,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -72,6 +63,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
72 | private final File modsFolder; | 63 | private final File modsFolder; |
73 | 64 | ||
74 | /** | 65 | /** |
66 | + * "Mods" folder to use | ||
67 | + */ | ||
68 | + private final File versionedModsFolder; | ||
69 | + | ||
70 | + /** | ||
75 | * Base "liteconfig" folder under which all other lite mod configs and liteloader configs are placed | 71 | * Base "liteconfig" folder under which all other lite mod configs and liteloader configs are placed |
76 | */ | 72 | */ |
77 | private final File configBaseFolder; | 73 | private final File configBaseFolder; |
@@ -85,6 +81,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -85,6 +81,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
85 | * File containing the properties | 81 | * File containing the properties |
86 | */ | 82 | */ |
87 | private File propertiesFile; | 83 | private File propertiesFile; |
84 | + | ||
85 | + /** | ||
86 | + * JSON file containing the list of enabled/disabled mods by profile | ||
87 | + */ | ||
88 | + private File enabledModsFile; | ||
88 | 89 | ||
89 | /** | 90 | /** |
90 | * Internal properties loaded from inside the jar | 91 | * Internal properties loaded from inside the jar |
@@ -108,22 +109,30 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -108,22 +109,30 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
108 | private LiteLoaderEnumerator enumerator; | 109 | private LiteLoaderEnumerator enumerator; |
109 | 110 | ||
110 | /** | 111 | /** |
112 | + * List of mods passed into the command line | ||
113 | + */ | ||
114 | + private EnabledModsList enabledModsList; | ||
115 | + | ||
116 | + /** | ||
111 | * @param gameDirectory | 117 | * @param gameDirectory |
112 | * @param assetsDirectory | 118 | * @param assetsDirectory |
113 | * @param profile | 119 | * @param profile |
114 | */ | 120 | */ |
115 | public LiteLoaderBootstrap(File gameDirectory, File assetsDirectory, String profile) | 121 | public LiteLoaderBootstrap(File gameDirectory, File assetsDirectory, String profile) |
116 | { | 122 | { |
117 | - this.gameDirectory = gameDirectory; | ||
118 | - this.assetsDirectory = assetsDirectory; | ||
119 | - this.profile = profile; | 123 | + this.gameDirectory = gameDirectory; |
124 | + this.assetsDirectory = assetsDirectory; | ||
125 | + this.profile = profile; | ||
120 | 126 | ||
121 | - this.modsFolder = new File(this.gameDirectory, "mods"); | ||
122 | - this.configBaseFolder = new File(this.gameDirectory, "liteconfig"); | ||
123 | - this.logFile = new File(this.configBaseFolder, "liteloader.log"); | ||
124 | - this.propertiesFile = new File(this.configBaseFolder, "liteloader.properties"); | 127 | + this.modsFolder = new File(this.gameDirectory, "mods"); |
128 | + this.versionedModsFolder = new File(this.modsFolder, LiteLoaderVersion.CURRENT.getMinecraftVersion()); | ||
129 | + this.configBaseFolder = new File(this.gameDirectory, "liteconfig"); | ||
130 | + this.logFile = new File(this.configBaseFolder, "liteloader.log"); | ||
131 | + this.propertiesFile = new File(this.configBaseFolder, "liteloader.properties"); | ||
132 | + this.enabledModsFile = new File(this.configBaseFolder, "liteloader.profiles.json"); | ||
125 | 133 | ||
126 | if (!this.modsFolder.exists()) this.modsFolder.mkdirs(); | 134 | if (!this.modsFolder.exists()) this.modsFolder.mkdirs(); |
135 | + if (!this.versionedModsFolder.exists()) this.versionedModsFolder.mkdirs(); | ||
127 | if (!this.configBaseFolder.exists()) this.configBaseFolder.mkdirs(); | 136 | if (!this.configBaseFolder.exists()) this.configBaseFolder.mkdirs(); |
128 | } | 137 | } |
129 | 138 | ||
@@ -131,45 +140,43 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -131,45 +140,43 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
131 | * @see com.mumfrey.liteloader.launch.ILoaderBootstrap#preInit(net.minecraft.launchwrapper.LaunchClassLoader, boolean) | 140 | * @see com.mumfrey.liteloader.launch.ILoaderBootstrap#preInit(net.minecraft.launchwrapper.LaunchClassLoader, boolean) |
132 | */ | 141 | */ |
133 | @Override | 142 | @Override |
134 | - public void preInit(LaunchClassLoader classLoader, boolean loadTweaks) | 143 | + public void preInit(LaunchClassLoader classLoader, boolean loadTweaks, List<String> modsToLoad) |
135 | { | 144 | { |
145 | + LiteLoaderLogger.info("LiteLoader begin PREINIT..."); | ||
146 | + | ||
136 | // Set up the bootstrap | 147 | // Set up the bootstrap |
137 | if (!this.prepare()) return; | 148 | if (!this.prepare()) return; |
138 | 149 | ||
139 | - LiteLoaderBootstrap.logInfo("LiteLoader %s starting up...", LiteLoaderBootstrap.VERSION.getLoaderVersion()); | 150 | + LiteLoaderLogger.info("LiteLoader %s starting up...", LiteLoaderVersion.CURRENT.getLoaderVersion()); |
140 | 151 | ||
141 | // Print the branding version if any was provided | 152 | // Print the branding version if any was provided |
142 | if (this.branding != null) | 153 | if (this.branding != null) |
143 | { | 154 | { |
144 | - LiteLoaderBootstrap.logInfo("Active Pack: %s", this.branding); | 155 | + LiteLoaderLogger.info("Active Pack: %s", this.branding); |
145 | } | 156 | } |
146 | 157 | ||
147 | - LiteLoaderBootstrap.logInfo("Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase()); | 158 | + LiteLoaderLogger.info("Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase()); |
148 | 159 | ||
149 | - this.enumerator = new LiteLoaderEnumerator(this, classLoader, loadTweaks); | ||
150 | - this.enumerator.discoverMods(); | 160 | + this.enabledModsList = EnabledModsList.createFrom(this.enabledModsFile); |
161 | + this.enabledModsList.processModsList(this.profile, modsToLoad); | ||
151 | 162 | ||
152 | - LiteLoaderBootstrap.logInfo("LiteLoader PreInit completed"); | 163 | + this.enumerator = new LiteLoaderEnumerator(this, classLoader, this.enabledModsList, loadTweaks); |
164 | + this.enumerator.discoverMods(); | ||
165 | + | ||
166 | + LiteLoaderLogger.info("LiteLoader PREINIT complete"); | ||
153 | } | 167 | } |
154 | 168 | ||
155 | /* (non-Javadoc) | 169 | /* (non-Javadoc) |
156 | * @see com.mumfrey.liteloader.launch.ILoaderBootstrap#init(java.util.List, net.minecraft.launchwrapper.LaunchClassLoader) | 170 | * @see com.mumfrey.liteloader.launch.ILoaderBootstrap#init(java.util.List, net.minecraft.launchwrapper.LaunchClassLoader) |
157 | */ | 171 | */ |
158 | @Override | 172 | @Override |
159 | - public void init(List<String> modsToLoad, LaunchClassLoader classLoader) | 173 | + public void init(LaunchClassLoader classLoader) |
160 | { | 174 | { |
161 | // PreInit failed | 175 | // PreInit failed |
162 | if (this.enumerator == null) return; | 176 | if (this.enumerator == null) return; |
163 | 177 | ||
164 | - try | ||
165 | - { | ||
166 | - if (LiteLoaderBootstrap.logger.getHandlers().length < 1) | ||
167 | - this.prepareLogger(); | ||
168 | - } | ||
169 | - catch (Exception ex) {} | ||
170 | - | ||
171 | - LiteLoaderBootstrap.logger.info("Beginning LiteLoader Init..."); | ||
172 | - LiteLoader.init(this, this.enumerator, modsToLoad, classLoader); | 178 | + LiteLoaderLogger.info("LiteLoader begin INIT..."); |
179 | + LiteLoader.init(this, this.enumerator, this.enabledModsList, classLoader); | ||
173 | } | 180 | } |
174 | 181 | ||
175 | /* (non-Javadoc) | 182 | /* (non-Javadoc) |
@@ -181,15 +188,8 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -181,15 +188,8 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
181 | // PreInit failed | 188 | // PreInit failed |
182 | if (this.enumerator == null) return; | 189 | if (this.enumerator == null) return; |
183 | 190 | ||
184 | - try | ||
185 | - { | ||
186 | - if (LiteLoaderBootstrap.logger.getHandlers().length < 1) | ||
187 | - this.prepareLogger(); | ||
188 | - } | ||
189 | - catch (Exception ex) {} | ||
190 | - | ||
191 | - LiteLoaderBootstrap.logger.info("Beginning LiteLoader PostInit..."); | ||
192 | - LiteLoader.postInit(); | 191 | + LiteLoaderLogger.info("LiteLoader begin POSTINIT..."); |
192 | + LiteLoader.getInstance().postInit(); | ||
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
@@ -217,7 +217,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -217,7 +217,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
217 | } | 217 | } |
218 | catch (Throwable th) | 218 | catch (Throwable th) |
219 | { | 219 | { |
220 | - LiteLoaderBootstrap.logger.log(Level.SEVERE, "Error initialising LiteLoader Bootstrap", th); | 220 | + LiteLoaderLogger.severe(th, "Error initialising LiteLoader Bootstrap"); |
221 | return false; | 221 | return false; |
222 | } | 222 | } |
223 | 223 | ||
@@ -230,26 +230,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -230,26 +230,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
230 | */ | 230 | */ |
231 | private void prepareLogger() throws SecurityException, IOException | 231 | private void prepareLogger() throws SecurityException, IOException |
232 | { | 232 | { |
233 | - LiteLoaderBootstrap.logger.setUseParentHandlers(false); | ||
234 | - LiteLoaderBootstrap.useStdOut = System.getProperty("liteloader.log", "stderr").equalsIgnoreCase("stdout") || this.localProperties.getProperty("log", "stderr").equalsIgnoreCase("stdout"); | ||
235 | - | ||
236 | - StreamHandler consoleHandler = useStdOut ? new com.mumfrey.liteloader.util.log.ConsoleHandler() : new java.util.logging.ConsoleHandler(); | ||
237 | - consoleHandler.setFormatter(new LiteLoaderLogFormatter(false)); | ||
238 | - LiteLoaderBootstrap.logger.addHandler(consoleHandler); | ||
239 | - | ||
240 | - FileHandler logFileHandler = new FileHandler(this.logFile.getAbsolutePath()); | ||
241 | - logFileHandler.setFormatter(new LiteLoaderLogFormatter(true)); | ||
242 | - LiteLoaderBootstrap.logger.addHandler(logFileHandler); | ||
243 | - } | ||
244 | - | ||
245 | - /** | ||
246 | - * Get the output stream which we are using for console output | ||
247 | - * | ||
248 | - * @return | ||
249 | - */ | ||
250 | - public static final PrintStream getConsoleStream() | ||
251 | - { | ||
252 | - return LiteLoaderBootstrap.useStdOut ? System.out : System.err; | 233 | + Logger logger = LiteLoaderLogger.getLogger(); |
234 | + Layout<? extends Serializable> layout = PatternLayout.createLayout("[%d{HH:mm:ss}] [%t/%level]: %msg%n", logger.getContext().getConfiguration(), null, "UTF-8", "True"); | ||
235 | + FileAppender fileAppender = FileAppender.createAppender(this.logFile.getAbsolutePath(), "False", "False", "LiteLoader", "True", "True", "True", layout, null, "False", "", logger.getContext().getConfiguration()); | ||
236 | + fileAppender.start(); | ||
237 | + logger.addAppender(fileAppender); | ||
253 | } | 238 | } |
254 | 239 | ||
255 | /** | 240 | /** |
@@ -314,11 +299,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -314,11 +299,11 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
314 | { | 299 | { |
315 | try | 300 | try |
316 | { | 301 | { |
317 | - this.localProperties.store(new FileWriter(this.propertiesFile), String.format("Properties for LiteLoader %s", LiteLoaderBootstrap.VERSION)); | 302 | + this.localProperties.store(new FileWriter(this.propertiesFile), String.format("Properties for LiteLoader %s", LiteLoaderVersion.CURRENT)); |
318 | } | 303 | } |
319 | catch (Throwable th) | 304 | catch (Throwable th) |
320 | { | 305 | { |
321 | - LiteLoaderBootstrap.logger.log(Level.WARNING, "Error writing liteloader properties", th); | 306 | + LiteLoaderLogger.warning(th, "Error writing liteloader properties"); |
322 | } | 307 | } |
323 | } | 308 | } |
324 | 309 | ||
@@ -355,6 +340,14 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -355,6 +340,14 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
355 | } | 340 | } |
356 | 341 | ||
357 | /** | 342 | /** |
343 | + * Get the mods folder | ||
344 | + */ | ||
345 | + public File getVersionedModsFolder() | ||
346 | + { | ||
347 | + return this.versionedModsFolder; | ||
348 | + } | ||
349 | + | ||
350 | + /** | ||
358 | * Get the base "liteconfig" folder | 351 | * Get the base "liteconfig" folder |
359 | */ | 352 | */ |
360 | public File getConfigBaseFolder() | 353 | public File getConfigBaseFolder() |
@@ -369,6 +362,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -369,6 +362,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
369 | * @param defaultValue | 362 | * @param defaultValue |
370 | * @return | 363 | * @return |
371 | */ | 364 | */ |
365 | + @Override | ||
372 | public boolean getAndStoreBooleanProperty(String propertyName, boolean defaultValue) | 366 | public boolean getAndStoreBooleanProperty(String propertyName, boolean defaultValue) |
373 | { | 367 | { |
374 | boolean result = this.localProperties.getProperty(propertyName, String.valueOf(defaultValue)).equalsIgnoreCase("true"); | 368 | boolean result = this.localProperties.getProperty(propertyName, String.valueOf(defaultValue)).equalsIgnoreCase("true"); |
@@ -377,11 +371,25 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -377,11 +371,25 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
377 | } | 371 | } |
378 | 372 | ||
379 | /** | 373 | /** |
374 | + * Get a boolean propery from the properties file and also write the new value back to the properties file | ||
375 | + * | ||
376 | + * @param propertyName | ||
377 | + * @param defaultValue | ||
378 | + * @return | ||
379 | + */ | ||
380 | + @Override | ||
381 | + public boolean getBooleanProperty(String propertyName) | ||
382 | + { | ||
383 | + return this.localProperties.getProperty(propertyName, "false").equalsIgnoreCase("true"); | ||
384 | + } | ||
385 | + | ||
386 | + /** | ||
380 | * Set a boolean property | 387 | * Set a boolean property |
381 | * | 388 | * |
382 | * @param propertyName | 389 | * @param propertyName |
383 | * @param value | 390 | * @param value |
384 | */ | 391 | */ |
392 | + @Override | ||
385 | public void setBooleanProperty(String propertyName, boolean value) | 393 | public void setBooleanProperty(String propertyName, boolean value) |
386 | { | 394 | { |
387 | this.localProperties.setProperty(propertyName, String.valueOf(value)); | 395 | this.localProperties.setProperty(propertyName, String.valueOf(value)); |
@@ -396,7 +404,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -396,7 +404,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
396 | { | 404 | { |
397 | if (this.localProperties != null) | 405 | if (this.localProperties != null) |
398 | { | 406 | { |
399 | - this.localProperties.setProperty(modKey, String.valueOf(LiteLoaderBootstrap.VERSION.getLoaderRevision())); | 407 | + this.localProperties.setProperty(modKey, String.valueOf(LiteLoaderVersion.CURRENT.getLoaderRevision())); |
400 | this.writeProperties(); | 408 | this.writeProperties(); |
401 | } | 409 | } |
402 | } | 410 | } |
@@ -458,16 +466,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | @@ -458,16 +466,7 @@ class LiteLoaderBootstrap implements ILoaderBootstrap | ||
458 | } | 466 | } |
459 | catch (Throwable th) | 467 | catch (Throwable th) |
460 | { | 468 | { |
461 | - LiteLoaderBootstrap.logger.log(Level.WARNING, "Setting branding failed", th); | 469 | + LiteLoaderLogger.warning(th, "Setting branding failed"); |
462 | } | 470 | } |
463 | } | 471 | } |
464 | - | ||
465 | - /** | ||
466 | - * @param string | ||
467 | - * @param args | ||
468 | - */ | ||
469 | - private static void logInfo(String string, Object... args) | ||
470 | - { | ||
471 | - LiteLoaderBootstrap.logger.info(String.format(string, args)); | ||
472 | - } | ||
473 | } | 472 | } |