├── .gitignore
├── BON_LICENSE.txt
├── GSON_LICENSE.txt
├── LICENSE
├── MCPMappingViewer.ico
├── README.md
├── build.gradle
├── change.log
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
└── main
├── java
├── bspkrs
│ └── mmv
│ │ ├── ClassSrgData.java
│ │ ├── CsvData.java
│ │ ├── CsvFile.java
│ │ ├── ExcData.java
│ │ ├── ExcFile.java
│ │ ├── FieldSrgData.java
│ │ ├── McpBotCommand.java
│ │ ├── McpMappingLoader.java
│ │ ├── MemberSrgData.java
│ │ ├── MethodSrgData.java
│ │ ├── ParamCsvData.java
│ │ ├── ParamCsvFile.java
│ │ ├── RemoteZipHandler.java
│ │ ├── SplittedNaturalComparator.java
│ │ ├── SrgFile.java
│ │ ├── StaticMethodsFile.java
│ │ ├── TSrgFile.java
│ │ ├── VersionFetcher.java
│ │ ├── gui
│ │ ├── BrowseActionListener.java
│ │ ├── MappingGui.java
│ │ └── TableColumnAdjuster.java
│ │ └── version
│ │ ├── AppVersionChecker.java
│ │ └── NaturalOrderComparator.java
└── immibis
│ └── bon
│ ├── IProgressListener.java
│ ├── NameSet.java
│ └── gui
│ ├── Reference.java
│ └── Side.java
└── resources
└── bspkrs
└── mmv
└── gui
└── icon
├── bspkrs.png
├── bspkrs128.png
├── bspkrs16.png
├── bspkrs24.png
├── bspkrs32.png
├── bspkrs48.png
└── bspkrs64.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # package
2 | *.jar
3 |
4 | # eclipse
5 | .classpath
6 | .project
7 | .metadata/
8 | .settings/
9 | .recommenders/
10 | bin/
11 |
12 | # (no) idea
13 | .idea
14 | *.iml
15 | *.ipr
16 | *.iws
17 | out/
18 |
19 | # gradle
20 | /.gradle/
21 | /build/
22 | !/gradle/wrapper/gradle-wrapper.jar
23 |
24 | dist
25 |
--------------------------------------------------------------------------------
/BON_LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2013 Alex "immibis" Campbell
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/GSON_LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2014 bspkrs
2 | Portions Copyright (C) 2014 Alex "immibis" Campbell
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/MCPMappingViewer.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bspkrs/MCPMappingViewer/756b6bd16fcc7bb1eb60fd9b78796cd9aee4277f/MCPMappingViewer.ico
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | *** This project is no longer maintained ***
2 |
3 | MCP Mapping Viewer
4 | =================
5 | A small GUI for viewing the mappings from Minecraft obfuscated code names to MCP code names.
6 |
7 | ### Links of Interest
8 | - [Official Minecraft Forum Thread](http://www.minecraftforum.net/topic/2115030-)
9 | - [Binary Downloads](http://bspk.rs/MC/MCPMappingViewer/index.html)
10 | - [Issue Tracking System](https://github.com/bspkrs/MCPMappingViewer/issues)
11 |
12 | * * *
13 |
14 | #### How to build from the source code ####
15 |
16 | Run `gradlew build` from your favorite command line facilities
17 |
18 | * * *
19 |
20 | Copyright (C) 2013-2022 bspkrs
21 | Portions Copyright (C) 2013 Alex "immibis" Campbell (see BON_LICENSE.txt for details)
22 | GSON is licensed under the Apache License 2.0 (see GSON_LICENSE.txt for details)
23 |
24 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
27 |
28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'java-library'
4 | id 'eclipse'
5 | id 'idea'
6 | id 'com.github.johnrengelman.shadow' version '7.0.0'
7 | id 'edu.sc.seis.launch4j' version '2.5.0'
8 | }
9 |
10 | version = '1.0.3'
11 | ext.mainClassName = "bspkrs.mmv.gui.MappingGui"
12 |
13 | java {
14 | toolchain {
15 | languageVersion = JavaLanguageVersion.of(8)
16 | }
17 | }
18 |
19 | repositories {
20 | mavenCentral()
21 | }
22 |
23 | dependencies {
24 | implementation 'com.google.code.gson:gson:2.8.6'
25 | }
26 |
27 | [compileJava, compileTestJava].each { cJava ->
28 | cJava.options.compilerArgs += ['-Xlint:unchecked']
29 | cJava.options.encoding = 'UTF-8'
30 | cJava.options.incremental = true
31 | cJava.options.fork = true
32 | }
33 |
34 | processResources {
35 | from 'LICENSE'
36 | }
37 |
38 | build.dependsOn(shadowJar)
39 |
40 | jar {
41 | destinationDirectory = temporaryDir
42 | }
43 |
44 | shadowJar {
45 | archiveClassifier.set('')
46 | }
47 |
48 | wrapper {
49 | distributionType = Wrapper.DistributionType.ALL
50 | }
51 |
52 | jar.manifest {
53 | attributes 'Main-Class': mainClassName
54 | }
55 |
56 | createExe {
57 | dependsOn 'build'
58 | mainClassName = mainClassName
59 | copyConfigurable = project.tasks.shadowJar.outputs.files
60 | jar = "lib/${project.tasks.shadowJar.archiveFileName}"
61 | outputDir = 'libs'
62 | outfile = tasks.shadowJar.archiveName - '.jar' + '.exe'
63 | productName = 'MCP Mapping Viewer'
64 | icon = "${projectDir}/MCPMappingViewer.ico"
65 | supportUrl = 'https://www.minecraftforum.net/topic/2115030'
66 | copyright = 'Copyright 2013-2021 bspkrs, portions Copyright 2013-2014 Alex "Immibis" Campbell'
67 | version = "${project.version}"
68 | }
69 |
70 | task run(type: JavaExec) {
71 | classpath = sourceSets.main.runtimeClasspath
72 |
73 | main = mainClassName
74 | }
75 |
--------------------------------------------------------------------------------
/change.log:
--------------------------------------------------------------------------------
1 | 0.7.3 - 30-Jun-2014
2 | - fixed version checker derping due to dropbox server changes
3 | 0.7.2 - 18-Apr-2014
4 | - fixed derp where column sort settings were reset on search
5 | 0.7.1 - 12-Apr-2014
6 | - fixed compabibility with latest Forge releases
7 | 0.7.0 - 01-Apr-2014
8 | - fixed a potential issue with not adding the header row when exporting CSV files
9 | - added support for viewing and editing params.csv :D
10 | 0.6.1 - 24-Feb-2014
11 | - added code to make SRG name searches actually highlight the item they are meant to find
12 | 0.6.0 - 22-Jan-2014
13 | - saving of edits back to CSVs is now possible! careful if you are editing Forge CSVs!
14 | - when using side Universal (Forge), edits will produce multiple bot commands unless the item is client only
15 | - better handling of button states based on edits
16 | 0.5.3 - 05-Dec-2013
17 | - added application icon and About image
18 | - cleaned up some messy code
19 | - filter is now clear on load
20 | 0.5.2 - 03-Dec-2013
21 | - added search history
22 | 0.5.1 - 26-Nov-2013
23 | - fixed derp in method to get the bot command
24 | 0.5.0 - 25-Nov-2013
25 | - added basic support for generating MCPBot commands to execute in a DCC session with the bot
26 | 0.2.2 - 14-Nov-2013
27 | - proper fixed CsvFile parser defect
28 | 0.2.1 - 14-Nov-2013
29 | - fixed major logic flaw in CsvFile parser
30 | 0.2.0 - 14-Nov-2013
31 | - many UI improvements and tweaks
32 | - column sort is now remembered
33 | - added global search functionality
34 | - added option to force reload from mcp/conf files vs cached data
35 | - added version notifications (non-naggy, you'll only be notified once per new version)
36 | - improved exception handling
37 | 0.1.0a - 12-Nov-2013
38 | - initial release!
39 | - acts as an obfuscation map viewer
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bspkrs/MCPMappingViewer/756b6bd16fcc7bb1eb60fd9b78796cd9aee4277f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/ClassSrgData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | public class ClassSrgData implements Comparable
19 | {
20 | public static enum SortType
21 | {
22 | PKG,
23 | OBF
24 | }
25 |
26 | private final String obfName;
27 | private final String srgName;
28 | private String srgPkgName;
29 | private final boolean isClientOnly;
30 |
31 | public static SortType sortType = SortType.PKG;
32 |
33 | public ClassSrgData(String obfName, String srgName, String srgPkgName, boolean isClientOnly)
34 | {
35 | this.obfName = obfName;
36 | this.srgName = srgName;
37 | this.srgPkgName = srgPkgName;
38 | this.isClientOnly = isClientOnly;
39 | }
40 |
41 | public String getObfName()
42 | {
43 | return this.obfName;
44 | }
45 |
46 | public String getSrgName()
47 | {
48 | return this.srgName;
49 | }
50 |
51 | public String getSrgPkgName()
52 | {
53 | return this.srgPkgName;
54 | }
55 |
56 | public ClassSrgData setSrgPkgName(String pkg)
57 | {
58 | this.srgPkgName = pkg;
59 | return this;
60 | }
61 |
62 | public boolean isClientOnly()
63 | {
64 | return isClientOnly;
65 | }
66 |
67 | public String getFullyQualifiedSrgName()
68 | {
69 | return srgPkgName + "/" + srgName;
70 | }
71 |
72 | @Override
73 | public int compareTo(ClassSrgData o)
74 | {
75 | if (sortType == SortType.PKG)
76 | if (o != null)
77 | return getFullyQualifiedSrgName().compareTo(o.getFullyQualifiedSrgName());
78 | else
79 | return 1;
80 | else if (o != null)
81 | if (obfName.length() != o.obfName.length())
82 | return obfName.length() - o.obfName.length();
83 | else
84 | return obfName.compareTo(o.obfName);
85 | else
86 | return 1;
87 |
88 | }
89 |
90 | public boolean contains(String s)
91 | {
92 | return srgName.contains(s) || obfName.contains(s) || this.srgPkgName.contains(s);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/CsvData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | public class CsvData implements Comparable
19 | {
20 | private final String srgName;
21 | private String mcpName;
22 | private final int side;
23 | private String comment;
24 | private boolean needsQuoted;
25 |
26 | public CsvData(String srgName, String mcpName, int side, String comment)
27 | {
28 | this.srgName = srgName;
29 | this.mcpName = mcpName;
30 | this.side = side;
31 |
32 | if (comment.contains(",") || (!comment.isEmpty() && comment.charAt(0) == '"' && comment.charAt(comment.length() - 1) == '"'))
33 | {
34 | needsQuoted = true;
35 | if (comment.charAt(0) == '"' && comment.charAt(comment.length() - 1) == '"')
36 | this.comment = comment.substring(1, comment.length() - 1);
37 | else
38 | this.comment = comment;
39 | }
40 | else
41 | {
42 | this.comment = comment;
43 | needsQuoted = false;
44 | }
45 | }
46 |
47 | public String toCsv()
48 | {
49 | return srgName + "," + mcpName + "," + side + "," + (needsQuoted ? "\"" + comment + "\"" : comment);
50 | }
51 |
52 | public String getSrgName()
53 | {
54 | return srgName;
55 | }
56 |
57 | public String getMcpName()
58 | {
59 | return mcpName;
60 | }
61 |
62 | public CsvData setMcpName(String mcpName)
63 | {
64 | this.mcpName = mcpName;
65 | return this;
66 | }
67 |
68 | public int getSide()
69 | {
70 | return side;
71 | }
72 |
73 | public String getComment()
74 | {
75 | return comment;
76 | }
77 |
78 | public CsvData setComment(String comment)
79 | {
80 | this.comment = comment;
81 | return this;
82 | }
83 |
84 | @Override
85 | public int compareTo(CsvData o)
86 | {
87 | if (o != null)
88 | return this.srgName.compareTo(o.srgName);
89 |
90 | return 1;
91 | }
92 |
93 | public boolean contains(String s)
94 | {
95 | return this.mcpName.contains(s) || this.comment.contains(s);
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/CsvFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | * Portions Copyright (C) 2014 Alex "immibis" Campbell
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
7 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
8 | * Software is furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 | package bspkrs.mmv;
18 |
19 | import java.io.BufferedReader;
20 | import java.io.File;
21 | import java.io.FileReader;
22 | import java.io.FileWriter;
23 | import java.io.IOException;
24 | import java.io.PrintWriter;
25 | import java.text.SimpleDateFormat;
26 | import java.util.Date;
27 | import java.util.Map;
28 | import java.util.Scanner;
29 | import java.util.TreeMap;
30 |
31 | public class CsvFile
32 | {
33 | private final File file;
34 | private final Map srgMemberName2CsvData;
35 | private boolean isDirty;
36 | private String headerLine;
37 |
38 | public CsvFile(File file) throws IOException
39 | {
40 | this.file = file;
41 | srgMemberName2CsvData = new TreeMap();
42 | readFromFile();
43 | isDirty = false;
44 | }
45 |
46 | public void readFromFile() throws IOException
47 | {
48 | Scanner in = new Scanner(new BufferedReader(new FileReader(file)));
49 | try
50 | {
51 | in.useDelimiter(",");
52 | headerLine = in.nextLine(); // Skip header row
53 | while (in.hasNextLine())
54 | {
55 | String srgName = in.next();
56 | String mcpName = in.next();
57 | String side = in.next();
58 | String comment = in.nextLine().substring(1);
59 | srgMemberName2CsvData.put(srgName, new CsvData(srgName, mcpName, Integer.valueOf(side), comment));
60 | }
61 | }
62 | finally
63 | {
64 | in.close();
65 | }
66 | }
67 |
68 | public void writeToFile() throws IOException
69 | {
70 | if (isDirty)
71 | {
72 | if (file.exists())
73 | {
74 | File fileBak = new File(file.getAbsolutePath() + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".bak");
75 | file.renameTo(fileBak);
76 | }
77 |
78 | file.createNewFile();
79 |
80 | PrintWriter out = new PrintWriter(new FileWriter(file));
81 | out.println(headerLine);
82 |
83 | for (CsvData data : srgMemberName2CsvData.values())
84 | out.println(data.toCsv());
85 |
86 | out.close();
87 |
88 | isDirty = false;
89 | }
90 | }
91 |
92 | public boolean hasCsvDataForKey(String srgName)
93 | {
94 | return srgMemberName2CsvData.containsKey(srgName);
95 | }
96 |
97 | public CsvData getCsvDataForKey(String srgName)
98 | {
99 | return srgMemberName2CsvData.get(srgName);
100 | }
101 |
102 | public void updateCsvDataForKey(String srgName, CsvData csvData)
103 | {
104 | srgMemberName2CsvData.put(srgName, csvData);
105 | isDirty = true;
106 | }
107 |
108 | public boolean isDirty()
109 | {
110 | return isDirty;
111 | }
112 |
113 | public void setIsDirty(boolean bol)
114 | {
115 | isDirty = bol;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/ExcData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.regex.Matcher;
21 | import java.util.regex.Pattern;
22 |
23 | public class ExcData implements Comparable
24 | {
25 | private final String srgOwner;
26 | private final String srgName;
27 | private final String descriptor;
28 | private final String[] exceptions;
29 | private final String[] parameters;
30 | private final String[] paramTypes;
31 |
32 | public ExcData(String srgOwner, String srgName, String descriptor, String[] exceptions, String[] parameters)
33 | {
34 | this.srgOwner = srgOwner;
35 | this.srgName = srgName;
36 | this.descriptor = descriptor;
37 | this.exceptions = exceptions;
38 | paramTypes = splitMethodDesc(descriptor);
39 | this.parameters = parameters;
40 | }
41 |
42 | public ExcData(String srgOwner, String srgName, String descriptor, String[] exceptions, boolean isStatic)
43 | {
44 | this.srgOwner = srgOwner;
45 | this.srgName = srgName;
46 | this.descriptor = descriptor;
47 | this.exceptions = exceptions;
48 | paramTypes = splitMethodDesc(descriptor);
49 | parameters = genParamNames(ExcData.getSrgId(srgName), paramTypes, isStatic);
50 | }
51 |
52 | public String getSrgClassOwner()
53 | {
54 | return srgOwner;
55 | }
56 |
57 | public String getSrgMethodName()
58 | {
59 | return srgName;
60 | }
61 |
62 | public String getDescriptor()
63 | {
64 | return descriptor;
65 | }
66 |
67 | public String[] getExceptions()
68 | {
69 | return exceptions;
70 | }
71 |
72 | public String[] getParameters()
73 | {
74 | return parameters;
75 | }
76 |
77 | public String[] getParamTypes()
78 | {
79 | return paramTypes;
80 | }
81 |
82 | public boolean contains(String s)
83 | {
84 | if (srgName.contains(s))
85 | return true;
86 | else
87 | for (String param : parameters)
88 | if (param.contains(s))
89 | return true;
90 |
91 | return false;
92 | }
93 |
94 | @Override
95 | public int compareTo(ExcData o)
96 | {
97 | return srgName.compareTo(o.srgName);
98 | }
99 |
100 | public static String[] splitMethodDesc(String desc)
101 | {
102 | //\[*(?:L[^;]+;|[ZBCSIFDJ])
103 | int beginIndex = desc.indexOf('(');
104 | int endIndex = desc.lastIndexOf(')');
105 | if (((beginIndex == -1) && (endIndex != -1)) || ((beginIndex != -1) && (endIndex == -1)))
106 | {
107 | System.err.println(beginIndex);
108 | System.err.println(endIndex);
109 | throw new RuntimeException();
110 | }
111 | String x0;
112 | if ((beginIndex == -1) && (endIndex == -1))
113 | {
114 | x0 = desc;
115 | }
116 | else
117 | {
118 | x0 = desc.substring(beginIndex + 1, endIndex);
119 | }
120 | Pattern pattern = Pattern.compile("\\[*(?:L[^;]+;|[ZBCSIFDJ])");
121 | Matcher matcher = pattern.matcher(x0);
122 |
123 | ArrayList listMatches = new ArrayList();
124 |
125 | while (matcher.find())
126 | {
127 | listMatches.add(matcher.group());
128 | }
129 |
130 | return listMatches.toArray(new String[listMatches.size()]);
131 | }
132 |
133 | public static String[] genParamNames(String srgId, String[] paramTypes, boolean isStatic)
134 | {
135 | boolean skip2 = (paramTypes.length >= 4) && paramTypes[0].equals("Ljava/lang/String;") && paramTypes[1].equals('I')
136 | && paramTypes[0].equals(paramTypes[2]) && paramTypes[1].equals(paramTypes[3]);
137 |
138 | String[] ret = new String[paramTypes.length];
139 | int idOffset = isStatic ? 0 : 1;
140 | if (skip2)
141 | idOffset += 2;
142 |
143 | for (int i = 0; i < paramTypes.length; i++)
144 | {
145 | ret[i] = "p_" + srgId + "_" + (i + idOffset) + "_";
146 | if (paramTypes[i].equals("D") || paramTypes[i].equals("J"))
147 | idOffset++;
148 | }
149 |
150 | return ret;
151 | }
152 |
153 | public static String getSrgId(String srgName)
154 | {
155 | Pattern pattern = Pattern.compile("func_(i?[0-9]+)_");
156 | Matcher matcher = pattern.matcher(srgName);
157 | if (matcher.find())
158 | return matcher.group(1);
159 | return srgName;
160 | }
161 |
162 | @Override
163 | public String toString()
164 | {
165 | return String.format(" Owner: %s\n SRG Name: %s\n Descriptor: %s\n Exceptions: %s\n Parameters: %s\n Param Types: %s", srgOwner, srgName, descriptor, Arrays.toString(exceptions), Arrays.toString(parameters), Arrays.toString(paramTypes));
166 | }
167 | }
168 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/ExcFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | * Portions Copyright (C) 2014 Alex "immibis" Campbell
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
7 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
8 | * Software is furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 | package bspkrs.mmv;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.util.HashMap;
23 | import java.util.Map;
24 | import java.util.Scanner;
25 |
26 | public class ExcFile
27 | {
28 | public final Map srgMethodName2ExcData;
29 | public final Map srgParamName2ExcData;
30 |
31 | public ExcFile(File f) throws IOException
32 | {
33 | srgMethodName2ExcData = new HashMap();
34 | srgParamName2ExcData = new HashMap();
35 | // example lines:
36 | // net/minecraft/util/ChunkCoordinates=CL_00001555
37 | // net/minecraft/world/chunk/storage/AnvilChunkLoader.func_75816_a(Lnet/minecraft/world/World;Lnet/minecraft/world/chunk/Chunk;)V=net/minecraft/world/MinecraftException,java/io/IOException|p_75816_1_,p_75816_2_
38 | // net/minecraft/world/biome/BiomeGenMutated.func_150571_c(III)I=|p_150571_1_,p_150571_2_,p_150571_3_
39 | // net/minecraft/world/chunk/storage/AnvilChunkLoader.func_75818_b()V=|
40 | // net/minecraft/server/MinecraftServer.func_145747_a(Lnet/minecraft/util/IChatComponent;)V=|p_145747_1_
41 |
42 | Scanner in = new Scanner(new FileReader(f));
43 | try
44 | {
45 | while (in.hasNextLine())
46 | {
47 | if (in.hasNext("#"))
48 | {
49 | in.nextLine();
50 | continue;
51 | }
52 |
53 | in.useDelimiter("\\.");
54 | String srgOwner = in.next();
55 | in.useDelimiter("\\(");
56 |
57 | if (!in.hasNext())
58 | if (in.hasNextLine())
59 | in.nextLine();
60 | else
61 | break;
62 |
63 | String srgName = in.next().substring(1);
64 | in.useDelimiter("=");
65 | String descriptor = in.next();
66 | in.useDelimiter("\\|");
67 | String excs = in.next().substring(1);
68 | String params = in.nextLine().substring(1);
69 |
70 | ExcData toAdd = new ExcData(srgOwner, srgName, descriptor,
71 | (excs.length() > 0 ? excs.split(",") : new String[0]),
72 | (params.length() > 0 ? params.split(",") : new String[0]));
73 |
74 | ExcData existing = srgMethodName2ExcData.get(srgName);
75 |
76 | if ((existing == null) || (existing.getParameters().length < toAdd.getParameters().length))
77 | {
78 | srgMethodName2ExcData.put(srgName, toAdd);
79 |
80 | for (String parameter : toAdd.getParameters())
81 | srgParamName2ExcData.put(parameter, toAdd);
82 | }
83 | }
84 | }
85 | finally
86 | {
87 | in.close();
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/FieldSrgData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | public class FieldSrgData extends MemberSrgData implements Comparable
19 | {
20 | public FieldSrgData(String obfOwner, String obfName, String srgOwner, String srgPkg, String srgName, boolean isClientOnly)
21 | {
22 | super(obfOwner, obfName, srgOwner, srgPkg, srgName, isClientOnly);
23 | }
24 |
25 | @Override
26 | public int compareTo(FieldSrgData o)
27 | {
28 | if (o != null)
29 | return this.getSrgName().compareTo(o.getSrgName());
30 | else
31 | return 1;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/McpBotCommand.java:
--------------------------------------------------------------------------------
1 | package bspkrs.mmv;
2 |
3 | public class McpBotCommand
4 | {
5 | public enum BotCommand
6 | {
7 | SF,
8 | SM,
9 | SP,
10 | FSF,
11 | FSM,
12 | FSP;
13 | }
14 |
15 | public enum MemberType
16 | {
17 | FIELD,
18 | METHOD,
19 | PARAM;
20 | }
21 |
22 | public static BotCommand getCommand(MemberType type, boolean isForced)
23 | {
24 | switch (type)
25 | {
26 | case METHOD:
27 | return isForced ? BotCommand.FSM : BotCommand.SM;
28 | case PARAM:
29 | return isForced ? BotCommand.FSP : BotCommand.SP;
30 | default:
31 | return isForced ? BotCommand.FSF : BotCommand.SF;
32 | }
33 | }
34 |
35 | private final BotCommand command;
36 | private final String srgName;
37 | private final String newName;
38 | private final String comment;
39 |
40 | public McpBotCommand(BotCommand command, String srgName, String newName, String comment)
41 | {
42 | this.command = command;
43 | this.srgName = srgName;
44 | this.newName = newName;
45 | this.comment = comment;
46 | }
47 |
48 | public McpBotCommand(BotCommand command, String srgName, String newName)
49 | {
50 | this(command, srgName, newName, "");
51 | }
52 |
53 | public static McpBotCommand getMcpBotCommand(MemberType type, boolean isForced, String srgName, String newName, String comment)
54 | {
55 | return new McpBotCommand(getCommand(type, isForced), srgName, newName, comment);
56 | }
57 |
58 | public BotCommand getCommand()
59 | {
60 | return command;
61 | }
62 |
63 | public String getNewName()
64 | {
65 | return newName;
66 | }
67 |
68 | @Override
69 | public String toString()
70 | {
71 | return String.format("!%s %s %s %s", command.toString().toLowerCase(), srgName, newName, comment);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/McpMappingLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 bspkrs
3 | * Portions Copyright (C) 2014 Alex "immibis" Campbell
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
7 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
8 | * Software is furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 | package bspkrs.mmv;
18 |
19 | import immibis.bon.IProgressListener;
20 |
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.security.DigestException;
24 | import java.security.NoSuchAlgorithmException;
25 | import java.util.Collection;
26 | import java.util.Map;
27 | import java.util.Map.Entry;
28 | import java.util.Set;
29 | import java.util.TreeMap;
30 | import java.util.TreeSet;
31 |
32 | import javax.swing.table.AbstractTableModel;
33 | import javax.swing.table.TableModel;
34 |
35 | import bspkrs.mmv.McpBotCommand.MemberType;
36 | import bspkrs.mmv.gui.MappingGui;
37 |
38 | public class McpMappingLoader
39 | {
40 |
41 | public static class CantLoadMCPMappingException extends Exception
42 | {
43 | private static final long serialVersionUID = 1;
44 |
45 | public CantLoadMCPMappingException(String reason)
46 | {
47 | super(reason);
48 | }
49 | }
50 |
51 | private final File baseDir = new File(new File(System.getProperty("user.home")), ".cache/MCPMappingViewer");
52 | private final String baseSrgDir = "{mc_ver}";
53 | private final String baseMappingDir = "{mc_ver}/{channel}_{map_ver}";
54 | private final String baseMappingUrl = "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_{channel}/{map_ver}-{mc_ver}/mcp_{channel}-{map_ver}-{mc_ver}.zip";
55 | private final String newBaseSrgUrl = "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_config/{mc_ver}/mcp_config-{mc_ver}.zip";
56 | private final String oldBaseSrgUrl = "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp/{mc_ver}/mcp-{mc_ver}-srg.zip";
57 |
58 | private final File srgDir;
59 | private final File mappingDir;
60 | private final File srgFile;
61 | private final File excFile;
62 | private final File staticMethodsFile;
63 | private SrgFile srgFileData;
64 | private ExcFile excFileData;
65 | private StaticMethodsFile staticMethods;
66 | private CsvFile csvFieldData, csvMethodData;
67 | private ParamCsvFile csvParamData;
68 | private final MappingGui parentGui;
69 | private final Map commandMap = new TreeMap(); // srgName -> McpBotCommand
70 | public final Map srgMethodData2CsvData = new TreeMap();
71 | public final Map srgFieldData2CsvData = new TreeMap();
72 | public final Map> excData2MapParamCsvData = new TreeMap>();
73 |
74 | public McpMappingLoader(MappingGui parentGui, String mappingString, IProgressListener progress) throws IOException, CantLoadMCPMappingException, NoSuchAlgorithmException, DigestException
75 | {
76 | progress.setMax(6);
77 | progress.set(0);
78 | this.parentGui = parentGui;
79 |
80 | // mappingString: __, eg, 1.8_snapshot_20151118
81 | String[] tokens = mappingString.split("_");
82 | if (tokens.length < 3)
83 | throw new CantLoadMCPMappingException("Invalid mapping string specified.");
84 |
85 | boolean isNew = tokens[0].compareTo("1.13") >= 0;
86 | if (tokens[0].contains("1.9") || tokens[0].contains("1.8") || tokens[0].contains("1.7"))
87 | isNew = false;
88 |
89 | String baseSrgUrl = isNew ? newBaseSrgUrl : oldBaseSrgUrl;
90 | String srgFileName = isNew ? "config/joined.tsrg" : "joined.srg";
91 | String excFileName = isNew ? "config/exceptions.txt" : "joined.exc";
92 | String staticMethodsFileName = isNew ? "config/static_methods.txt" : "static_methods.txt";
93 |
94 | progress.set(0, "Fetching SRG data");
95 | srgDir = getSubDirForZip(tokens, baseSrgUrl, baseSrgDir);
96 | progress.set(1, "Fetching CSV data");
97 | mappingDir = getSubDirForZip(tokens, baseMappingUrl, baseMappingDir);
98 |
99 | srgFile = new File(srgDir, srgFileName);
100 | excFile = new File(srgDir, excFileName);
101 | staticMethodsFile = new File(srgDir, staticMethodsFileName);
102 |
103 | if (!srgFile.exists())
104 | throw new CantLoadMCPMappingException("Unable to find joined.srg. Your MCP conf folder may be corrupt.");
105 |
106 | if (!excFile.exists())
107 | throw new CantLoadMCPMappingException("Unable to find joined.exc. Your MCP conf folder may be corrupt.");
108 |
109 | if (!staticMethodsFile.exists())
110 | throw new CantLoadMCPMappingException("Unable to find static_methods.txt. Your MCP conf folder may be corrupt.");
111 |
112 | progress.set(2, "Loading CSV data");
113 | loadCsvMapping();
114 | progress.set(3, "Loading SRG data");
115 | loadSrgMapping(isNew);
116 | progress.set(4, "Linking SRG data with CSV data");
117 | linkSrgDataToCsvData();
118 | progress.set(5, "Linking EXC data with CSV data");
119 | linkExcDataToSetParamCsvData();
120 | }
121 |
122 | private File getSubDirForZip(String[] tokens, String baseZipUrl, String baseSubDir) throws CantLoadMCPMappingException, NoSuchAlgorithmException, DigestException, IOException
123 | {
124 | if (!baseDir.exists() && !baseDir.mkdirs())
125 | throw new CantLoadMCPMappingException("Application data folder does not exist and cannot be created.");
126 |
127 | File subDir = new File(baseDir, replaceTokens(baseSubDir, tokens));
128 | if (!subDir.exists() && !subDir.mkdirs())
129 | throw new CantLoadMCPMappingException("Data folder does not exist and cannot be created.");
130 |
131 | RemoteZipHandler rzh = new RemoteZipHandler(replaceTokens(baseZipUrl, tokens), subDir, "SHA1");
132 | rzh.checkRemoteZip();
133 |
134 | return subDir;
135 | }
136 |
137 | private String replaceTokens(String s, String[] tokens)
138 | {
139 | return s.replace("{mc_ver}", tokens[0]).replace("{channel}", tokens[1]).replace("{map_ver}", tokens[2]);
140 | }
141 |
142 | private void loadSrgMapping(boolean newFormat) throws IOException
143 | {
144 | staticMethods = new StaticMethodsFile(staticMethodsFile);
145 | excFileData = new ExcFile(excFile);
146 | srgFileData = newFormat
147 | ? new TSrgFile(srgFile, excFileData, staticMethods)
148 | : new SrgFile(srgFile, excFileData, staticMethods);
149 | }
150 |
151 | private void loadCsvMapping() throws IOException
152 | {
153 | csvFieldData = new CsvFile(new File(mappingDir, "fields.csv"));
154 | csvMethodData = new CsvFile(new File(mappingDir, "methods.csv"));
155 | csvParamData = new ParamCsvFile(new File(mappingDir, "params.csv"));
156 | }
157 |
158 | private void linkSrgDataToCsvData()
159 | {
160 | for (Entry methodData : srgFileData.srgMethodName2MethodData.entrySet())
161 | {
162 | if (!srgMethodData2CsvData.containsKey(methodData.getValue()) && csvMethodData.hasCsvDataForKey(methodData.getKey()))
163 | {
164 | srgMethodData2CsvData.put(methodData.getValue(), csvMethodData.getCsvDataForKey(methodData.getKey()));
165 | }
166 | else if (srgMethodData2CsvData.containsKey(methodData.getValue()))
167 | System.out.println("SRG method " + methodData.getKey() + " has multiple entries in CSV file!");
168 | }
169 |
170 | for (Entry fieldData : srgFileData.srgFieldName2FieldData.entrySet())
171 | {
172 | if (!srgFieldData2CsvData.containsKey(fieldData.getValue()) && csvFieldData.hasCsvDataForKey(fieldData.getKey()))
173 | {
174 | srgFieldData2CsvData.put(fieldData.getValue(), csvFieldData.getCsvDataForKey(fieldData.getKey()));
175 | }
176 | else if (srgFieldData2CsvData.containsKey(fieldData.getValue()))
177 | System.out.println("SRG field " + fieldData.getKey() + " has multiple entries in CSV file!");
178 | }
179 | }
180 |
181 | private void linkExcDataToSetParamCsvData()
182 | {
183 | for (Entry excData : excFileData.srgMethodName2ExcData.entrySet())
184 | {
185 | if (!excData2MapParamCsvData.containsKey(excData.getValue()) && excData.getValue().getParameters().length > 0)
186 | {
187 | TreeMap params = new TreeMap();
188 | for (String srgName : excData.getValue().getParameters())
189 | if (csvParamData.hasCsvDataForKey(srgName))
190 | params.put(srgName, csvParamData.getCsvDataForKey(srgName));
191 |
192 | excData2MapParamCsvData.put(excData.getValue(), params);
193 | }
194 | else if (excData2MapParamCsvData.containsKey(excData.getValue()))
195 | System.out.println("EXC method param " + excData.getKey() + " has multiple entries in CSV file!");
196 | }
197 | }
198 |
199 | private CsvData processMemberDataEdit(MemberType type, Map srg2MemberData,
200 | Map extends MemberSrgData, CsvData> memberData2CsvData,
201 | String srgName, String mcpName, String comment)
202 | {
203 | MemberSrgData memberData = srg2MemberData.get(srgName);
204 | CsvData csvData = null;
205 |
206 | if (memberData != null)
207 | {
208 | boolean isForced = memberData2CsvData.containsKey(memberData);
209 | if (isForced)
210 | {
211 | csvData = memberData2CsvData.get(memberData);
212 | if (!mcpName.trim().equals(csvData.getMcpName()) || !comment.trim().equals(csvData.getComment()))
213 | {
214 | csvData.setMcpName(mcpName.trim());
215 | csvData.setComment(comment.trim());
216 | }
217 | else
218 | return null;
219 | }
220 | else
221 | {
222 | csvData = new CsvData(srgName, mcpName.trim(), 2, comment.trim());
223 | }
224 |
225 | commandMap.put(srgName, McpBotCommand.getMcpBotCommand(type, isForced, csvData.getSrgName(), csvData.getMcpName(), csvData.getComment()));
226 | }
227 |
228 | return csvData;
229 | }
230 |
231 | public String getBotCommands(boolean clear)
232 | {
233 | String r = "";
234 |
235 | for (McpBotCommand command : commandMap.values())
236 | r += command.toString() + "\n";
237 |
238 | if (clear)
239 | commandMap.clear();
240 |
241 | return r;
242 | }
243 |
244 | public boolean hasPendingCommands()
245 | {
246 | return !commandMap.isEmpty();
247 | }
248 |
249 | public TableModel getSearchResults(String input, IProgressListener progress)
250 | {
251 | if (input == null || input.trim().isEmpty())
252 | return getClassModel();
253 |
254 | if (progress != null)
255 | {
256 | progress.setMax(3);
257 | progress.set(0);
258 | }
259 |
260 | Set results = new TreeSet();
261 |
262 | // Search Class objects
263 | for (ClassSrgData classData : srgFileData.srgClassName2ClassData.values())
264 | if (classData.contains(input))
265 | results.add(classData);
266 |
267 | if (progress != null)
268 | progress.set(1);
269 |
270 | // Search Methods
271 | for (Entry> entry : srgFileData.class2MethodDataSet.entrySet())
272 | {
273 | if (!results.contains(entry.getKey()))
274 | {
275 | for (MethodSrgData methodData : entry.getValue())
276 | {
277 | CsvData csv = srgMethodData2CsvData.get(methodData);
278 | if (methodData.contains(input) || csv != null && csv.contains(input))
279 | {
280 | results.add(entry.getKey());
281 | break;
282 | }
283 | }
284 | }
285 | }
286 |
287 | if (progress != null)
288 | progress.set(2);
289 |
290 | // Search Fields
291 | for (Entry> entry : srgFileData.class2FieldDataSet.entrySet())
292 | {
293 | if (!results.contains(entry.getKey()))
294 | {
295 | for (FieldSrgData fieldData : entry.getValue())
296 | {
297 | CsvData csv = srgFieldData2CsvData.get(fieldData);
298 | if (fieldData.contains(input) || csv != null && csv.contains(input))
299 | {
300 | results.add(entry.getKey());
301 | break;
302 | }
303 | }
304 | }
305 | }
306 |
307 | return new ClassModel(results);
308 | }
309 |
310 | public TableModel getClassModel()
311 | {
312 | return new ClassModel(srgFileData.srgClassName2ClassData.values());
313 | }
314 |
315 | public TableModel getMethodModel(String srgPkgAndOwner)
316 | {
317 | ClassSrgData classData = srgFileData.srgClassName2ClassData.get(srgPkgAndOwner);
318 | return new MethodModel(srgFileData.class2MethodDataSet.get(classData));
319 | }
320 |
321 | public TableModel getParamModel(String srgMethodName)
322 | {
323 | if (excFileData.srgMethodName2ExcData.containsKey(srgMethodName))
324 | return new ParamModel(excFileData.srgMethodName2ExcData.get(srgMethodName));
325 | else
326 | return MappingGui.paramsDefaultModel;
327 | }
328 |
329 | public TableModel getFieldModel(String srgPkgAndOwner)
330 | {
331 | ClassSrgData classData = srgFileData.srgClassName2ClassData.get(srgPkgAndOwner);
332 | return new FieldModel(srgFileData.class2FieldDataSet.get(classData));
333 | }
334 |
335 | @SuppressWarnings("rawtypes")
336 | public class ClassModel extends AbstractTableModel
337 | {
338 | private static final long serialVersionUID = 1L;
339 | public final String[] columnNames = { "Pkg name", "SRG name", "Obf name" };
340 | private final Class[] columnTypes = { String.class, String.class, String.class };
341 | private final boolean[] isColumnEditable = { false, false, false };
342 | private final Object[][] data;
343 | private final Collection collectionRef;
344 |
345 | public ClassModel(Collection map)
346 | {
347 | collectionRef = map;
348 |
349 | data = new Object[collectionRef.size()][columnNames.length];
350 |
351 | int i = 0;
352 |
353 | for (ClassSrgData classData : collectionRef)
354 | {
355 | data[i][0] = classData.getSrgPkgName();
356 | data[i][1] = classData.getSrgName();
357 | data[i][2] = classData.getObfName();
358 | i++;
359 | }
360 | }
361 |
362 | @Override
363 | public int getRowCount()
364 | {
365 | return data.length;
366 | }
367 |
368 | @Override
369 | public int getColumnCount()
370 | {
371 | return columnNames.length;
372 | }
373 |
374 | @Override
375 | public String getColumnName(int columnIndex)
376 | {
377 | if (columnIndex < columnNames.length && columnIndex >= 0)
378 | return columnNames[columnIndex];
379 |
380 | return "";
381 | }
382 |
383 | @Override
384 | public Class> getColumnClass(int columnIndex)
385 | {
386 | if (columnIndex < columnTypes.length && columnIndex >= 0)
387 | return columnTypes[columnIndex];
388 |
389 | return String.class;
390 | }
391 |
392 | @Override
393 | public boolean isCellEditable(int rowIndex, int columnIndex)
394 | {
395 | if (columnIndex < isColumnEditable.length && columnIndex >= 0)
396 | return isColumnEditable[columnIndex];
397 |
398 | return false;
399 | }
400 |
401 | @Override
402 | public Object getValueAt(int rowIndex, int columnIndex)
403 | {
404 | return data[rowIndex][Math.min(columnIndex, data[rowIndex].length - 1)];
405 | }
406 | }
407 |
408 | @SuppressWarnings("rawtypes")
409 | public class MethodModel extends AbstractTableModel
410 | {
411 | private static final long serialVersionUID = 1L;
412 | private final String[] columnNames = { "MCP Name", "SRG Name", "Obf Name", "SRG Descriptor", "Comment" };
413 | private final Class[] columnTypes = { String.class, String.class, String.class, String.class, String.class };
414 | private final boolean[] isColumnEditable = { true, false, false, false, true };
415 | private final Object[][] data;
416 | private final Set setRef;
417 |
418 | public MethodModel(Set srgMethodSet)
419 | {
420 | setRef = srgMethodSet;
421 |
422 | data = new Object[setRef.size()][columnNames.length];
423 |
424 | int i = 0;
425 |
426 | for (MethodSrgData methodData : setRef)
427 | {
428 | CsvData csvData = srgMethodData2CsvData.get(methodData);
429 | if (csvData != null)
430 | {
431 | data[i][0] = csvData.getMcpName();
432 | data[i][4] = csvData.getComment();
433 | }
434 | else
435 | {
436 | data[i][0] = "";
437 | data[i][4] = "";
438 | }
439 | data[i][1] = methodData.getSrgName();
440 | data[i][2] = methodData.getObfName();
441 | data[i][3] = methodData.getSrgDescriptor();
442 |
443 | i++;
444 | }
445 | }
446 |
447 | @Override
448 | public int getRowCount()
449 | {
450 | return data.length;
451 | }
452 |
453 | @Override
454 | public int getColumnCount()
455 | {
456 | return columnNames.length;
457 | }
458 |
459 | @Override
460 | public String getColumnName(int columnIndex)
461 | {
462 | if (columnIndex < columnNames.length && columnIndex >= 0)
463 | return columnNames[columnIndex];
464 |
465 | return "";
466 | }
467 |
468 | @Override
469 | public Class> getColumnClass(int columnIndex)
470 | {
471 | if (columnIndex < columnTypes.length && columnIndex >= 0)
472 | return columnTypes[columnIndex];
473 |
474 | return String.class;
475 | }
476 |
477 | @Override
478 | public boolean isCellEditable(int rowIndex, int columnIndex)
479 | {
480 | if (columnIndex < isColumnEditable.length && columnIndex >= 0)
481 | return isColumnEditable[columnIndex];
482 |
483 | return false;
484 | }
485 |
486 | @Override
487 | public Object getValueAt(int rowIndex, int columnIndex)
488 | {
489 | return data[rowIndex][Math.min(columnIndex, data[rowIndex].length - 1)];
490 | }
491 |
492 | @Override
493 | public void setValueAt(Object aValue, int rowIndex, int columnIndex)
494 | {
495 | data[rowIndex][columnIndex] = aValue;
496 |
497 | if (columnIndex == 4 && aValue != null && (data[rowIndex][0] == null || data[rowIndex][0].toString().trim().isEmpty()))
498 | return; // if only the comment has been set, don't bother adding a command
499 |
500 | String srgName = (String) data[rowIndex][1];
501 | String mcpName = (String) data[rowIndex][0];
502 | String comment = (String) data[rowIndex][4];
503 |
504 | if (mcpName.trim().isEmpty())
505 | return;
506 |
507 | CsvData result = processMemberDataEdit(MemberType.METHOD, srgFileData.srgMethodName2MethodData, srgMethodData2CsvData, srgName, mcpName, comment);
508 |
509 | if (result != null)
510 | {
511 | csvMethodData.updateCsvDataForKey(srgName, result);
512 | srgMethodData2CsvData.put(srgFileData.srgMethodName2MethodData.get(srgName), result);
513 | parentGui.setCsvFileEdited(true);
514 | }
515 | }
516 | }
517 |
518 | @SuppressWarnings("rawtypes")
519 | public class ParamModel extends AbstractTableModel
520 | {
521 | private static final long serialVersionUID = 1L;
522 | private final String[] columnNames = { "MCP Name", "SRG Name", "Type" };
523 | private final Class[] columnTypes = { String.class, String.class, String.class };
524 | private final boolean[] isColumnEditable = { true, false, false };
525 | private final Object[][] data;
526 |
527 | public ParamModel(ExcData excData)
528 | {
529 | data = new Object[excData.getParameters().length][columnNames.length];
530 |
531 | for (int i = 0; i < excData.getParameters().length; i++)
532 | {
533 | if (excData2MapParamCsvData.containsKey(excData) && excData2MapParamCsvData.get(excData).containsKey(excData.getParameters()[i]))
534 | data[i][0] = excData2MapParamCsvData.get(excData).get(excData.getParameters()[i]).getMcpName();
535 | else
536 | data[i][0] = "";
537 |
538 | data[i][1] = excData.getParameters()[i];
539 | data[i][2] = excData.getParamTypes()[i];
540 | //i++;
541 | }
542 | }
543 |
544 | @Override
545 | public int getRowCount()
546 | {
547 | return data.length;
548 | }
549 |
550 | @Override
551 | public int getColumnCount()
552 | {
553 | return columnNames.length;
554 | }
555 |
556 | @Override
557 | public String getColumnName(int columnIndex)
558 | {
559 | if (columnIndex < columnNames.length && columnIndex >= 0)
560 | return columnNames[columnIndex];
561 |
562 | return "";
563 | }
564 |
565 | @Override
566 | public Class> getColumnClass(int columnIndex)
567 | {
568 | if (columnIndex < columnTypes.length && columnIndex >= 0)
569 | return columnTypes[columnIndex];
570 |
571 | return String.class;
572 | }
573 |
574 | @Override
575 | public boolean isCellEditable(int rowIndex, int columnIndex)
576 | {
577 | if (columnIndex < isColumnEditable.length && columnIndex >= 0)
578 | return isColumnEditable[columnIndex];
579 |
580 | return false;
581 | }
582 |
583 | @Override
584 | public Object getValueAt(int rowIndex, int columnIndex)
585 | {
586 | return data[rowIndex][Math.min(columnIndex, data[rowIndex].length - 1)];
587 | }
588 |
589 | @Override
590 | public void setValueAt(Object aValue, int rowIndex, int columnIndex)
591 | {
592 | data[rowIndex][columnIndex] = aValue;
593 |
594 | String srgName = (String) data[rowIndex][1];
595 | String mcpName = (String) data[rowIndex][0];
596 |
597 | if (mcpName.trim().isEmpty())
598 | return;
599 |
600 | ExcData excData = excFileData.srgParamName2ExcData.get(srgName);
601 | ParamCsvData csvData = null;
602 | boolean isForced = csvParamData.hasCsvDataForKey(srgName);
603 |
604 | if (isForced)
605 | {
606 | csvData = csvParamData.getCsvDataForKey(srgName);
607 | if (!mcpName.trim().equals(csvData.getMcpName()))
608 | csvData.setMcpName(mcpName.trim());
609 | else
610 | return;
611 | }
612 | else
613 | {
614 | csvData = new ParamCsvData(srgName, mcpName, 2);
615 | excData2MapParamCsvData.get(excData).put(srgName, csvData);
616 | }
617 |
618 | commandMap.put(srgName, McpBotCommand.getMcpBotCommand(MemberType.PARAM, isForced, csvData.getSrgName(), csvData.getMcpName(), ""));
619 |
620 | csvParamData.updateCsvDataForKey(srgName, csvData);
621 | parentGui.setCsvFileEdited(true);
622 | }
623 | }
624 |
625 | @SuppressWarnings("rawtypes")
626 | public class FieldModel extends AbstractTableModel
627 | {
628 | private static final long serialVersionUID = 1L;
629 | private final String[] columnNames = { "MCP Name", "SRG Name", "Obf Name", "Comment" };
630 | private final Class[] columnTypes = { String.class, String.class, String.class, String.class };
631 | private final boolean[] isColumnEditable = { true, false, false, true };
632 | private final Object[][] data;
633 | private final Set setRef;
634 |
635 | public FieldModel(Set srgFieldSet)
636 | {
637 | setRef = srgFieldSet;
638 |
639 | data = new Object[setRef.size()][columnNames.length];
640 |
641 | int i = 0;
642 |
643 | for (FieldSrgData fieldData : setRef)
644 | {
645 | CsvData csvData = srgFieldData2CsvData.get(fieldData);
646 | if (csvData != null)
647 | {
648 | data[i][0] = csvData.getMcpName();
649 | data[i][3] = csvData.getComment();
650 | }
651 | else
652 | {
653 | data[i][0] = "";
654 | data[i][3] = "";
655 | }
656 | data[i][1] = fieldData.getSrgName();
657 | data[i][2] = fieldData.getObfName();
658 |
659 | i++;
660 | }
661 | }
662 |
663 | @Override
664 | public int getRowCount()
665 | {
666 | return data.length;
667 | }
668 |
669 | @Override
670 | public int getColumnCount()
671 | {
672 | return columnNames.length;
673 | }
674 |
675 | @Override
676 | public String getColumnName(int columnIndex)
677 | {
678 | if (columnIndex < columnNames.length && columnIndex >= 0)
679 | return columnNames[columnIndex];
680 |
681 | return "";
682 | }
683 |
684 | @Override
685 | public Class> getColumnClass(int columnIndex)
686 | {
687 | if (columnIndex < columnTypes.length && columnIndex >= 0)
688 | return columnTypes[columnIndex];
689 |
690 | return String.class;
691 | }
692 |
693 | @Override
694 | public boolean isCellEditable(int rowIndex, int columnIndex)
695 | {
696 | if (columnIndex < isColumnEditable.length && columnIndex >= 0)
697 | return isColumnEditable[columnIndex];
698 |
699 | return false;
700 | }
701 |
702 | @Override
703 | public Object getValueAt(int rowIndex, int columnIndex)
704 | {
705 | return data[rowIndex][Math.min(columnIndex, data[rowIndex].length - 1)];
706 | }
707 |
708 | @Override
709 | public void setValueAt(Object aValue, int rowIndex, int columnIndex)
710 | {
711 | data[rowIndex][columnIndex] = aValue;
712 |
713 | if (columnIndex == 3 && aValue != null && (data[rowIndex][0] == null || data[rowIndex][0].toString().trim().isEmpty()))
714 | return; // if only the comment has been set, don't bother adding a command
715 |
716 | String srgName = (String) data[rowIndex][1];
717 | String mcpName = (String) data[rowIndex][0];
718 | String comment = (String) data[rowIndex][3];
719 |
720 | if (mcpName.trim().isEmpty())
721 | return;
722 |
723 | CsvData result = processMemberDataEdit(MemberType.FIELD, srgFileData.srgFieldName2FieldData, srgFieldData2CsvData, srgName, mcpName, comment);
724 |
725 | if (result != null)
726 | {
727 | csvFieldData.updateCsvDataForKey(srgName, result);
728 | srgFieldData2CsvData.put(srgFileData.srgFieldName2FieldData.get(srgName), result);
729 | parentGui.setCsvFileEdited(true);
730 | }
731 | }
732 | }
733 | }
734 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/MemberSrgData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | public class MemberSrgData
19 | {
20 | private final String obfOwner;
21 | private final String obfName;
22 | private final String srgOwner;
23 | private final String srgPkg;
24 | private final String srgName;
25 | private final boolean isClientOnly;
26 |
27 | public MemberSrgData(String obfOwner, String obfName, String srgOwner, String srgPkg, String srgName, boolean isClientOnly)
28 | {
29 | this.obfOwner = obfOwner;
30 | this.obfName = obfName;
31 | this.srgOwner = srgOwner;
32 | this.srgPkg = srgPkg;
33 | this.srgName = srgName;
34 | this.isClientOnly = isClientOnly;
35 | }
36 |
37 | public String getObfOwner()
38 | {
39 | return obfOwner;
40 | }
41 |
42 | public String getObfName()
43 | {
44 | return obfName;
45 | }
46 |
47 | public String getSrgOwner()
48 | {
49 | return srgOwner;
50 | }
51 |
52 | public String getSrgName()
53 | {
54 | return srgName;
55 | }
56 |
57 | public boolean isClientOnly()
58 | {
59 | return isClientOnly;
60 | }
61 |
62 | public String getSrgPkg()
63 | {
64 | return srgPkg;
65 | }
66 |
67 | public boolean contains(String s)
68 | {
69 | return srgName.contains(s) || obfName.contains(s);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/MethodSrgData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 |
19 | public class MethodSrgData extends MemberSrgData implements Comparable
20 | {
21 | private final String obfDescriptor;
22 | private final String srgDescriptor;
23 |
24 | public MethodSrgData(String obfOwner, String obfName, String obfDescriptor, String srgOwner, String srgPkg, String srgName, String srgDescriptor, boolean isClientOnly)
25 | {
26 | super(obfOwner, obfName, srgOwner, srgPkg, srgName, isClientOnly);
27 | this.obfDescriptor = obfDescriptor;
28 | this.srgDescriptor = srgDescriptor;
29 | }
30 |
31 | public String getObfDescriptor()
32 | {
33 | return obfDescriptor;
34 | }
35 |
36 | public String getSrgDescriptor()
37 | {
38 | return srgDescriptor;
39 | }
40 |
41 | @Override
42 | public int compareTo(MethodSrgData o)
43 | {
44 | if (o != null)
45 | return getSrgName().compareTo(o.getSrgName());
46 | else
47 | return 1;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/ParamCsvData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | public class ParamCsvData implements Comparable
19 | {
20 | private final String srgName;
21 | private String mcpName;
22 | private final int side;
23 |
24 | public ParamCsvData(String srgName, String mcpName, int side)
25 | {
26 | this.srgName = srgName;
27 | this.mcpName = mcpName;
28 | this.side = side;
29 | }
30 |
31 | public String toCsv()
32 | {
33 | return srgName + "," + mcpName + "," + side;
34 | }
35 |
36 | public String getSrgName()
37 | {
38 | return srgName;
39 | }
40 |
41 | public String getMcpName()
42 | {
43 | return mcpName;
44 | }
45 |
46 | public ParamCsvData setMcpName(String mcpName)
47 | {
48 | this.mcpName = mcpName;
49 | return this;
50 | }
51 |
52 | public int getSide()
53 | {
54 | return side;
55 | }
56 |
57 | @Override
58 | public int compareTo(ParamCsvData o)
59 | {
60 | if (o != null)
61 | return srgName.compareTo(o.srgName);
62 |
63 | return 1;
64 | }
65 |
66 | public boolean contains(String s)
67 | {
68 | return mcpName.contains(s);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/ParamCsvFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 bspkrs
3 | * Portions Copyright (C) 2014 Alex "immibis" Campbell
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
6 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
7 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
8 | * Software is furnished to do so, subject to the following conditions:
9 | *
10 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
13 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 | package bspkrs.mmv;
18 |
19 | import java.io.BufferedReader;
20 | import java.io.File;
21 | import java.io.FileReader;
22 | import java.io.FileWriter;
23 | import java.io.IOException;
24 | import java.io.PrintWriter;
25 | import java.text.SimpleDateFormat;
26 | import java.util.Date;
27 | import java.util.Map;
28 | import java.util.Scanner;
29 | import java.util.TreeMap;
30 |
31 | public class ParamCsvFile
32 | {
33 | private final File file;
34 | private final Map srgParamName2ParamCsvData;
35 | private boolean isDirty;
36 | private String headerLine;
37 |
38 | public ParamCsvFile(File file) throws IOException
39 | {
40 | this.file = file;
41 | srgParamName2ParamCsvData = new TreeMap();
42 | readFromFile();
43 | isDirty = false;
44 | }
45 |
46 | public void readFromFile() throws IOException
47 | {
48 | Scanner in = new Scanner(new BufferedReader(new FileReader(file)));
49 | try
50 | {
51 | in.useDelimiter(",");
52 | headerLine = in.nextLine(); // Skip header row
53 | while (in.hasNextLine())
54 | {
55 | String srgName = in.next();
56 | String mcpName = in.next();
57 | String side = in.nextLine().substring(1);
58 | srgParamName2ParamCsvData.put(srgName, new ParamCsvData(srgName, mcpName, Integer.valueOf(side)));
59 | }
60 | }
61 | finally
62 | {
63 | in.close();
64 | }
65 | }
66 |
67 | public void writeToFile() throws IOException
68 | {
69 | if (isDirty)
70 | {
71 | if (file.exists())
72 | {
73 | File fileBak = new File(file.getAbsolutePath() + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".bak");
74 | file.renameTo(fileBak);
75 | }
76 |
77 | file.createNewFile();
78 |
79 | PrintWriter out = new PrintWriter(new FileWriter(file));
80 | out.println(headerLine);
81 |
82 | for (ParamCsvData data : srgParamName2ParamCsvData.values())
83 | out.println(data.toCsv());
84 |
85 | out.close();
86 |
87 | isDirty = false;
88 | }
89 | }
90 |
91 | public boolean hasCsvDataForKey(String srgName)
92 | {
93 | return srgParamName2ParamCsvData.containsKey(srgName);
94 | }
95 |
96 | public ParamCsvData getCsvDataForKey(String srgName)
97 | {
98 | return srgParamName2ParamCsvData.get(srgName);
99 | }
100 |
101 | public void updateCsvDataForKey(String srgName, ParamCsvData csvData)
102 | {
103 | srgParamName2ParamCsvData.put(srgName, csvData);
104 | isDirty = true;
105 | }
106 |
107 | public boolean isDirty()
108 | {
109 | return isDirty;
110 | }
111 |
112 | public void setIsDirty(boolean bol)
113 | {
114 | isDirty = bol;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/RemoteZipHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | import java.io.File;
19 | import java.io.FileInputStream;
20 | import java.io.FileNotFoundException;
21 | import java.io.FileOutputStream;
22 | import java.io.FileWriter;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.io.OutputStream;
26 | import java.io.PrintWriter;
27 | import java.net.MalformedURLException;
28 | import java.net.URL;
29 | import java.net.URLConnection;
30 | import java.security.DigestException;
31 | import java.security.MessageDigest;
32 | import java.security.NoSuchAlgorithmException;
33 | import java.util.ArrayList;
34 | import java.util.List;
35 | import java.util.Scanner;
36 | import java.util.zip.ZipEntry;
37 | import java.util.zip.ZipInputStream;
38 |
39 | import bspkrs.mmv.gui.MappingGui;
40 |
41 | public class RemoteZipHandler
42 | {
43 | private final URL zipUrl;
44 | private final URL digestUrl;
45 | private final File localDir;
46 | private final String digestType;
47 | private final String zipFileName;
48 |
49 | public RemoteZipHandler(String urlString, File dir, String digestType) throws MalformedURLException
50 | {
51 | zipUrl = new URL(urlString);
52 | if (digestType != null)
53 | digestUrl = new URL(urlString + "." + digestType.toLowerCase());
54 | else
55 | digestUrl = null;
56 | String[] tokens = urlString.split("/");
57 | zipFileName = tokens[tokens.length - 1];
58 | localDir = dir;
59 | this.digestType = digestType;
60 | }
61 |
62 | public void checkRemoteZip() throws IOException, NoSuchAlgorithmException, DigestException
63 | {
64 | // fetch zip file sha1
65 | boolean fetchZip = true;
66 | String remoteHash = null;
67 | File digestFile = null;
68 | if (digestType != null)
69 | {
70 | // check hash against local hash if exists
71 | remoteHash = loadTextFromURL(digestUrl, new String[] { "" })[0];
72 | if (!remoteHash.isEmpty())
73 | {
74 | digestFile = new File(localDir, zipFileName + "." + digestType.toLowerCase());
75 |
76 | // if local digest exists and hashes match skip getting the zip file
77 | if (digestFile.exists())
78 | {
79 | String existingHash = loadTextFromFile(digestFile, new String[] { "" })[0];
80 | if (!existingHash.isEmpty() && remoteHash.equals(existingHash))
81 | fetchZip = false;
82 | }
83 | }
84 | }
85 |
86 | if (fetchZip)
87 | {
88 | // download zip
89 | File localZip = new File(localDir, zipFileName);
90 | if (localZip.exists())
91 | localZip.delete();
92 | OutputStream output = new FileOutputStream(localZip);
93 | try
94 | {
95 | URLConnection uc = zipUrl.openConnection();
96 | uc.addRequestProperty("User-Agent", "MMV/" + MappingGui.VERSION_NUMBER);
97 | byte[] buffer = new byte[1024]; // Or whatever
98 | int bytesRead;
99 | try (InputStream is = uc.getInputStream())
100 | {
101 | while ((bytesRead = is.read(buffer)) > 0)
102 | output.write(buffer, 0, bytesRead);
103 | }
104 | }
105 | finally
106 | {
107 | output.close();
108 | }
109 |
110 | // Check hash of downloaded file to ensure we received it correctly
111 | if (digestType != null && !remoteHash.isEmpty())
112 | {
113 | String downloadHash = getFileDigest(new FileInputStream(localZip), digestType);
114 | if (!remoteHash.equals(downloadHash))
115 | throw new java.security.DigestException("Remote digest does not match digest of downloaded file!");
116 | }
117 |
118 | // extract zip file
119 | extractZip(localZip, localDir);
120 | if (localZip.exists())
121 | localZip.delete();
122 |
123 | // save new hash after successful extract
124 | if (digestType != null && !remoteHash.isEmpty())
125 | {
126 | if (digestFile.exists())
127 | digestFile.delete();
128 | digestFile.createNewFile();
129 | PrintWriter out = new PrintWriter(new FileWriter(digestFile));
130 | out.print(remoteHash);
131 | out.close();
132 | }
133 | }
134 | }
135 |
136 | public static String[] loadTextFromURL(URL url, String[] defaultValue)
137 | {
138 | List arraylist = new ArrayList();
139 | Scanner scanner = null;
140 | try
141 | {
142 | URLConnection uc = url.openConnection();
143 | uc.addRequestProperty("User-Agent", "MMV/" + MappingGui.VERSION_NUMBER);
144 | InputStream is = uc.getInputStream();
145 | scanner = new Scanner(is, "UTF-8");
146 |
147 | while (scanner.hasNextLine())
148 | {
149 | arraylist.add(scanner.nextLine());
150 | }
151 | }
152 | catch (Throwable e)
153 | {
154 | return defaultValue;
155 | }
156 | finally
157 | {
158 | if (scanner != null)
159 | scanner.close();
160 | }
161 | return arraylist.toArray(new String[arraylist.size()]);
162 | }
163 |
164 | public static String[] loadTextFromFile(File file, String[] defaultValue)
165 | {
166 | ArrayList lines = new ArrayList();
167 |
168 | Scanner scanner = null;
169 | try
170 | {
171 | scanner = new Scanner(file);
172 | while (scanner.hasNextLine())
173 | lines.add(scanner.nextLine());
174 | }
175 | catch (FileNotFoundException e)
176 | {
177 | return defaultValue;
178 | }
179 | finally
180 | {
181 | if (scanner != null)
182 | scanner.close();
183 | }
184 |
185 | return lines.toArray(new String[lines.size()]);
186 | }
187 |
188 | public static String getFileDigest(InputStream is, String digestType) throws NoSuchAlgorithmException, IOException
189 | {
190 | MessageDigest md = MessageDigest.getInstance(digestType);
191 | byte[] dataBytes = new byte[1024];
192 |
193 | int nread = 0;
194 |
195 | while ((nread = is.read(dataBytes)) != -1)
196 | md.update(dataBytes, 0, nread);
197 |
198 | is.close();
199 |
200 | byte[] mdbytes = md.digest();
201 |
202 | //convert the byte to hex format
203 | StringBuffer sb = new StringBuffer("");
204 | for (int i = 0; i < mdbytes.length; i++)
205 | sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
206 | return sb.toString();
207 | }
208 |
209 | public static void extractZip(File zipFile, File destDir) throws IOException
210 | {
211 | byte[] buffer = new byte[1024];
212 | if (!destDir.exists())
213 | destDir.mkdirs();
214 |
215 | ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));
216 | ZipEntry ze = zis.getNextEntry();
217 | try
218 | {
219 | while (ze != null)
220 | {
221 | String fileName = ze.getName();
222 | File newFile = new File(destDir, fileName);
223 | if (!newFile.toPath().normalize().startsWith(destDir.toPath().normalize())) {
224 | throw new IOException("Bad zip entry");
225 | }
226 | if (ze.isDirectory())
227 | {
228 | if (newFile.exists())
229 | deleteDirAndContents(newFile);
230 | newFile.mkdirs();
231 | }
232 | else
233 | {
234 | if (newFile.exists())
235 | newFile.delete();
236 | if (newFile.getParentFile() != null && !newFile.getParentFile().exists())
237 | newFile.getParentFile().mkdirs();
238 | FileOutputStream fos = new FileOutputStream(newFile);
239 | int len;
240 | while ((len = zis.read(buffer)) > 0)
241 | fos.write(buffer, 0, len);
242 |
243 | fos.close();
244 | }
245 | ze = zis.getNextEntry();
246 | }
247 | }
248 | finally
249 | {
250 | zis.closeEntry();
251 | zis.close();
252 | }
253 | }
254 |
255 | public static boolean deleteDirAndContents(File dir)
256 | {
257 | if (dir.isDirectory())
258 | {
259 | String[] children = dir.list();
260 | for (int i = 0; i < children.length; i++)
261 | {
262 | boolean success = deleteDirAndContents(new File(dir, children[i]));
263 | if (!success)
264 | return false;
265 | }
266 | }
267 | return dir.delete();
268 | }
269 | }
270 |
--------------------------------------------------------------------------------
/src/main/java/bspkrs/mmv/SplittedNaturalComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 bspkrs
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
6 | * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 | * Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12 | * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 | package bspkrs.mmv;
17 |
18 | import java.util.Comparator;
19 |
20 | import bspkrs.mmv.version.NaturalOrderComparator;
21 |
22 | public class SplittedNaturalComparator implements Comparator