Commit 11a9a320c246bc607c46b0770c8d65b7d47cf248
Migrate project to git and gradle
Showing
53 changed files
with
268 additions
and
4371 deletions
Too many changes to show.
To preserve performance only 53 of 352 files are displayed.
.classpath deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<classpath> | |
3 | - <classpathentry kind="src" path="debug"/> | |
4 | - <classpathentry kind="src" path="resources"/> | |
5 | - <classpathentry kind="src" path="java/common"/> | |
6 | - <classpathentry kind="src" path="java/client"/> | |
7 | - <classpathentry combineaccessrules="false" exported="true" kind="src" path="/Client"/> | |
8 | - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | |
9 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar"/> | |
10 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/com/google/guava/guava/17.0/guava-17.0.jar"/> | |
11 | - <classpathentry exported="true" 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.11.jar" sourcepath="externals/launchwrapper/src"/> | |
13 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar"/> | |
14 | - <classpathentry kind="lib" path="/Client/jars/libraries/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar"/> | |
15 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/io/netty/netty-all/4.0.15.Final/netty-all-4.0.15.Final.jar"/> | |
16 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/apache/logging/log4j/log4j-api/2.0-beta9/log4j-api-2.0-beta9.jar"/> | |
17 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/apache/logging/log4j/log4j-core/2.0-beta9/log4j-core-2.0-beta9.jar"/> | |
18 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar"/> | |
19 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/com/mojang/authlib/1.5.17/authlib-1.5.17.jar"/> | |
20 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.1/lwjgl-2.9.1.jar"/> | |
21 | - <classpathentry exported="true" kind="lib" path="lib/asm-debug-all-5.0.3.jar"/> | |
22 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.1/lwjgl_util-2.9.1.jar"/> | |
23 | - <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/com/mojang/realms/1.6.1/realms-1.6.1.jar"/> | |
24 | - <classpathentry kind="output" path="bin"/> | |
25 | -</classpath> |
.gitignore
0 → 100644
1 | +# Build # | |
2 | +######### | |
3 | +MANIFEST.MF | |
4 | +dependency-reduced-pom.xml | |
5 | +.checkstyle | |
6 | + | |
7 | +# Compiled # | |
8 | +############ | |
9 | +bin | |
10 | +build | |
11 | +dist | |
12 | +lib | |
13 | +out | |
14 | +run | |
15 | +target | |
16 | +*.com | |
17 | +*.class | |
18 | +*.dll | |
19 | +*.exe | |
20 | +*.o | |
21 | +*.so | |
22 | +*.launch | |
23 | + | |
24 | +# Databases # | |
25 | +############# | |
26 | +*.db | |
27 | +*.sql | |
28 | +*.sqlite | |
29 | + | |
30 | +# Packages # | |
31 | +############ | |
32 | +*.7z | |
33 | +*.dmg | |
34 | +*.gz | |
35 | +*.iso | |
36 | +*.rar | |
37 | +*.tar | |
38 | +*.zip | |
39 | + | |
40 | +# Repository # | |
41 | +############## | |
42 | +.git | |
43 | + | |
44 | +# Logging # | |
45 | +########### | |
46 | +/logs | |
47 | +*.log | |
48 | + | |
49 | +# Misc # | |
50 | +######## | |
51 | +*.bak | |
52 | + | |
53 | +# System # | |
54 | +########## | |
55 | +.DS_Store | |
56 | +ehthumbs.db | |
57 | +Thumbs.db | |
58 | + | |
59 | +# Project # | |
60 | +########### | |
61 | +.classpath | |
62 | +.externalToolBuilders | |
63 | +.gradle | |
64 | +.nb-gradle | |
65 | +.idea | |
66 | +.project | |
67 | +.settings | |
68 | +eclipse | |
69 | +nbproject | |
70 | +atlassian-ide-plugin.xml | |
71 | +build.xml | |
72 | +nb-configuration.xml | |
73 | +*.iml | |
74 | +*.ipr | |
75 | +*.iws | |
76 | + | ... | ... |
.project deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<projectDescription> | |
3 | - <name>LiteLoader</name> | |
4 | - <comment></comment> | |
5 | - <projects> | |
6 | - </projects> | |
7 | - <buildSpec> | |
8 | - <buildCommand> | |
9 | - <name>org.eclipse.jdt.core.javabuilder</name> | |
10 | - <arguments> | |
11 | - </arguments> | |
12 | - </buildCommand> | |
13 | - </buildSpec> | |
14 | - <natures> | |
15 | - <nature>org.eclipse.jdt.core.javanature</nature> | |
16 | - </natures> | |
17 | - <variableList> | |
18 | - <variable> | |
19 | - <name>MCP_LOC</name> | |
20 | - <value>$%7BPARENT-2-PROJECT_LOC%7D</value> | |
21 | - </variable> | |
22 | - </variableList> | |
23 | -</projectDescription> |
.settings/org.eclipse.core.resources.prefs deleted
100644 → 0
.settings/org.eclipse.jdt.core.prefs deleted
100644 → 0
1 | -#Fri Aug 17 17:54:35 BST 2012 | |
2 | -eclipse.preferences.version=1 | |
3 | -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | |
4 | -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | |
5 | -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | |
6 | -org.eclipse.jdt.core.compiler.compliance=1.6 | |
7 | -org.eclipse.jdt.core.compiler.debug.lineNumber=generate | |
8 | -org.eclipse.jdt.core.compiler.debug.localVariable=generate | |
9 | -org.eclipse.jdt.core.compiler.debug.sourceFile=generate | |
10 | -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | |
11 | -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | |
12 | -org.eclipse.jdt.core.compiler.source=1.6 |
.settings/org.eclipse.jdt.ui.prefs deleted
100644 → 0
LiteLoader.iml deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<module type="JAVA_MODULE" version="4"> | |
3 | - <component name="EclipseModuleManager"> | |
4 | - <libelement value="file:///Client/jars/libraries/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar" /> | |
5 | - <libelement value="file:///Client/jars/libraries/com/google/guava/guava/17.0/guava-17.0.jar" /> | |
6 | - <libelement value="file:///Client/jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar" /> | |
7 | - <libelement value="jar://$MODULE_DIR$/lib/launchwrapper-1.11.jar!/" /> | |
8 | - <libelement value="jar://$MODULE_DIR$/lib/asm-debug-all-5.0.3.jar!/" /> | |
9 | - <libelement value="file:///Client/jars/libraries/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar" /> | |
10 | - <libelement value="file:///Client/jars/libraries/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar" /> | |
11 | - <libelement value="file:///Client/jars/libraries/io/netty/netty-all/4.0.15.Final/netty-all-4.0.15.Final.jar" /> | |
12 | - <libelement value="file:///Client/jars/libraries/org/apache/logging/log4j/log4j-api/2.0-beta9/log4j-api-2.0-beta9.jar" /> | |
13 | - <libelement value="file:///Client/jars/libraries/org/apache/logging/log4j/log4j-core/2.0-beta9/log4j-core-2.0-beta9.jar" /> | |
14 | - <libelement value="file:///Client/jars/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar" /> | |
15 | - <libelement value="file:///Client/jars/libraries/com/mojang/authlib/1.5.17/authlib-1.5.17.jar" /> | |
16 | - <libelement value="file:///Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.1/lwjgl-2.9.1.jar" /> | |
17 | - <src_description expected_position="0"> | |
18 | - <src_folder value="file://$MODULE_DIR$/debug" expected_position="0" /> | |
19 | - <src_folder value="file://$MODULE_DIR$/resources" expected_position="1" /> | |
20 | - <src_folder value="file://$MODULE_DIR$/java/common" expected_position="2" /> | |
21 | - <src_folder value="file://$MODULE_DIR$/java/client" expected_position="3" /> | |
22 | - </src_description> | |
23 | - </component> | |
24 | - <component name="NewModuleRootManager" inherit-compiler-output="false"> | |
25 | - <output url="file://$MODULE_DIR$/bin" /> | |
26 | - <exclude-output /> | |
27 | - <content url="file://$MODULE_DIR$"> | |
28 | - <sourceFolder url="file://$MODULE_DIR$/debug" isTestSource="false" /> | |
29 | - <sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" /> | |
30 | - <sourceFolder url="file://$MODULE_DIR$/java/common" isTestSource="false" /> | |
31 | - <sourceFolder url="file://$MODULE_DIR$/java/client" isTestSource="false" /> | |
32 | - </content> | |
33 | - <orderEntry type="sourceFolder" forTests="false" /> | |
34 | - <orderEntry type="module" module-name="Client" exported="" /> | |
35 | - <orderEntry type="jdk" jdkName="JavaSE-1.6" jdkType="JavaSDK" /> | |
36 | - <orderEntry type="module-library" exported=""> | |
37 | - <library name="launchwrapper-1.11.jar"> | |
38 | - <CLASSES> | |
39 | - <root url="jar://$MODULE_DIR$/lib/launchwrapper-1.11.jar!/" /> | |
40 | - </CLASSES> | |
41 | - <JAVADOC /> | |
42 | - <SOURCES> | |
43 | - <root url="file://$MODULE_DIR$/externals/launchwrapper/src" /> | |
44 | - </SOURCES> | |
45 | - </library> | |
46 | - </orderEntry> | |
47 | - <orderEntry type="module-library" exported=""> | |
48 | - <library> | |
49 | - <CLASSES> | |
50 | - <root url="jar://$MODULE_DIR$/lib/asm-debug-all-5.0.3.jar!/" /> | |
51 | - </CLASSES> | |
52 | - <JAVADOC /> | |
53 | - <SOURCES /> | |
54 | - </library> | |
55 | - </orderEntry> | |
56 | - </component> | |
57 | -</module> | |
58 | - |
README.md deleted
100644 → 0
1 | -LiteLoader | |
2 | ----------- | |
3 | - | |
4 | -Important Setup Note | |
5 | --------------------- | |
6 | -MCP 9.10 does not include the latest MCPBot mappings, since developing mods without these updated | |
7 | -mappings is a massive nuisance LiteLoader is built using a recent snapshot of the MCP mappings. | |
8 | - | |
9 | -The latest MCPTEST mappings can always be retrieved from [http://mcpbot.bspk.rs/testcsv/](http://mcpbot.bspk.rs/testcsv/) | |
10 | - | |
11 | -Getting the updated mappings | |
12 | ----------------------------- | |
13 | - | |
14 | -To get the updated mappings, perform these steps **before** decompiling minecraft for the first | |
15 | -time. If you have already decompiled minecraft, run the MPC **cleanup** task first to remove the | |
16 | -invalid sources, or simply delete the *temp* and *src* directories from your MCP installation. | |
17 | - | |
18 | -- Using a text editor, open **/mcp910/conf/mcp.cfg** | |
19 | -- Locate the setting **UpdateUrl** and change the domain to *dl.liteloader.com* as shown | |
20 | - | |
21 | - UpdateUrl = http://dl.liteloader.com/files/mcprolling_{version}/ | |
22 | - | |
23 | -- Save the file and run the **updatemcp** script, it should prompt you to download 3 files. | |
24 | -- Type **yes** to accept the download. | |
25 | -- Run **decompile** as normal. | |
26 | 0 | \ No newline at end of file |
ant/build_liteloader.xml deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8" ?> | |
2 | -<project name="liteloader" basedir="." default="development"> | |
3 | - | |
4 | - <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="tasks/ant-contrib.jar" /> | |
5 | - | |
6 | - <!-- Versions !!IMPORTANT --> | |
7 | - <property name="version" value="1.8.0_00" /> | |
8 | - <property name="mcversion" value="1.8" /> | |
9 | - <property name="author" value="Mumfrey" /> | |
10 | - | |
11 | - <!-- Project definitions and dependencies --> | |
12 | - <property name="upstream" value="" /> | |
13 | - <property name="project" value="LiteLoader" /> | |
14 | - <property name="displayname" value="LiteLoader" /> | |
15 | - <property name="md5set" value="mcp" /> | |
16 | - <property name="outmd5set" value="liteloader" /> | |
17 | - <property name="tweakclass" value="com.mumfrey.liteloader.launch.LiteLoaderTweaker" /> | |
18 | - | |
19 | - <property name="mcp.dir" location="../../.." /> | |
20 | - <property name="build.dir" location="${mcp.dir}/build" /> | |
21 | - <property name="eclipse.dir" location="${mcp.dir}/eclipse" /> | |
22 | - <property name="temp.dir" location="${mcp.dir}/temp" /> | |
23 | - <property name="md5.dir" location="${mcp.dir}/md5" /> | |
24 | - <property name="libs.dir" location="${mcp.dir}/lib" /> | |
25 | - <property name="src.dir" location="${build.dir}/src"/> | |
26 | - <property name="mc.src.dir" location="${mcp.dir}/src/minecraft" /> | |
27 | - <property name="mc.bin.dir" location="${mcp.dir}/bin/minecraft" /> | |
28 | - <property name="reobf.dir" location="${mcp.dir}/reobf/minecraft" /> | |
29 | - <property name="mc.libs.dir" location="${mcp.dir}/jars/libraries" /> | |
30 | - | |
31 | - <property name="dist.dir" location="${build.dir}/dist" /> | |
32 | - <property name="filetype" value="jar" /> | |
33 | - | |
34 | - <property name="python_windows" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" /> | |
35 | - <property name="python_linux" location="/usr/bin/python" /> | |
36 | - | |
37 | - <property environment="env" /> | |
38 | - | |
39 | - <target name="setup_client"> | |
40 | - <property name="clientjar" value="true" /> | |
41 | - <property name="suffix" value="" /> | |
42 | - <property name="javadocpath" value="docs" /> | |
43 | - </target> | |
44 | - | |
45 | - <target name="setup_core"> | |
46 | - <property name="suffix" value="-core" /> | |
47 | - <property name="javadocpath" value="coredocs" /> | |
48 | - </target> | |
49 | - | |
50 | - <target name="setup_development"> | |
51 | - <property name="skipremoval" value="DEV" /> | |
52 | - <property name="md5.outfile" value="${md5.dir}/client_${outmd5set}.md5" /> | |
53 | - <property name="artefact.name" value="${ant.project.name}${suffix}-${mcversion}" /> | |
54 | - <property name="stage.dir" location="${build.dir}/stage/${ant.project.name}/${version}" /> | |
55 | - <property name="meta.version" value="${version}" /> | |
56 | - </target> | |
57 | - | |
58 | - <target name="setup_production"> | |
59 | - <property name="skipremoval" value="" /> | |
60 | - <property name="md5.outfile" value="${md5.dir}/client_${outmd5set}_production.md5" /> | |
61 | - <property name="artefact.name" value="${ant.project.name}${suffix}-${mcversion}" /> | |
62 | - <property name="stage.dir" location="${build.dir}/stage/${ant.project.name}/${version}" /> | |
63 | - <property name="meta.version" value="${version}" /> | |
64 | - </target> | |
65 | - | |
66 | - <target name="setup_jenkins"> | |
67 | - <property name="skipremoval" value="" /> | |
68 | - <property name="md5.outfile" value="${md5.dir}/client_${outmd5set}_production.md5" /> | |
69 | - <property name="artefact.name" value="${ant.project.name}${suffix}-${mcversion}-SNAPSHOT" /> | |
70 | - <property name="stage.dir" location="${build.dir}/stage" /> | |
71 | - <property name="brand" value="${mcversion}-SNAPSHOT-r${env.SVN_REVISION}-b${env.BUILD_NUMBER}-${env.BUILD_ID}" /> | |
72 | - <property name="meta.version" value="${version} [${brand}]" /> | |
73 | - <property name="jenkins" value="" /> | |
74 | - </target> | |
75 | - | |
76 | - <!-- Main target --> | |
77 | - <target name="development" depends="setup_client, setup_development, build" description="Entry point for MCP and upstream builds" /> | |
78 | - | |
79 | - <target name="production" depends="setup_client, setup_production, build, javadoc, mcpjar" description="Entry point for production builds" /> | |
80 | - | |
81 | - <target name="jenkins" depends="setup_client, setup_jenkins, build, javadoc, mcpjar" description="Entry point for CI builds" /> | |
82 | - | |
83 | - <target name="core" depends="setup_core, setup_jenkins, build, javadoc, mcpjar" description="Entry point for CI builds" /> | |
84 | - | |
85 | - <target name="build" description="Perform all tasks for a client build" depends="init, recompile, reobfuscate, savemd5, stage, jar" > | |
86 | - </target> | |
87 | - | |
88 | - <target name="clean"> | |
89 | - <echo level="info" message="Cleaning output directories" /> | |
90 | - | |
91 | - <delete dir="${src.dir}" /> | |
92 | - <delete dir="${mcp.dir}/reobf" /> | |
93 | - </target> | |
94 | - | |
95 | - <target name="contributesource" description="Contribute an upstream project source code to the source path"> | |
96 | - <echo level="info" message="Contributing project ${lib}" /> | |
97 | - <copy todir="${src.dir}" verbose="false" overwrite="true" failonerror="false"> | |
98 | - <fileset dir="${eclipse.dir}/${lib}/java${sub}"> | |
99 | - <exclude name="**/debug" /> | |
100 | - <exclude name="**/debug/*.java" /> | |
101 | - </fileset> | |
102 | - <fileset dir="${eclipse.dir}/${lib}/src${sub}" /> | |
103 | - <filterchain> | |
104 | - <linecontains negate="true"> | |
105 | - <contains value="@MCPONLY${skipremoval}" /> | |
106 | - </linecontains> | |
107 | - </filterchain> | |
108 | - </copy> | |
109 | - </target> | |
110 | - | |
111 | - <target name="contributeclientsource" description="Contribute client source if building a client jar" if="clientjar"> | |
112 | - <antcall target="contributesource"> | |
113 | - <param name="lib" value="${project}" /> | |
114 | - <param name="sub" value="/client" /> | |
115 | - </antcall> | |
116 | - </target> | |
117 | - | |
118 | - <target name="contributeresources" description="Contribute resources to the staging path"> | |
119 | - <echo level="info" message="Contributing project resources for ${lib}" /> | |
120 | - <copy todir="${stage.dir}" verbose="false" failonerror="false"> | |
121 | - <fileset dir="${eclipse.dir}/${lib}/resources" excludes=".svn/**"> | |
122 | - <exclude name="**/Thumbs.db" /> | |
123 | - <exclude name="**/minecraft.key" /> | |
124 | - </fileset> | |
125 | - </copy> | |
126 | - </target> | |
127 | - | |
128 | - <target name="findmd5dir"> | |
129 | - <echo level="info" message="Searching for existing MD5 directory..." /> | |
130 | - <condition property="md5dir.exists"> | |
131 | - <available file="${md5.dir}" type="dir"/> | |
132 | - </condition> | |
133 | - </target> | |
134 | - | |
135 | - <target name="findmd5" depends="findmd5dir"> | |
136 | - <echo level="info" message="Searching for existing MD5 sets..." /> | |
137 | - <condition property="md5set.exists"> | |
138 | - <available file="${md5.dir}/client_${md5set}.md5" type="file"/> | |
139 | - </condition> | |
140 | - </target> | |
141 | - | |
142 | - <target name="seedmd5" depends="findmd5" unless="md5set.exists"> | |
143 | - <echo level="info" message="MD5 sets not found, seeding..." /> | |
144 | - <ant target="genmd5" antfile="seed_md5.xml" inheritall="true" /> | |
145 | - </target> | |
146 | - | |
147 | - <target name="notifymd5ok" depends="findmd5" if="md5set.exists"> | |
148 | - <echo level="info" message="MD5 sets already exist, skipping MD5 set seeding" /> | |
149 | - </target> | |
150 | - | |
151 | - <target name="preparemd5" description="Copy patched MD5 to the temp directory" depends="seedmd5, notifymd5ok, clean"> | |
152 | - <echo level="info" message="Prepare exclusion MD5s, using exclusion set "${md5set}"" /> | |
153 | - | |
154 | - <copy tofile="${temp.dir}/client.md5" file="${md5.dir}/client_${md5set}.md5" failonerror="true" verbose="true" overwrite="true" /> | |
155 | - </target> | |
156 | - | |
157 | - <target name="prepare" description="Prepare source for MCP" depends="preparemd5"> | |
158 | - <echo level="info" message="Prepare sources for compile" /> | |
159 | - | |
160 | - <echo level="info" message="Contributing libs" /> | |
161 | - <copy todir="${libs.dir}" verbose="true" overwrite="true"> | |
162 | - <fileset dir="${eclipse.dir}/${project}/lib"> | |
163 | - <exclude name="**/authlib*.jar" /> | |
164 | - <exclude name="**/log4j*.jar" /> | |
165 | - </fileset> | |
166 | - </copy> | |
167 | - | |
168 | - <echo level="info" message="Contributing MC source" /> | |
169 | - <copy todir="${src.dir}" verbose="false" overwrite="true"> | |
170 | - <fileset dir="${mc.src.dir}" /> | |
171 | - </copy> | |
172 | - | |
173 | - <echo level="info" message="Contributing upstream projects" /> | |
174 | - <foreach list="${upstream}" param="lib" target="contributesource" /> | |
175 | - | |
176 | - <antcall target="contributesource"> | |
177 | - <param name="lib" value="${project}" /> | |
178 | - <param name="sub" value="/common" /> | |
179 | - </antcall> | |
180 | - | |
181 | - <antcall target="contributeclientsource" /> | |
182 | - </target> | |
183 | - | |
184 | - <target name="init" description="Initialize build environment" depends="prepare"> | |
185 | - <echo append="false" file="${temp.dir}/build.cfg" message="[OUTPUT]
SrcClient = build/src" /> | |
186 | - | |
187 | - <echo level="info" message="Cleaning old stage and dist, MCP reobf directories" /> | |
188 | - | |
189 | - <delete dir="${stage.dir}" /> | |
190 | - | |
191 | - <echo level="info" message="Creating stage and dist dirs" /> | |
192 | - <mkdir dir="${stage.dir}" /> | |
193 | - <mkdir dir="${dist.dir}" /> | |
194 | - <mkdir dir="${md5.dir}" /> | |
195 | - </target> | |
196 | - | |
197 | - <target name="recompile" description="MCP recompile"> | |
198 | - <echo level="info" message="Compiling projects" /> | |
199 | - | |
200 | - <exec executable="${python_windows}" dir="${mcp.dir}" osfamily="windows"> | |
201 | - <arg value="runtime/recompile.py" /> | |
202 | - <arg value="--client" /> | |
203 | - <arg value="--config" /> | |
204 | - <arg value="${temp.dir}/build.cfg" /> | |
205 | - <arg value="%*" /> | |
206 | - </exec> | |
207 | - | |
208 | - <exec executable="${python_linux}" dir="${mcp.dir}" osfamily="unix"> | |
209 | - <arg value="runtime/recompile.py" /> | |
210 | - <arg value="--client" /> | |
211 | - <arg value="--config" /> | |
212 | - <arg value="${temp.dir}/build.cfg" /> | |
213 | - <arg value="%*" /> | |
214 | - </exec> | |
215 | - </target> | |
216 | - | |
217 | - <target name="reobfuscate" description="MCP reobfuscate"> | |
218 | - <echo level="info" message="Obfuscating classes" /> | |
219 | - | |
220 | - <exec executable="${python_windows}" dir="${mcp.dir}" osfamily="windows"> | |
221 | - <arg value="runtime/reobfuscate.py" /> | |
222 | - <arg value="--client" /> | |
223 | - <arg value="%*" /> | |
224 | - </exec> | |
225 | - | |
226 | - <exec executable="${python_linux}" dir="${mcp.dir}" osfamily="unix"> | |
227 | - <arg value="runtime/reobfuscate.py" /> | |
228 | - <arg value="--client" /> | |
229 | - <arg value="%*" /> | |
230 | - </exec> | |
231 | - </target> | |
232 | - | |
233 | - <target name="savemd5" description="Put post-obfuscation MD5 to stored md5 set" if="outmd5set"> | |
234 | - <echo level="info" message="Storing obfuscated MD5s" /> | |
235 | - | |
236 | - <copy file="${temp.dir}/client_reobf.md5" tofile="${md5.outfile}" overwrite="true" verbose="true" /> | |
237 | - </target> | |
238 | - | |
239 | - <target name="stage" description="Stage resources into staging directory"> | |
240 | - <echo level="info" message="Staging resources" /> | |
241 | - | |
242 | - <copy todir="${stage.dir}" overwrite="true"> | |
243 | - <fileset dir="${reobf.dir}" excludes=".svn/**, *.txt"> | |
244 | - <exclude name="?.class" /> | |
245 | - <exclude name="??.class" /> | |
246 | - <exclude name="???.class" /> | |
247 | - <exclude name="/net/minecraft/**" /> | |
248 | - </fileset> | |
249 | - </copy> | |
250 | - | |
251 | - <foreach list="${upstream}" param="lib" target="contributeresources" /> | |
252 | - | |
253 | - <antcall target="contributeresources"> | |
254 | - <param name="lib" value="${project}" /> | |
255 | - </antcall> | |
256 | - | |
257 | - <antcall target="stamp"> | |
258 | - </antcall> | |
259 | - </target> | |
260 | - | |
261 | - <target name="stamp" description="Stamp build information into staged resources" if="jenkins"> | |
262 | - <echo level="info" message="Writing branding information into artefact staging area" /> | |
263 | - <echo level="info" message="Brand: ${brand}" /> | |
264 | - | |
265 | - <replaceregexp file="${stage.dir}/liteloader.properties" byline="true" match="^brand=.*$" replace="brand=${brand}" /> | |
266 | - </target> | |
267 | - | |
268 | - <target name="jar" description="Build the client jar"> | |
269 | - <echo level="info" message="Building final output" /> | |
270 | - | |
271 | - <mkdir dir="${dist.dir}" /> | |
272 | - | |
273 | - <jar destfile="${dist.dir}/${artefact.name}.${filetype}" duplicate="preserve" index="true" manifestencoding="UTF-8"> | |
274 | - <manifest> | |
275 | - <attribute name="Built-By" value="MCP (http://mcp.ocean-labs.de)" /> | |
276 | - <attribute name="Implementation-Vendor" value="${author}" /> | |
277 | - <attribute name="Implementation-Title" value="${ant.project.name}" /> | |
278 | - <attribute name="Implementation-Version" value="${meta.version}" /> | |
279 | - <attribute name="TweakClass" value="${tweakclass}" /> | |
280 | - <attribute name="TweakName" value="${displayname}" /> | |
281 | - <attribute name="TweakVersion" value="${version}" /> | |
282 | - <attribute name="TweakAuthor" value="${author}" /> | |
283 | - </manifest> | |
284 | - <fileset dir="${stage.dir}" /> | |
285 | - </jar> | |
286 | - </target> | |
287 | - | |
288 | - <target name="compiledebug" description="Recompile with debug classes"> | |
289 | - <copy todir="${src.dir}" verbose="false" overwrite="true" failonerror="false"> | |
290 | - <fileset dir="${eclipse.dir}/${project}/debug" /> | |
291 | - </copy> | |
292 | - | |
293 | - <antcall target="recompile" /> | |
294 | - </target> | |
295 | - | |
296 | - <target name="mcpjar" description="Build the MCP-names jar" depends="compiledebug"> | |
297 | - <echo level="info" message="Building mcpnamesjars" /> | |
298 | - | |
299 | - <mkdir dir="${dist.dir}" /> | |
300 | - | |
301 | - <delete file="${dist.dir}/${artefact.name}-mcpnames.${filetype}" /> | |
302 | - <delete file="${dist.dir}/${artefact.name}-mcpnames-sources.${filetype}" /> | |
303 | - | |
304 | - <jar destfile="${dist.dir}/${artefact.name}-mcpnames.${filetype}" duplicate="preserve" index="true" manifestencoding="UTF-8"> | |
305 | - <manifest> | |
306 | - <attribute name="Built-By" value="MCP (http://mcp.ocean-labs.de)" /> | |
307 | - <attribute name="Implementation-Vendor" value="${author}" /> | |
308 | - <attribute name="Implementation-Title" value="${ant.project.name}" /> | |
309 | - <attribute name="Implementation-Version" value="${meta.version}" /> | |
310 | - <attribute name="TweakClass" value="${tweakclass}" /> | |
311 | - <attribute name="TweakName" value="${displayname}" /> | |
312 | - <attribute name="TweakVersion" value="${version}" /> | |
313 | - <attribute name="TweakAuthor" value="${author}" /> | |
314 | - </manifest> | |
315 | - <fileset dir="${mc.bin.dir}"> | |
316 | - <include name="com/mumfrey/**" /> | |
317 | - <include name="net/eq2online/**" /> | |
318 | - </fileset> | |
319 | - <fileset dir="${eclipse.dir}/${project}/resources" excludes=".svn/**" /> | |
320 | - <fileset dir="${eclipse.dir}/${project}/debug" excludes=".svn/**"> | |
321 | - <exclude name="**/*.java" /> | |
322 | - </fileset> | |
323 | - </jar> | |
324 | - <jar destfile="${dist.dir}/${artefact.name}-mcpnames-sources.${filetype}" duplicate="preserve" index="false" filesetmanifest="skip"> | |
325 | - <fileset dir="${eclipse.dir}/${project}/java/common" /> | |
326 | - <fileset dir="${eclipse.dir}/${project}/java/client" /> | |
327 | - <fileset dir="${eclipse.dir}/${project}/debug" /> | |
328 | - <fileset dir="${eclipse.dir}/${project}/resources" /> | |
329 | - </jar> | |
330 | - </target> | |
331 | - | |
332 | - <target name="javadoc" description="Create the javadoc jar"> | |
333 | - <echo level="info" message="Generating javadoc" /> | |
334 | - | |
335 | - <javadoc destdir="${stage.dir}/${javadocpath}" useexternalfile="true"> | |
336 | - <fileset dir="${eclipse.dir}/${project}/java"> | |
337 | - <exclude name="**/debug" /> | |
338 | - <exclude name="**/debug/*.java" /> | |
339 | - </fileset> | |
340 | - <classpath> | |
341 | - <fileset dir="${mc.libs.dir}"> | |
342 | - <include name="**/*.jar" /> | |
343 | - </fileset> | |
344 | - <fileset dir="${libs.dir}"> | |
345 | - <include name="*.jar" /> | |
346 | - </fileset> | |
347 | - <pathelement location="${mc.bin.dir}"/> | |
348 | - </classpath> | |
349 | - <arg value="-XDignore.symbol.file" /> | |
350 | - </javadoc> | |
351 | - <jar destfile="${dist.dir}/${artefact.name}-javadoc.${filetype}" duplicate="preserve" index="true" manifestencoding="UTF-8"> | |
352 | - <manifest> | |
353 | - <attribute name="Built-By" value="MCP (http://mcp.ocean-labs.de)" /> | |
354 | - <attribute name="Implementation-Vendor" value="${author}" /> | |
355 | - <attribute name="Implementation-Title" value="${ant.project.name}" /> | |
356 | - <attribute name="Implementation-Version" value="${version}" /> | |
357 | - </manifest> | |
358 | - <fileset dir="${stage.dir}/${javadocpath}" /> | |
359 | - </jar> | |
360 | - <copy file="${dist.dir}/${artefact.name}-javadoc.${filetype}" tofile="${dist.dir}/${artefact.name}-mcpnames-javadoc.${filetype}" /> | |
361 | - </target> | |
362 | - | |
363 | - <target name="deploy" depends="production" description="Deploy artifact to local minecraft installation in APPDATA"> | |
364 | - <mkdir dir="${env.APPDATA}/.minecraft/libraries/com/mumfrey/liteloader/${mcversion}"/> | |
365 | - <copy todir="${env.APPDATA}/.minecraft/libraries/com/mumfrey/liteloader/${mcversion}" file="${dist.dir}/${artefact.name}.${filetype}" failonerror="false" overwrite="true" /> | |
366 | - <copy todir="${eclipse.dir}/LiteLoaderInstaller/src/main/resources" file="${dist.dir}/${artefact.name}.${filetype}" failonerror="false" overwrite="true" /> | |
367 | - </target> | |
368 | -</project> | |
369 | 0 | \ No newline at end of file |
ant/build_srgjar.xml deleted
100644 → 0
1 | -<?xml version="1.0" encoding="ISO-8859-1"?> | |
2 | -<project name="liteloadertosrg" basedir="." default="build" xmlns:ivy="antlib:org.apache.ivy.ant"> | |
3 | - | |
4 | - <property name="project.name" value="liteloader" /> | |
5 | - <property name="version" value="1.8" /> | |
6 | - <property name="author" value="Mumfrey" /> | |
7 | - | |
8 | - <property name="mcp.dir" location="../../.." /> | |
9 | - <property name="mcp.temp.dir" location="${mcp.dir}/temp" /> | |
10 | - <property name="minecraft.src.dir" location="${mcp.dir}/src/minecraft" /> | |
11 | - <property name="lib.dir" location="./lib" /> | |
12 | - <property name="temp.dir" location="./temp" /> | |
13 | - <property name="out.dir" location="${temp.dir}/out" /> | |
14 | - <property name="dist.dir" location="${mcp.dir}/build/dist" /> | |
15 | - <property name="src.dir" location="${temp.dir}/src" /> | |
16 | - <property name="map.file" location="${temp.dir}/range.map" /> | |
17 | - <property name="insrg.file" location="${mcp.temp.dir}/client_ro_srg.srg" /> | |
18 | - <property name="outsrg.file" location="${temp.dir}/remap.srg" /> | |
19 | - <property name="liteloader.src.base" location="../java" /> | |
20 | - | |
21 | - <property name="python_windows" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" /> | |
22 | - <property name="python_linux" location="/usr/bin/python" /> | |
23 | - | |
24 | - <path id="class.path"> | |
25 | - <fileset dir="${lib.dir}"> | |
26 | - <include name="**/*.jar" /> | |
27 | - </fileset> | |
28 | - </path> | |
29 | - | |
30 | - <target name="build"> | |
31 | - <property name="artefact" location="${dist.dir}/${project.name}-${version}-srgnames-sources.jar" /> | |
32 | - <ivy:configure file="ivysettings.xml" /> | |
33 | - <antcall target="jar" /> | |
34 | - </target> | |
35 | - | |
36 | - <target name="jenkins"> | |
37 | - <property name="artefact" location="${dist.dir}/${project.name}-${version}-SNAPSHOT-srgnames-sources.jar" /> | |
38 | - <ivy:configure file="ivysettings.xml" /> | |
39 | - <antcall target="jar" /> | |
40 | - </target> | |
41 | - | |
42 | - <path id="classpath"> | |
43 | - <fileset dir="${ivy.lib.dir}"> | |
44 | - <include name="**/*.jar"/> | |
45 | - </fileset> | |
46 | - </path> | |
47 | - | |
48 | - <target name="clean"> | |
49 | - <echo message="Cleaning working directories..." /> | |
50 | - | |
51 | - <delete dir="${temp.dir}" failonerror="false" /> | |
52 | - | |
53 | - <mkdir dir="${src.dir}"/> | |
54 | - <mkdir dir="${out.dir}"/> | |
55 | - <mkdir dir="${temp.dir}"/> | |
56 | - </target> | |
57 | - | |
58 | - <target name="init" depends="clean"> | |
59 | - <echo message="Aggregating sources..." /> | |
60 | - | |
61 | - <copy todir="${src.dir}" overwrite="true"> | |
62 | - <fileset dir="${minecraft.src.dir}"> | |
63 | - <exclude name="*.java" /> | |
64 | - </fileset> | |
65 | - <fileset dir="${liteloader.src.base}/common"> | |
66 | - <exclude name="**/Jump.java" /> | |
67 | - </fileset> | |
68 | - <fileset dir="${liteloader.src.base}/client" /> | |
69 | - </copy> | |
70 | - | |
71 | - <echo message="Fetching dependencies..." /> | |
72 | - <ivy:retrieve sync="true" /> | |
73 | - </target> | |
74 | - | |
75 | - <target name="reobfSrg" depends="init"> | |
76 | - <echo message="Running reobf to generate srgs..." /> | |
77 | - | |
78 | - <exec executable="${python_windows}" dir="${mcp.dir}" osfamily="windows"> | |
79 | - <arg value="runtime/reobfuscate.py" /> | |
80 | - <arg value="--srgnames" /> | |
81 | - <arg value="--client" /> | |
82 | - </exec> | |
83 | - | |
84 | - <exec executable="${python_linux}" dir="${mcp.dir}" osfamily="unix"> | |
85 | - <arg value="runtime/reobfuscate.py" /> | |
86 | - <arg value="--srgnames" /> | |
87 | - <arg value="--client" /> | |
88 | - </exec> | |
89 | - </target> | |
90 | - | |
91 | - <target name="extractRanges" depends="reobfSrg"> | |
92 | - <echo message="Extracting ranges from source..." /> | |
93 | - | |
94 | - <java classname="net.minecraftforge.srg2source.ast.RangeExtractor" output="${temp.dir}/extractRanges.log"> | |
95 | - <classpath refid="class.path" /> | |
96 | - <arg value="${src.dir}" /> | |
97 | - <arg value="${lib.dir}" /> | |
98 | - <arg value="${map.file}" /> | |
99 | - </java> | |
100 | - </target> | |
101 | - | |
102 | - <target name="flipsrg" depends="extractRanges"> | |
103 | - <echo message="Remapping SRG file..." /> | |
104 | - | |
105 | - <copy file="${insrg.file}" tofile="${outsrg.file}" overwrite="true" /> | |
106 | - <replaceregexp file="${outsrg.file}" byline="true" match="(FD|CL): ([^\s]+) ([^\s]+)" replace="\1: \3 \2" /> | |
107 | - <replaceregexp file="${outsrg.file}" byline="true" match="MD: ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)" replace="MD: \3 \4 \1 \2" /> | |
108 | - </target> | |
109 | - | |
110 | - <target name="applyRanges" depends="flipsrg"> | |
111 | - <echo message="Remapping ranges in source..." /> | |
112 | - | |
113 | - <java classname="net.minecraftforge.srg2source.rangeapplier.RangeApplier" output="${temp.dir}/applyRanges.log"> | |
114 | - <classpath refid="class.path" /> | |
115 | - <arg value="--srcRoot=${src.dir}" /> | |
116 | - <arg value="--srcRangeMap=${map.file}" /> | |
117 | - <arg value="--srgFiles=${outsrg.file}" /> | |
118 | - <arg value="--outDir=${out.dir}" /> | |
119 | - </java> | |
120 | - </target> | |
121 | - | |
122 | - <target name="jar" depends="applyRanges"> | |
123 | - <echo message="Building src jar..." /> | |
124 | - | |
125 | - <jar destfile="${artefact}" duplicate="preserve" index="true" manifestencoding="UTF-8"> | |
126 | - <manifest> | |
127 | - <attribute name="Implementation-Vendor" value="${author}" /> | |
128 | - <attribute name="Implementation-Title" value="${ant.project.name}" /> | |
129 | - <attribute name="Implementation-Version" value="${version}" /> | |
130 | - </manifest> | |
131 | - <fileset dir="${out.dir}"> | |
132 | - <exclude name="net/minecraft/**" /> | |
133 | - </fileset> | |
134 | - </jar> | |
135 | - </target> | |
136 | -</project> | |
137 | 0 | \ No newline at end of file |
ant/ivy.xml deleted
100644 → 0
1 | -<?xml version="1.0" encoding="ISO-8859-1"?> | |
2 | -<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"> | |
3 | - <info organisation="com.mumfrey" module="liteloader" status="integration"> | |
4 | - <ivyauthor name="Adam Mummery-Smith" /> | |
5 | - </info> | |
6 | - <dependencies> | |
7 | - <dependency org="org.ow2.asm" name="asm-debug-all" rev="4.1" /> | |
8 | - <dependency org="com.google.guava" name="guava" rev="15.0" /> | |
9 | - <dependency org="net.sf.opencsv" name="opencsv" rev="2.3" /> | |
10 | - <dependency org="net.sf.jopt-simple" name="jopt-simple" rev="4.6" /> | |
11 | - <dependency org="org.eclipse.jgit" name="org.eclipse.jgit" rev="3.2.0.201312181205-r" /> | |
12 | - <dependency org="org.eclipse.core" name="contenttype" rev="3.4.200-v20130326-1255" /> | |
13 | - <dependency org="org.eclipse.core" name="jobs" rev="3.5.300-v20130429-1813" /> | |
14 | - <dependency org="org.eclipse.core" name="runtime" rev="3.9.0-v20130326-1255" /> | |
15 | - <dependency org="org.eclipse" name="osgi" rev="3.9.1-v20130814-1242" /> | |
16 | - <dependency org="org.eclipse.text" name="org.eclipse.text" rev="3.5.101" /> | |
17 | - <dependency org="org.eclipse.equinox" name="common" rev="3.6.200-v20130402-1505" /> | |
18 | - <dependency org="org.eclipse.equinox" name="preferences" rev="3.5.100-v20130422-1538" /> | |
19 | - <dependency org="org.eclipse.jdt" name="org.eclipse.jdt.core" rev="3.10.0.v20131029-1755" /> | |
20 | - <dependency org="net.minecraftforge.srg2source" name="Srg2Source" rev="3.2-SNAPSHOT" /> | |
21 | - </dependencies> | |
22 | -</ivy-module> |
ant/ivysettings.xml deleted
100644 → 0
1 | -<?xml version="1.0" encoding="ISO-8859-1"?> | |
2 | -<ivysettings> | |
3 | - <settings defaultResolver="srg2source" /> | |
4 | - <resolvers> | |
5 | - <chain name="srg2source"> | |
6 | - <ibiblio name="m2" m2compatible="true" /> | |
7 | - <ibiblio name="forge" m2compatible="true" root="http://files.minecraftforge.net/maven/"/> | |
8 | - <ibiblio name="eclipse" m2compatible="true" root="https://repo.eclipse.org/content/groups/eclipse/"/> | |
9 | - </chain> | |
10 | - </resolvers> | |
11 | -</ivysettings> | |
12 | 0 | \ No newline at end of file |
ant/seed_md5.xml deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8" ?> | |
2 | -<project name="mcp" basedir="." default="genmd5"> | |
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="recompile" /> | |
15 | - <antcall target="reobfuscate" /> | |
16 | - <antcall target="savemd5" /> | |
17 | - </target> | |
18 | - | |
19 | - <target name="clean"> | |
20 | - <echo level="info" message="Cleaning output directories" /> | |
21 | - | |
22 | - <delete dir="${mcp.dir}/reobf" /> | |
23 | - </target> | |
24 | - | |
25 | - <target name="init" depends="clean" description="Initialize environment"> | |
26 | - <echo level="info" message="Initialising environment" /> | |
27 | - | |
28 | - <mkdir dir="${md5.dir}" /> | |
29 | - </target> | |
30 | - | |
31 | - <target name="recompile" depends="init" description="MCP recompile"> | |
32 | - <echo level="info" message="Compiling MCP sources" /> | |
33 | - | |
34 | - <exec executable="${python_windows}" dir="${mcp.dir}" osfamily="windows"> | |
35 | - <arg value="runtime/recompile.py" /> | |
36 | - <arg value="--client" /> | |
37 | - <arg value="%*" /> | |
38 | - </exec> | |
39 | - | |
40 | - <exec executable="${python_linux}" dir="${mcp.dir}" osfamily="unix"> | |
41 | - <arg value="runtime/recompile.py" /> | |
42 | - <arg value="--client" /> | |
43 | - <arg value="%*" /> | |
44 | - </exec> | |
45 | - | |
46 | - </target> | |
47 | - | |
48 | - <target name="reobfuscate" description="MCP reobfuscate"> | |
49 | - <echo level="info" message="Obfuscating classes" /> | |
50 | - | |
51 | - <exec executable="${python_windows}" dir="${mcp.dir}" osfamily="windows"> | |
52 | - <arg value="runtime/reobfuscate.py" /> | |
53 | - <arg value="--client" /> | |
54 | - <arg value="%*" /> | |
55 | - </exec> | |
56 | - | |
57 | - <exec executable="${python_linux}" dir="${mcp.dir}" osfamily="unix"> | |
58 | - <arg value="runtime/reobfuscate.py" /> | |
59 | - <arg value="--client" /> | |
60 | - <arg value="%*" /> | |
61 | - </exec> | |
62 | - | |
63 | - </target> | |
64 | - | |
65 | - <target name="savemd5" description="Put post-obfuscation MD5 to stored md5 set" if="outmd5set"> | |
66 | - <echo level="info" message="Storing obfuscated MD5s" /> | |
67 | - | |
68 | - <copy file="${temp.dir}/client_reobf.md5" tofile="${md5.dir}/client_mcp.md5" overwrite="true" verbose="true" /> | |
69 | - </target> | |
70 | -</project> | |
71 | 0 | \ No newline at end of file |
ant/tasks/ant-contrib.jar deleted
100644 → 0
No preview for this file type
build.gradle
0 → 100644
1 | +buildscript { | |
2 | + repositories { | |
3 | + mavenLocal() | |
4 | + mavenCentral() | |
5 | + maven { | |
6 | + name = "forge" | |
7 | + url = "http://files.minecraftforge.net/maven" | |
8 | + } | |
9 | + maven { | |
10 | + name = "sonatype" | |
11 | + url = "https://oss.sonatype.org/content/repositories/snapshots/" | |
12 | + } | |
13 | + } | |
14 | + dependencies { | |
15 | + classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT' | |
16 | + } | |
17 | +} | |
18 | + | |
19 | +apply plugin: 'net.minecraftforge.gradle.tweaker-client' | |
20 | +apply plugin: 'maven' | |
21 | + | |
22 | +// Artefact details | |
23 | +ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0' | |
24 | +ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown' | |
25 | +ext.commit = project.hasProperty("commit") ? commit : 'unknown' | |
26 | +ext.classifier = project.hasProperty("buildType") ? buildType : 'SNAPSHOT' | |
27 | +ext.isReleaseBuild = "RELEASE".equals(project.classifier.toUpperCase()) | |
28 | +ext.mavenRepo = project.isReleaseBuild ? "mavenUrl" : "mavenSnapshotUrl" | |
29 | + | |
30 | +// Basic project information | |
31 | +group = "com.mumfrey" | |
32 | +archivesBaseName = "liteloader" | |
33 | +version = buildVersion + (project.isReleaseBuild ? '' : '-' + project.classifier) | |
34 | + | |
35 | +// Extended project information | |
36 | +ext.projectName = 'LiteLoader' | |
37 | +ext.inceptionYear = '2012' | |
38 | +ext.packaging = 'jar' | |
39 | + | |
40 | +ext.startClass = 'com.mumfrey.liteloader.debug.Start' | |
41 | +ext.tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker' | |
42 | + | |
43 | +// Minimum version of Java required | |
44 | +sourceCompatibility = '1.6' | |
45 | +targetCompatibility = '1.6' | |
46 | + | |
47 | +minecraft { | |
48 | + version = project.mcVersion | |
49 | + mappings = project.mcMappings | |
50 | + runDir = "run" | |
51 | + tweakClass = project.tweakClass | |
52 | +} | |
53 | + | |
54 | +sourceSets { | |
55 | + client { | |
56 | + compileClasspath += main.compileClasspath + main.output | |
57 | + } | |
58 | + debug { | |
59 | + compileClasspath += client.compileClasspath + client.output | |
60 | + } | |
61 | +} | |
62 | + | |
63 | +javadoc { | |
64 | + source sourceSets.client.allJava | |
65 | + source sourceSets.debug.allJava | |
66 | +} | |
67 | + | |
68 | +// hacks for run configs | |
69 | +afterEvaluate { | |
70 | + def mc = plugins.getPlugin 'net.minecraftforge.gradle.tweaker-client' | |
71 | + mc.replacer.putReplacement '{RUN_CLIENT_MAIN}', project.startClass | |
72 | + mc.replacer.putReplacement '{RUN_CLIENT_TWEAKER}', minecraft.tweakClass | |
73 | +} | |
74 | + | |
75 | +// manifest entries for all jars | |
76 | +def jarManifest = { | |
77 | + mainAttributes ( | |
78 | + 'Built-By': System.properties['user.name'], | |
79 | + 'Created-By': System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", | |
80 | + 'Implementation-Title': name, | |
81 | + 'Implementation-Version': version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit, | |
82 | + 'Implementation-Vendor': url | |
83 | + ) | |
84 | +} | |
85 | + | |
86 | +jar { | |
87 | + from sourceSets.client.output | |
88 | + from sourceSets.debug.output | |
89 | + manifest jarManifest | |
90 | +} | |
91 | + | |
92 | +task releaseJar(type: Jar) { | |
93 | + from sourceSets.main.output | |
94 | + from sourceSets.client.output | |
95 | + manifest jarManifest | |
96 | + classifier = 'release' | |
97 | +} | |
98 | + | |
99 | +task javadocJar(type: Jar, dependsOn: javadoc) { | |
100 | + from javadoc.destinationDir | |
101 | + classifier = 'javadoc' | |
102 | +} | |
103 | + | |
104 | +// Hey @AbrarSyed why can't we just turn this off >:( | |
105 | +task runClient(type: JavaExec, overwrite: true) { | |
106 | + doFirst { | |
107 | + println "Do not use runClient, it is not compatible with Mixin" | |
108 | + System.exit(-1) | |
109 | + } | |
110 | +} | |
111 | + | |
112 | +tasks.withType(JavaCompile) { | |
113 | + options.compilerArgs += ['-Xlint:all', '-Xlint:-path'] | |
114 | + options.deprecation = true | |
115 | + options.encoding = 'utf8' | |
116 | +} | |
117 | + | |
118 | +if (JavaVersion.current().isJava8Compatible()) { | |
119 | + tasks.withType(Javadoc) { | |
120 | + // disable the crazy super-strict doclint tool in Java 8 | |
121 | + options.addStringOption('Xdoclint:none', '-quiet') | |
122 | + } | |
123 | +} | |
124 | + | |
125 | +reobf { | |
126 | + jar { | |
127 | + useSrgSrg() | |
128 | + } | |
129 | + releaseJar { | |
130 | + useNotchSrg() | |
131 | + classpath = sourceSets.main.compileClasspath | |
132 | + } | |
133 | +} | |
134 | + | |
135 | +compileJava.doFirst { | |
136 | + println '------------------------------------------------------------' | |
137 | + println 'Running ' + (project.isReleaseBuild ? "RELEASE" : "SNAPSHOT") + ' build' | |
138 | + println '------------------------------------------------------------' | |
139 | +} | |
140 | + | |
141 | +build.dependsOn "reobfReleaseJar" | |
142 | + | |
143 | +artifacts { | |
144 | + if (project.isReleaseBuild) { | |
145 | + archives jar | |
146 | + } | |
147 | + archives releaseJar | |
148 | + archives sourceJar | |
149 | + archives javadocJar | |
150 | +} | |
151 | + | |
152 | +uploadArchives { | |
153 | + repositories { | |
154 | + mavenDeployer { | |
155 | + if (project.hasProperty(project.mavenRepo)) { | |
156 | + repository(url: project.getProperty(project.mavenRepo)) { | |
157 | + authentication(userName: project.mavenUsername, password: project.mavenPassword) | |
158 | + } | |
159 | + } | |
160 | + pom { | |
161 | + groupId = project.group | |
162 | + version = project.version | |
163 | + artifactId = project.archivesBaseName | |
164 | + project { | |
165 | + name project.archivesBaseName | |
166 | + packaging 'jar' | |
167 | + description 'LiteLoader' | |
168 | + url 'http://www.liteloader.com/' | |
169 | + scm { | |
170 | + url 'http://develop.liteloader.com/liteloader/LiteLoader' | |
171 | + connection 'scm:git:http://develop.liteloader.com/liteloader/LiteLoader.git' | |
172 | + developerConnection 'scm:git:http://develop.liteloader.com/liteloader/LiteLoader.git' | |
173 | + } | |
174 | + issueManagement { | |
175 | + system 'GitLab Issues' | |
176 | + url 'http://develop.liteloader.com/liteloader/LiteLoader/issues' | |
177 | + } | |
178 | + } | |
179 | + } | |
180 | + } | |
181 | + } | |
182 | +} | ... | ... |
gradle.properties
0 → 100644
java/common/com/mumfrey/liteloader/modconfig/ConfigPanel.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.modconfig; | |
2 | - | |
3 | - | |
4 | -/** | |
5 | - * Interface for mod config panels to implement | |
6 | - * | |
7 | - * @author Adam Mummery-Smith | |
8 | - */ | |
9 | -public interface ConfigPanel | |
10 | -{ | |
11 | - /** | |
12 | - * Panels should return the text to display at the top of the config panel window | |
13 | - */ | |
14 | - public abstract String getPanelTitle(); | |
15 | - | |
16 | - /** | |
17 | - * Get the height of the content area for scrolling purposes, return -1 to disable scrolling | |
18 | - */ | |
19 | - public abstract int getContentHeight(); | |
20 | - | |
21 | - /** | |
22 | - * Called when the panel is displayed, initialise the panel (read settings, etc) | |
23 | - * | |
24 | - * @param host panel host | |
25 | - */ | |
26 | - public abstract void onPanelShown(ConfigPanelHost host); | |
27 | - | |
28 | - /** | |
29 | - * Called when the window is resized whilst the panel is active | |
30 | - * | |
31 | - * @param host panel host | |
32 | - */ | |
33 | - public abstract void onPanelResize(ConfigPanelHost host); | |
34 | - | |
35 | - /** | |
36 | - * Called when the panel is closed, panel should save settings | |
37 | - */ | |
38 | - public abstract void onPanelHidden(); | |
39 | - | |
40 | - /** | |
41 | - * Called every tick | |
42 | - */ | |
43 | - public abstract void onTick(ConfigPanelHost host); | |
44 | - | |
45 | - /** | |
46 | - * Draw the configuration panel | |
47 | - * | |
48 | - * @param host | |
49 | - * @param mouseX | |
50 | - * @param mouseY | |
51 | - * @param partialTicks | |
52 | - */ | |
53 | - public abstract void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks); | |
54 | - | |
55 | - /** | |
56 | - * Called when a mouse button is pressed | |
57 | - * | |
58 | - * @param host | |
59 | - * @param mouseX | |
60 | - * @param mouseY | |
61 | - * @param mouseButton | |
62 | - */ | |
63 | - public abstract void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton); | |
64 | - | |
65 | - /** | |
66 | - * Called when a mouse button is released | |
67 | - * | |
68 | - * @param host | |
69 | - * @param mouseX | |
70 | - * @param mouseY | |
71 | - * @param mouseButton | |
72 | - */ | |
73 | - public abstract void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton); | |
74 | - | |
75 | - /** | |
76 | - * Called when the mouse is moved | |
77 | - * | |
78 | - * @param host | |
79 | - * @param mouseX | |
80 | - * @param mouseY | |
81 | - */ | |
82 | - public abstract void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY); | |
83 | - | |
84 | - /** | |
85 | - * Called when a key is pressed | |
86 | - * | |
87 | - * @param host | |
88 | - * @param keyChar | |
89 | - * @param keyCode | |
90 | - */ | |
91 | - public abstract void keyPressed(ConfigPanelHost host, char keyChar, int keyCode); | |
92 | -} |
java/common/com/mumfrey/liteloader/permissions/Permissions.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.permissions; | |
2 | - | |
3 | -/** | |
4 | - * Represents a set of permissions assigned by an authority | |
5 | - * | |
6 | - * @author Adam Mummery-Smith | |
7 | - */ | |
8 | -public interface Permissions | |
9 | -{ | |
10 | - /** | |
11 | - * Returns true if the specified permission is set in this permission container | |
12 | - * | |
13 | - * @param permission Name of the permission to test for | |
14 | - * @return True if the permission exists in this set | |
15 | - */ | |
16 | - public abstract boolean getPermissionSet(String permission); | |
17 | - | |
18 | - /** | |
19 | - * Returns true if the authority says we have this permission or false if the permission is denied or not set | |
20 | - * | |
21 | - * @param permission Name of the permission to test for | |
22 | - */ | |
23 | - public abstract boolean getHasPermission(String permission); | |
24 | - | |
25 | - /** | |
26 | - * Returns true if the authority says we have this permission or if the permission is not specified by the authority returns the default value | |
27 | - * | |
28 | - * @param permission Name of the permission to test for | |
29 | - * @param defaultValue Value to return if the permission is NOT specified by the authority | |
30 | - * | |
31 | - * @return State of the authority permission or default value if not specified | |
32 | - */ | |
33 | - public abstract boolean getHasPermission(String permission, boolean defaultValue); | |
34 | -} |
java/common/com/mumfrey/liteloader/permissions/PermissionsManager.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.permissions; | |
2 | - | |
3 | -import com.mumfrey.liteloader.Permissible; | |
4 | -import com.mumfrey.liteloader.common.GameEngine; | |
5 | - | |
6 | -/** | |
7 | - * Interface for permissions manager implementations | |
8 | - * | |
9 | - * @author Adam Mummery-Smith | |
10 | - */ | |
11 | -public interface PermissionsManager | |
12 | -{ | |
13 | - /** | |
14 | - * Get the underlying permissions node for this manager for the specified mod | |
15 | - * | |
16 | - * @param mod Mod to fetch permissions for | |
17 | - */ | |
18 | - public abstract Permissions getPermissions(Permissible mod); | |
19 | - | |
20 | - /** | |
21 | - * Get the time the permissions for the specified mod were last updated | |
22 | - * | |
23 | - * @param mod Mod to check for | |
24 | - * @return Timestamp when the permissions were last updated | |
25 | - */ | |
26 | - public abstract Long getPermissionUpdateTime(Permissible mod); | |
27 | - | |
28 | - /** | |
29 | - * Handler for tick event | |
30 | - * | |
31 | - * @param engine | |
32 | - * @param partialTicks | |
33 | - * @param inGame | |
34 | - */ | |
35 | - public abstract void onTick(GameEngine<?, ?> engine, float partialTicks, boolean inGame); | |
36 | - | |
37 | - /** | |
38 | - * Register a new event listener, the registered object will receive callbacks for permissions events | |
39 | - * | |
40 | - * @param permissible | |
41 | - */ | |
42 | - public abstract void registerPermissible(Permissible permissible); | |
43 | - | |
44 | - /** | |
45 | - * Perform any necessary validation to check for a tamper condition, can and should be called from as | |
46 | - * many places as possible | |
47 | - */ | |
48 | - public abstract void tamperCheck(); | |
49 | -} |
java/common/com/mumfrey/liteloader/permissions/PermissionsManagerServer.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.permissions; | |
2 | - | |
3 | -import java.util.List; | |
4 | - | |
5 | -import net.minecraft.entity.player.EntityPlayerMP; | |
6 | -import net.minecraft.network.PacketBuffer; | |
7 | - | |
8 | -import com.mumfrey.liteloader.Permissible; | |
9 | -import com.mumfrey.liteloader.ServerPluginChannelListener; | |
10 | -import com.mumfrey.liteloader.common.GameEngine; | |
11 | - | |
12 | -/** | |
13 | - * TODO implementation | |
14 | - * | |
15 | - * @author Adam Mummery-Smith | |
16 | - */ | |
17 | -public class PermissionsManagerServer implements PermissionsManager, ServerPluginChannelListener | |
18 | -{ | |
19 | - public PermissionsManagerServer() | |
20 | - { | |
21 | - } | |
22 | - | |
23 | - @Override | |
24 | - public String getName() | |
25 | - { | |
26 | - return null; | |
27 | - } | |
28 | - | |
29 | - @Override | |
30 | - public void onCustomPayload(EntityPlayerMP sender, String channel, PacketBuffer data) | |
31 | - { | |
32 | - } | |
33 | - | |
34 | - @Override | |
35 | - public Permissions getPermissions(Permissible mod) | |
36 | - { | |
37 | - return null; | |
38 | - } | |
39 | - | |
40 | - @Override | |
41 | - public Long getPermissionUpdateTime(Permissible mod) | |
42 | - { | |
43 | - return null; | |
44 | - } | |
45 | - | |
46 | - @Override | |
47 | - public void onTick(GameEngine<?, ?> engine, float partialTicks, boolean inGame) | |
48 | - { | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public List<String> getChannels() | |
53 | - { | |
54 | - return null; | |
55 | - } | |
56 | - | |
57 | - @Override | |
58 | - public void registerPermissible(Permissible permissible) | |
59 | - { | |
60 | - } | |
61 | - | |
62 | - @Override | |
63 | - public void tamperCheck() | |
64 | - { | |
65 | - } | |
66 | -} |
java/common/com/mumfrey/liteloader/permissions/ServerPermissions.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.permissions; | |
2 | - | |
3 | -import java.util.regex.Matcher; | |
4 | -import java.util.regex.Pattern; | |
5 | - | |
6 | -import net.eq2online.permissions.ReplicatedPermissionsContainer; | |
7 | -import net.minecraft.network.PacketBuffer; | |
8 | - | |
9 | - | |
10 | -/** | |
11 | - * Replicated permissions implementation | |
12 | - * | |
13 | - * @author Adam Mummery-Smith | |
14 | - */ | |
15 | -public class ServerPermissions implements ReplicatedPermissions | |
16 | -{ | |
17 | - /** | |
18 | - * Pattern for recognising valid permissions in the server feed | |
19 | - */ | |
20 | - private static final Pattern permissionPattern = Pattern.compile("^([\\+\\-])(([a-z0-9]+\\.)*[a-z0-9\\*]+)$", Pattern.CASE_INSENSITIVE); | |
21 | - | |
22 | - protected String modName; | |
23 | - | |
24 | - /** | |
25 | - * Root permission node | |
26 | - */ | |
27 | - protected Permission permissions = new Permission(); | |
28 | - | |
29 | - /** | |
30 | - * Time the permissions were updated | |
31 | - */ | |
32 | - protected long createdTime = 0L; | |
33 | - | |
34 | - /** | |
35 | - * Expiry time of the current data cache | |
36 | - */ | |
37 | - protected long validUntil = 0L; | |
38 | - | |
39 | - /** | |
40 | - * Time to cache server responses by default | |
41 | - */ | |
42 | - protected long cacheTime = 10L * 60L * 1000L; // 10 minutes | |
43 | - | |
44 | - /** | |
45 | - * Time to wait when refreshing server permissions before trying again | |
46 | - */ | |
47 | - protected long refreshTime = 15L * 1000L; // 15 seconds | |
48 | - | |
49 | - /** | |
50 | - * @param data | |
51 | - */ | |
52 | - public ServerPermissions(PacketBuffer data) | |
53 | - { | |
54 | - this.createdTime = System.currentTimeMillis(); | |
55 | - this.validUntil = this.createdTime + this.cacheTime; | |
56 | - | |
57 | - ReplicatedPermissionsContainer response = ReplicatedPermissionsContainer.fromPacketBuffer(data); | |
58 | - | |
59 | - if (response != null) | |
60 | - { | |
61 | - response.sanitise(); | |
62 | - | |
63 | - this.modName = response.modName; | |
64 | - this.validUntil = System.currentTimeMillis() + response.remoteCacheTimeSeconds * 1000L; | |
65 | - | |
66 | - for (String permissionString : response.permissions) | |
67 | - { | |
68 | - Matcher permissionMatcher = permissionPattern.matcher(permissionString); | |
69 | - | |
70 | - if (permissionMatcher.matches()) | |
71 | - { | |
72 | - String name = permissionMatcher.group(2); | |
73 | - boolean value = permissionMatcher.group(1).equals("+"); | |
74 | - | |
75 | - this.permissions.setPermissionAndValue(name, value); | |
76 | - } | |
77 | - } | |
78 | - } | |
79 | - } | |
80 | - | |
81 | - /** | |
82 | - * Get the permissible mod name | |
83 | - */ | |
84 | - public String getModName() | |
85 | - { | |
86 | - return this.modName; | |
87 | - } | |
88 | - | |
89 | - /* (non-Javadoc) | |
90 | - * @see net.eq2online.permissions.Permissions#getPermissionSet(java.lang.String) | |
91 | - */ | |
92 | - @Override | |
93 | - public boolean getPermissionSet(String permission) | |
94 | - { | |
95 | - return this.permissions.getPermission(permission) != null; | |
96 | - } | |
97 | - | |
98 | - /* (non-Javadoc) | |
99 | - * @see net.eq2online.permissions.Permissions#getHasPermission(java.lang.String) | |
100 | - */ | |
101 | - @Override | |
102 | - public boolean getHasPermission(String permission) | |
103 | - { | |
104 | - Permission perm = this.permissions.getPermission(permission); | |
105 | - return perm != null && perm.getValue(); | |
106 | - } | |
107 | - | |
108 | - /* (non-Javadoc) | |
109 | - * @see net.eq2online.permissions.Permissions#getHasPermission(java.lang.String, boolean) | |
110 | - */ | |
111 | - @Override | |
112 | - public boolean getHasPermission(String permission, boolean defaultValue) | |
113 | - { | |
114 | - Permission perm = this.permissions.getPermission(permission); | |
115 | - | |
116 | - return perm != null ? perm.getValue() : defaultValue; | |
117 | - } | |
118 | - | |
119 | - /* (non-Javadoc) | |
120 | - * @see net.eq2online.permissions.ReplicatedPermissions#getReplicationTime() | |
121 | - */ | |
122 | - @Override | |
123 | - public long getReplicationTime() | |
124 | - { | |
125 | - return this.createdTime; | |
126 | - } | |
127 | - | |
128 | - /* (non-Javadoc) | |
129 | - * @see net.eq2online.permissions.ReplicatedPermissions#isValid() | |
130 | - */ | |
131 | - @Override | |
132 | - public boolean isValid() | |
133 | - { | |
134 | - return System.currentTimeMillis() < this.validUntil; | |
135 | - } | |
136 | - | |
137 | - /* (non-Javadoc) | |
138 | - * @see net.eq2online.permissions.ReplicatedPermissions#invalidate() | |
139 | - */ | |
140 | - @Override | |
141 | - public void invalidate() | |
142 | - { | |
143 | - this.validUntil = 0L; | |
144 | - } | |
145 | - | |
146 | - @Override | |
147 | - public void notifyRefreshPending() | |
148 | - { | |
149 | - this.validUntil = System.currentTimeMillis() + this.refreshTime; | |
150 | - } | |
151 | -} |
java/common/com/mumfrey/liteloader/transformers/ClassTransformer.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers; | |
2 | - | |
3 | -import net.minecraft.launchwrapper.IClassTransformer; | |
4 | - | |
5 | -import org.objectweb.asm.ClassReader; | |
6 | -import org.objectweb.asm.ClassWriter; | |
7 | -import org.objectweb.asm.tree.ClassNode; | |
8 | - | |
9 | -/** | |
10 | - * Base class for transformers which work via ClassNode | |
11 | - * | |
12 | - * @author Adam Mummery-Smith | |
13 | - */ | |
14 | -public abstract class ClassTransformer implements IClassTransformer | |
15 | -{ | |
16 | - public static final String HORIZONTAL_RULE = "----------------------------------------------------------------------------------------------------"; | |
17 | - | |
18 | - private ClassReader classReader; | |
19 | - private ClassNode classNode; | |
20 | - | |
21 | - /** | |
22 | - * @param basicClass | |
23 | - */ | |
24 | - protected final ClassNode readClass(byte[] basicClass, boolean cacheReader) | |
25 | - { | |
26 | - ClassReader classReader = new ClassReader(basicClass); | |
27 | - if (cacheReader) this.classReader = classReader; | |
28 | - | |
29 | - ClassNode classNode = new ClassNode(); | |
30 | - classReader.accept(classNode, ClassReader.EXPAND_FRAMES); | |
31 | - return classNode; | |
32 | - } | |
33 | - | |
34 | - /** | |
35 | - * @param classNode | |
36 | - */ | |
37 | - protected final byte[] writeClass(ClassNode classNode) | |
38 | - { | |
39 | - // Use optimised writer for speed | |
40 | - if (this.classReader != null && this.classNode == classNode) | |
41 | - { | |
42 | - this.classNode = null; | |
43 | - IsolatedClassWriter writer = new IsolatedClassWriter(this.classReader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); | |
44 | - this.classReader = null; | |
45 | - classNode.accept(writer); | |
46 | - return writer.toByteArray(); | |
47 | - } | |
48 | - | |
49 | - this.classNode = null; | |
50 | - | |
51 | - IsolatedClassWriter writer = new IsolatedClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); | |
52 | - classNode.accept(writer); | |
53 | - return writer.toByteArray(); | |
54 | - } | |
55 | - | |
56 | - protected static String getSimpleClassName(ClassNode classNode) | |
57 | - { | |
58 | - String className = classNode.name.replace('/', '.'); | |
59 | - int dotPos = className.lastIndexOf('.'); | |
60 | - return dotPos == -1 ? className : className.substring(dotPos + 1); | |
61 | - } | |
62 | -} | |
63 | 0 | \ No newline at end of file |
java/common/com/mumfrey/liteloader/transformers/event/EventInfo.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event; | |
2 | - | |
3 | -import org.objectweb.asm.Type; | |
4 | - | |
5 | -import com.mumfrey.liteloader.core.event.Cancellable; | |
6 | -import com.mumfrey.liteloader.core.event.EventCancellationException; | |
7 | - | |
8 | -/** | |
9 | - * Contains information about an injected event, including the source object and whether the event | |
10 | - * is cancellable and/or cancelled. | |
11 | - * | |
12 | - * @author Adam Mummery-Smith | |
13 | - * | |
14 | - * @param <S> Source object type. For non-static methods this will be the containing object instance. | |
15 | - */ | |
16 | -public class EventInfo<S> implements Cancellable | |
17 | -{ | |
18 | - protected static final String STRING = "Ljava/lang/String;"; | |
19 | - protected static final String OBJECT = "Ljava/lang/Object;"; | |
20 | - | |
21 | - private final String name; | |
22 | - | |
23 | - private final S source; | |
24 | - | |
25 | - private final boolean cancellable; | |
26 | - | |
27 | - private boolean cancelled; | |
28 | - | |
29 | - public EventInfo(String name, S source, boolean cancellable) | |
30 | - { | |
31 | - this.name = name; | |
32 | - this.source = source; | |
33 | - this.cancellable = cancellable; | |
34 | - } | |
35 | - | |
36 | - public S getSource() | |
37 | - { | |
38 | - return this.source; | |
39 | - } | |
40 | - | |
41 | - public String getName() | |
42 | - { | |
43 | - return this.name; | |
44 | - } | |
45 | - | |
46 | - protected String getSourceClass() | |
47 | - { | |
48 | - return this.source != null ? this.source.getClass().getSimpleName() : null; | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public String toString() | |
53 | - { | |
54 | - return String.format("EventInfo(TYPE=%s,NAME=%s,SOURCE=%s,CANCELLABLE=%s)", this.getClass().getSimpleName(), this.name, this.getSourceClass(), this.cancellable); | |
55 | - } | |
56 | - | |
57 | - /* (non-Javadoc) | |
58 | - * @see com.mumfrey.liteloader.core.event.Cancellable#isCancellable() | |
59 | - */ | |
60 | - @Override | |
61 | - public final boolean isCancellable() | |
62 | - { | |
63 | - return this.cancellable; | |
64 | - } | |
65 | - | |
66 | - /* (non-Javadoc) | |
67 | - * @see com.mumfrey.liteloader.transformers.event.Cancellable#isCancelled() | |
68 | - */ | |
69 | - @Override | |
70 | - public final boolean isCancelled() | |
71 | - { | |
72 | - return this.cancelled; | |
73 | - } | |
74 | - | |
75 | - /* (non-Javadoc) | |
76 | - * @see com.mumfrey.liteloader.transformers.event.Cancellable#cancel() | |
77 | - */ | |
78 | - @Override | |
79 | - public void cancel() throws EventCancellationException | |
80 | - { | |
81 | - if (!this.cancellable) | |
82 | - { | |
83 | - throw new EventCancellationException(String.format("The event %s is not cancellable.", this.name)); | |
84 | - } | |
85 | - | |
86 | - this.cancelled = true; | |
87 | - } | |
88 | - | |
89 | - protected static String getEventInfoClassName() | |
90 | - { | |
91 | - return EventInfo.class.getName(); | |
92 | - } | |
93 | - | |
94 | - /** | |
95 | - * @param returnType | |
96 | - */ | |
97 | - protected static String getEventInfoClassName(Type returnType) | |
98 | - { | |
99 | - return returnType.equals(Type.VOID_TYPE) ? EventInfo.class.getName() : ReturnEventInfo.class.getName(); | |
100 | - } | |
101 | - | |
102 | - public static String getConstructorDescriptor(Type returnType) | |
103 | - { | |
104 | - if (returnType.equals(Type.VOID_TYPE)) | |
105 | - { | |
106 | - return EventInfo.getConstructorDescriptor(); | |
107 | - } | |
108 | - | |
109 | - if (returnType.getSort() == Type.OBJECT) | |
110 | - { | |
111 | - return String.format("(%s%sZ%s)V", EventInfo.STRING, EventInfo.OBJECT, EventInfo.OBJECT); | |
112 | - } | |
113 | - | |
114 | - return String.format("(%s%sZ%s)V", EventInfo.STRING, EventInfo.OBJECT, returnType.getDescriptor()); | |
115 | - } | |
116 | - | |
117 | - public static String getConstructorDescriptor() | |
118 | - { | |
119 | - return String.format("(%s%sZ)V", EventInfo.STRING, EventInfo.OBJECT); | |
120 | - } | |
121 | - | |
122 | - public static String getIsCancelledMethodName() | |
123 | - { | |
124 | - return "isCancelled"; | |
125 | - } | |
126 | - | |
127 | - public static String getIsCancelledMethodSig() | |
128 | - { | |
129 | - return "()Z"; | |
130 | - } | |
131 | -} |
java/common/com/mumfrey/liteloader/transformers/event/EventInjectionTransformer.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event; | |
2 | - | |
3 | -import com.mumfrey.liteloader.transformers.ObfProvider; | |
4 | - | |
5 | -import net.minecraft.launchwrapper.IClassTransformer; | |
6 | - | |
7 | -public abstract class EventInjectionTransformer implements IClassTransformer | |
8 | -{ | |
9 | - public EventInjectionTransformer() | |
10 | - { | |
11 | - try | |
12 | - { | |
13 | - this.addEvents(); | |
14 | - } | |
15 | - catch (Exception ex) | |
16 | - { | |
17 | - ex.printStackTrace(); | |
18 | - } | |
19 | - } | |
20 | - | |
21 | - /* (non-Javadoc) | |
22 | - * @see net.minecraft.launchwrapper.IClassTransformer#transform(java.lang.String, java.lang.String, byte[]) | |
23 | - */ | |
24 | - @Override | |
25 | - public byte[] transform(String name, String transformedName, byte[] basicClass) | |
26 | - { | |
27 | - return basicClass; | |
28 | - } | |
29 | - | |
30 | - /** | |
31 | - * Subclasses should register events here | |
32 | - */ | |
33 | - protected abstract void addEvents(); | |
34 | - | |
35 | - /** | |
36 | - * Register a new event to be injected, the event instance will be created if it does not already exist | |
37 | - * | |
38 | - * @param eventName Name of the event to use/create. Beware that IllegalArgumentException if the event was already defined with incompatible parameters | |
39 | - * @param targetMethod Method descriptor to identify the method to inject into | |
40 | - * @param injectionPoint Delegate which finds the location(s) in the target method to inject into | |
41 | - * | |
42 | - * @return the event - for fluent interface | |
43 | - */ | |
44 | - protected final Event addEvent(String eventName, MethodInfo targetMethod, InjectionPoint injectionPoint) | |
45 | - { | |
46 | - return this.addEvent(Event.getOrCreate(eventName), targetMethod, injectionPoint); | |
47 | - } | |
48 | - | |
49 | - /** | |
50 | - * Register an event to be injected | |
51 | - * | |
52 | - * @param event Event to inject | |
53 | - * @param targetMethod Method descriptor to identify the method to inject into | |
54 | - * @param injectionPoint Delegate which finds the location(s) in the target method to inject into | |
55 | - * | |
56 | - * @return the event - for fluent interface | |
57 | - */ | |
58 | - protected final Event addEvent(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint) | |
59 | - { | |
60 | - if (event == null) | |
61 | - throw new IllegalArgumentException("Event cannot be null!"); | |
62 | - | |
63 | - if (injectionPoint == null) | |
64 | - throw new IllegalArgumentException("Injection point cannot be null for event " + event.getName()); | |
65 | - | |
66 | - if ("true".equals(System.getProperty("mcpenv"))) | |
67 | - { | |
68 | - EventTransformer.addEvent(event, targetMethod.owner, targetMethod.sig, injectionPoint); | |
69 | - } | |
70 | - else | |
71 | - { | |
72 | - EventTransformer.addEvent(event, targetMethod.owner, targetMethod.sigSrg, injectionPoint); | |
73 | - EventTransformer.addEvent(event, targetMethod.ownerObf, targetMethod.sigObf, injectionPoint); | |
74 | - } | |
75 | - | |
76 | - event.addPendingInjection(targetMethod); | |
77 | - | |
78 | - return event; | |
79 | - } | |
80 | - | |
81 | - /** | |
82 | - * Register an access injection interface | |
83 | - * | |
84 | - * @param interfaceName | |
85 | - */ | |
86 | - protected final void addAccessor(String interfaceName) | |
87 | - { | |
88 | - EventTransformer.addAccessor(interfaceName); | |
89 | - } | |
90 | - | |
91 | - /** | |
92 | - * Register an access injection interface and provide a contextual obfuscation provider | |
93 | - * | |
94 | - * @param interfaceName | |
95 | - * @param obfProvider | |
96 | - */ | |
97 | - protected final void addAccessor(String interfaceName, ObfProvider obfProvider) | |
98 | - { | |
99 | - EventTransformer.addAccessor(interfaceName, obfProvider); | |
100 | - } | |
101 | -} |
java/common/com/mumfrey/liteloader/transformers/event/EventProxyTransformer.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event; | |
2 | - | |
3 | -import org.objectweb.asm.Opcodes; | |
4 | -import org.objectweb.asm.tree.ClassNode; | |
5 | -import org.objectweb.asm.tree.InsnNode; | |
6 | -import org.objectweb.asm.tree.MethodNode; | |
7 | - | |
8 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
9 | -import com.mumfrey.liteloader.transformers.ClassTransformer; | |
10 | - | |
11 | -/** | |
12 | - * Transformer responsible for transforming/generating the EventProxy inner classes, separated from the Event Transformer | |
13 | - * itself so that we can place it higher up the tranformer chain to avoid broken mod transformers screwing things up. | |
14 | - * | |
15 | - * @author Adam Mummery-Smith | |
16 | - */ | |
17 | -public class EventProxyTransformer extends ClassTransformer | |
18 | -{ | |
19 | - public EventProxyTransformer() | |
20 | - { | |
21 | - } | |
22 | - | |
23 | - @Override | |
24 | - public byte[] transform(String name, String transformedName, byte[] basicClass) | |
25 | - { | |
26 | - if (transformedName != null && transformedName.startsWith(Obf.EventProxy.name)) | |
27 | - { | |
28 | - int dollarPos = transformedName.indexOf('$'); | |
29 | - int proxyIndex = (dollarPos > -1) ? Integer.parseInt(transformedName.substring(dollarPos + 1)) : 0; | |
30 | - if (proxyIndex != 1) | |
31 | - { | |
32 | - try | |
33 | - { | |
34 | - return this.transformEventProxy(transformedName, basicClass, proxyIndex); | |
35 | - } | |
36 | - catch (Throwable th) | |
37 | - { | |
38 | - th.printStackTrace(); | |
39 | - } | |
40 | - } | |
41 | - } | |
42 | - | |
43 | - return basicClass; | |
44 | - } | |
45 | - | |
46 | - private byte[] transformEventProxy(String transformedName, byte[] basicClass, int proxyIndex) | |
47 | - { | |
48 | - ClassNode classNode = this.getProxyByteCode(transformedName, basicClass, proxyIndex); | |
49 | - return this.writeClass(Event.populateProxy(classNode, proxyIndex == 0 ? 1 : proxyIndex)); | |
50 | - } | |
51 | - | |
52 | - private ClassNode getProxyByteCode(String transformedName, byte[] basicClass, int proxyIndex) | |
53 | - { | |
54 | - if (proxyIndex == 0 || basicClass != null) | |
55 | - { | |
56 | - ClassNode classNode = this.readClass(basicClass, true); | |
57 | - | |
58 | - for (MethodNode method : classNode.methods) | |
59 | - { | |
60 | - // Strip the sanity code out of the EventProxy class initialiser | |
61 | - if ("<clinit>".equals(method.name)) | |
62 | - { | |
63 | - method.instructions.clear(); | |
64 | - method.instructions.add(new InsnNode(Opcodes.RETURN)); | |
65 | - } | |
66 | - } | |
67 | - | |
68 | - return classNode; | |
69 | - } | |
70 | - | |
71 | - ClassNode classNode = new ClassNode(); | |
72 | - classNode.visit(50, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, transformedName.replace('.', '/'), null, "java/lang/Object", null); | |
73 | - return classNode; | |
74 | - } | |
75 | -} |
java/common/com/mumfrey/liteloader/transformers/event/Jump.java deleted
100644 → 0
1 | -//package com.mumfrey.liteloader.transformers.event; | |
2 | -// | |
3 | -//import org.objectweb.asm.Opcodes; | |
4 | -//import org.objectweb.asm.tree.AbstractInsnNode; | |
5 | -//import org.objectweb.asm.tree.InsnList; | |
6 | -//import org.objectweb.asm.tree.InsnNode; | |
7 | -//import org.objectweb.asm.tree.JumpInsnNode; | |
8 | -//import org.objectweb.asm.tree.MethodInsnNode; | |
9 | -//import org.objectweb.asm.tree.VarInsnNode; | |
10 | -// | |
11 | -//public class Jump extends Event | |
12 | -//{ | |
13 | -// Jump(String name, boolean cancellable, int priority) | |
14 | -// { | |
15 | -// super(name, cancellable, priority); | |
16 | -// } | |
17 | -// | |
18 | -// @Override | |
19 | -// protected void validate(AbstractInsnNode injectionPoint, boolean cancellable, int globalEventID) | |
20 | -// { | |
21 | -// if (!(injectionPoint instanceof JumpInsnNode)) | |
22 | -// { | |
23 | -// throw new IllegalArgumentException("Attempted to inject a JUMP event where no JUMP is present"); | |
24 | -// } | |
25 | -// | |
26 | -// super.validate(injectionPoint, cancellable, globalEventID); | |
27 | -// } | |
28 | -// | |
29 | -// @Override | |
30 | -// protected void injectCancellationCode(InsnList insns, AbstractInsnNode injectionPoint, int eventInfoVar) throws IllegalArgumentException | |
31 | -// { | |
32 | -// int opcode = injectionPoint.getOpcode(); | |
33 | -// | |
34 | -// if (opcode == Opcodes.JSR) throw new IllegalArgumentException("Can't jump on finally clause"); | |
35 | -// | |
36 | -// if (opcode == Opcodes.IFEQ || opcode == Opcodes.IFNE || opcode == Opcodes.IFLT || opcode == Opcodes.IFGE | |
37 | -// || opcode == Opcodes.IFGT || opcode == Opcodes.IFLE || opcode == Opcodes.IFNULL || opcode == Opcodes.IFNONNULL) | |
38 | -// { | |
39 | -// insns.add(new InsnNode(Opcodes.POP)); | |
40 | -// } | |
41 | -// | |
42 | -// if (opcode == Opcodes.IF_ICMPEQ || opcode == Opcodes.IF_ICMPNE || opcode == Opcodes.IF_ICMPLT || opcode == Opcodes.IF_ICMPGE | |
43 | -// || opcode == Opcodes.IF_ICMPGT || opcode == Opcodes.IF_ICMPLE || opcode == Opcodes.IF_ACMPEQ || opcode == Opcodes.IF_ACMPNE) | |
44 | -// { | |
45 | -// insns.add(new InsnNode(Opcodes.POP)); | |
46 | -// insns.add(new InsnNode(Opcodes.POP)); | |
47 | -// } | |
48 | -// | |
49 | -// insns.add(new VarInsnNode(Opcodes.ALOAD, eventInfoVar)); | |
50 | -// insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, this.eventInfoClass, "isCancelled", "()Z")); | |
51 | -// | |
52 | -// ((JumpInsnNode)injectionPoint).setOpcode(Opcodes.IFEQ); | |
53 | -// } | |
54 | -//} |
java/common/com/mumfrey/liteloader/transformers/event/ReadOnlyInsnList.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event; | |
2 | - | |
3 | -import java.util.ListIterator; | |
4 | - | |
5 | -import org.objectweb.asm.tree.AbstractInsnNode; | |
6 | -import org.objectweb.asm.tree.InsnList; | |
7 | - | |
8 | -/** | |
9 | - * Read-only wrapper for InsnList | |
10 | - * | |
11 | - * @author Adam Mummery-Smith | |
12 | - */ | |
13 | -public class ReadOnlyInsnList extends InsnList | |
14 | -{ | |
15 | - private InsnList insnList; | |
16 | - | |
17 | - public ReadOnlyInsnList(InsnList insns) | |
18 | - { | |
19 | - this.insnList = insns; | |
20 | - } | |
21 | - | |
22 | - void dispose() | |
23 | - { | |
24 | - this.insnList = null; | |
25 | - } | |
26 | - | |
27 | - @Override | |
28 | - public void set(AbstractInsnNode location, AbstractInsnNode insn) | |
29 | - { | |
30 | - throw new UnsupportedOperationException(); | |
31 | - } | |
32 | - | |
33 | - @Override | |
34 | - public void add(AbstractInsnNode insn) | |
35 | - { | |
36 | - throw new UnsupportedOperationException(); | |
37 | - } | |
38 | - | |
39 | - @Override | |
40 | - public void add(InsnList insns) | |
41 | - { | |
42 | - throw new UnsupportedOperationException(); | |
43 | - } | |
44 | - | |
45 | - @Override | |
46 | - public void insert(AbstractInsnNode insn) | |
47 | - { | |
48 | - throw new UnsupportedOperationException(); | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public void insert(InsnList insns) | |
53 | - { | |
54 | - throw new UnsupportedOperationException(); | |
55 | - } | |
56 | - | |
57 | - @Override | |
58 | - public void insert(AbstractInsnNode location, AbstractInsnNode insn) | |
59 | - { | |
60 | - throw new UnsupportedOperationException(); | |
61 | - } | |
62 | - | |
63 | - @Override | |
64 | - public void insert(AbstractInsnNode location, InsnList insns) | |
65 | - { | |
66 | - throw new UnsupportedOperationException(); | |
67 | - } | |
68 | - | |
69 | - @Override | |
70 | - public void insertBefore(AbstractInsnNode location, AbstractInsnNode insn) | |
71 | - { | |
72 | - throw new UnsupportedOperationException(); | |
73 | - } | |
74 | - | |
75 | - @Override | |
76 | - public void insertBefore(AbstractInsnNode location, InsnList insns) | |
77 | - { | |
78 | - throw new UnsupportedOperationException(); | |
79 | - } | |
80 | - | |
81 | - @Override | |
82 | - public void remove(AbstractInsnNode insn) | |
83 | - { | |
84 | - throw new UnsupportedOperationException(); | |
85 | - } | |
86 | - | |
87 | - @Override | |
88 | - public AbstractInsnNode[] toArray() | |
89 | - { | |
90 | -// throw new UnsupportedOperationException(); | |
91 | - return this.insnList.toArray(); | |
92 | - } | |
93 | - | |
94 | - @Override | |
95 | - public int size() | |
96 | - { | |
97 | - return this.insnList.size(); | |
98 | - } | |
99 | - | |
100 | - @Override | |
101 | - public AbstractInsnNode getFirst() | |
102 | - { | |
103 | - return this.insnList.getFirst(); | |
104 | - } | |
105 | - | |
106 | - @Override | |
107 | - public AbstractInsnNode getLast() | |
108 | - { | |
109 | - return this.insnList.getLast(); | |
110 | - } | |
111 | - | |
112 | - @Override | |
113 | - public AbstractInsnNode get(int index) | |
114 | - { | |
115 | - return this.insnList.get(index); | |
116 | - } | |
117 | - | |
118 | - @Override | |
119 | - public boolean contains(AbstractInsnNode insn) | |
120 | - { | |
121 | - return this.insnList.contains(insn); | |
122 | - } | |
123 | - | |
124 | - @Override | |
125 | - public int indexOf(AbstractInsnNode insn) | |
126 | - { | |
127 | - return this.insnList.indexOf(insn); | |
128 | - } | |
129 | - | |
130 | - @Override | |
131 | - public ListIterator<AbstractInsnNode> iterator() | |
132 | - { | |
133 | - return this.insnList.iterator(); | |
134 | - } | |
135 | - | |
136 | - @Override | |
137 | - public ListIterator<AbstractInsnNode> iterator(int index) | |
138 | - { | |
139 | - return this.insnList.iterator(index); | |
140 | - } | |
141 | - | |
142 | - @Override | |
143 | - public void resetLabels() | |
144 | - { | |
145 | - this.insnList.resetLabels(); | |
146 | - } | |
147 | -} |
java/common/com/mumfrey/liteloader/transformers/event/ReturnEventInfo.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event; | |
2 | - | |
3 | -import org.objectweb.asm.Type; | |
4 | - | |
5 | -import com.mumfrey.liteloader.core.event.EventCancellationException; | |
6 | - | |
7 | -/** | |
8 | - * EventInfo for events which have a return type | |
9 | - * | |
10 | - * @author Adam Mummery-Smith | |
11 | - * | |
12 | - * @param <S> Source object type. For non-static methods this will be the containing object instance. | |
13 | - * @param <R> Return type | |
14 | - */ | |
15 | -public class ReturnEventInfo<S, R> extends EventInfo<S> | |
16 | -{ | |
17 | - private R returnValue; | |
18 | - | |
19 | - public ReturnEventInfo(String name, S source, boolean cancellable) | |
20 | - { | |
21 | - super(name, source, cancellable); | |
22 | - this.returnValue = null; | |
23 | - } | |
24 | - | |
25 | - public ReturnEventInfo(String name, S source, boolean cancellable, R returnValue) | |
26 | - { | |
27 | - super(name, source, cancellable); | |
28 | - this.returnValue = returnValue; | |
29 | - } | |
30 | - | |
31 | - @SuppressWarnings("unchecked") | |
32 | - public ReturnEventInfo(String name, S source, boolean cancellable, byte returnValue) | |
33 | - { | |
34 | - super(name, source, cancellable); | |
35 | - this.returnValue = (R)Byte.valueOf(returnValue); | |
36 | - } | |
37 | - | |
38 | - @SuppressWarnings("unchecked") | |
39 | - public ReturnEventInfo(String name, S source, boolean cancellable, char returnValue) | |
40 | - { | |
41 | - super(name, source, cancellable); | |
42 | - this.returnValue = (R)Character.valueOf(returnValue); | |
43 | - } | |
44 | - | |
45 | - @SuppressWarnings("unchecked") | |
46 | - public ReturnEventInfo(String name, S source, boolean cancellable, double returnValue) | |
47 | - { | |
48 | - super(name, source, cancellable); | |
49 | - this.returnValue = (R)Double.valueOf(returnValue); | |
50 | - } | |
51 | - | |
52 | - @SuppressWarnings("unchecked") | |
53 | - public ReturnEventInfo(String name, S source, boolean cancellable, float returnValue) | |
54 | - { | |
55 | - super(name, source, cancellable); | |
56 | - this.returnValue = (R)Float.valueOf(returnValue); | |
57 | - } | |
58 | - | |
59 | - @SuppressWarnings("unchecked") | |
60 | - public ReturnEventInfo(String name, S source, boolean cancellable, int returnValue) | |
61 | - { | |
62 | - super(name, source, cancellable); | |
63 | - this.returnValue = (R)Integer.valueOf(returnValue); | |
64 | - } | |
65 | - | |
66 | - @SuppressWarnings("unchecked") | |
67 | - public ReturnEventInfo(String name, S source, boolean cancellable, long returnValue) | |
68 | - { | |
69 | - super(name, source, cancellable); | |
70 | - this.returnValue = (R)Long.valueOf(returnValue); | |
71 | - } | |
72 | - | |
73 | - @SuppressWarnings("unchecked") | |
74 | - public ReturnEventInfo(String name, S source, boolean cancellable, short returnValue) | |
75 | - { | |
76 | - super(name, source, cancellable); | |
77 | - this.returnValue = (R)Short.valueOf(returnValue); | |
78 | - } | |
79 | - | |
80 | - @SuppressWarnings("unchecked") | |
81 | - public ReturnEventInfo(String name, S source, boolean cancellable, boolean returnValue) | |
82 | - { | |
83 | - super(name, source, cancellable); | |
84 | - this.returnValue = (R)Boolean.valueOf(returnValue); | |
85 | - } | |
86 | - | |
87 | - /** | |
88 | - * Sets a return value for this event and cancels the event (required in order to return the new value) | |
89 | - * | |
90 | - * @param returnValue | |
91 | - */ | |
92 | - public void setReturnValue(R returnValue) throws EventCancellationException | |
93 | - { | |
94 | - super.cancel(); | |
95 | - | |
96 | - this.returnValue = returnValue; | |
97 | - } | |
98 | - | |
99 | - public R getReturnValue() | |
100 | - { | |
101 | - return this.returnValue; | |
102 | - } | |
103 | - | |
104 | - // All of the accessors below are to avoid having to generate unboxing conversions in bytecode | |
105 | - public byte getReturnValueB() { if (this.returnValue == null) return 0; return (Byte) this.returnValue; } | |
106 | - public char getReturnValueC() { if (this.returnValue == null) return 0; return (Character)this.returnValue; } | |
107 | - public double getReturnValueD() { if (this.returnValue == null) return 0.0; return (Double) this.returnValue; } | |
108 | - public float getReturnValueF() { if (this.returnValue == null) return 0.0F; return (Float) this.returnValue; } | |
109 | - public int getReturnValueI() { if (this.returnValue == null) return 0; return (Integer) this.returnValue; } | |
110 | - public long getReturnValueJ() { if (this.returnValue == null) return 0; return (Long) this.returnValue; } | |
111 | - public short getReturnValueS() { if (this.returnValue == null) return 0; return (Short) this.returnValue; } | |
112 | - public boolean getReturnValueZ() { if (this.returnValue == null) return false; return (Boolean) this.returnValue; } | |
113 | - | |
114 | - public static String getReturnAccessor(Type returnType) | |
115 | - { | |
116 | - if (returnType.getSort() == Type.OBJECT) | |
117 | - { | |
118 | - return "getReturnValue"; | |
119 | - } | |
120 | - | |
121 | - return String.format("getReturnValue%s", returnType.getDescriptor()); | |
122 | - } | |
123 | - | |
124 | - public static String getReturnDescriptor(Type returnType) | |
125 | - { | |
126 | - if (returnType.getSort() == Type.OBJECT) | |
127 | - { | |
128 | - return String.format("()%s", EventInfo.OBJECT); | |
129 | - } | |
130 | - | |
131 | - return String.format("()%s", returnType.getDescriptor()); | |
132 | - } | |
133 | -} |
java/common/com/mumfrey/liteloader/transformers/event/inject/BeforeFieldAccess.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.inject; | |
2 | - | |
3 | -import org.objectweb.asm.tree.AbstractInsnNode; | |
4 | -import org.objectweb.asm.tree.FieldInsnNode; | |
5 | - | |
6 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
7 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
8 | - | |
9 | -/** | |
10 | - * An injection point which searches for GETFIELD and SETFIELD opcodes matching its arguments and returns a list of insns | |
11 | - * immediately prior to matching instructions. Only the field name is required, owners and signatures are optional and can | |
12 | - * be used to disambiguate between fields of the same name but with different types, or belonging to different classes. | |
13 | - * | |
14 | - * @author Adam Mummery-Smith | |
15 | - */ | |
16 | -public class BeforeFieldAccess extends BeforeInvoke | |
17 | -{ | |
18 | - private final int opcode; | |
19 | - | |
20 | - public BeforeFieldAccess(int opcode, String... fieldNames) | |
21 | - { | |
22 | - super(fieldNames); | |
23 | - this.opcode = opcode; | |
24 | - } | |
25 | - | |
26 | - public BeforeFieldAccess(int opcode, String fieldName, int ordinal) | |
27 | - { | |
28 | - super(fieldName, ordinal); | |
29 | - this.opcode = opcode; | |
30 | - } | |
31 | - | |
32 | - public BeforeFieldAccess(int opcode, String[] fieldNames, int ordinal) | |
33 | - { | |
34 | - super(fieldNames, ordinal); | |
35 | - this.opcode = opcode; | |
36 | - } | |
37 | - | |
38 | - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners) | |
39 | - { | |
40 | - super(fieldNames, fieldOwners); | |
41 | - this.opcode = opcode; | |
42 | - } | |
43 | - | |
44 | - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners, int ordinal) | |
45 | - { | |
46 | - super(fieldNames, fieldOwners, ordinal); | |
47 | - this.opcode = opcode; | |
48 | - } | |
49 | - | |
50 | - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners, String[] fieldSignatures) | |
51 | - { | |
52 | - super(fieldNames, fieldOwners, fieldSignatures); | |
53 | - this.opcode = opcode; | |
54 | - } | |
55 | - | |
56 | - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners, String[] fieldSignatures, int ordinal) | |
57 | - { | |
58 | - super(fieldNames, fieldOwners, fieldSignatures, ordinal); | |
59 | - this.opcode = opcode; | |
60 | - } | |
61 | - | |
62 | - public BeforeFieldAccess(int opcode, Obf fieldNames, int ordinal) | |
63 | - { | |
64 | - super(fieldNames.names, ordinal); | |
65 | - this.opcode = opcode; | |
66 | - } | |
67 | - | |
68 | - public BeforeFieldAccess(int opcode, Obf fieldNames, Obf fieldOwners) | |
69 | - { | |
70 | - super(fieldNames.names, fieldOwners.names); | |
71 | - this.opcode = opcode; | |
72 | - } | |
73 | - | |
74 | - public BeforeFieldAccess(int opcode, Obf fieldNames, Obf fieldOwners, int ordinal) | |
75 | - { | |
76 | - super(fieldNames.names, fieldOwners.names, ordinal); | |
77 | - this.opcode = opcode; | |
78 | - } | |
79 | - | |
80 | - public BeforeFieldAccess(int opcode, MethodInfo fieldInfo) | |
81 | - { | |
82 | - super(fieldInfo); | |
83 | - this.opcode = opcode; | |
84 | - } | |
85 | - | |
86 | - public BeforeFieldAccess(int opcode, MethodInfo fieldInfo, int ordinal) | |
87 | - { | |
88 | - super(fieldInfo, ordinal); | |
89 | - this.opcode = opcode; | |
90 | - } | |
91 | - | |
92 | - @Override | |
93 | - protected boolean matchesInsn(AbstractInsnNode insn) | |
94 | - { | |
95 | - return insn instanceof FieldInsnNode && ((FieldInsnNode)insn).getOpcode() == this.opcode; | |
96 | - } | |
97 | -} |
java/common/com/mumfrey/liteloader/transformers/event/inject/BeforeNew.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.inject; | |
2 | - | |
3 | -import java.util.Collection; | |
4 | -import java.util.ListIterator; | |
5 | - | |
6 | -import org.objectweb.asm.Opcodes; | |
7 | -import org.objectweb.asm.tree.AbstractInsnNode; | |
8 | -import org.objectweb.asm.tree.InsnList; | |
9 | -import org.objectweb.asm.tree.TypeInsnNode; | |
10 | - | |
11 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
12 | -import com.mumfrey.liteloader.transformers.event.Event; | |
13 | -import com.mumfrey.liteloader.transformers.event.InjectionPoint; | |
14 | - | |
15 | -public class BeforeNew extends InjectionPoint | |
16 | -{ | |
17 | - private final String[] classNames; | |
18 | - | |
19 | - private final int ordinal; | |
20 | - | |
21 | - public BeforeNew(Obf className) | |
22 | - { | |
23 | - this(-1, className.names); | |
24 | - } | |
25 | - | |
26 | - public BeforeNew(String... classNames) | |
27 | - { | |
28 | - this(-1, classNames); | |
29 | - } | |
30 | - | |
31 | - public BeforeNew(int ordinal, Obf className) | |
32 | - { | |
33 | - this(ordinal, className.names); | |
34 | - } | |
35 | - | |
36 | - public BeforeNew(int ordinal, String... classNames) | |
37 | - { | |
38 | - this.ordinal = Math.max(-1, ordinal); | |
39 | - this.classNames = classNames; | |
40 | - | |
41 | - for (int i = 0; i < this.classNames.length; i++) | |
42 | - { | |
43 | - this.classNames[i] = this.classNames[i].replace('.', '/'); | |
44 | - } | |
45 | - } | |
46 | - | |
47 | - @Override | |
48 | - public boolean find(String desc, InsnList insns, Collection<AbstractInsnNode> nodes, Event event) | |
49 | - { | |
50 | - boolean found = false; | |
51 | - int ordinal = 0; | |
52 | - | |
53 | - ListIterator<AbstractInsnNode> iter = insns.iterator(); | |
54 | - while (iter.hasNext()) | |
55 | - { | |
56 | - AbstractInsnNode insn = iter.next(); | |
57 | - | |
58 | - if (insn instanceof TypeInsnNode && insn.getOpcode() == Opcodes.NEW && this.matchesOwner((TypeInsnNode)insn)) | |
59 | - { | |
60 | - if (this.ordinal == -1 || this.ordinal == ordinal) | |
61 | - { | |
62 | - nodes.add(insn); | |
63 | - found = true; | |
64 | - } | |
65 | - | |
66 | - ordinal++; | |
67 | - } | |
68 | - } | |
69 | - | |
70 | - return found; | |
71 | - } | |
72 | - | |
73 | - private boolean matchesOwner(TypeInsnNode insn) | |
74 | - { | |
75 | - for (String className : this.classNames) | |
76 | - { | |
77 | - if (className.equals(insn.desc)) return true; | |
78 | - } | |
79 | - | |
80 | - return false; | |
81 | - } | |
82 | - | |
83 | -} |
java/common/com/mumfrey/liteloader/transformers/event/inject/BeforeReturn.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.inject; | |
2 | - | |
3 | -import java.util.Collection; | |
4 | -import java.util.ListIterator; | |
5 | - | |
6 | -import org.objectweb.asm.Opcodes; | |
7 | -import org.objectweb.asm.Type; | |
8 | -import org.objectweb.asm.tree.AbstractInsnNode; | |
9 | -import org.objectweb.asm.tree.InsnList; | |
10 | -import org.objectweb.asm.tree.InsnNode; | |
11 | - | |
12 | -import com.mumfrey.liteloader.transformers.event.Event; | |
13 | -import com.mumfrey.liteloader.transformers.event.InjectionPoint; | |
14 | - | |
15 | -/** | |
16 | - * An injection point which searches for RETURN opcodes in the supplied method and either finds all insns or | |
17 | - * the insn at the specified ordinal | |
18 | - * | |
19 | - * @author Adam Mummery-Smith | |
20 | - */ | |
21 | -public class BeforeReturn extends InjectionPoint | |
22 | -{ | |
23 | - private final int ordinal; | |
24 | - | |
25 | - public BeforeReturn() | |
26 | - { | |
27 | - this(-1); | |
28 | - } | |
29 | - | |
30 | - public BeforeReturn(int ordinal) | |
31 | - { | |
32 | - this.ordinal = Math.max(-1, ordinal); | |
33 | - } | |
34 | - | |
35 | - @Override | |
36 | - public boolean find(String desc, InsnList insns, Collection<AbstractInsnNode> nodes, Event event) | |
37 | - { | |
38 | - boolean found = false; | |
39 | - int returnOpcode = Type.getReturnType(desc).getOpcode(Opcodes.IRETURN); | |
40 | - int ordinal = 0; | |
41 | - | |
42 | - ListIterator<AbstractInsnNode> iter = insns.iterator(); | |
43 | - while (iter.hasNext()) | |
44 | - { | |
45 | - AbstractInsnNode insn = iter.next(); | |
46 | - | |
47 | - if (insn instanceof InsnNode && insn.getOpcode() == returnOpcode) | |
48 | - { | |
49 | - if (this.ordinal == -1 || this.ordinal == ordinal) | |
50 | - { | |
51 | - nodes.add(insn); | |
52 | - found = true; | |
53 | - } | |
54 | - | |
55 | - ordinal++; | |
56 | - } | |
57 | - } | |
58 | - | |
59 | - return found; | |
60 | - } | |
61 | -} |
java/common/com/mumfrey/liteloader/transformers/event/inject/BeforeStringInvoke.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.inject; | |
2 | - | |
3 | -import java.util.Collection; | |
4 | - | |
5 | -import org.objectweb.asm.tree.AbstractInsnNode; | |
6 | -import org.objectweb.asm.tree.InsnList; | |
7 | -import org.objectweb.asm.tree.LdcInsnNode; | |
8 | - | |
9 | -import com.mumfrey.liteloader.transformers.event.Event; | |
10 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
11 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | |
12 | - | |
13 | -/** | |
14 | - * An injection point which searches for a matching String LDC insn immediately prior to a qualifying invoke | |
15 | - * | |
16 | - * @author Adam Mummery-Smith | |
17 | - */ | |
18 | -public class BeforeStringInvoke extends BeforeInvoke | |
19 | -{ | |
20 | - private static final String STRING_VOID_SIG = "(Ljava/lang/String;)V"; | |
21 | - | |
22 | - private final String ldcValue; | |
23 | - | |
24 | - private boolean foundLdc; | |
25 | - | |
26 | - public BeforeStringInvoke(String ldcValue, MethodInfo method) | |
27 | - { | |
28 | - this(ldcValue, method, -1); | |
29 | - } | |
30 | - | |
31 | - public BeforeStringInvoke(String ldcValue, MethodInfo method, int ordinal) | |
32 | - { | |
33 | - super(method, ordinal); | |
34 | - this.ldcValue = ldcValue; | |
35 | - | |
36 | - for (int i = 0; i < this.methodSignatures.length; i++) | |
37 | - if (!STRING_VOID_SIG.equals(this.methodSignatures[i])) | |
38 | - throw new IllegalArgumentException("BeforeStringInvoke requires method with with signature " + STRING_VOID_SIG); | |
39 | - } | |
40 | - | |
41 | - @Override | |
42 | - public boolean find(String desc, InsnList insns, Collection<AbstractInsnNode> nodes, Event event) | |
43 | - { | |
44 | - this.foundLdc = false; | |
45 | - | |
46 | - return super.find(desc, insns, nodes, event); | |
47 | - } | |
48 | - | |
49 | - @Override | |
50 | - protected void inspectInsn(String desc, InsnList insns, AbstractInsnNode insn) | |
51 | - { | |
52 | - if (insn instanceof LdcInsnNode) | |
53 | - { | |
54 | - LdcInsnNode node = (LdcInsnNode)insn; | |
55 | - if (node.cst instanceof String && this.ldcValue.equals(node.cst)) | |
56 | - { | |
57 | - if (this.logging) LiteLoaderLogger.info("BeforeInvoke found a matching LDC with value %s", node.cst); | |
58 | - this.foundLdc = true; | |
59 | - return; | |
60 | - } | |
61 | - } | |
62 | - | |
63 | - this.foundLdc = false; | |
64 | - } | |
65 | - | |
66 | - @Override | |
67 | - protected boolean matchesInsn(InsnInfo nodeInfo, int ordinal) | |
68 | - { | |
69 | - if (this.logging) LiteLoaderLogger.debug("BeforeInvoke foundLdc \"%s\" = %s", this.ldcValue, this.foundLdc); | |
70 | - return this.foundLdc && super.matchesInsn(nodeInfo, ordinal); | |
71 | - } | |
72 | -} |
java/common/com/mumfrey/liteloader/transformers/event/inject/JumpInsnPoint.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.inject; | |
2 | - | |
3 | -import java.util.Collection; | |
4 | -import java.util.ListIterator; | |
5 | - | |
6 | -import org.objectweb.asm.tree.AbstractInsnNode; | |
7 | -import org.objectweb.asm.tree.InsnList; | |
8 | -import org.objectweb.asm.tree.JumpInsnNode; | |
9 | - | |
10 | -import com.mumfrey.liteloader.transformers.event.Event; | |
11 | -import com.mumfrey.liteloader.transformers.event.InjectionPoint; | |
12 | - | |
13 | -/** | |
14 | - * An injection point which searches for JUMP opcodes (if, try/catch, continue, break, conditional assignment, etc.) | |
15 | - * with either a particular opcode or at a particular ordinal in the method body (eg. "the Nth JUMP insn" where N is the | |
16 | - * ordinal of the instruction). By default it returns all JUMP instructions in a method body. | |
17 | - * | |
18 | - * @author Adam Mummery-Smith | |
19 | - */ | |
20 | -public class JumpInsnPoint extends InjectionPoint | |
21 | -{ | |
22 | - private final int opCode; | |
23 | - | |
24 | - private final int ordinal; | |
25 | - | |
26 | - public JumpInsnPoint() | |
27 | - { | |
28 | - this(0, -1); | |
29 | - } | |
30 | - | |
31 | - public JumpInsnPoint(int ordinal) | |
32 | - { | |
33 | - this(0, ordinal); | |
34 | - } | |
35 | - | |
36 | - public JumpInsnPoint(int opCode, int ordinal) | |
37 | - { | |
38 | - this.opCode = opCode; | |
39 | - this.ordinal = ordinal; | |
40 | - } | |
41 | - | |
42 | - @Override | |
43 | - public boolean find(String desc, InsnList insns, Collection<AbstractInsnNode> nodes, Event event) | |
44 | - { | |
45 | - boolean found = false; | |
46 | - int ordinal = 0; | |
47 | - | |
48 | - ListIterator<AbstractInsnNode> iter = insns.iterator(); | |
49 | - while (iter.hasNext()) | |
50 | - { | |
51 | - AbstractInsnNode insn = iter.next(); | |
52 | - | |
53 | - if (insn instanceof JumpInsnNode && (this.opCode == -1 || insn.getOpcode() == this.opCode)) | |
54 | - { | |
55 | - if (this.ordinal == -1 || this.ordinal == ordinal) | |
56 | - { | |
57 | - nodes.add(insn); | |
58 | - found = true; | |
59 | - } | |
60 | - | |
61 | - ordinal++; | |
62 | - } | |
63 | - } | |
64 | - | |
65 | - return found; | |
66 | - } | |
67 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonDescriptor.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | -import java.util.UUID; | |
5 | - | |
6 | -import com.google.gson.annotations.SerializedName; | |
7 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
8 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
9 | - | |
10 | -/** | |
11 | - * A JSON method descriptor, | |
12 | - * | |
13 | - * @author Adam Mummery-Smith | |
14 | - */ | |
15 | -public class JsonDescriptor implements Serializable | |
16 | -{ | |
17 | - private static final long serialVersionUID = 1L; | |
18 | - | |
19 | - /** | |
20 | - * Key used to refer to this method descriptor elsewhere | |
21 | - */ | |
22 | - @SerializedName("id") | |
23 | - private String key; | |
24 | - | |
25 | - /** | |
26 | - * Name of the class which owns this method | |
27 | - */ | |
28 | - @SerializedName("owner") | |
29 | - private String owner; | |
30 | - | |
31 | - /** | |
32 | - * Method name | |
33 | - */ | |
34 | - @SerializedName("name") | |
35 | - private String name; | |
36 | - | |
37 | - /** | |
38 | - * Method return type, assumes VOID if none specified | |
39 | - */ | |
40 | - @SerializedName("return") | |
41 | - private String returnType; | |
42 | - | |
43 | - /** | |
44 | - * Argument types for the method | |
45 | - */ | |
46 | - @SerializedName("args") | |
47 | - private String[] argumentTypes; | |
48 | - | |
49 | - /** | |
50 | - * Get the key used to refer to this method descriptor | |
51 | - */ | |
52 | - public String getKey() | |
53 | - { | |
54 | - if (this.key == null) | |
55 | - { | |
56 | - this.key = "UserDescriptor" + UUID.randomUUID().toString(); | |
57 | - } | |
58 | - | |
59 | - return this.key; | |
60 | - } | |
61 | - | |
62 | - /** | |
63 | - * @param obfTable | |
64 | - * @return MethodInfo for this descriptor | |
65 | - */ | |
66 | - public MethodInfo parse(JsonObfuscationTable obfTable) | |
67 | - { | |
68 | - if (this.owner == null || this.name == null) | |
69 | - { | |
70 | - throw new InvalidEventJsonException("Method descriptor was invalid, must specify owner and name!"); | |
71 | - } | |
72 | - | |
73 | - Obf owner = obfTable.parseClass(this.owner); | |
74 | - Obf name = obfTable.parseMethod(this.name); | |
75 | - | |
76 | - if (this.argumentTypes == null && this.returnType == null) | |
77 | - { | |
78 | - return new MethodInfo(owner, name); | |
79 | - } | |
80 | - | |
81 | - Object returnType = obfTable.parseType(this.returnType == null ? "VOID" : this.returnType); | |
82 | - Object[] args = (this.argumentTypes != null ? new Object[this.argumentTypes.length] : new Object[0]); | |
83 | - if (this.argumentTypes != null) | |
84 | - { | |
85 | - for (int arg = 0; arg < this.argumentTypes.length; arg++) | |
86 | - { | |
87 | - args[arg] = obfTable.parseType(this.argumentTypes[arg]); | |
88 | - } | |
89 | - } | |
90 | - | |
91 | - return new MethodInfo(owner, name, returnType, args); | |
92 | - } | |
93 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonEvent.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | -import java.util.ArrayList; | |
5 | -import java.util.List; | |
6 | - | |
7 | -import com.google.gson.annotations.SerializedName; | |
8 | -import com.mumfrey.liteloader.transformers.event.Event; | |
9 | -import com.mumfrey.liteloader.transformers.event.InjectionPoint; | |
10 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
11 | - | |
12 | -/** | |
13 | - * An event definition in JSON, serialisable class read by Gson | |
14 | - * | |
15 | - * @author Adam Mummery-Smith | |
16 | - */ | |
17 | -public class JsonEvent implements Serializable | |
18 | -{ | |
19 | - private static final long serialVersionUID = 1L; | |
20 | - | |
21 | - private static int nextEventID = 0; | |
22 | - | |
23 | - /** | |
24 | - * Event name | |
25 | - */ | |
26 | - @SerializedName("name") | |
27 | - private String name; | |
28 | - | |
29 | - /** | |
30 | - * Whether the event is cancellable | |
31 | - */ | |
32 | - @SerializedName("cancellable") | |
33 | - private boolean cancellable; | |
34 | - | |
35 | - /** | |
36 | - * Event priority (relative to other events at the same injection point) | |
37 | - */ | |
38 | - @SerializedName("priority") | |
39 | - private int priority = 1000; | |
40 | - | |
41 | - /** | |
42 | - * Injection points specified in the JSON file | |
43 | - */ | |
44 | - @SerializedName("injections") | |
45 | - private List<JsonInjection> jsonInjections; | |
46 | - | |
47 | - /** | |
48 | - * Listeners defined in the JSON file | |
49 | - */ | |
50 | - @SerializedName("listeners") | |
51 | - private List<String> jsonListeners; | |
52 | - | |
53 | - /** | |
54 | - * Listener methods parsed from the JSON | |
55 | - */ | |
56 | - private transient List<MethodInfo> listeners = new ArrayList<MethodInfo>(); | |
57 | - | |
58 | - /** | |
59 | - * Get the name of this event | |
60 | - */ | |
61 | - public String getName() | |
62 | - { | |
63 | - if (this.name == null) | |
64 | - { | |
65 | - this.name = "onUserEvent" + (JsonEvent.nextEventID++); | |
66 | - } | |
67 | - | |
68 | - return this.name; | |
69 | - } | |
70 | - | |
71 | - /** | |
72 | - * Get whether this event is cancellable or not | |
73 | - */ | |
74 | - public boolean isCancellable() | |
75 | - { | |
76 | - return this.cancellable; | |
77 | - } | |
78 | - | |
79 | - /** | |
80 | - * Get the event priority | |
81 | - */ | |
82 | - public int getPriority() | |
83 | - { | |
84 | - return this.priority; | |
85 | - } | |
86 | - | |
87 | - /** | |
88 | - * Get the list of listeners parsed from the JSON | |
89 | - */ | |
90 | - public List<MethodInfo> getListeners() | |
91 | - { | |
92 | - return this.listeners; | |
93 | - } | |
94 | - | |
95 | - /** | |
96 | - * Parse the JSON to initialise this object | |
97 | - */ | |
98 | - public void parse(JsonMethods methods) | |
99 | - { | |
100 | - this.parseInjectionPoints(methods); | |
101 | - this.parseListeners(methods); | |
102 | - } | |
103 | - | |
104 | - /** | |
105 | - * @param methods | |
106 | - */ | |
107 | - private void parseInjectionPoints(JsonMethods methods) | |
108 | - { | |
109 | - if (this.jsonInjections == null || this.jsonInjections.isEmpty()) | |
110 | - { | |
111 | - throw new InvalidEventJsonException("Event " + this.getName() + " does not have any defined injections"); | |
112 | - } | |
113 | - | |
114 | - for (JsonInjection injection : this.jsonInjections) | |
115 | - { | |
116 | - injection.parse(methods); | |
117 | - } | |
118 | - } | |
119 | - | |
120 | - /** | |
121 | - * @param methods | |
122 | - */ | |
123 | - private void parseListeners(JsonMethods methods) | |
124 | - { | |
125 | - if (this.jsonListeners == null || this.jsonListeners.isEmpty()) | |
126 | - { | |
127 | - throw new InvalidEventJsonException("Event " + this.getName() + " does not have any defined listeners"); | |
128 | - } | |
129 | - | |
130 | - for (String listener : this.jsonListeners) | |
131 | - { | |
132 | - this.listeners.add(methods.get(listener)); | |
133 | - } | |
134 | - } | |
135 | - | |
136 | - /** | |
137 | - * @param transformer Transformer to register events with | |
138 | - * @return Event which was registered | |
139 | - */ | |
140 | - public Event register(ModEventInjectionTransformer transformer) | |
141 | - { | |
142 | - Event event = Event.getOrCreate(this.getName(), this.isCancellable(), this.getPriority()); | |
143 | - | |
144 | - for (JsonInjection injection : this.jsonInjections) | |
145 | - { | |
146 | - MethodInfo targetMethod = injection.getMethod(); | |
147 | - InjectionPoint injectionPoint = injection.getInjectionPoint(); | |
148 | - | |
149 | - transformer.registerEvent(event, targetMethod, injectionPoint); | |
150 | - } | |
151 | - | |
152 | - for (MethodInfo listener : this.listeners) | |
153 | - { | |
154 | - event.addListener(listener); | |
155 | - } | |
156 | - | |
157 | - return event; | |
158 | - } | |
159 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonEvents.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | -import java.util.ArrayList; | |
5 | -import java.util.List; | |
6 | -import java.util.regex.Matcher; | |
7 | -import java.util.regex.Pattern; | |
8 | - | |
9 | -import com.google.gson.Gson; | |
10 | -import com.google.gson.GsonBuilder; | |
11 | -import com.google.gson.annotations.SerializedName; | |
12 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
13 | -import com.mumfrey.liteloader.transformers.ObfProvider; | |
14 | - | |
15 | -/** | |
16 | - * Serialisable class which represents a set of event injection definitions. Instances of this class are | |
17 | - * created by deserialising with JSON. The JSON string should be passed to the static {@link #parse} method | |
18 | - * which returns an instance of the class. | |
19 | - * | |
20 | - * After parsing, the events defined here can be injected into an event transformer instance by calling the | |
21 | - * {@link #register} method | |
22 | - * | |
23 | - * @author Adam Mummery-Smith | |
24 | - */ | |
25 | -public class JsonEvents implements Serializable, ObfProvider | |
26 | -{ | |
27 | - private static final long serialVersionUID = 1L; | |
28 | - | |
29 | - private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); | |
30 | - | |
31 | - /** | |
32 | - * Tokens are an instruction to the parser to look up a value rather than using a literal | |
33 | - */ | |
34 | - private static final Pattern tokenPattern = Pattern.compile("^\\$\\{([a-zA-Z0-9_\\-\\.\\$]+)\\}$"); | |
35 | - | |
36 | - /** | |
37 | - * Serialised obfusctation entries | |
38 | - */ | |
39 | - @SerializedName("obfuscation") | |
40 | - private JsonObfuscationTable obfuscation; | |
41 | - | |
42 | - /** | |
43 | - * Serialised method descriptors | |
44 | - */ | |
45 | - @SerializedName("descriptors") | |
46 | - private List<JsonDescriptor> descriptors; | |
47 | - | |
48 | - /** | |
49 | - * Serialised events | |
50 | - */ | |
51 | - @SerializedName("events") | |
52 | - private List<JsonEvent> events; | |
53 | - | |
54 | - /** | |
55 | - * List of accessor interfaces | |
56 | - */ | |
57 | - @SerializedName("accessors") | |
58 | - private List<String> accessors; | |
59 | - | |
60 | - /** | |
61 | - * Parsed method descriptors | |
62 | - */ | |
63 | - private transient JsonMethods methods; | |
64 | - | |
65 | - /** | |
66 | - * Parsed accessors | |
67 | - */ | |
68 | - private transient List<String> accessorInterfaces = new ArrayList<String>(); | |
69 | - | |
70 | - /** | |
71 | - * Attempts to parse the information in this object | |
72 | - */ | |
73 | - private void parse() | |
74 | - { | |
75 | - if (this.obfuscation == null) | |
76 | - { | |
77 | - this.obfuscation = new JsonObfuscationTable(); | |
78 | - } | |
79 | - | |
80 | - try | |
81 | - { | |
82 | - // Parse the obfuscation table | |
83 | - this.obfuscation.parse(); | |
84 | - | |
85 | - // Parse the descriptor list | |
86 | - this.methods = new JsonMethods(this.obfuscation, this.descriptors); | |
87 | - | |
88 | - if (this.events != null) | |
89 | - { | |
90 | - // Parse the events | |
91 | - for (JsonEvent event : this.events) | |
92 | - { | |
93 | - event.parse(this.methods); | |
94 | - } | |
95 | - } | |
96 | - | |
97 | - if (this.accessors != null) | |
98 | - { | |
99 | - for (String accessor : this.accessors) | |
100 | - { | |
101 | - if (accessor != null) | |
102 | - { | |
103 | - Obf accessorName = this.obfuscation.parseClass(accessor); | |
104 | - this.accessorInterfaces.add(accessorName.name); | |
105 | - } | |
106 | - } | |
107 | - } | |
108 | - } | |
109 | - catch (InvalidEventJsonException ex) | |
110 | - { | |
111 | - throw ex; | |
112 | - } | |
113 | - catch (Exception ex) | |
114 | - { | |
115 | - throw new InvalidEventJsonException("An error occurred whilst parsing the event definition: " + ex.getClass().getSimpleName() + ": " + ex.getMessage(), ex); | |
116 | - } | |
117 | - } | |
118 | - | |
119 | - public boolean hasAccessors() | |
120 | - { | |
121 | - return this.accessorInterfaces.size() > 0; | |
122 | - } | |
123 | - | |
124 | - /** | |
125 | - * Parse a token name, returns the token name as a string if the token is valid, or null if the token is not valid | |
126 | - * | |
127 | - * @param token | |
128 | - */ | |
129 | - static String parseToken(String token) | |
130 | - { | |
131 | - token = token.replace(" ", "").trim(); | |
132 | - | |
133 | - Matcher tokenPatternMatcher = JsonEvents.tokenPattern.matcher(token); | |
134 | - if (tokenPatternMatcher.matches()) | |
135 | - { | |
136 | - return tokenPatternMatcher.group(1); | |
137 | - } | |
138 | - | |
139 | - return null; | |
140 | - } | |
141 | - | |
142 | - /** | |
143 | - * Called to register all events defined in this object into the specified transformer | |
144 | - * | |
145 | - * @param transformer | |
146 | - */ | |
147 | - public void register(ModEventInjectionTransformer transformer) | |
148 | - { | |
149 | - for (JsonEvent event : this.events) | |
150 | - { | |
151 | - event.register(transformer); | |
152 | - } | |
153 | - | |
154 | - for (String interfaceName : this.accessorInterfaces) | |
155 | - { | |
156 | - transformer.registerAccessor(interfaceName, this); | |
157 | - } | |
158 | - } | |
159 | - | |
160 | - /* (non-Javadoc) | |
161 | - * @see com.mumfrey.liteloader.transformers.ObfProvider#getByName(java.lang.String) | |
162 | - */ | |
163 | - @Override | |
164 | - public Obf getByName(String name) | |
165 | - { | |
166 | - return this.obfuscation.getByName(name); | |
167 | - } | |
168 | - | |
169 | -// public String toJson() | |
170 | -// { | |
171 | -// return JsonEvents.gson.toJson(this); | |
172 | -// } | |
173 | - | |
174 | - /** | |
175 | - * Parse a new JsonEvents object from the supplied JSON string | |
176 | - * | |
177 | - * @param json | |
178 | - * @return new JsonEvents instance | |
179 | - * @throws InvalidEventJsonException if the JSON ins invalid | |
180 | - */ | |
181 | - public static JsonEvents parse(String json) throws InvalidEventJsonException | |
182 | - { | |
183 | - try | |
184 | - { | |
185 | - JsonEvents newJsonEvents = JsonEvents.gson.fromJson(json, JsonEvents.class); | |
186 | - newJsonEvents.parse(); | |
187 | - return newJsonEvents; | |
188 | - } | |
189 | - catch (InvalidEventJsonException ex) | |
190 | - { | |
191 | - throw ex; | |
192 | - } | |
193 | - catch (Throwable th) | |
194 | - { | |
195 | - throw new InvalidEventJsonException("An error occurred whilst parsing the event definition: " + th.getClass().getSimpleName() + ": " + th.getMessage(), th); | |
196 | - } | |
197 | - } | |
198 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonInjection.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | -import java.lang.reflect.Constructor; | |
5 | - | |
6 | -import com.google.gson.annotations.SerializedName; | |
7 | -import com.mumfrey.liteloader.transformers.event.InjectionPoint; | |
8 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
9 | -import com.mumfrey.liteloader.transformers.event.inject.BeforeInvoke; | |
10 | -import com.mumfrey.liteloader.transformers.event.inject.BeforeReturn; | |
11 | -import com.mumfrey.liteloader.transformers.event.inject.BeforeStringInvoke; | |
12 | -import com.mumfrey.liteloader.transformers.event.inject.MethodHead; | |
13 | - | |
14 | -/** | |
15 | - * A JSON injection point definition | |
16 | - * | |
17 | - * @author Adam Mummery-Smith | |
18 | - */ | |
19 | -public class JsonInjection implements Serializable | |
20 | -{ | |
21 | - private static final long serialVersionUID = 1L; | |
22 | - | |
23 | - /** | |
24 | - * Method to inject into | |
25 | - */ | |
26 | - @SerializedName("method") | |
27 | - private String methodName; | |
28 | - | |
29 | - /** | |
30 | - * Type of injection point | |
31 | - */ | |
32 | - @SerializedName("type") | |
33 | - private JsonInjectionType type; | |
34 | - | |
35 | - /** | |
36 | - * Shift type (optional) | |
37 | - */ | |
38 | - @SerializedName("shift") | |
39 | - private JsonInjectionShiftType shift; | |
40 | - | |
41 | - /** | |
42 | - * Target method to search for when using INVOKE and INVOKESTRING | |
43 | - */ | |
44 | - @SerializedName("target") | |
45 | - private String target; | |
46 | - | |
47 | - /** | |
48 | - * Ordinal to use when using INVOKE and INVOKESTRING | |
49 | - */ | |
50 | - @SerializedName("ordinal") | |
51 | - private int ordinal = -1; | |
52 | - | |
53 | - /** | |
54 | - * InjectionPoint class to use for CUSTOM | |
55 | - */ | |
56 | - @SerializedName("class") | |
57 | - private String className; | |
58 | - | |
59 | - /** | |
60 | - * Constructor arguments to pass wehn using CUSTOM | |
61 | - */ | |
62 | - @SerializedName("args") | |
63 | - private Object[] args; | |
64 | - | |
65 | - private transient MethodInfo method; | |
66 | - | |
67 | - private transient InjectionPoint injectionPoint; | |
68 | - | |
69 | - public MethodInfo getMethod() | |
70 | - { | |
71 | - return this.method; | |
72 | - } | |
73 | - | |
74 | - public InjectionPoint getInjectionPoint() | |
75 | - { | |
76 | - return this.injectionPoint; | |
77 | - } | |
78 | - | |
79 | - public void parse(JsonMethods methods) | |
80 | - { | |
81 | - this.method = this.parseMethod(methods); | |
82 | - this.injectionPoint = this.parseInjectionPoint(methods); | |
83 | - } | |
84 | - | |
85 | - private MethodInfo parseMethod(JsonMethods methods) | |
86 | - { | |
87 | - try | |
88 | - { | |
89 | - return methods.get(this.methodName); | |
90 | - } | |
91 | - catch (NullPointerException ex) | |
92 | - { | |
93 | - throw new InvalidEventJsonException("'method' must not be null for injection"); | |
94 | - } | |
95 | - } | |
96 | - | |
97 | - public InjectionPoint parseInjectionPoint(JsonMethods methods) | |
98 | - { | |
99 | - switch (this.type) | |
100 | - { | |
101 | - case INVOKE: | |
102 | - return this.applyShift(new BeforeInvoke(methods.get(this.getTarget()), this.ordinal)); | |
103 | - | |
104 | - case INVOKESTRING: | |
105 | - return this.applyShift(new BeforeStringInvoke(this.getArg(0).toString(), methods.get(this.getTarget()), this.ordinal)); | |
106 | - | |
107 | - case RETURN: | |
108 | - return this.applyShift(new BeforeReturn(this.ordinal)); | |
109 | - | |
110 | - case HEAD: | |
111 | - return new MethodHead(); | |
112 | - | |
113 | - case CUSTOM: | |
114 | - try | |
115 | - { | |
116 | - @SuppressWarnings("unchecked") | |
117 | - Class<InjectionPoint> injectionPointClass = (Class<InjectionPoint>)Class.forName(this.className); | |
118 | - if (this.args != null) | |
119 | - { | |
120 | - Constructor<InjectionPoint> ctor = injectionPointClass.getDeclaredConstructor(Object[].class); | |
121 | - return ctor.newInstance(this.args); | |
122 | - } | |
123 | - return injectionPointClass.newInstance(); | |
124 | - } | |
125 | - catch (Exception ex) | |
126 | - { | |
127 | - throw new RuntimeException(ex); | |
128 | - } | |
129 | - } | |
130 | - | |
131 | - throw new InvalidEventJsonException("Could not parse injection type"); | |
132 | - } | |
133 | - | |
134 | - private Object getArg(int arg) | |
135 | - { | |
136 | - if (this.args == null || this.args.length >= this.args.length || arg < 0) | |
137 | - return ""; | |
138 | - | |
139 | - return this.args[arg]; | |
140 | - } | |
141 | - | |
142 | - private String getTarget() | |
143 | - { | |
144 | - if (this.target != null && this.shift == null) | |
145 | - { | |
146 | - if (this.target.startsWith("before(") && this.target.endsWith(")")) | |
147 | - { | |
148 | - this.target = this.target.substring(7, this.target.length() - 1); | |
149 | - this.shift = JsonInjectionShiftType.BEFORE; | |
150 | - } | |
151 | - else if (this.target.startsWith("after(") && this.target.endsWith(")")) | |
152 | - { | |
153 | - this.target = this.target.substring(6, this.target.length() - 1); | |
154 | - this.shift = JsonInjectionShiftType.AFTER; | |
155 | - } | |
156 | - } | |
157 | - | |
158 | - if (this.target == null) | |
159 | - { | |
160 | - throw new InvalidEventJsonException("'target' is required for injection type " + this.type.name()); | |
161 | - } | |
162 | - | |
163 | - return this.target; | |
164 | - } | |
165 | - | |
166 | - private InjectionPoint applyShift(InjectionPoint injectionPoint) | |
167 | - { | |
168 | - if (this.shift != null) | |
169 | - { | |
170 | - switch (this.shift) | |
171 | - { | |
172 | - case AFTER: | |
173 | - return InjectionPoint.after(injectionPoint); | |
174 | - | |
175 | - case BEFORE: | |
176 | - return InjectionPoint.before(injectionPoint); | |
177 | - } | |
178 | - } | |
179 | - | |
180 | - return injectionPoint; | |
181 | - } | |
182 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonInjectionShiftType.java deleted
100644 → 0
java/common/com/mumfrey/liteloader/transformers/event/json/JsonMethods.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.util.HashMap; | |
4 | -import java.util.List; | |
5 | -import java.util.Map; | |
6 | - | |
7 | -import com.mumfrey.liteloader.core.runtime.Methods; | |
8 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
9 | - | |
10 | -/** | |
11 | - * A simple registry of MethodInfo objects parsed from the JSON, objects which consume the specified | |
12 | - * MethodInfo objects will be passed an instance of this object at parse time. | |
13 | - * | |
14 | - * @author Adam Mummery-Smith | |
15 | - */ | |
16 | -public class JsonMethods | |
17 | -{ | |
18 | - /** | |
19 | - * Serialised obfusctation entries | |
20 | - */ | |
21 | - private final JsonObfuscationTable obfuscation; | |
22 | - | |
23 | - /** | |
24 | - * Method descriptors | |
25 | - */ | |
26 | - private final List<JsonDescriptor> descriptors; | |
27 | - | |
28 | - /** | |
29 | - * Method descriptors which have been parsed from the descriptors collection | |
30 | - */ | |
31 | - private Map<String, MethodInfo> methods = new HashMap<String, MethodInfo>(); | |
32 | - | |
33 | - /** | |
34 | - * @param obfuscation | |
35 | - * @param descriptors | |
36 | - */ | |
37 | - public JsonMethods(JsonObfuscationTable obfuscation, List<JsonDescriptor> descriptors) | |
38 | - { | |
39 | - this.obfuscation = obfuscation; | |
40 | - this.descriptors = descriptors; | |
41 | - | |
42 | - this.parse(); | |
43 | - } | |
44 | - | |
45 | - /** | |
46 | - * | |
47 | - */ | |
48 | - private void parse() | |
49 | - { | |
50 | - if (this.descriptors != null) | |
51 | - { | |
52 | - for (JsonDescriptor descriptor : this.descriptors) | |
53 | - { | |
54 | - this.methods.put(descriptor.getKey(), descriptor.parse(this.obfuscation)); | |
55 | - } | |
56 | - } | |
57 | - } | |
58 | - | |
59 | - /** | |
60 | - * Fetches a method descriptor by token | |
61 | - * | |
62 | - * @param token | |
63 | - */ | |
64 | - public MethodInfo get(String token) | |
65 | - { | |
66 | - String key = JsonEvents.parseToken(token); | |
67 | - if (key == null) | |
68 | - { | |
69 | - throw new InvalidEventJsonException("\"" + token + "\" is not a valid token"); | |
70 | - } | |
71 | - | |
72 | - MethodInfo method = this.methods.get(key); | |
73 | - if (method != null) | |
74 | - { | |
75 | - return method; | |
76 | - } | |
77 | - | |
78 | - MethodInfo builtinMethod = Methods.getByName(key); | |
79 | - if (builtinMethod != null) | |
80 | - { | |
81 | - return builtinMethod; | |
82 | - } | |
83 | - | |
84 | - throw new InvalidEventJsonException("Could not locate method descriptor with token " + token); | |
85 | - } | |
86 | -} | |
87 | 0 | \ No newline at end of file |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonObf.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | -import java.util.UUID; | |
5 | - | |
6 | -import com.google.gson.annotations.SerializedName; | |
7 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
8 | - | |
9 | -public class JsonObf implements Serializable | |
10 | -{ | |
11 | - private static final long serialVersionUID = 1L; | |
12 | - | |
13 | - @SerializedName("id") | |
14 | - private String key; | |
15 | - | |
16 | - @SerializedName("mcp") | |
17 | - private String mcp; | |
18 | - | |
19 | - @SerializedName("srg") | |
20 | - private String srg; | |
21 | - | |
22 | - @SerializedName("obf") | |
23 | - private String obf; | |
24 | - | |
25 | - public String getKey() | |
26 | - { | |
27 | - if (this.key == null) | |
28 | - { | |
29 | - this.key = "UserObfuscationMapping" + UUID.randomUUID().toString(); | |
30 | - } | |
31 | - | |
32 | - return this.key; | |
33 | - } | |
34 | - | |
35 | - public Obf parse() | |
36 | - { | |
37 | - String seargeName = this.getFirstValidEntry(this.srg, this.mcp, this.obf, this.getKey()); | |
38 | - String obfName = this.getFirstValidEntry(this.obf, this.srg, this.mcp, this.getKey()); | |
39 | - String mcpName = this.getFirstValidEntry(this.mcp, this.srg, this.obf, this.getKey()); | |
40 | - | |
41 | - return new Mapping(seargeName, obfName, mcpName); | |
42 | - } | |
43 | - | |
44 | - private String getFirstValidEntry(String... entries) | |
45 | - { | |
46 | - for (String entry : entries) | |
47 | - { | |
48 | - if (entry != null) return entry; | |
49 | - } | |
50 | - | |
51 | - throw new InvalidEventJsonException("No valid entry found in list!"); | |
52 | - } | |
53 | - | |
54 | - public static class Mapping extends Obf | |
55 | - { | |
56 | - protected Mapping(String seargeName, String obfName, String mcpName) | |
57 | - { | |
58 | - super(seargeName, obfName, mcpName); | |
59 | - } | |
60 | - } | |
61 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/JsonObfuscationTable.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.Serializable; | |
4 | -import java.util.HashMap; | |
5 | -import java.util.List; | |
6 | -import java.util.Map; | |
7 | - | |
8 | -import com.google.gson.annotations.SerializedName; | |
9 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
10 | -import com.mumfrey.liteloader.core.runtime.Packets; | |
11 | - | |
12 | -/** | |
13 | - * JSON-defined obfuscation table entries used like a registry by the other JSON components to look up obfuscation mappings | |
14 | - * for methods and fields. | |
15 | - * | |
16 | - * @author Adam Mummery-Smith | |
17 | - */ | |
18 | -public class JsonObfuscationTable implements Serializable | |
19 | -{ | |
20 | - private static final long serialVersionUID = 1L; | |
21 | - | |
22 | - @SerializedName("classes") | |
23 | - private List<JsonObf> jsonClasses; | |
24 | - | |
25 | - @SerializedName("methods") | |
26 | - private List<JsonObf> jsonMethods; | |
27 | - | |
28 | - @SerializedName("fields") | |
29 | - private List<JsonObf> jsonFields; | |
30 | - | |
31 | - // Parsed values | |
32 | - private transient Map<String, Obf> classObfs = new HashMap<String, Obf>(); | |
33 | - private transient Map<String, Obf> methodObfs = new HashMap<String, Obf>(); | |
34 | - private transient Map<String, Obf> fieldObfs = new HashMap<String, Obf>(); | |
35 | - | |
36 | - /** | |
37 | - * Parse the entries in each collection to actual Obf objects | |
38 | - */ | |
39 | - public void parse() | |
40 | - { | |
41 | - if (this.jsonClasses != null) | |
42 | - { | |
43 | - for (JsonObf jsonClass : this.jsonClasses) | |
44 | - { | |
45 | - this.classObfs.put(jsonClass.getKey(), jsonClass.parse()); | |
46 | - } | |
47 | - } | |
48 | - | |
49 | - if (this.jsonMethods != null) | |
50 | - { | |
51 | - for (JsonObf jsonMethod : this.jsonMethods) | |
52 | - { | |
53 | - this.methodObfs.put(jsonMethod.getKey(), jsonMethod.parse()); | |
54 | - } | |
55 | - } | |
56 | - | |
57 | - if (this.jsonFields != null) | |
58 | - { | |
59 | - for (JsonObf jsonField : this.jsonFields) | |
60 | - { | |
61 | - this.fieldObfs.put(jsonField.getKey(), jsonField.parse()); | |
62 | - } | |
63 | - } | |
64 | - } | |
65 | - | |
66 | - /** | |
67 | - * Look up a type (a class or primitive type) by token | |
68 | - */ | |
69 | - public Object parseType(String token) | |
70 | - { | |
71 | - token = token.replace(" ", "").trim(); | |
72 | - | |
73 | - if ("I".equals(token) || "INT".equals(token)) return Integer.TYPE; | |
74 | - if ("J".equals(token) || "LONG".equals(token)) return Long.TYPE; | |
75 | - if ("V".equals(token) || "VOID".equals(token)) return Void.TYPE; | |
76 | - if ("Z".equals(token) || "BOOLEAN".equals(token) || "BOOL".equals(token)) return Boolean.TYPE; | |
77 | - if ("B".equals(token) || "BYTE".equals(token)) return Byte.TYPE; | |
78 | - if ("C".equals(token) || "CHAR".equals(token)) return Character.TYPE; | |
79 | - if ("S".equals(token) || "SHORT".equals(token)) return Short.TYPE; | |
80 | - if ("D".equals(token) || "DOUBLE".equals(token)) return Double.TYPE; | |
81 | - if ("F".equals(token) || "FLOAT".equals(token)) return Float.TYPE; | |
82 | - if ("STRING".equals(token)) return String.class; | |
83 | - | |
84 | - if (token.startsWith("L") && token.endsWith(";")) | |
85 | - { | |
86 | - token = token.substring(1, token.length() - 1).replace('/', '.'); | |
87 | - } | |
88 | - | |
89 | - return this.parseClass(token); | |
90 | - } | |
91 | - | |
92 | - /** | |
93 | - * Find an obf entry of any type by name | |
94 | - * | |
95 | - * @param name | |
96 | - */ | |
97 | - public Obf getByName(String name) | |
98 | - { | |
99 | - Obf classObf = this.classObfs.get(name); | |
100 | - if (classObf != null) | |
101 | - { | |
102 | - return classObf; | |
103 | - } | |
104 | - | |
105 | - Obf methodObf = this.methodObfs.get(name); | |
106 | - if (methodObf != null) | |
107 | - { | |
108 | - return methodObf; | |
109 | - } | |
110 | - | |
111 | - Obf fieldObf = this.fieldObfs.get(name); | |
112 | - if (fieldObf != null) | |
113 | - { | |
114 | - return fieldObf; | |
115 | - } | |
116 | - | |
117 | - return null; | |
118 | - } | |
119 | - | |
120 | - /** | |
121 | - * @param token | |
122 | - */ | |
123 | - public Obf parseClass(String token) | |
124 | - { | |
125 | - return this.parseObf(token, this.classObfs, false); | |
126 | - } | |
127 | - | |
128 | - /** | |
129 | - * @param token | |
130 | - */ | |
131 | - public Obf parseMethod(String token) | |
132 | - { | |
133 | - return this.parseObf(token, this.methodObfs, false); | |
134 | - } | |
135 | - | |
136 | - /** | |
137 | - * @param token | |
138 | - */ | |
139 | - public Obf parseField(String token) | |
140 | - { | |
141 | - return this.parseObf(token, this.fieldObfs, false); | |
142 | - } | |
143 | - | |
144 | - /** | |
145 | - * @param token | |
146 | - * @param obfs | |
147 | - * @param returnNullOnFailure return null instead of throwing an exception | |
148 | - */ | |
149 | - private Obf parseObf(String token, Map<String, Obf> obfs, boolean returnNullOnFailure) | |
150 | - { | |
151 | - String key = JsonEvents.parseToken(token); | |
152 | - | |
153 | - if (key != null) | |
154 | - { | |
155 | - if (obfs.containsKey(key)) | |
156 | - { | |
157 | - return obfs.get(key); | |
158 | - } | |
159 | - | |
160 | - Obf obf = Obf.getByName(key); | |
161 | - if (obf != null) | |
162 | - { | |
163 | - return obf; | |
164 | - } | |
165 | - | |
166 | - Packets packet = Packets.getByName(key); | |
167 | - if (packet != null) | |
168 | - { | |
169 | - return packet; | |
170 | - } | |
171 | - | |
172 | - if (returnNullOnFailure) | |
173 | - { | |
174 | - return null; | |
175 | - } | |
176 | - | |
177 | - throw new InvalidEventJsonException("The token " + token + " could not be resolved to a type"); | |
178 | - } | |
179 | - | |
180 | - return new JsonObf.Mapping(token, token, token); | |
181 | - } | |
182 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import com.mumfrey.liteloader.transformers.ClassTransformer; | |
4 | -import com.mumfrey.liteloader.transformers.ObfProvider; | |
5 | -import com.mumfrey.liteloader.transformers.event.Event; | |
6 | -import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer; | |
7 | -import com.mumfrey.liteloader.transformers.event.InjectionPoint; | |
8 | -import com.mumfrey.liteloader.transformers.event.MethodInfo; | |
9 | -import com.mumfrey.liteloader.transformers.event.json.ModEvents.ModEventDefinition; | |
10 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | |
11 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; | |
12 | - | |
13 | -/** | |
14 | - * Event transformer which manages injections of mod events specified via events.json in the mod container | |
15 | - * | |
16 | - * @author Adam Mummery-Smith | |
17 | - */ | |
18 | -public class ModEventInjectionTransformer extends EventInjectionTransformer | |
19 | -{ | |
20 | - @Override | |
21 | - protected void addEvents() | |
22 | - { | |
23 | - for (ModEventDefinition eventsDefinition : ModEvents.getEvents().values()) | |
24 | - { | |
25 | - this.addEvents(eventsDefinition); | |
26 | - } | |
27 | - } | |
28 | - | |
29 | - /** | |
30 | - * @param identifier | |
31 | - * @param json | |
32 | - */ | |
33 | - private void addEvents(ModEventDefinition def) | |
34 | - { | |
35 | - JsonEvents events = null; | |
36 | - | |
37 | - try | |
38 | - { | |
39 | - LiteLoaderLogger.info("Parsing events for mod with id %s", def.getIdentifier()); | |
40 | - events = JsonEvents.parse(def.getJson()); | |
41 | - } | |
42 | - catch (InvalidEventJsonException ex) | |
43 | - { | |
44 | - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); | |
45 | - LiteLoaderLogger.debug(ex.getMessage()); | |
46 | - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); | |
47 | - LiteLoaderLogger.debug(def.getJson()); | |
48 | - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); | |
49 | - LiteLoaderLogger.severe(ex, "Invalid JSON event declarations for mod with id %s", def.getIdentifier()); | |
50 | - } | |
51 | - catch (Throwable ex) | |
52 | - { | |
53 | - LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", def.getIdentifier()); | |
54 | - } | |
55 | - | |
56 | - try | |
57 | - { | |
58 | - if (events != null) | |
59 | - { | |
60 | - if (events.hasAccessors()) | |
61 | - { | |
62 | - LiteLoaderLogger.info("%s contains Accessor definitions, injecting into classpath...", def.getIdentifier()); | |
63 | - def.injectIntoClassPath(); | |
64 | - } | |
65 | - | |
66 | - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering events for mod with id %s", def.getIdentifier()); | |
67 | - events.register(this); | |
68 | - def.onEventsInjected(); | |
69 | - } | |
70 | - } | |
71 | - catch (Throwable ex) | |
72 | - { | |
73 | - LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", def.getIdentifier()); | |
74 | - } | |
75 | - } | |
76 | - | |
77 | - protected Event registerEvent(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint) | |
78 | - { | |
79 | - return super.addEvent(event, targetMethod, injectionPoint); | |
80 | - } | |
81 | - | |
82 | - protected void registerAccessor(String interfaceName, ObfProvider obfProvider) | |
83 | - { | |
84 | - super.addAccessor(interfaceName, obfProvider); | |
85 | - } | |
86 | -} |
java/common/com/mumfrey/liteloader/transformers/event/json/ModEvents.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.transformers.event.json; | |
2 | - | |
3 | -import java.io.File; | |
4 | -import java.net.MalformedURLException; | |
5 | -import java.util.HashMap; | |
6 | -import java.util.Map; | |
7 | - | |
8 | -import net.minecraft.launchwrapper.Launch; | |
9 | - | |
10 | -import com.google.common.base.Charsets; | |
11 | -import com.mumfrey.liteloader.api.ContainerRegistry.DisabledReason; | |
12 | -import com.mumfrey.liteloader.api.EnumerationObserver; | |
13 | -import com.mumfrey.liteloader.core.ModInfo; | |
14 | -import com.mumfrey.liteloader.core.api.LoadableModFile; | |
15 | -import com.mumfrey.liteloader.interfaces.LoadableMod; | |
16 | -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; | |
17 | -import com.mumfrey.liteloader.interfaces.TweakContainer; | |
18 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | |
19 | - | |
20 | -public class ModEvents implements EnumerationObserver | |
21 | -{ | |
22 | - public static class ModEventDefinition | |
23 | - { | |
24 | - private final LoadableModFile file; | |
25 | - | |
26 | - private final String identifier; | |
27 | - | |
28 | - private final String json; | |
29 | - | |
30 | - public ModEventDefinition(LoadableModFile file, String json) | |
31 | - { | |
32 | - this.file = file; | |
33 | - this.identifier = file.getIdentifier(); | |
34 | - this.json = json; | |
35 | - } | |
36 | - | |
37 | - public String getIdentifier() | |
38 | - { | |
39 | - return this.identifier; | |
40 | - } | |
41 | - | |
42 | - public String getJson() | |
43 | - { | |
44 | - return this.json; | |
45 | - } | |
46 | - | |
47 | - public void onEventsInjected() | |
48 | - { | |
49 | - this.file.onEventsInjected(); | |
50 | - } | |
51 | - | |
52 | - public void injectIntoClassPath() | |
53 | - { | |
54 | - try | |
55 | - { | |
56 | - this.file.injectIntoClassPath(Launch.classLoader, true); | |
57 | - } | |
58 | - catch (MalformedURLException ex) | |
59 | - { | |
60 | - ex.printStackTrace(); | |
61 | - } | |
62 | - } | |
63 | - } | |
64 | - | |
65 | - private static final String DEFINITION_FILENAME = "events.json"; | |
66 | - | |
67 | - private static Map<String, ModEventDefinition> events = new HashMap<String, ModEventDefinition>(); | |
68 | - | |
69 | - @Override | |
70 | - public void onRegisterEnabledContainer(LoaderEnumerator enumerator, LoadableMod<?> container) | |
71 | - { | |
72 | - if (container instanceof LoadableModFile) | |
73 | - { | |
74 | - LoadableModFile file = (LoadableModFile)container; | |
75 | - if (!file.exists()) return; | |
76 | - | |
77 | - String json = file.getFileContents(ModEvents.DEFINITION_FILENAME, Charsets.UTF_8); | |
78 | - if (json == null) return; | |
79 | - | |
80 | - LiteLoaderLogger.info("Registering %s for mod with id %s", ModEvents.DEFINITION_FILENAME, file.getIdentifier()); | |
81 | - ModEvents.events.put(file.getIdentifier(), new ModEventDefinition(file, json)); | |
82 | - } | |
83 | - } | |
84 | - | |
85 | - @Override | |
86 | - public void onRegisterDisabledContainer(LoaderEnumerator enumerator, LoadableMod<?> container, DisabledReason reason) | |
87 | - { | |
88 | - } | |
89 | - | |
90 | - @Override | |
91 | - public void onRegisterTweakContainer(LoaderEnumerator enumerator, TweakContainer<File> container) | |
92 | - { | |
93 | - } | |
94 | - | |
95 | - @Override | |
96 | - public void onModAdded(LoaderEnumerator enumerator, ModInfo<LoadableMod<?>> mod) | |
97 | - { | |
98 | - } | |
99 | - | |
100 | - static Map<String, ModEventDefinition> getEvents() | |
101 | - { | |
102 | - return events; | |
103 | - } | |
104 | -} |
java/common/com/mumfrey/liteloader/util/ChatUtilities.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import java.util.List; | |
4 | - | |
5 | -import net.minecraft.util.ChatComponentText; | |
6 | -import net.minecraft.util.ChatStyle; | |
7 | -import net.minecraft.util.EnumChatFormatting; | |
8 | -import net.minecraft.util.IChatComponent; | |
9 | - | |
10 | -/** | |
11 | - * Utility functions for chat | |
12 | - * | |
13 | - * @author Adam Mummery-Smith | |
14 | - */ | |
15 | -public abstract class ChatUtilities | |
16 | -{ | |
17 | - private static String formattingCodeLookup; | |
18 | - | |
19 | - static | |
20 | - { | |
21 | - StringBuilder formattingCodes = new StringBuilder(); | |
22 | - | |
23 | - for (EnumChatFormatting chatFormat : EnumChatFormatting.values()) | |
24 | - { | |
25 | - formattingCodes.append(chatFormat.toString().charAt(1)); | |
26 | - } | |
27 | - | |
28 | - ChatUtilities.formattingCodeLookup = formattingCodes.toString(); | |
29 | - } | |
30 | - | |
31 | - private ChatUtilities() {} | |
32 | - | |
33 | - /** | |
34 | - * Get a chat style from a legacy formatting code | |
35 | - * | |
36 | - * @param code Code | |
37 | - * @return | |
38 | - */ | |
39 | - public static ChatStyle getChatStyleFromCode(char code) | |
40 | - { | |
41 | - int pos = ChatUtilities.formattingCodeLookup.indexOf(code); | |
42 | - if (pos < 0) return null; | |
43 | - EnumChatFormatting format = EnumChatFormatting.values()[pos]; | |
44 | - | |
45 | - ChatStyle style = new ChatStyle(); | |
46 | - if (format.isColor()) | |
47 | - { | |
48 | - style.setColor(format); | |
49 | - } | |
50 | - else if (format.isFancyStyling()) | |
51 | - { | |
52 | - switch (format) | |
53 | - { | |
54 | - case BOLD: style.setBold(true); break; | |
55 | - case ITALIC: style.setItalic(true); break; | |
56 | - case STRIKETHROUGH: style.setStrikethrough(true); break; | |
57 | - case UNDERLINE: style.setUnderlined(true); break; | |
58 | - case OBFUSCATED: style.setObfuscated(true); break; | |
59 | - } | |
60 | - } | |
61 | - | |
62 | - return style; | |
63 | - } | |
64 | - | |
65 | - /** | |
66 | - * Convert a component containing text formatted with legacy codes to a native ChatComponent structure | |
67 | - */ | |
68 | - public static IChatComponent convertLegacyCodes(IChatComponent chat) | |
69 | - { | |
70 | - return ChatUtilities.covertCodesInPlace(chat); | |
71 | - } | |
72 | - | |
73 | - private static List<IChatComponent> covertCodesInPlace(List<IChatComponent> siblings) | |
74 | - { | |
75 | - for (int index = 0; index < siblings.size(); index++) | |
76 | - { | |
77 | - siblings.set(index, ChatUtilities.covertCodesInPlace(siblings.get(index))); | |
78 | - } | |
79 | - | |
80 | - return siblings; | |
81 | - } | |
82 | - | |
83 | - @SuppressWarnings("unchecked") | |
84 | - private static IChatComponent covertCodesInPlace(IChatComponent component) | |
85 | - { | |
86 | - IChatComponent newComponent = null; | |
87 | - if (component instanceof ChatComponentText) | |
88 | - { | |
89 | - ChatComponentText textComponent = (ChatComponentText)component; | |
90 | - ChatStyle style = textComponent.getChatStyle(); | |
91 | - String text = textComponent.getChatComponentText_TextValue(); | |
92 | - | |
93 | - int pos = text.indexOf('\247'); | |
94 | - while (pos > -1 && text != null) | |
95 | - { | |
96 | - if (pos < text.length() - 1) | |
97 | - { | |
98 | - IChatComponent head = new ChatComponentText(pos > 0 ? text.substring(0, pos) : "").setChatStyle(style); | |
99 | - style = ChatUtilities.getChatStyleFromCode(text.charAt(pos + 1)); | |
100 | - text = text.substring(pos + 2); | |
101 | - newComponent = (newComponent == null) ? head : newComponent.appendSibling(head); | |
102 | - pos = text.indexOf('\247'); | |
103 | - } | |
104 | - else | |
105 | - { | |
106 | - text = null; | |
107 | - } | |
108 | - } | |
109 | - | |
110 | - if (text != null) | |
111 | - { | |
112 | - IChatComponent tail = new ChatComponentText(text).setChatStyle(style); | |
113 | - newComponent = (newComponent == null) ? tail : newComponent.appendSibling(tail); | |
114 | - } | |
115 | - } | |
116 | - | |
117 | - if (newComponent == null) | |
118 | - { | |
119 | - ChatUtilities.covertCodesInPlace(component.getSiblings()); | |
120 | - return component; | |
121 | - } | |
122 | - | |
123 | - for (IChatComponent oldSibling : ChatUtilities.covertCodesInPlace(component.getSiblings())) | |
124 | - { | |
125 | - newComponent.appendSibling(oldSibling); | |
126 | - } | |
127 | - | |
128 | - return newComponent; | |
129 | - } | |
130 | -} |
java/common/com/mumfrey/liteloader/util/EntityUtilities.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import net.minecraft.entity.Entity; | |
4 | -import net.minecraft.util.MovingObjectPosition; | |
5 | -import net.minecraft.util.Vec3; | |
6 | - | |
7 | -public abstract class EntityUtilities | |
8 | -{ | |
9 | - public static MovingObjectPosition rayTraceFromEntity(Entity entity, double traceDistance, float partialTicks) | |
10 | - { | |
11 | - Vec3 var4 = EntityUtilities.getPositionEyes(entity, partialTicks); | |
12 | - Vec3 var5 = entity.getLook(partialTicks); | |
13 | - Vec3 var6 = var4.addVector(var5.xCoord * traceDistance, var5.yCoord * traceDistance, var5.zCoord * traceDistance); | |
14 | - return entity.worldObj.rayTraceBlocks(var4, var6, false, false, true); | |
15 | - } | |
16 | - | |
17 | - public static Vec3 getPositionEyes(Entity entity, float partialTicks) | |
18 | - { | |
19 | - if (partialTicks == 1.0F) | |
20 | - { | |
21 | - return new Vec3(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ); | |
22 | - } | |
23 | - | |
24 | - double interpX = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks; | |
25 | - double interpY = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks + entity.getEyeHeight(); | |
26 | - double interpZ = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks; | |
27 | - return new Vec3(interpX, interpY, interpZ); | |
28 | - } | |
29 | -} |
java/common/com/mumfrey/liteloader/util/Input.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import net.minecraft.client.settings.KeyBinding; | |
4 | -import net.minecraft.network.INetHandler; | |
5 | -import net.minecraft.network.play.server.S01PacketJoinGame; | |
6 | -import net.minecraft.world.World; | |
7 | - | |
8 | -import com.mumfrey.liteloader.api.CoreProvider; | |
9 | -import com.mumfrey.liteloader.core.LiteLoaderMods; | |
10 | -import com.mumfrey.liteloader.util.jinput.ComponentRegistry; | |
11 | - | |
12 | -public abstract class Input implements CoreProvider | |
13 | -{ | |
14 | - /** | |
15 | - * Register a key for a mod | |
16 | - * | |
17 | - * @param binding | |
18 | - */ | |
19 | - public abstract void registerKeyBinding(KeyBinding binding); | |
20 | - | |
21 | - /** | |
22 | - * Unregisters a registered keybind with the game settings class, thus removing it from the "controls" screen | |
23 | - * | |
24 | - * @param binding | |
25 | - */ | |
26 | - public abstract void unRegisterKeyBinding(KeyBinding binding); | |
27 | - | |
28 | - /** | |
29 | - * Writes mod bindings to disk | |
30 | - */ | |
31 | - public abstract void storeBindings(); | |
32 | - | |
33 | - /** | |
34 | - * Gets the underlying JInput component registry | |
35 | - */ | |
36 | - public abstract ComponentRegistry getComponentRegistry(); | |
37 | - | |
38 | - /** | |
39 | - * Returns a handle to the event described by descriptor (or null if no component is found matching the | |
40 | - * descriptor. Retrieving an event via this method adds the controller (if found) to the polling list and | |
41 | - * causes it to raise events against the specified handler. | |
42 | - * | |
43 | - * This method returns an {@link InputEvent} which is passed as an argument to the relevant callback on | |
44 | - * the supplied handler in order to identify the event. For example: | |
45 | - * | |
46 | - * this.joystickButton = input.getEvent(descriptor, this); | |
47 | - * | |
48 | - * then in onAxisEvent | |
49 | - * | |
50 | - * if (source == this.joystickButton) // do something with button | |
51 | - * | |
52 | - * @param descriptor | |
53 | - * @param handler | |
54 | - */ | |
55 | - public abstract InputEvent getEvent(String descriptor, InputHandler handler); | |
56 | - | |
57 | - /** | |
58 | - * Get events for all components which match the supplied descriptor | |
59 | - * | |
60 | - * @param descriptor | |
61 | - * @param handler | |
62 | - */ | |
63 | - public abstract InputEvent[] getEvents(String descriptor, InputHandler handler); | |
64 | - | |
65 | - @Override | |
66 | - public void onPostInitComplete(LiteLoaderMods mods) | |
67 | - { | |
68 | - } | |
69 | - | |
70 | - @Override | |
71 | - public void onStartupComplete() | |
72 | - { | |
73 | - } | |
74 | - | |
75 | - @Override | |
76 | - public void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) | |
77 | - { | |
78 | - } | |
79 | - | |
80 | - @Override | |
81 | - public void onWorldChanged(World world) | |
82 | - { | |
83 | - } | |
84 | - | |
85 | - @Override | |
86 | - public void onPostRender(int mouseX, int mouseY, float partialTicks) | |
87 | - { | |
88 | - } | |
89 | -} | |
90 | 0 | \ No newline at end of file |
java/common/com/mumfrey/liteloader/util/InputEvent.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import net.java.games.input.Component; | |
4 | -import net.java.games.input.Controller; | |
5 | -import net.java.games.input.Event; | |
6 | - | |
7 | -/** | |
8 | - * A handle to an input event, this handle will be used to call back the handler for the specified | |
9 | - * component's events. This class represents a singly-linked list of delegates with each delegate's | |
10 | - * next field pointing to the next delegate in the chain | |
11 | - * | |
12 | - * @author Adam Mummery-Smith | |
13 | - */ | |
14 | -public class InputEvent | |
15 | -{ | |
16 | - /** | |
17 | - * Controller this event is delegating events for | |
18 | - */ | |
19 | - private final Controller controller; | |
20 | - | |
21 | - /** | |
22 | - * Component this event is delegating events for | |
23 | - */ | |
24 | - private final Component component; | |
25 | - | |
26 | - /** | |
27 | - * Event handler | |
28 | - */ | |
29 | - private final InputHandler handler; | |
30 | - | |
31 | - /** | |
32 | - * Next event handler in the chain | |
33 | - */ | |
34 | - private InputEvent next; | |
35 | - | |
36 | - /** | |
37 | - * @param controller | |
38 | - * @param component | |
39 | - * @param handler | |
40 | - */ | |
41 | - InputEvent(Controller controller, Component component, InputHandler handler) | |
42 | - { | |
43 | - this.controller = controller; | |
44 | - this.component = component; | |
45 | - this.handler = handler; | |
46 | - } | |
47 | - | |
48 | - /** | |
49 | - * Link this delegate to the specified delegate and return the start of the delegate chain | |
50 | - * | |
51 | - * @param chain delegate to link to (will be null if the chain is empty) | |
52 | - */ | |
53 | - InputEvent link(InputEvent chain) | |
54 | - { | |
55 | - if (chain == null) return this; // Chain is empty, return self | |
56 | - return chain.append(this); // Append self to the start of the chain | |
57 | - } | |
58 | - | |
59 | - /** | |
60 | - * Append specified delegate to the end of the delegate chain | |
61 | - * | |
62 | - * @param delegate | |
63 | - */ | |
64 | - private InputEvent append(InputEvent delegate) | |
65 | - { | |
66 | - InputEvent tail = this; // Start here | |
67 | - | |
68 | - while (tail.next != null) // Find the end of the chain | |
69 | - tail = tail.next; | |
70 | - | |
71 | - tail.next = delegate; // Append the new delegate | |
72 | - return this; // Return the start of the delegate chain (eg. this node) | |
73 | - } | |
74 | - | |
75 | - /** | |
76 | - * @param event | |
77 | - */ | |
78 | - void onEvent(Event event) | |
79 | - { | |
80 | - if (this.component.isAnalog()) | |
81 | - { | |
82 | - this.onAxisEvent(event.getValue(), event.getNanos()); | |
83 | - } | |
84 | - else if (this.component.getIdentifier() == Component.Identifier.Axis.POV) | |
85 | - { | |
86 | - this.onPovEvent(event.getValue(), event.getNanos()); | |
87 | - } | |
88 | - else | |
89 | - { | |
90 | - this.onButtonEvent(event.getValue() == 1.0F); | |
91 | - } | |
92 | - } | |
93 | - | |
94 | - /** | |
95 | - * @param value | |
96 | - * @param nanos | |
97 | - */ | |
98 | - private void onAxisEvent(float value, long nanos) | |
99 | - { | |
100 | - this.handler.onAxisEvent(this, value, nanos); | |
101 | - if (this.next != null) this.next.onAxisEvent(value, nanos); | |
102 | - } | |
103 | - | |
104 | - /** | |
105 | - * @param value | |
106 | - * @param nanos | |
107 | - */ | |
108 | - private void onPovEvent(float value, long nanos) | |
109 | - { | |
110 | - this.handler.onPovEvent(this, value, nanos); | |
111 | - if (this.next != null) this.next.onPovEvent(value, nanos); | |
112 | - } | |
113 | - | |
114 | - /** | |
115 | - * @param pressed | |
116 | - */ | |
117 | - private void onButtonEvent(boolean pressed) | |
118 | - { | |
119 | - this.handler.onButtonEvent(this, pressed); | |
120 | - if (this.next != null) this.next.onButtonEvent(pressed); | |
121 | - } | |
122 | - | |
123 | - public Controller getController() | |
124 | - { | |
125 | - return this.controller; | |
126 | - } | |
127 | - | |
128 | - public Component getComponent() | |
129 | - { | |
130 | - return this.component; | |
131 | - } | |
132 | -} |
java/common/com/mumfrey/liteloader/util/InputHandler.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -/** | |
4 | - * Interface for objects which handle JInput events | |
5 | - * | |
6 | - * @author Adam Mummery-Smith | |
7 | - */ | |
8 | -public interface InputHandler | |
9 | -{ | |
10 | - /** | |
11 | - * Called when an analogue (axis) event is raised on the specified component | |
12 | - * | |
13 | - * @param source | |
14 | - * @param nanos | |
15 | - * @param value | |
16 | - */ | |
17 | - void onAxisEvent(InputEvent source, float value, long nanos); | |
18 | - | |
19 | - /** | |
20 | - * Called when a POV (Point-Of-View) event is raised on the specified component | |
21 | - * | |
22 | - * @param source | |
23 | - * @param value | |
24 | - * @param nanos | |
25 | - */ | |
26 | - void onPovEvent(InputEvent source, float value, long nanos); | |
27 | - | |
28 | - /** | |
29 | - * Called when a button event is raised on the specified component | |
30 | - * | |
31 | - * @param source | |
32 | - * @param value | |
33 | - */ | |
34 | - void onButtonEvent(InputEvent source, boolean value); | |
35 | -} |
java/common/com/mumfrey/liteloader/util/ObfuscationUtilities.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import net.minecraft.launchwrapper.IClassTransformer; | |
4 | -import net.minecraft.launchwrapper.Launch; | |
5 | -import net.minecraft.server.MinecraftServer; | |
6 | -import net.minecraft.util.BlockPos; | |
7 | - | |
8 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
9 | - | |
10 | -public class ObfuscationUtilities | |
11 | -{ | |
12 | - /** | |
13 | - * True if FML is being used, in which case we use searge names instead of raw field/method names | |
14 | - */ | |
15 | - private static boolean fmlDetected = false; | |
16 | - | |
17 | - private static boolean seargeNames = false; | |
18 | - | |
19 | - static | |
20 | - { | |
21 | - // Check for FML | |
22 | - ObfuscationUtilities.fmlDetected = ObfuscationUtilities.fmlIsPresent(); | |
23 | - | |
24 | - try | |
25 | - { | |
26 | - MinecraftServer.class.getDeclaredField("serverRunning"); | |
27 | - } | |
28 | - catch (SecurityException ex) | |
29 | - { | |
30 | - } | |
31 | - catch (NoSuchFieldException ex) | |
32 | - { | |
33 | - ObfuscationUtilities.seargeNames = true; | |
34 | - } | |
35 | - } | |
36 | - | |
37 | - public static boolean fmlIsPresent() | |
38 | - { | |
39 | - for (IClassTransformer transformer : Launch.classLoader.getTransformers()) | |
40 | - if (transformer.getClass().getName().contains("fml")) return true; | |
41 | - | |
42 | - return false; | |
43 | - } | |
44 | - | |
45 | - /** | |
46 | - * Abstraction helper function | |
47 | - * | |
48 | - * @param fieldName Name of field to get, returned unmodified if in debug mode | |
49 | - * @return Obfuscated field name if present | |
50 | - */ | |
51 | - public static String getObfuscatedFieldName(String fieldName, String obfuscatedFieldName, String seargeFieldName) | |
52 | - { | |
53 | - boolean deobfuscated = BlockPos.class.getSimpleName().equals("BlockPos"); | |
54 | - return deobfuscated ? (ObfuscationUtilities.seargeNames ? seargeFieldName : fieldName) : (ObfuscationUtilities.fmlDetected ? seargeFieldName : obfuscatedFieldName); | |
55 | - } | |
56 | - | |
57 | - /** | |
58 | - * Abstraction helper function | |
59 | - * | |
60 | - * @param obf Field to get, returned unmodified if in debug mode | |
61 | - * @return Obfuscated field name if present | |
62 | - */ | |
63 | - public static String getObfuscatedFieldName(Obf obf) | |
64 | - { | |
65 | - boolean deobfuscated = BlockPos.class.getSimpleName().equals("BlockPos"); | |
66 | - return deobfuscated ? (ObfuscationUtilities.seargeNames ? obf.srg : obf.name) : (ObfuscationUtilities.fmlDetected ? obf.srg : obf.obf); | |
67 | - } | |
68 | -} |
java/common/com/mumfrey/liteloader/util/Position.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import net.minecraft.entity.Entity; | |
4 | -import net.minecraft.util.Vec3; | |
5 | - | |
6 | -/** | |
7 | - * A 3D vector position with rotation as well | |
8 | - * | |
9 | - * @author Adam Mummery-Smith | |
10 | - */ | |
11 | -public class Position extends Vec3 | |
12 | -{ | |
13 | - public final float yaw; | |
14 | - | |
15 | - public final float pitch; | |
16 | - | |
17 | - public Position(double x, double y, double z) | |
18 | - { | |
19 | - this(x, y, z, 0.0F, 0.0F); | |
20 | - } | |
21 | - | |
22 | - public Position(double x, double y, double z, float yaw, float pitch) | |
23 | - { | |
24 | - super(x, y, z); | |
25 | - | |
26 | - this.yaw = yaw; | |
27 | - this.pitch = pitch; | |
28 | - } | |
29 | - | |
30 | - public Position(Entity entity) | |
31 | - { | |
32 | - this(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); | |
33 | - } | |
34 | - | |
35 | - public Position(Entity entity, boolean usePrevious) | |
36 | - { | |
37 | - this(usePrevious ? entity.prevPosX : entity.posX, usePrevious ? entity.prevPosY : entity.posY, usePrevious ? entity.prevPosZ : entity.posZ, usePrevious ? entity.prevRotationYaw : entity.rotationYaw, usePrevious ? entity.prevRotationPitch : entity.rotationPitch); | |
38 | - } | |
39 | - | |
40 | - public void applyTo(Entity entity) | |
41 | - { | |
42 | - entity.posX = this.xCoord; | |
43 | - entity.posY = this.yCoord; | |
44 | - entity.posZ = this.zCoord; | |
45 | - entity.rotationYaw = this.yaw; | |
46 | - entity.rotationPitch = this.pitch; | |
47 | - } | |
48 | - | |
49 | - @Override | |
50 | - public String toString() | |
51 | - { | |
52 | - return "(" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ", " + this.yaw + ", " + this.pitch + ")"; | |
53 | - } | |
54 | -} |
java/common/com/mumfrey/liteloader/util/PrivateFields.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -import java.lang.reflect.Field; | |
4 | -import java.lang.reflect.Modifier; | |
5 | - | |
6 | -import net.minecraft.network.play.client.C15PacketClientSettings; | |
7 | - | |
8 | -import com.mumfrey.liteloader.core.runtime.Obf; | |
9 | - | |
10 | -/** | |
11 | - * Wrapper for obf/mcp reflection-accessed private fields, mainly added to centralise the locations I have to update the obfuscated field names | |
12 | - * | |
13 | - * @author Adam Mummery-Smith | |
14 | - * | |
15 | - * @param <P> Parent class type, the type of the class that owns the field | |
16 | - * @param <T> Field type, the type of the field value | |
17 | - */ | |
18 | -public class PrivateFields<P, T> | |
19 | -{ | |
20 | - /** | |
21 | - * Class to which this field belongs | |
22 | - */ | |
23 | - public final Class<P> parentClass; | |
24 | - | |
25 | - /** | |
26 | - * Name used to access the field, determined at init | |
27 | - */ | |
28 | - private final String fieldName; | |
29 | - | |
30 | - private boolean errorReported = false; | |
31 | - | |
32 | - /** | |
33 | - * Creates a new private field entry | |
34 | - * | |
35 | - * @param obf | |
36 | - */ | |
37 | - protected PrivateFields(Class<P> owner, Obf obf) | |
38 | - { | |
39 | - this.parentClass = owner; | |
40 | - this.fieldName = ObfuscationUtilities.getObfuscatedFieldName(obf); | |
41 | - } | |
42 | - | |
43 | - /** | |
44 | - * Get the current value of this field on the instance class supplied | |
45 | - * | |
46 | - * @param instance Class to get the value of | |
47 | - * @return field value or null if errors occur | |
48 | - */ | |
49 | - @SuppressWarnings("unchecked") | |
50 | - public T get(P instance) | |
51 | - { | |
52 | - try | |
53 | - { | |
54 | - Field field = this.parentClass.getDeclaredField(this.fieldName); | |
55 | - field.setAccessible(true); | |
56 | - return (T)field.get(instance); | |
57 | - } | |
58 | - catch (Exception ex) | |
59 | - { | |
60 | - if (!this.errorReported) | |
61 | - { | |
62 | - this.errorReported = true; | |
63 | - ex.printStackTrace(); | |
64 | - } | |
65 | - return null; | |
66 | - } | |
67 | - } | |
68 | - | |
69 | - /** | |
70 | - * Set the value of this field on the instance class supplied | |
71 | - * | |
72 | - * @param instance Object to set the value of the field on | |
73 | - * @param value value to set | |
74 | - * @return value | |
75 | - */ | |
76 | - public T set(P instance, T value) | |
77 | - { | |
78 | - try | |
79 | - { | |
80 | - Field field = this.parentClass.getDeclaredField(this.fieldName); | |
81 | - field.setAccessible(true); | |
82 | - field.set(instance, value); | |
83 | - } | |
84 | - catch (Exception ex) | |
85 | - { | |
86 | - if (!this.errorReported) | |
87 | - { | |
88 | - this.errorReported = true; | |
89 | - ex.printStackTrace(); | |
90 | - } | |
91 | - } | |
92 | - | |
93 | - return value; | |
94 | - } | |
95 | - | |
96 | - /** | |
97 | - * Set the value of this FINAL field on the instance class supplied | |
98 | - * | |
99 | - * @param instance Object to set the value of the field on | |
100 | - * @param value value to set | |
101 | - * @return value | |
102 | - */ | |
103 | - public T setFinal(P instance, T value) | |
104 | - { | |
105 | - try | |
106 | - { | |
107 | - Field modifiers = Field.class.getDeclaredField("modifiers"); | |
108 | - modifiers.setAccessible(true); | |
109 | - | |
110 | - Field field = this.parentClass.getDeclaredField(this.fieldName); | |
111 | - modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); | |
112 | - field.setAccessible(true); | |
113 | - field.set(instance, value); | |
114 | - } | |
115 | - catch (Exception ex) | |
116 | - { | |
117 | - if (!this.errorReported) | |
118 | - { | |
119 | - this.errorReported = true; | |
120 | - ex.printStackTrace(); | |
121 | - } | |
122 | - } | |
123 | - | |
124 | - return value; | |
125 | - } | |
126 | - | |
127 | - public static final PrivateFields<C15PacketClientSettings, Integer> viewDistance = new PrivateFields<C15PacketClientSettings, Integer>(C15PacketClientSettings.class, Obf.viewDistance); | |
128 | - | |
129 | -} | |
130 | 0 | \ No newline at end of file |
java/common/com/mumfrey/liteloader/util/SortableValue.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util; | |
2 | - | |
3 | -/** | |
4 | - * Struct which contains a mapping of a priority value to another object, used for sorting items using | |
5 | - * the native functionality in TreeMap and TreeSet | |
6 | - * | |
7 | - * @author Adam Mummery-Smith | |
8 | - */ | |
9 | -public class SortableValue<T> implements Comparable<SortableValue<?>> | |
10 | -{ | |
11 | - private final int priority; | |
12 | - | |
13 | - private final int order; | |
14 | - | |
15 | - private final T value; | |
16 | - | |
17 | - public SortableValue(int priority, int order, T value) | |
18 | - { | |
19 | - this.priority = priority; | |
20 | - this.order = order; | |
21 | - this.value = value; | |
22 | - } | |
23 | - | |
24 | - public int getPriority() | |
25 | - { | |
26 | - return this.priority; | |
27 | - } | |
28 | - | |
29 | - public int getOrder() | |
30 | - { | |
31 | - return this.order; | |
32 | - } | |
33 | - | |
34 | - public T getValue() | |
35 | - { | |
36 | - return this.value; | |
37 | - } | |
38 | - | |
39 | - @Override | |
40 | - public int compareTo(SortableValue<?> other) | |
41 | - { | |
42 | - if (other == null) return 0; | |
43 | - if (other.priority == this.priority) return this.order - other.order; | |
44 | - return (this.priority - other.priority); | |
45 | - } | |
46 | -} |
java/common/com/mumfrey/liteloader/util/jinput/ComponentRegistry.java deleted
100644 → 0
1 | -package com.mumfrey.liteloader.util.jinput; | |
2 | - | |
3 | -import java.util.ArrayList; | |
4 | -import java.util.HashMap; | |
5 | -import java.util.Map.Entry; | |
6 | - | |
7 | -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; | |
8 | - | |
9 | -import net.java.games.input.Component; | |
10 | -import net.java.games.input.Controller; | |
11 | -import net.java.games.input.ControllerEnvironment; | |
12 | - | |
13 | -/** | |
14 | - * Registry which keeps track of mappings of JInput descriptors to the controller and component references | |
15 | - * | |
16 | - * @author Adam Mummery-Smith | |
17 | - */ | |
18 | -public class ComponentRegistry | |
19 | -{ | |
20 | - /** | |
21 | - * List of components | |
22 | - */ | |
23 | - private static HashMap<String, Component> components = new HashMap<String, Component>(); | |
24 | - | |
25 | - /** | |
26 | - * List of controllers | |
27 | - */ | |
28 | - private static HashMap<String, Controller> controllers = new HashMap<String, Controller>(); | |
29 | - | |
30 | - /** | |
31 | - * Constructor | |
32 | - */ | |
33 | - public ComponentRegistry() | |
34 | - { | |
35 | - } | |
36 | - | |
37 | - public void enumerate() | |
38 | - { | |
39 | - try | |
40 | - { | |
41 | - LiteLoaderLogger.info("JInput Component Registry is initialising..."); | |
42 | - this.enumerate(ControllerEnvironment.getDefaultEnvironment()); | |
43 | - LiteLoaderLogger.info("JInput Component Registry initialised, found %d controller(s) %d component(s)", ControllerEnvironment.getDefaultEnvironment().getControllers().length, components.size()); | |
44 | - } | |
45 | - catch (Throwable th) | |
46 | - { | |
47 | - } | |
48 | - } | |
49 | - | |
50 | - public void enumerate(ControllerEnvironment environment) | |
51 | - { | |
52 | - components.clear(); | |
53 | - controllers.clear(); | |
54 | - | |
55 | - for (Controller controller : environment.getControllers()) | |
56 | - { | |
57 | - LiteLoaderLogger.info("Inspecting %s controller %s on %s...", controller.getType(), controller.getName(), controller.getPortType()); | |
58 | - for (Component component : controller.getComponents()) | |
59 | - { | |
60 | - this.addComponent(controller, component); | |
61 | - } | |
62 | - } | |
63 | - } | |
64 | - | |
65 | - private String addComponent(Controller controller, Component component) | |
66 | - { | |
67 | - String descriptor = ComponentRegistry.getDescriptor(controller, component); | |
68 | - components.put(descriptor, component); | |
69 | - controllers.put(descriptor, controller); | |
70 | - return descriptor; | |
71 | - } | |
72 | - | |
73 | - public ArrayList<Component> getComponents(String descriptor) | |
74 | - { | |
75 | - ArrayList<Component> components = new ArrayList<Component>(); | |
76 | - | |
77 | - int offset = 0; | |
78 | - Component component = null; | |
79 | - | |
80 | - do | |
81 | - { | |
82 | - component = this.getComponent(descriptor, offset++); | |
83 | - | |
84 | - if (components.contains(component)) | |
85 | - component = null; | |
86 | - | |
87 | - if (component != null) | |
88 | - { | |
89 | - components.add(component); | |
90 | - } | |
91 | - | |
92 | - } while (component != null && components.size() < 32); | |
93 | - | |
94 | - return components; | |
95 | - } | |
96 | - | |
97 | - public Component getComponent(String descriptor) | |
98 | - { | |
99 | - return this.getComponent(descriptor, 0); | |
100 | - } | |
101 | - | |
102 | - protected Component getComponent(String descriptor, int offset) | |
103 | - { | |
104 | - if (components.containsKey(descriptor)) | |
105 | - { | |
106 | - return components.get(descriptor); | |
107 | - } | |
108 | - | |
109 | - for (Entry<String, Component> entry : components.entrySet()) | |
110 | - { | |
111 | - if (matches(entry.getKey(), descriptor)) | |
112 | - { | |
113 | - if (--offset < 0) | |
114 | - return entry.getValue(); | |
115 | - } | |
116 | - } | |
117 | - | |
118 | - return null; | |
119 | - } | |
120 | - | |
121 | - public ArrayList<Controller> getControllers(String descriptor) | |
122 | - { | |
123 | - ArrayList<Controller> controllers = new ArrayList<Controller>(); | |
124 | - | |
125 | - int offset = 0; | |
126 | - Controller controller = null; | |
127 | - | |
128 | - do | |
129 | - { | |
130 | - controller = this.getController(descriptor, offset++); | |
131 | - | |
132 | - if (controllers.contains(controller)) | |
133 | - controller = null; | |
134 | - | |
135 | - if (controller != null) | |
136 | - { | |
137 | - controllers.add(controller); | |
138 | - } | |
139 | - | |
140 | - } while (controller != null && controllers.size() < 32); | |
141 | - | |
142 | - return controllers; | |
143 | - } | |
144 | - | |
145 | - public Controller getController(String descriptor) | |
146 | - { | |
147 | - return this.getController(descriptor, 0); | |
148 | - } | |
149 | - | |
150 | - protected Controller getController(String descriptor, int offset) | |
151 | - { | |
152 | - if (controllers.containsKey(descriptor)) | |
153 | - { | |
154 | - return controllers.get(descriptor); | |
155 | - } | |
156 | - | |
157 | - for (Entry<String, Controller> entry : controllers.entrySet()) | |
158 | - { | |
159 | - if (matches(entry.getKey(), descriptor)) | |
160 | - { | |
161 | - if (--offset < 0) | |
162 | - return entry.getValue(); | |
163 | - } | |
164 | - } | |
165 | - | |
166 | - return null; | |
167 | - } | |
168 | - | |
169 | - public static String getDescriptor(Controller controller, Component component) | |
170 | - { | |
171 | - int index = 0; | |
172 | - String controllerPath = ComponentRegistry.getControllerPath(controller); | |
173 | - String componentId = component.getIdentifier().getName(); | |
174 | - | |
175 | - String descriptor = ComponentRegistry.getDescriptor(controllerPath, componentId, index); | |
176 | - | |
177 | - while (components.containsKey(descriptor) && components.get(descriptor) != component) | |
178 | - { | |
179 | - descriptor = ComponentRegistry.getDescriptor(controllerPath, componentId, ++index); | |
180 | - } | |
181 | - | |
182 | - return descriptor; | |
183 | - } | |
184 | - | |
185 | - /** | |
186 | - * @param type | |
187 | - * @param name | |
188 | - * @param portType | |
189 | - * @param portNumber | |
190 | - * @param component | |
191 | - * @param index | |
192 | - */ | |
193 | - public static String getDescriptor(String type, String name, String portType, int portNumber, String component, int index) | |
194 | - { | |
195 | - String controllerPath = ComponentRegistry.getControllerPath(type, name, portType, portNumber); | |
196 | - return ComponentRegistry.getDescriptor(controllerPath, component, index); | |
197 | - } | |
198 | - | |
199 | - /** | |
200 | - * @param controller | |
201 | - * @param component | |
202 | - * @param index | |
203 | - */ | |
204 | - private static String getDescriptor(String controller, String component, int index) | |
205 | - { | |
206 | - String descriptor = String.format("jinput:%s/%s/%d", controller, ComponentRegistry.format(component), index); | |
207 | - return descriptor; | |
208 | - } | |
209 | - | |
210 | - /** | |
211 | - * @param controller | |
212 | - */ | |
213 | - private static String getControllerPath(Controller controller) | |
214 | - { | |
215 | - return ComponentRegistry.getControllerPath( | |
216 | - controller.getType().toString().toLowerCase(), | |
217 | - controller.getName(), | |
218 | - controller.getPortType().toString(), | |
219 | - controller.getPortNumber() | |
220 | - ); | |
221 | - } | |
222 | - | |
223 | - /** | |
224 | - * @param type | |
225 | - * @param name | |
226 | - * @param portType | |
227 | - * @param portNumber | |
228 | - */ | |
229 | - public static String getControllerPath(String type, String name, String portType, int portNumber) | |
230 | - { | |
231 | - return String.format("%s/%s/%s/%d", | |
232 | - ComponentRegistry.format(type), | |
233 | - ComponentRegistry.format(name), | |
234 | - ComponentRegistry.format(portType), | |
235 | - portNumber | |
236 | - ); | |
237 | - } | |
238 | - | |
239 | - public static boolean matches(String descriptor, String wildDescriptor) | |
240 | - { | |
241 | - String[] descriptorParts = ComponentRegistry.splitDescriptor(descriptor.trim()); | |
242 | - String[] wildDescriptorParts = ComponentRegistry.splitDescriptor(wildDescriptor.trim()); | |
243 | - | |
244 | - if (descriptorParts.length != wildDescriptorParts.length) return false; | |
245 | - | |
246 | - for (int i = 0; i < descriptorParts.length; i++) | |
247 | - { | |
248 | - if (wildDescriptorParts[i].length() > 0 && descriptorParts[i].length() > 0 && !wildDescriptorParts[i].equals(descriptorParts[i]) && !wildDescriptorParts[i].equals("*")) | |
249 | - return false; | |
250 | - } | |
251 | - | |
252 | - return true; | |
253 | - } | |
254 | - | |
255 | - public static String[] splitDescriptor(String descriptor) | |
256 | - { | |
257 | - if (descriptor.startsWith("jinput:")) | |
258 | - { | |
259 | - String[] path = descriptor.split("(?<!\\\\)/"); | |
260 | - for (int i = 0; i < path.length; i++) path[i] = path[i].replaceAll("\\\\/", "/"); | |
261 | - return path; | |
262 | - } | |
263 | - | |
264 | - return new String[0]; | |
265 | - } | |
266 | - | |
267 | - public static String format(String descriptorPart) | |
268 | - { | |
269 | - return descriptorPart == null ? "0" : descriptorPart.replaceAll("/", "\\\\/"); | |
270 | - } | |
271 | -} |