├── .github ├── FUNDING.yml └── CODEOWNERS ├── .mailmap ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── javadoc.options ├── changelogs ├── 0.4 │ ├── 0.4.2.md │ ├── 0.4.3.md │ ├── 0.4.1.md │ └── 0.4.4.md ├── 0.5 │ ├── 0.5.2.md │ ├── 0.5.7.md │ ├── 0.5.1.md │ ├── 0.5.5.md │ ├── 0.5.0.md │ ├── 0.5.3.md │ └── 0.5.6.md ├── 0.3 │ ├── 0.3.2.md │ ├── 0.3.1.md │ └── 0.3.0.md ├── 0.5.8.md ├── 0.1 │ └── 0.1.0.md ├── 0.2 │ └── 0.2.0.md └── 0.6.0.md ├── lorenz-io-jam ├── gradle.properties ├── build.gradle.kts └── src │ ├── test │ └── resources │ │ └── test.jam │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── org.cadixdev.lorenz.io.MappingFormat │ └── java │ └── org │ └── cadixdev │ └── lorenz │ └── io │ └── jam │ ├── package-info.java │ ├── JamConstants.java │ └── JamMappingFormat.java ├── lorenz-dsl-groovy ├── gradle.properties ├── build.gradle.kts └── src │ └── main │ └── java │ └── org │ └── cadixdev │ └── lorenz │ └── dsl │ └── groovy │ ├── package-info.java │ ├── DslUtil.java │ ├── MethodMappingDsl.java │ ├── MappingDsl.java │ └── MappingSetDsl.java ├── lorenz-io-enigma ├── gradle.properties ├── build.gradle.kts └── src │ ├── test │ └── resources │ │ └── test.enigma │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── org.cadixdev.lorenz.io.MappingFormat │ └── java │ └── org │ └── cadixdev │ └── lorenz │ └── io │ └── enigma │ ├── package-info.java │ ├── FabricEnigmaMappingFormat.java │ ├── EnigmaMappingFormat.java │ ├── EnigmaConstants.java │ └── FabricEnigmaWriter.java ├── lorenz-io-proguard ├── gradle.properties ├── build.gradle.kts └── src │ └── main │ ├── resources │ └── META-INF │ │ └── services │ │ └── org.cadixdev.lorenz.io.MappingFormat │ └── java │ └── org │ └── cadixdev │ └── lorenz │ └── io │ └── proguard │ ├── ProGuardConstants.java │ ├── package-info.java │ └── ProGuardFormat.java ├── lorenz ├── gradle.properties ├── src │ ├── test │ │ ├── resources │ │ │ ├── test.tsrg │ │ │ ├── test.csrg │ │ │ ├── test.srg │ │ │ └── test.xsrg │ │ ├── java │ │ │ ├── test │ │ │ │ └── inheritance │ │ │ │ │ ├── a │ │ │ │ │ ├── BaseClass.java │ │ │ │ │ └── PublicBaseClass.java │ │ │ │ │ └── TestClass.java │ │ │ └── org │ │ │ │ └── cadixdev │ │ │ │ └── lorenz │ │ │ │ └── test │ │ │ │ ├── asm │ │ │ │ ├── AsmFieldTypeProviderTest.java │ │ │ │ └── LorenzRemapperInheritanceTest.java │ │ │ │ ├── io │ │ │ │ └── srg │ │ │ │ │ ├── SrgReaderTest.java │ │ │ │ │ ├── XSrgReaderTest.java │ │ │ │ │ ├── CSrgReaderTest.java │ │ │ │ │ └── TSrgReaderTest.java │ │ │ │ └── model │ │ │ │ └── jar │ │ │ │ └── CompositeFieldTypeProviderTest.java │ │ └── groovy │ │ │ └── org │ │ │ └── cadixdev │ │ │ └── lorenz │ │ │ └── test │ │ │ ├── MappingObserveSpec.groovy │ │ │ ├── util │ │ │ └── BinaryToolSpec.groovy │ │ │ └── MappingReverseSpec.groovy │ └── main │ │ ├── java │ │ └── org │ │ │ └── cadixdev │ │ │ └── lorenz │ │ │ ├── impl │ │ │ ├── model │ │ │ │ ├── package-info.java │ │ │ │ ├── TopLevelClassMappingImpl.java │ │ │ │ ├── FieldMappingImpl.java │ │ │ │ ├── MethodParameterMappingImpl.java │ │ │ │ └── AbstractMemberMappingImpl.java │ │ │ ├── merge │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ │ ├── model │ │ │ ├── package-info.java │ │ │ ├── jar │ │ │ │ ├── package-info.java │ │ │ │ ├── FieldTypeProvider.java │ │ │ │ └── CompositeFieldTypeProvider.java │ │ │ ├── MemberMapping.java │ │ │ ├── MethodParameterMapping.java │ │ │ └── ExtensionKey.java │ │ │ ├── io │ │ │ ├── srg │ │ │ │ ├── csrg │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── CSrgMappingFormat.java │ │ │ │ ├── tsrg │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── TSrgMappingFormat.java │ │ │ │ ├── xsrg │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── XSrgMappingFormat.java │ │ │ │ ├── package-info.java │ │ │ │ ├── SrgMappingFormat.java │ │ │ │ └── SrgConstants.java │ │ │ ├── package-info.java │ │ │ ├── BinaryMappingsReader.java │ │ │ ├── BinaryMappingsWriter.java │ │ │ ├── MappingsReader.java │ │ │ ├── TextMappingsWriter.java │ │ │ ├── MappingFormats.java │ │ │ ├── MappingsWriter.java │ │ │ └── TextMappingFormat.java │ │ │ ├── merge │ │ │ ├── package-info.java │ │ │ ├── MethodMergeStrategy.java │ │ │ └── FieldMergeStrategy.java │ │ │ ├── util │ │ │ ├── Reversible.java │ │ │ ├── MappingChangedListener.java │ │ │ ├── BinaryTool.java │ │ │ └── Registry.java │ │ │ ├── package-info.java │ │ │ └── asm │ │ │ └── AsmFieldTypeProvider.java │ │ └── resources │ │ └── META-INF │ │ └── services │ │ └── org.cadixdev.lorenz.io.MappingFormat └── build.gradle.kts ├── settings.gradle.kts ├── .travis.yml ├── gradle.properties ├── .gitattributes ├── LICENSE.txt ├── HEADER.txt ├── gradlew.bat ├── .gitignore ├── etc └── codestyle-intellij.xml └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: jamierocks 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/about-codeowners/ 2 | 3 | * @jamierocks 4 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # Jamie Mansfield 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CadixDev/Lorenz/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/javadoc.options: -------------------------------------------------------------------------------- 1 | -tag "apiNote:a:API Note:" 2 | -tag "implSpec:a:Implementation Requirements:" 3 | -tag "implNote:a:Implementation Note:" 4 | -------------------------------------------------------------------------------- /changelogs/0.4/0.4.2.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.4.2 2 | ============ 3 | 4 | This version of Lorenz addresses a critical bug in the Enigma reader, that prevents inner 5 | classes from preceding the other members of a class. 6 | -------------------------------------------------------------------------------- /changelogs/0.4/0.4.3.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.4.3 2 | ============ 3 | 4 | This version of Lorenz introduces a number of improvements to the Enigma IO classes, namely 5 | fixing support that has been broken under 0.4.x. 6 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.2.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.2 2 | ============ 3 | 4 | Lorenz 0.5.2 addresses issues with using Lorenz's ASM Remapper on Atlas >= 0.2.0. 5 | Specifically, it should now be possibly to concurrently access mappings. 6 | -------------------------------------------------------------------------------- /lorenz-io-jam/gradle.properties: -------------------------------------------------------------------------------- 1 | projectName = Lorenz-IO-JAM 2 | description = An implementation of the JAM mapping format for Lorenz. 3 | projectUrl = https://www.jamiemansfield.me/projects/lorenz 4 | projectInceptionYear = 2018 5 | -------------------------------------------------------------------------------- /changelogs/0.3/0.3.2.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.3.2 2 | ============ 3 | 4 | This version of Lorenz addresses a critical bug in the TSRG writer, that causes invalid output 5 | (missing class names). 6 | 7 | *Lorenz is available through Maven Central*. 8 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/gradle.properties: -------------------------------------------------------------------------------- 1 | projectName = Lorenz-DSL-Groovy 2 | description = A DSL for easing use of Lorenz within Groovy projects. 3 | projectUrl = https://www.jamiemansfield.me/projects/lorenz 4 | projectInceptionYear = 2019 5 | -------------------------------------------------------------------------------- /lorenz-io-enigma/gradle.properties: -------------------------------------------------------------------------------- 1 | projectName = Lorenz-IO-Enigma 2 | description = An implementation of the Enigma mapping format for Lorenz. 3 | projectUrl = https://www.jamiemansfield.me/projects/lorenz 4 | projectInceptionYear = 2018 5 | -------------------------------------------------------------------------------- /lorenz-io-proguard/gradle.properties: -------------------------------------------------------------------------------- 1 | projectName = Lorenz-IO-ProGuard 2 | description = An implementation of the ProGuard mapping format for Lorenz. 3 | projectUrl = https://www.jamiemansfield.me/projects/lorenz 4 | projectInceptionYear = 2019 5 | -------------------------------------------------------------------------------- /lorenz/gradle.properties: -------------------------------------------------------------------------------- 1 | projectName = Lorenz 2 | description = A library for modelling, creating, and manipulating Java de-obfuscation mappings. 3 | projectUrl = https://www.jamiemansfield.me/projects/lorenz 4 | projectInceptionYear = 2016 5 | -------------------------------------------------------------------------------- /changelogs/0.5.8.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.8 2 | === 3 | 4 | ## Fixes 5 | 6 | - [GH-53]\: Don't de-obfuscate field types twice, which can cause 7 | invalid output in some conditions. 8 | 9 | [GH-53]: https://github.com/CadixDev/Lorenz/issues/53 10 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | val projectName: String by settings 2 | rootProject.name = projectName 3 | 4 | include( 5 | "lorenz", 6 | "lorenz-dsl-groovy", 7 | "lorenz-io-enigma", 8 | "lorenz-io-jam", 9 | "lorenz-io-proguard" 10 | ) 11 | -------------------------------------------------------------------------------- /changelogs/0.3/0.3.1.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.3.1 2 | ============ 3 | 4 | The revision of Lorenz brings about no new features or bug-fixes, rather completes the effort 5 | begun in 0.3.0 to better document Lorenz. 6 | 7 | *Lorenz is available through Maven Central*. 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /lorenz-io-jam/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | } 4 | 5 | dependencies { 6 | api(project(":lorenz")) 7 | } 8 | 9 | tasks.jar.configure { 10 | manifest.attributes(mapOf("Automatic-Module-Name" to "${project.group}.lorenz.io.jam")) 11 | } 12 | -------------------------------------------------------------------------------- /lorenz-io-enigma/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | } 4 | 5 | dependencies { 6 | api(project(":lorenz")) 7 | } 8 | 9 | tasks.jar.configure { 10 | manifest.attributes(mapOf("Automatic-Module-Name" to "${project.group}.lorenz.io.enigma")) 11 | } 12 | -------------------------------------------------------------------------------- /lorenz-io-proguard/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | } 4 | 5 | dependencies { 6 | api(project(":lorenz")) 7 | } 8 | 9 | tasks.jar.configure { 10 | manifest.attributes(mapOf("Automatic-Module-Name" to "${project.group}.lorenz.io.proguard")) 11 | } 12 | -------------------------------------------------------------------------------- /changelogs/0.1/0.1.0.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.1.0 2 | ============ 3 | 4 | This is the first production-ready release of Lorenz, despite it being a 'pre-release'. 5 | The API is not stable, and will be subject to lots of changes between now and 1.0.0. 6 | 7 | *Lorenz releases are available through Maven Central*. 8 | -------------------------------------------------------------------------------- /lorenz/src/test/resources/test.tsrg: -------------------------------------------------------------------------------- 1 | # yu uk/jamierocks/Comment 2 | uih uk/jamierocks/CommentTest # op uk/jr/Operator 3 | ght uk/jamierocks/Test 4 | rft log 5 | hyuip (I)Z isEven 6 | ght$ds uk/jamierocks/Test$Example 7 | juh server 8 | hyuip (I)Z isOdd 9 | ght$ds$bg uk/jamierocks/Test$Example$Inner 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # The Basics 2 | dist: trusty 3 | language: java 4 | jdk: 5 | - oraclejdk8 6 | 7 | script: ./gradlew build 8 | after_success: 9 | - '[[ "$TRAVIS_PULL_REQUEST" = "false" && "$TRAVIS_BRANCH" = "develop" ]] && ./gradlew uploadArchives' 10 | 11 | # Ugh. 12 | notifications: 13 | email: false 14 | -------------------------------------------------------------------------------- /lorenz/src/test/resources/test.csrg: -------------------------------------------------------------------------------- 1 | # yu uk/jamierocks/Comment 2 | uih uk/jamierocks/CommentTest # op uk/jr/Operator 3 | ght uk/jamierocks/Test 4 | ght$ds uk/jamierocks/Test$Example 5 | ght$ds$bg uk/jamierocks/Test$Example$Inner 6 | ght rft log 7 | ght$ds juh server 8 | ght hyuip (I)Z isEven 9 | ght$ds hyuip (I)Z isOdd 10 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project Information 2 | projectName = Lorenz 3 | projectUrl = https://www.cadixdev.org/ 4 | projectInceptionYear = 2016 5 | 6 | # Build Settings 7 | javaVersion = 1.8 8 | groovyVersion = 3.0.7 9 | asmVersion = 7.1 10 | bombeVersion = 0.5.0-SNAPSHOT 11 | junitVersion = 5.5.1 12 | spockVersion = 2.0-M4-groovy-3.0 13 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | } 4 | 5 | val groovyVersion: String by rootProject 6 | 7 | dependencies { 8 | implementation("org.codehaus.groovy:groovy:$groovyVersion") 9 | api(project(":lorenz")) 10 | } 11 | 12 | tasks.jar.configure { 13 | manifest.attributes(mapOf("Automatic-Module-Name" to "${project.group}.lorenz.dsl.groovy")) 14 | } 15 | -------------------------------------------------------------------------------- /lorenz/src/test/resources/test.srg: -------------------------------------------------------------------------------- 1 | # CL: yu uk/jamierocks/Comment 2 | CL: uih uk/jamierocks/CommentTest # CL: op uk/jr/Operator 3 | CL: ght uk/jamierocks/Test 4 | CL: ght$ds uk/jamierocks/Test$Example 5 | CL: ght$ds$bg uk/jamierocks/Test$Example$Inner 6 | FD: ght/rft uk/jamierocks/Test/log 7 | FD: ght$ds/juh uk/jamierocks/Test$Example/server 8 | MD: ght/hyuip (I)Z uk/jamierocks/Test/isEven (I)Z 9 | MD: ght$ds/hyuip (I)Z uk/jamierocks/Test$Example/isOdd (I)Z 10 | -------------------------------------------------------------------------------- /changelogs/0.4/0.4.1.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.4.1 2 | ============ 3 | 4 | This version of Lorenz addresses a critical bug in the Enigma writer, that causes invalid 5 | output (totally broken). 6 | 7 | ### Broken 8 | 9 | ``` 10 | CLASS none/aet 11 | 12 | METHOD c getDeathMessage (Lnone/afq;)Lnone/iw; 13 | 14 | 15 | ARG 0 entity 16 | ``` 17 | 18 | ### Fixed 19 | 20 | ``` 21 | CLASS none/aet 22 | METHOD c getDeathMessage (Lnone/afq;)Lnone/iw; 23 | ARG 0 entity 24 | ``` 25 | -------------------------------------------------------------------------------- /lorenz-io-jam/src/test/resources/test.jam: -------------------------------------------------------------------------------- 1 | # CL yu uk/jamierocks/Comment 2 | CL uih uk/jamierocks/CommentTest # CL op uk/jr/Operator 3 | CL ght uk/jamierocks/Test 4 | CL ght$ds uk/jamierocks/Test$Example 5 | CL ght$ds$bg uk/jamierocks/Test$Example$Inner 6 | FD ght rft Ljava/util/logging/Logger; log 7 | FD ght$ds juh Luk/jamierocks/Server; server 8 | MD ght hyuip (I)Z isEven 9 | MD ght$ds hyuip (I)Z isOdd 10 | MP ght hyuip (I)Z 0 num 11 | MP ght$ds hyuip (I)Z 0 num 12 | -------------------------------------------------------------------------------- /lorenz/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | } 4 | 5 | val bombeVersion: String by rootProject 6 | val asmVersion: String by rootProject 7 | 8 | dependencies { 9 | api("org.cadixdev:bombe:$bombeVersion") 10 | 11 | // Optional dependencies 12 | implementation("org.ow2.asm:asm-commons:$asmVersion") 13 | implementation("org.cadixdev:bombe-jar:$bombeVersion") 14 | } 15 | 16 | tasks.jar.configure { 17 | manifest.attributes(mapOf("Automatic-Module-Name" to "${project.group}.lorenz")) 18 | } 19 | -------------------------------------------------------------------------------- /lorenz/src/test/resources/test.xsrg: -------------------------------------------------------------------------------- 1 | # CL: yu uk/jamierocks/Comment 2 | CL: uih uk/jamierocks/CommentTest # CL: op uk/jr/Operator 3 | CL: ght uk/jamierocks/Test 4 | CL: ght$ds uk/jamierocks/Test$Example 5 | CL: ght$ds$bg uk/jamierocks/Test$Example$Inner 6 | FD: ght/rft Ljava/util/logging/Logger; uk/jamierocks/Test/log Ljava/util/logging/Logger; 7 | FD: ght$ds/juh Luk/jamierocks/Server; uk/jamierocks/Test$Example/server Luk/jamierocks/Server; 8 | MD: ght/hyuip (I)Z uk/jamierocks/Test/isEven (I)Z 9 | MD: ght$ds/hyuip (I)Z uk/jamierocks/Test$Example/isOdd (I)Z 10 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.7.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.7 2 | === 3 | 4 | ## Fixes 5 | 6 | - CSRG and TSRG now ignore package mappings, rather than erroneously reading them 7 | as class mappings. 8 | - `MappingSet#deobfuscate(FieldType)` will now correctly de-obfuscate object types 9 | of inner classes, where the parent class has a mapping - but the inner class 10 | does not. 11 | - [GH-29]\: Avoid inheriting field mappings from a parent where the child class has 12 | a field of its own, of the same signature. 13 | 14 | [GH-29]: https://github.com/CadixDev/Lorenz/issues/29 15 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.1.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.1 2 | ============ 3 | 4 | Lorenz 0.5.1 brings some minor additions, that were missed during previous dev cycles, 5 | identified during the development of Lorenz 0.6. 6 | 7 | ## ProGuard Reader 8 | 9 | Lorenz 0.5.1 includes a `lorenz-io-proguard` module, that allows you to read 10 | ProGuard output files (for example, Mojang's mapping files for Minecraft). You can 11 | obtain the ProGuard `MappingFormat` with `MappingFormats.byId("proguard")`. 12 | 13 | Importantly, the ProGuard module **does not** support writing mapping files. 14 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/test/resources/test.enigma: -------------------------------------------------------------------------------- 1 | # CLASS yu uk/jamierocks/Comment 2 | CLASS uih uk/jamierocks/CommentTest # CLASS op uk/jr/Operator 3 | CLASS ght uk/jamierocks/Test 4 | CLASS ght$ds Example 5 | CLASS ght$ds$bg Inner 6 | METHOD dup print (I)Z 7 | ARG 0 num 8 | FIELD juh server Luk/jamierocks/Server; 9 | METHOD hyuip isOdd (I)Z 10 | ARG 0 num 11 | CLASS ght$beep Beep 12 | CLASS ght$beep$boop Boop 13 | METHOD dup print (I)Z 14 | ARG 0 num 15 | FIELD rft log Ljava/util/logging/Logger; 16 | METHOD hyuip isEven (I)Z 17 | ARG 0 num 18 | -------------------------------------------------------------------------------- /changelogs/0.4/0.4.4.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.4.4 2 | ============ 3 | 4 | Lorenz 0.4.4 is the combination of bugs identified in the development of Lorenz 0.5.0, specifically 5 | with regards to the mapping format implementations, in addition to a faulty mapping model method. 6 | 7 | ## IO 8 | 9 | - TSRG: Don't write empty class line for parents 10 | - TSRG: Correct a length check, preventing some **valid** mappings from being read 11 | - Enigma: Output field types properly, using the *obfuscated* type 12 | 13 | ## Mapping Model 14 | 15 | - Fix the faulty implementation of `ClassMapping::hasMappings`, specifically it did'nt consider method 16 | argument mappings 17 | -------------------------------------------------------------------------------- /changelogs/0.3/0.3.0.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.3.0 2 | ============ 3 | 4 | This version of Lorenz largely builds on the efforts of the previous release, in addition 5 | to some preparation for supporting the Enigma and JAM mapping formats. 6 | 7 | ## Changes 8 | 9 | - In accordance with the Java specification, I have corrected the naming of MethodDescriptor 10 | / MethodSignature (I had them the reverse way round). 11 | - Model construction is now handled through a `MappingSetModelFactory` - allowing models to 12 | be used together 13 | - Introduced an (unused) FieldSignature and FieldTypeProvider 14 | 15 | ## Migrating from 0.2.0 16 | 17 | Migration should be a fairly easy task, unless MethodDescriptor/MethodSignature was used. 18 | There have been no other breaking changes. 19 | 20 | *Lorenz is available through Maven Central*. 21 | -------------------------------------------------------------------------------- /changelogs/0.2/0.2.0.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.2.0 2 | ============ 3 | 4 | This version of Lorenz begins to address some of the issues that present using it within 5 | Nocturne - which is largely driving the functionality I desire for 1.0.0. 6 | 7 | ## Changes 8 | 9 | - The API has been split from the implementation 10 | - The parser classes have been renamed: `*Parser -> *Processor`, `.parser. -> .reader.` 11 | - The two variants of SRG are now supported: CSRG and TSRG 12 | 13 | ## Migrating from 0.1.0 14 | 15 | Despite the far-reaching internal changes, migrating from 0.1.0 is a rather simple procedure. 16 | 17 | - Model classes can no longer be constructed manually, instead the `createMapping` methods 18 | should be used. To create a MappingSet, `MappingSet.create()` should be used 19 | - The reader class imports will need to be changes, to use the new package name and class 20 | names mentioned above 21 | 22 | *Lorenz is available through Maven Central*. 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Handle line endings automatically for files detected as text 2 | # and leave all files detected as binary untouched. 3 | * text=auto 4 | 5 | # 6 | # The above will handle all files NOT found below 7 | # 8 | # These files are text and should be normalized (Convert crlf => lf) 9 | *.css text 10 | *.df text 11 | *.htm text 12 | *.html text 13 | *.java text 14 | *.js text 15 | *.json text 16 | *.jsp text 17 | *.jspf text 18 | *.properties text 19 | *.sh text 20 | *.svg text 21 | *.tld text 22 | *.txt text 23 | *.xml text 24 | 25 | # These files are binary and should be left untouched 26 | # (binary is a macro for -text -diff) 27 | *.class binary 28 | *.dll binary 29 | *.ear binary 30 | *.gif binary 31 | *.ico binary 32 | *.jar binary 33 | *.jpg binary 34 | *.jpeg binary 35 | *.png binary 36 | *.so binary 37 | *.war binary 38 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Jamie Mansfield 4 | Copyright (c) contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /HEADER.txt: -------------------------------------------------------------------------------- 1 | This file is part of Lorenz, licensed under the MIT License (MIT). 2 | 3 | Copyright (c) Jamie Mansfield 4 | Copyright (c) contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lorenz-io-jam/src/main/resources/META-INF/services/org.cadixdev.lorenz.io.MappingFormat: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of Lorenz, licensed under the MIT License (MIT). 3 | # 4 | # Copyright (c) Jamie Mansfield 5 | # Copyright (c) contributors 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | # 25 | 26 | org.cadixdev.lorenz.io.jam.JamMappingFormat 27 | -------------------------------------------------------------------------------- /lorenz-io-proguard/src/main/resources/META-INF/services/org.cadixdev.lorenz.io.MappingFormat: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of Lorenz, licensed under the MIT License (MIT). 3 | # 4 | # Copyright (c) Jamie Mansfield 5 | # Copyright (c) contributors 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | # 25 | 26 | org.cadixdev.lorenz.io.proguard.ProGuardFormat 27 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.5.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.5 2 | ============ 3 | 4 | ## Writer configurations 5 | 6 | Writer configurations are a powerful new feature that allows the output of 7 | mappings writers to be fine-tuned as consumers would like. Currently, this 8 | is limited to: 9 | 10 | - The sorting functions used to write mappings for classes, fields, and 11 | methods. 12 | - The API is open-ended, so there is potential for further additions to be 13 | made. 14 | 15 | Writer configurations can be created fluently through use the provided 16 | builder, which includes our default implementations. 17 | 18 | ```java 19 | protected MappingsWriterConfig config = MappingsWriterConfig.builder() 20 | .classMappingComparator(Comparator.comparing(Mapping::getFullObfuscatedName)) 21 | .fieldMappingComparator(Comparator.comparing(Mapping::getFullObfuscatedName)) 22 | .methodMappingComparator(Comparator.comparing(Mapping::getFullObfuscatedName)) 23 | .build(); 24 | ``` 25 | 26 | They are applied to a mappings writer by use of the new `#setConfig` method, 27 | and can be retrieved through the corresponding `#getConfig()` method. 28 | 29 | ```java 30 | writer.setConfig(MappingsWriterConfig.builder().build()); 31 | ``` 32 | 33 | ## Fixes 34 | 35 | - The Kin mapping writer now produces consistent output, sorting the 36 | mappings as per the provided comparators. Output is also now rid of 'junk' 37 | mappings (those without valid children mappings, or a de-obf mapping of 38 | their own). 39 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/main/resources/META-INF/services/org.cadixdev.lorenz.io.MappingFormat: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of Lorenz, licensed under the MIT License (MIT). 3 | # 4 | # Copyright (c) Jamie Mansfield 5 | # Copyright (c) contributors 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | # 25 | 26 | org.cadixdev.lorenz.io.enigma.EnigmaMappingFormat 27 | org.cadixdev.lorenz.io.enigma.FabricEnigmaMappingFormat 28 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/model/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The default Lorenz model implementation. 28 | */ 29 | package org.cadixdev.lorenz.impl.model; 30 | -------------------------------------------------------------------------------- /lorenz/src/test/java/test/inheritance/a/BaseClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package test.inheritance.a; 27 | 28 | abstract class BaseClass { 29 | 30 | void helloWorld() { 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/merge/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The default Lorenz mapping set merge implementation. 28 | */ 29 | package org.cadixdev.lorenz.impl.merge; 30 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * A model of the various mappings types that Lorenz represents. 28 | */ 29 | package org.cadixdev.lorenz.model; 30 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/csrg/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the CSRG mapping format. 28 | */ 29 | package org.cadixdev.lorenz.io.srg.csrg; 30 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/tsrg/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the TSRG mapping format. 28 | */ 29 | package org.cadixdev.lorenz.io.srg.tsrg; 30 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/xsrg/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the XSRG mapping format. 28 | */ 29 | package org.cadixdev.lorenz.io.srg.xsrg; 30 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/main/java/org/cadixdev/lorenz/io/enigma/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the Enigma mapping format. 28 | */ 29 | package org.cadixdev.lorenz.io.enigma; 30 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The abstract IO classes that can be extended to implement mapping formats 28 | * in Lorenz. 29 | */ 30 | package org.cadixdev.lorenz.io; 31 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/jar/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * A model for Java-specific types, often based on entries from the jvms manual. 28 | */ 29 | package org.cadixdev.lorenz.model.jar; 30 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the SRG mapping format and its 28 | * variants, CSRG and TSRG. 29 | */ 30 | package org.cadixdev.lorenz.io.srg; 31 | -------------------------------------------------------------------------------- /lorenz/src/main/resources/META-INF/services/org.cadixdev.lorenz.io.MappingFormat: -------------------------------------------------------------------------------- 1 | # 2 | # This file is part of Lorenz, licensed under the MIT License (MIT). 3 | # 4 | # Copyright (c) Jamie Mansfield 5 | # Copyright (c) contributors 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | # 25 | 26 | org.cadixdev.lorenz.io.srg.SrgMappingFormat 27 | org.cadixdev.lorenz.io.srg.csrg.CSrgMappingFormat 28 | org.cadixdev.lorenz.io.srg.tsrg.TSrgMappingFormat 29 | org.cadixdev.lorenz.io.srg.xsrg.XSrgMappingFormat 30 | -------------------------------------------------------------------------------- /lorenz/src/test/java/test/inheritance/a/PublicBaseClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package test.inheritance.a; 27 | 28 | public class PublicBaseClass extends BaseClass { 29 | 30 | @Override 31 | public void helloWorld() { 32 | super.helloWorld(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /lorenz/src/test/java/test/inheritance/TestClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package test.inheritance; 27 | 28 | import test.inheritance.a.PublicBaseClass; 29 | 30 | public class TestClass extends PublicBaseClass { 31 | 32 | @Override 33 | public void helloWorld() { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /lorenz-io-jam/src/main/java/org/cadixdev/lorenz/io/jam/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the JAM mapping format. 28 | * 29 | * @see github.com/caseif/JAM 30 | */ 31 | package org.cadixdev.lorenz.io.jam; 32 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/merge/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * An API for merging Lorenz mappings. The main API in this package is 28 | * {@link org.cadixdev.lorenz.merge.MappingSetMerger MappingSetMerger}. Also worth noting is 29 | * {@link org.cadixdev.lorenz.merge.MappingSetMergerHandler MappingSetMergerHandler}. 30 | * 31 | * @since 0.5.4 32 | */ 33 | package org.cadixdev.lorenz.merge; 34 | -------------------------------------------------------------------------------- /lorenz-io-proguard/src/main/java/org/cadixdev/lorenz/io/proguard/ProGuardConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.proguard; 27 | 28 | /** 29 | * A collection of constants and utilities specific to 30 | * the ProGuard mapping format. 31 | * 32 | * @author Jamie Mansfield 33 | * @since 0.5.1 34 | */ 35 | public final class ProGuardConstants { 36 | 37 | private ProGuardConstants() { 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The default Lorenz implementation. 28 | * 29 | *

Lorenz is split into API and implementation to allow for callbacks and 30 | * special-casing by external tools to be made easily. External tools can even 31 | * replace single components, by using the 32 | * {@link org.cadixdev.lorenz.MappingSetModelFactory}

. 33 | */ 34 | package org.cadixdev.lorenz.impl; 35 | -------------------------------------------------------------------------------- /lorenz-io-proguard/src/main/java/org/cadixdev/lorenz/io/proguard/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * The Lorenz-provided implementation of the 28 | * ProGuard mapping.txt 29 | * format. 30 | *

31 | * Currently we can only support reading ProGuard files, as Lorenz doesn't have a model 32 | * for all the data represented by the format. 33 | * 34 | * @since 0.5.1 35 | */ 36 | package org.cadixdev.lorenz.io.proguard; 37 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.0.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.0 2 | =========== 3 | 4 | Lorenz 0.5.0 has enjoyed a long development process (beginning the 1st of September!), 5 | and packs a bundle of cool changes. The most notable being the change of package, from 6 | `me.jamiemansfield.lorenz` to `org.cadixdev.lorenz`. 7 | 8 | ## Modularisation 9 | 10 | The long put-off modularisation has finally arrived - with the Enigma, JAM, and Kin 11 | mapping formats being given their own modules. 12 | 13 | - Enigma: `org.cadixdev:lorenz-io-enigma:0.5.0` 14 | - JAM: `org.cadixdev:lorenz-io-jam:0.5.0` 15 | - Kin: `org.cadixdev:lorenz-io-kin:0.5.0` 16 | 17 | Mapping formats can be introduced through service providers, and `MappingFormats` will 18 | populate a registry with all the formats found. You can get a mapping format, like the 19 | following: 20 | 21 | ```java 22 | final MappingFormat enigma = MappingFormats.byId("enigma"); 23 | final MappingFormat jam = MappingFormats.byId("jam"); 24 | final MappingFormat kin = MappingFormats.byId("kin"); 25 | ``` 26 | 27 | ## Merging and reversing 28 | 29 | Mapping sets can now be reversed (`A->B` -> `B->A`), and mapping sets merged 30 | (`A->B` + `B->C` = `A->C`). This can be achieved like the following. 31 | 32 | ```java 33 | // let a be a MappingSet 34 | // let b be a MappingSet 35 | 36 | final MappingSet reversed = a.reverse(); 37 | final MappingSet merged = a.merge(b); 38 | ``` 39 | 40 | ## Extension Data 41 | 42 | Lorenz now supports adding extension data to the mapping model (**no existing formats serialise this 43 | information**). 44 | 45 | ```java 46 | static final ExtensionKey EXTRA_NAME = new ExtensionKey<>(String.class, "extra_name"); 47 | 48 | final MappingSet mappings = new MappingSet(); 49 | mappings.set(EXTRA_NAME, "Beep Boop"); 50 | mappings.get(EXTRA_NAME).get(); // Beep Boop 51 | ``` 52 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.3.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.3 2 | ============ 3 | 4 | Lorenz 0.5.3 includes yet-another set of bug-fixes: 5 | 6 | - [Mercury/GH-14]: Inheritance completion now considers elevated return types 7 | - [Bombe/GH-11]: Bump Bombe dependency to 0.3.2, including a fix for remapping 8 | manifests without a `Main-Class` attribute 9 | - [Lorenz/GH-30]: Don't wrap `Writer`s in `TextMappingsWriter`, allowing files 10 | larger than `BufferedWriter`s buffer to be written (thanks to @phase for this 11 | bug-fix) 12 | - [Lorenz/GH-32]: Support blank comments in IO readers (affects SRG formats, JAM, 13 | and Enigma) 14 | 15 | Support for yet-another SRG variant, XSRG, has also been introduced with this 16 | release - the format is the same as the SRG format, though has field types 17 | ([Lorenz/GH-33]). 18 | 19 | Thanks to @phase and @DemonWav for their contributions towards this release. 20 | 21 | ### Registries 22 | 23 | `Registry` has been expanded to expose more of the underlying `Map`'s data: 24 | 25 | - `Registry#keys()`, returning a `Set` of `String`s which correspond to the 26 | identifier of registered values. 27 | - `Registry#entries()`, returning a `Set` of `Map.Entry`s. 28 | 29 | ### Improved Mapping Merging 30 | 31 | Mapping Merging, introduced with Lorenz 0.5.0, has always been a fairly 32 | lacklustre implementation - dropping mappings present on the b mapping set, if 33 | there wasn't a mapping in the a mapping set. 34 | 35 | Thanks to @DemonWav, that has now been resolved (see [Lorenz/GH-36]). 36 | 37 | [Mercury/GH-14]: https://github.com/CadixDev/Mercury/issues/14 38 | [Bombe/GH-11]: https://github.com/CadixDev/Bombe/issues/11 39 | [Lorenz/GH-30]: https://github.com/CadixDev/Lorenz/pull/30 40 | [Lorenz/GH-32]: https://github.com/CadixDev/Lorenz/issues/32 41 | [Lorenz/GH-33]: https://github.com/CadixDev/Lorenz/issues/33 42 | [Lorenz/GH-36]: https://github.com/CadixDev/Lorenz/pull/36 43 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/src/main/java/org/cadixdev/lorenz/dsl/groovy/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * A Groovy DSL, that simplifies the creation of Lorenz mappings. 28 | * 29 | *

30 |  *     def mappings = MappingSetDsl.create {
31 |  *         klass('a') {
32 |  *             deobf = 'Demo'
33 |  *             extension EXTRA, 'a.class'
34 |  *             field('g') { deobf = 'name' }
35 |  *             method('h', '()Ljava/lang/String;') { deobf = 'getName' }
36 |  *         }
37 |  *     }
38 |  * 
39 | * 40 | * @author Jamie Mansfield 41 | * @since 0.6.0 42 | */ 43 | package org.cadixdev.lorenz.dsl.groovy; 44 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/util/Reversible.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.util; 27 | 28 | /** 29 | * Interface for describing an object that can be reversed. 30 | * 31 | * @param The type of the reversible object 32 | * @param

The type of the parent object 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.5.0 36 | */ 37 | public interface Reversible { 38 | 39 | /** 40 | * Produces a new object that is a reverse copy of the original. 41 | * 42 | * @param parent The parent object 43 | * @return The reversed object 44 | */ 45 | T reverse(final P parent); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * Lorenz is a library built to interact with Java de-obfuscation mappings. 28 | * 29 | *

This library gives developers a way to express de-obfuscation mappings, in 30 | * addition to performing IO for a variety of formats (users can also write 31 | * their own readers and writers).

32 | * 33 | *

I developed Lorenz specifically for my needs, largely around Minecraft, and 34 | * so I have implemented IO classes for the following formats:

35 | *
    36 | *
  • SRG
  • 37 | *
  • CSRG
  • 38 | *
  • TSRG
  • 39 | *
  • XSRG
  • 40 | *
41 | */ 42 | package org.cadixdev.lorenz; 43 | -------------------------------------------------------------------------------- /lorenz/src/test/groovy/org/cadixdev/lorenz/test/MappingObserveSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test 27 | 28 | import org.cadixdev.lorenz.MappingSet 29 | import spock.lang.Specification 30 | 31 | class MappingObserveSpec extends Specification { 32 | 33 | def "can observe changes"() { 34 | given: 35 | def classMapping = new MappingSet().getOrCreateTopLevelClassMapping('a') 36 | classMapping.addListener { mapping, newName -> 37 | throw new IllegalArgumentException("beep boop") 38 | } 39 | 40 | when: 41 | classMapping.setDeobfuscatedName('Demo') 42 | 43 | then: 44 | thrown(IllegalArgumentException) 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/MemberMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.model; 27 | 28 | /** 29 | * Represents a mapping that is a member to a {@link ClassMapping}. 30 | * 31 | * @param The type of the mapping 32 | * @param

The type of the parent mapping 33 | * 34 | * @see FieldMapping 35 | * @see MethodMapping 36 | * @see InnerClassMapping 37 | * 38 | * @author Jamie Mansfield 39 | * @since 0.1.0 40 | */ 41 | public interface MemberMapping, P extends Mapping> extends Mapping { 42 | 43 | /** 44 | * Gets the parent {@link Mapping} of this member mapping. 45 | * 46 | * @return The parent mapping 47 | * @since 0.4.0 48 | */ 49 | P getParent(); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/util/MappingChangedListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.util; 27 | 28 | import org.cadixdev.lorenz.model.Mapping; 29 | 30 | /** 31 | * A listener for observing changes in {@link Mapping mappings}. 32 | * 33 | * @param The type of the mapping being changed 34 | * @param

The type of the mapping's parent 35 | * 36 | * @author Jamie Mansfield 37 | * @since 0.6.0 38 | */ 39 | @FunctionalInterface 40 | public interface MappingChangedListener, P> { 41 | 42 | /** 43 | * Called whenever the mapping's name is to be changed. 44 | * 45 | * @param mapping The mapping (still with the original de-obfuscated name) 46 | * @param newName The new de-obfuscated name 47 | */ 48 | void handle(final M mapping, final String newName); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /changelogs/0.5/0.5.6.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.5.6 2 | ============ 3 | 4 | Configurable Parallelism during mapping merges 5 | ---------------------------------------------- 6 | 7 | The mapping merging system introduced in 0.5.4 merges mappings in parallel - which in quick testing can 8 | improve the merge time by half. There may be cases where the max number of threads needs to be controlled. 9 | One common example is debugging Lorenz itself, having multiple merge threads running at once can make 10 | debugging a lot more difficult. 11 | 12 | This release just adds one new method to [`MergeConfig`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java): 13 | [`getParallelism()`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java#L84-L95). 14 | Set this value using the new [`withParallelism()`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java#L185-L202) 15 | method. Check the javadocs for more info. 16 | 17 | Allow arbitrary indexes for parameter mappings 18 | --------------------------------------------- 19 | 20 | Method mappings may now contain parameter mappings for arbitrary indexes, rather than being constrained to 21 | between 0 and the number of parameters in the method signature. This is nice from a general flexibility 22 | perspective as Lorenz is only a container and isn't intended for validating mappings, but also fixes the issue 23 | where Lorenz can't read mappings which using 1-indexed method parameters for instance methods. With this change 24 | it's up to the user to decide how to use parameter mappings, Lorenz doesn't dictate anything one way or the 25 | other (just like the other mapping types). 26 | 27 | Any code which worked with Lorenz before will still continue to work, as this change only removes constraints 28 | which used to be present. If some code was written which relied on the existing index checks then this will 29 | technically be a breaking change, as you'll need to handle those checks yourself. That is likely to be a minor 30 | edge case however, so this is still considered a minor release. 31 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/src/main/java/org/cadixdev/lorenz/dsl/groovy/DslUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.dsl.groovy; 27 | 28 | import groovy.lang.Closure; 29 | 30 | import java.util.function.Function; 31 | 32 | /** 33 | * Internal utility functions for the Lorenz Groovy DSL. 34 | * 35 | * @author Jamie Mansfield 36 | * @since 0.6.0 37 | */ 38 | class DslUtil { 39 | 40 | static final int RESOLVE_STRATEGY = Closure.DELEGATE_FIRST; 41 | 42 | static void setupAndCallDelegateClosure(final Object delegate, final Closure script) { 43 | script.setResolveStrategy(DslUtil.RESOLVE_STRATEGY); 44 | script.setDelegate(delegate); 45 | script.call(); 46 | } 47 | 48 | static T delegate(final T obj, final Function delegate, final Closure script) { 49 | setupAndCallDelegateClosure(delegate.apply(obj), script); 50 | return obj; 51 | } 52 | 53 | private DslUtil() { 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/BinaryMappingsReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import java.io.DataInputStream; 29 | import java.io.IOException; 30 | import java.io.InputStream; 31 | 32 | /** 33 | * An implementation of {@link MappingsReader} designed to aid 34 | * with the implementation of binary de-obfuscation mapping 35 | * formats. 36 | * 37 | * @author Jamie Mansfield 38 | * @since 0.4.0 39 | */ 40 | public abstract class BinaryMappingsReader extends MappingsReader { 41 | 42 | protected final DataInputStream stream; 43 | 44 | /** 45 | * Creates a new mappings reader, for the given {@link InputStream}. 46 | * 47 | * @param stream The input stream 48 | */ 49 | protected BinaryMappingsReader(final InputStream stream) { 50 | this.stream = new DataInputStream(stream); 51 | } 52 | 53 | @Override 54 | public void close() throws IOException { 55 | this.stream.close(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/BinaryMappingsWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import java.io.DataOutputStream; 29 | import java.io.IOException; 30 | import java.io.OutputStream; 31 | 32 | /** 33 | * An implementation of {@link MappingsWriter} designed to aid 34 | * with the implementation of binary de-obfuscation mapping 35 | * formats. 36 | * 37 | * @author Jamie Mansfield 38 | * @since 0.4.0 39 | */ 40 | public abstract class BinaryMappingsWriter extends MappingsWriter { 41 | 42 | protected final DataOutputStream stream; 43 | 44 | /** 45 | * Creates a new mappings writer, from the given {@link OutputStream}. 46 | * 47 | * @param stream The output stream, to write to 48 | */ 49 | protected BinaryMappingsWriter(final OutputStream stream) { 50 | this.stream = new DataOutputStream(stream); 51 | } 52 | 53 | @Override 54 | public void close() throws IOException { 55 | this.stream.close(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/main/java/org/cadixdev/lorenz/io/enigma/FabricEnigmaMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.enigma; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | 31 | import java.io.Reader; 32 | import java.io.Writer; 33 | 34 | /** 35 | * The Fabric Enigma mapping format. 36 | * 37 | * @author Jamie Mansfield 38 | * @since 0.6.0 39 | */ 40 | public class FabricEnigmaMappingFormat extends EnigmaMappingFormat { 41 | 42 | @Override 43 | public String getIdentifier() { 44 | return "fabric-engima"; 45 | } 46 | 47 | @Override 48 | public String getName() { 49 | return "Enigma (Fabric)"; 50 | } 51 | 52 | @Override 53 | public MappingsReader createReader(final Reader reader) { 54 | return new FabricEnigmaReader(reader); 55 | } 56 | 57 | @Override 58 | public MappingsWriter createWriter(final Writer writer) { 59 | return new FabricEnigmaWriter(writer); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /lorenz-io-jam/src/main/java/org/cadixdev/lorenz/io/jam/JamConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.jam; 27 | 28 | import java.util.regex.Pattern; 29 | 30 | /** 31 | * A collection of constants and utilities specific to 32 | * the JAM mapping format. 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.4.0 36 | */ 37 | public final class JamConstants { 38 | 39 | /** 40 | * A regex expression used to remove comments from lines. 41 | */ 42 | private static final Pattern HASH_COMMENT = Pattern.compile("#.*"); 43 | 44 | /** 45 | * The standard file extension used with the JAM format. 46 | */ 47 | public static final String STANDARD_EXTENSION = "jam"; 48 | 49 | /** 50 | * Removes present comments, from the given {@link String} line. 51 | * 52 | * @param line The line 53 | * @return The comment-omitted line 54 | */ 55 | public static String removeComments(final String line) { 56 | return HASH_COMMENT.matcher(line).replaceAll(""); 57 | } 58 | 59 | private JamConstants() { 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/jar/FieldTypeProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.model.jar; 27 | 28 | import org.cadixdev.lorenz.model.FieldMapping; 29 | import org.cadixdev.bombe.type.FieldType; 30 | 31 | import java.util.Optional; 32 | 33 | /** 34 | * A provider for establishing the type of a field, when it 35 | * is not already known. 36 | * 37 | * This is required as not all de-obfuscation mapping formats 38 | * include this data. Writers that do need to make use of 39 | * field types should throw a {@link RuntimeException} if a 40 | * provider is not present! 41 | * 42 | * @author Jamie Mansfield 43 | * @since 0.3.0 44 | */ 45 | @FunctionalInterface 46 | public interface FieldTypeProvider { 47 | 48 | /** 49 | * Provides a {@link FieldType} for the given {@link FieldMapping}, 50 | * if possible. 51 | * 52 | * @param mapping The field mapping 53 | * @return The type for the field, wrapped in an {@link Optional} 54 | * @since 0.4.0 55 | */ 56 | Optional provide(final FieldMapping mapping); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/SrgMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.srg; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | 32 | import java.io.Reader; 33 | import java.io.Writer; 34 | import java.util.Optional; 35 | 36 | /** 37 | * The SRG mapping format. 38 | * 39 | * @author Jamie Mansfield 40 | * @since 0.4.0 41 | */ 42 | public class SrgMappingFormat implements TextMappingFormat { 43 | 44 | @Override 45 | public String getIdentifier() { 46 | return "srg"; 47 | } 48 | 49 | @Override 50 | public String getName() { 51 | return "SRG"; 52 | } 53 | 54 | @Override 55 | public MappingsReader createReader(final Reader reader) { 56 | return new SrgReader(reader); 57 | } 58 | 59 | @Override 60 | public MappingsWriter createWriter(final Writer writer) { 61 | return new SrgWriter(writer); 62 | } 63 | 64 | @Override 65 | public Optional getStandardFileExtension() { 66 | return Optional.of(SrgConstants.STANDARD_EXTENSION); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /lorenz-io-jam/src/main/java/org/cadixdev/lorenz/io/jam/JamMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.jam; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | 32 | import java.io.Reader; 33 | import java.io.Writer; 34 | import java.util.Optional; 35 | 36 | /** 37 | * The JAM mapping format. 38 | * 39 | * @author Jamie Mansfield 40 | * @since 0.4.0 41 | */ 42 | public class JamMappingFormat implements TextMappingFormat { 43 | 44 | @Override 45 | public String getIdentifier() { 46 | return "jam"; 47 | } 48 | 49 | @Override 50 | public String getName() { 51 | return "JAM"; 52 | } 53 | 54 | @Override 55 | public MappingsReader createReader(final Reader reader) { 56 | return new JamReader(reader); 57 | } 58 | 59 | @Override 60 | public MappingsWriter createWriter(final Writer writer) { 61 | return new JamWriter(writer); 62 | } 63 | 64 | @Override 65 | public Optional getStandardFileExtension() { 66 | return Optional.of(JamConstants.STANDARD_EXTENSION); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/csrg/CSrgMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.srg.csrg; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | import org.cadixdev.lorenz.io.srg.SrgConstants; 32 | 33 | import java.io.Reader; 34 | import java.io.Writer; 35 | import java.util.Optional; 36 | 37 | /** 38 | * The CSRG mapping format. 39 | * 40 | * @author Jamie Mansfield 41 | * @since 0.4.0 42 | */ 43 | public class CSrgMappingFormat implements TextMappingFormat { 44 | 45 | @Override 46 | public String getIdentifier() { 47 | return "csrg"; 48 | } 49 | 50 | @Override 51 | public String getName() { 52 | return "CSRG"; 53 | } 54 | 55 | @Override 56 | public MappingsReader createReader(final Reader reader) { 57 | return new CSrgReader(reader); 58 | } 59 | 60 | @Override 61 | public MappingsWriter createWriter(final Writer writer) { 62 | return new CSrgWriter(writer); 63 | } 64 | 65 | @Override 66 | public Optional getStandardFileExtension() { 67 | return Optional.of(SrgConstants.CSrg.STANDARD_EXTENSION); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/tsrg/TSrgMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.srg.tsrg; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | import org.cadixdev.lorenz.io.srg.SrgConstants; 32 | 33 | import java.io.Reader; 34 | import java.io.Writer; 35 | import java.util.Optional; 36 | 37 | /** 38 | * The TSRG mapping format. 39 | * 40 | * @author Jamie Mansfield 41 | * @since 0.4.0 42 | */ 43 | public class TSrgMappingFormat implements TextMappingFormat { 44 | 45 | @Override 46 | public String getIdentifier() { 47 | return "tsrg"; 48 | } 49 | 50 | @Override 51 | public String getName() { 52 | return "TSRG"; 53 | } 54 | 55 | @Override 56 | public MappingsReader createReader(final Reader reader) { 57 | return new TSrgReader(reader); 58 | } 59 | 60 | @Override 61 | public MappingsWriter createWriter(final Writer writer) { 62 | return new TSrgWriter(writer); 63 | } 64 | 65 | @Override 66 | public Optional getStandardFileExtension() { 67 | return Optional.of(SrgConstants.TSrg.STANDARD_EXTENSION); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/xsrg/XSrgMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.srg.xsrg; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | import org.cadixdev.lorenz.io.srg.SrgConstants; 32 | 33 | import java.io.Reader; 34 | import java.io.Writer; 35 | import java.util.Optional; 36 | 37 | /** 38 | * The XSRG mapping format. 39 | * 40 | * @author Jamie Mansfield 41 | * @since 0.5.3 42 | */ 43 | public class XSrgMappingFormat implements TextMappingFormat { 44 | 45 | @Override 46 | public String getIdentifier() { 47 | return "xsrg"; 48 | } 49 | 50 | @Override 51 | public String getName() { 52 | return "XSRG"; 53 | } 54 | 55 | @Override 56 | public MappingsReader createReader(final Reader reader) { 57 | return new XSrgReader(reader); 58 | } 59 | 60 | @Override 61 | public MappingsWriter createWriter(final Writer writer) { 62 | return new XSrgWriter(writer); 63 | } 64 | 65 | @Override 66 | public Optional getStandardFileExtension() { 67 | return Optional.of(SrgConstants.XSrg.STANDARD_EXTENSION); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/MappingsReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import org.cadixdev.lorenz.MappingSet; 29 | 30 | import java.io.Closeable; 31 | import java.io.IOException; 32 | import java.io.InputStream; 33 | 34 | /** 35 | * Represents a reader that reads de-obfuscation mappings. 36 | * 37 | * @see TextMappingsReader 38 | * @see BinaryMappingsReader 39 | * 40 | * @author Jamie Mansfield 41 | * @since 0.4.0 42 | */ 43 | public abstract class MappingsReader implements Closeable { 44 | 45 | /** 46 | * Reads mappings from the previously given {@link InputStream}, to 47 | * a new {@link MappingSet}. 48 | * 49 | * @return The mapping set 50 | * @throws IOException Should an I/O issue occur 51 | */ 52 | public MappingSet read() throws IOException { 53 | return this.read(new MappingSet()); 54 | } 55 | 56 | /** 57 | * Reads mappings from the previously given {@link InputStream}, to 58 | * the given {@link MappingSet}. 59 | * 60 | * @param mappings The mapping set 61 | * @return The mapping set, to allow for chaining 62 | * @throws IOException Should an I/O issue occur 63 | */ 64 | public abstract MappingSet read(final MappingSet mappings) throws IOException; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/util/BinaryTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.util; 27 | 28 | /** 29 | * A utility for working with binary names in Lorenz. 30 | * 31 | * @author Jamie Mansfield 32 | * @since 0.5.7 33 | */ 34 | public final class BinaryTool { 35 | 36 | /** 37 | * Gets the split hierarchy of a binary name. 38 | *

39 | * For example, calling {@code from("a$b$c"}} would produce 40 | * {@code ["a", "b", "c"]}. 41 | * 42 | * @param binaryName The binary name 43 | * @return The name hierarchy 44 | */ 45 | public static String[] from(final String binaryName) { 46 | return binaryName.split("\\$"); 47 | } 48 | 49 | /** 50 | * Gets the binary name for a split hierarchy. 51 | * 52 | * @param name The hierarchy 53 | * @return The binary name 54 | */ 55 | public static String to(final String[] name) { 56 | final StringBuilder builder = new StringBuilder(); 57 | 58 | for (int i = 0; i < name.length; i++) { 59 | builder.append(name[i]); 60 | 61 | if (i != name.length - 1) { 62 | builder.append('$'); 63 | } 64 | } 65 | 66 | return builder.toString(); 67 | } 68 | 69 | private BinaryTool() { 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /lorenz-io-proguard/src/main/java/org/cadixdev/lorenz/io/proguard/ProGuardFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.proguard; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | 32 | import java.io.Reader; 33 | import java.io.Writer; 34 | import java.util.Optional; 35 | 36 | /** 37 | * The ProGuard mapping format. 38 | * 39 | * @author Jamie Mansfield 40 | * @since 0.5.1 41 | */ 42 | public class ProGuardFormat implements TextMappingFormat { 43 | 44 | @Override 45 | public String getIdentifier() { 46 | return "proguard"; 47 | } 48 | 49 | @Override 50 | public String getName() { 51 | return "ProGuard"; 52 | } 53 | 54 | @Override 55 | public MappingsReader createReader(final Reader reader) { 56 | return new ProGuardReader(reader); 57 | } 58 | 59 | @Override 60 | public MappingsWriter createWriter(final Writer writer) { 61 | throw new UnsupportedOperationException("cant write proguard"); 62 | } 63 | 64 | @Override 65 | public Optional getStandardFileExtension() { 66 | return Optional.empty(); 67 | } 68 | 69 | @Override 70 | public boolean supportsWriting() { 71 | return false; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/TextMappingsWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import org.cadixdev.lorenz.io.srg.SrgWriter; 29 | import org.cadixdev.lorenz.io.srg.csrg.CSrgWriter; 30 | import org.cadixdev.lorenz.io.srg.tsrg.TSrgWriter; 31 | 32 | import java.io.IOException; 33 | import java.io.PrintWriter; 34 | import java.io.Writer; 35 | 36 | /** 37 | * An implementation of {@link MappingsWriter} designed to aid 38 | * with the implementation of mapping writers for text-based 39 | * mapping formats. 40 | * 41 | * @see SrgWriter 42 | * @see CSrgWriter 43 | * @see TSrgWriter 44 | * 45 | * @author Jamie Mansfield 46 | * @since 0.4.0 47 | */ 48 | public abstract class TextMappingsWriter extends MappingsWriter { 49 | 50 | protected final PrintWriter writer; 51 | 52 | /** 53 | * Creates a new mappings writer, from the given {@link Writer}. 54 | * 55 | * @param writer The output writer, to write to 56 | */ 57 | protected TextMappingsWriter(final Writer writer) { 58 | if (writer instanceof PrintWriter) { 59 | this.writer = (PrintWriter) writer; 60 | } else { 61 | this.writer = new PrintWriter(writer); 62 | } 63 | } 64 | 65 | @Override 66 | public void close() throws IOException { 67 | this.writer.flush(); 68 | this.writer.close(); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/MethodParameterMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.model; 27 | 28 | import org.cadixdev.lorenz.merge.MappingSetMerger; 29 | 30 | /** 31 | * Represents a de-obfuscation mapping for a method parameter, 32 | * identified by index. 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.4.0 36 | */ 37 | public interface MethodParameterMapping extends MemberMapping { 38 | 39 | /** 40 | * Gets the index of the method parameter being mapped. 41 | * 42 | * @return The index 43 | */ 44 | int getIndex(); 45 | 46 | @Override 47 | default String getObfuscatedName() { 48 | return String.valueOf(this.getIndex()); 49 | } 50 | 51 | @Override 52 | default MethodParameterMapping reverse(final MethodMapping parent) { 53 | return parent.createParameterMapping(this.getIndex(), this.getDeobfuscatedName()); 54 | } 55 | 56 | @Override 57 | default MethodParameterMapping merge(final MethodParameterMapping with, final MethodMapping parent) { 58 | return MappingSetMerger.create(this.getMappings(), with.getMappings()).mergeMethodParameter(this, with, parent); 59 | } 60 | 61 | @Override 62 | default MethodParameterMapping copy(final MethodMapping parent) { 63 | return parent.createParameterMapping(this.getIndex(), this.getDeobfuscatedName()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/src/main/java/org/cadixdev/lorenz/dsl/groovy/MethodMappingDsl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.dsl.groovy; 27 | 28 | import groovy.lang.Closure; 29 | import groovy.lang.DelegatesTo; 30 | import org.cadixdev.lorenz.model.ClassMapping; 31 | import org.cadixdev.lorenz.model.MethodMapping; 32 | import org.cadixdev.lorenz.model.MethodParameterMapping; 33 | 34 | /** 35 | * A DSL to simplify the manipulation of {@link MethodMapping}s in Groovy. 36 | * 37 | * @author Jamie Mansfield 38 | * @since 0.6.0 39 | */ 40 | public class MethodMappingDsl extends MappingDsl { 41 | 42 | public MethodMappingDsl(final MethodMapping mapping) { 43 | super(mapping); 44 | } 45 | 46 | /** 47 | * Creates a method parameter mapping for the given index, 48 | * and applies the given {@link Closure} to it. 49 | * 50 | * @param index The index of the parameter 51 | * @param script The closure to use 52 | * @return The mapping 53 | * @see MethodMapping#getOrCreateParameterMapping(int) 54 | */ 55 | public MethodParameterMapping param( 56 | final int index, 57 | @DelegatesTo(strategy = DslUtil.RESOLVE_STRATEGY, value = MappingDsl.class) final Closure script) { 58 | return DslUtil.delegate( 59 | this.mapping.getOrCreateParameterMapping(index), 60 | MappingDsl::new, script); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/model/TopLevelClassMappingImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.impl.model; 27 | 28 | import org.cadixdev.lorenz.MappingSet; 29 | import org.cadixdev.lorenz.model.TopLevelClassMapping; 30 | 31 | /** 32 | * A basic implementation of {@link TopLevelClassMapping}. 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.2.0 36 | */ 37 | public class TopLevelClassMappingImpl 38 | extends AbstractClassMappingImpl 39 | implements TopLevelClassMapping { 40 | 41 | /** 42 | * Creates a new top-level class mapping, from the given parameters. 43 | * 44 | * @param mappings The mappings set, this mapping belongs to 45 | * @param obfuscatedName The obfuscated name 46 | * @param deobfuscatedName The de-obfuscated name 47 | */ 48 | public TopLevelClassMappingImpl(final MappingSet mappings, final String obfuscatedName, final String deobfuscatedName) { 49 | super(mappings, obfuscatedName.replace('.', '/'), deobfuscatedName.replace('.', '/')); 50 | } 51 | 52 | @Override 53 | public TopLevelClassMapping setDeobfuscatedName(String deobfuscatedName) { 54 | return super.setDeobfuscatedName(deobfuscatedName.replace('.', '/')); 55 | } 56 | 57 | @Override 58 | public boolean equals(final Object obj) { 59 | return this == obj || super.equals(obj) && obj instanceof TopLevelClassMapping; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /changelogs/0.6.0.md: -------------------------------------------------------------------------------- 1 | Lorenz 0.6.0 2 | ============ 3 | 4 | ## Groovy DSL 5 | 6 | Lorenz now has a Groovy DSL, that simplifies the creation of mappings. 7 | 8 | ```groovy 9 | def EXTRA = new ExtensionKey(String, 'extra') 10 | 11 | def mappings = MappingSetDsl.create { 12 | klass('a') { 13 | deobf = 'Demo' 14 | extension EXTRA, 'demo data' 15 | 16 | field('g') { deobf = 'name' } 17 | 18 | method('h', '(Z)Ljava/lang/String;') { 19 | deobf = 'getName' 20 | 21 | param(0) { deobf = 'example' } 22 | } 23 | } 24 | } 25 | ``` 26 | 27 | To use the Groovy DSL, simply add `org.cadixdev:lorenz-dsl-groovy:0.6.0` to your build 28 | tool. 29 | 30 | ## ASM Module 31 | 32 | Inline with changes made in Bombe 0.4.0, the ASM package is no more - with both classes 33 | now available under the same package in the core Lorenz module. 34 | 35 | ## Enigma Module 36 | 37 | The Enigma mapping format no longer erroneously reports the standard file extension as 38 | being "enigma", but rather the standard (as set by cuchaz's mapping project, and continued 39 | by the Fabric Project) "mapping". The former file extension is included as a supported file 40 | extension with the new multiple file extension functionality (detailed below). 41 | 42 | Additionally, we now have support for reading/writing Fabric's fork of the format, 43 | registered as `fabric-engima`. This implements the two major format changes made by the 44 | Fabric Project: 1. the removal of the `none/` prefix for un-packaged classes, and 2. not using 45 | the fully qualified name for inner classes (i.e. with the parent class' name). 46 | 47 | ## Mapping Formats 48 | 49 | ### Registration 50 | 51 | Mapping Formats are still registered by use of service loaders, populating a registry in 52 | `MappingFormats` - however their registration key (identifier) is now more explicit, and 53 | formats are able to provide a name. Implementations must now provide the following: 54 | - Name (can be used by tools such as Symphony) 55 | - Identifier (used as the registration key) 56 | 57 | ### File extensions 58 | 59 | Mapping Formats can now specify multiple file extensions that are typical, this will allow 60 | tools such as Symphony and Nocturne to give richer (and more useful) file choice dialogs. 61 | 62 | ### Miscellaneous 63 | 64 | - Mapping formats can now specify whether they support reading and writing. This will allow 65 | tools, for example, to only show supported formats in a file save or file read dialog 66 | - The Kin IO module has been removed. 67 | 68 | ## Conveniences 69 | 70 | - `Mapping#set(key, value)` now returns the `Mapping` allowing for fluent method calls. 71 | - The de-obfuscated names of `Mapping`s are now observable, through 72 | `Mapping#addListener(MappingChangedListener)`. 73 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/osx,linux,windows,gradle,jetbrains 3 | 4 | ### OSX ### 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | 9 | # Icon must end with two \r 10 | Icon 11 | 12 | 13 | # Thumbnails 14 | ._* 15 | 16 | # Files that might appear in the root of a volume 17 | .DocumentRevisions-V100 18 | .fseventsd 19 | .Spotlight-V100 20 | .TemporaryItems 21 | .Trashes 22 | .VolumeIcon.icns 23 | 24 | # Directories potentially created on remote AFP share 25 | .AppleDB 26 | .AppleDesktop 27 | Network Trash Folder 28 | Temporary Items 29 | .apdisk 30 | 31 | 32 | ### Linux ### 33 | *~ 34 | 35 | # temporary files which can be created if a process still has a handle open of a deleted file 36 | .fuse_hidden* 37 | 38 | # KDE directory preferences 39 | .directory 40 | 41 | # Linux trash folder which might appear on any partition or disk 42 | .Trash-* 43 | 44 | 45 | ### Windows ### 46 | # Windows image file caches 47 | Thumbs.db 48 | ehthumbs.db 49 | 50 | # Folder config file 51 | Desktop.ini 52 | 53 | # Recycle Bin used on file shares 54 | $RECYCLE.BIN/ 55 | 56 | # Windows Installer files 57 | *.cab 58 | *.msi 59 | *.msm 60 | *.msp 61 | 62 | # Windows shortcuts 63 | *.lnk 64 | 65 | 66 | ### Gradle ### 67 | .gradle 68 | build/ 69 | 70 | # Ignore Gradle GUI config 71 | gradle-app.setting 72 | 73 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 74 | !gradle-wrapper.jar 75 | 76 | # Cache of project 77 | .gradletasknamecache 78 | 79 | 80 | ### JetBrains ### 81 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 82 | 83 | *.iml 84 | 85 | ## Directory-based project format: 86 | .idea/ 87 | # if you remove the above rule, at least ignore the following: 88 | 89 | # User-specific stuff: 90 | # .idea/workspace.xml 91 | # .idea/tasks.xml 92 | # .idea/dictionaries 93 | # .idea/shelf 94 | 95 | # Sensitive or high-churn files: 96 | # .idea/dataSources.ids 97 | # .idea/dataSources.xml 98 | # .idea/sqlDataSources.xml 99 | # .idea/dynamic.xml 100 | # .idea/uiDesigner.xml 101 | 102 | # Gradle: 103 | # .idea/gradle.xml 104 | # .idea/libraries 105 | 106 | # Mongo Explorer plugin: 107 | # .idea/mongoSettings.xml 108 | 109 | ## File-based project format: 110 | *.ipr 111 | *.iws 112 | 113 | ## Plugin-specific files: 114 | 115 | # IntelliJ 116 | /out/ 117 | 118 | # mpeltonen/sbt-idea plugin 119 | .idea_modules/ 120 | 121 | # JIRA plugin 122 | atlassian-ide-plugin.xml 123 | 124 | # Crashlytics plugin (for Android Studio and IntelliJ) 125 | com_crashlytics_export_strings.xml 126 | crashlytics.properties 127 | crashlytics-build.properties 128 | fabric.properties 129 | 130 | ### Lorenz ## 131 | lorenz*/build/ 132 | lorenz*/out/ 133 | run/ 134 | -------------------------------------------------------------------------------- /lorenz/src/test/groovy/org/cadixdev/lorenz/test/util/BinaryToolSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.util 27 | 28 | import org.cadixdev.lorenz.util.BinaryTool 29 | import spock.lang.Specification 30 | 31 | class BinaryToolSpec extends Specification { 32 | 33 | def 'reads top level class binary name'(final String className) { 34 | when: 35 | def result = BinaryTool.from(className) 36 | 37 | then: 38 | result.length == 1 39 | result[0] == className 40 | 41 | where: 42 | className | _ 43 | 'a' | _ 44 | 'org/cadixdev/example/Example' | _ 45 | } 46 | 47 | def 'reads inner class binary name'(final String className, final String[] expected) { 48 | when: 49 | def result = BinaryTool.from(className) 50 | 51 | then: 52 | result == expected 53 | 54 | where: 55 | className | expected 56 | 'a$b' | ['a', 'b'] as String[] 57 | 'a$b$c' | ['a', 'b', 'c'] as String[] 58 | 'org/cadixdev/example/Example$Inner' | ['org/cadixdev/example/Example', 'Inner'] as String[] 59 | } 60 | 61 | def 'writes binary name'(final String[] input, final String expected) { 62 | when: 63 | def result = BinaryTool.to(input) 64 | 65 | then: 66 | result == expected 67 | 68 | where: 69 | input | expected 70 | ['a', 'b'] as String[] | 'a$b' 71 | ['a', 'b', 'c'] as String[] | 'a$b$c' 72 | ['org/cadixdev/example/Example', 'Inner'] as String[] | 'org/cadixdev/example/Example$Inner' 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/main/java/org/cadixdev/lorenz/io/enigma/EnigmaMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.enigma; 27 | 28 | import org.cadixdev.lorenz.io.MappingsReader; 29 | import org.cadixdev.lorenz.io.MappingsWriter; 30 | import org.cadixdev.lorenz.io.TextMappingFormat; 31 | 32 | import java.io.Reader; 33 | import java.io.Writer; 34 | import java.util.Arrays; 35 | import java.util.Collection; 36 | import java.util.Collections; 37 | import java.util.Optional; 38 | 39 | /** 40 | * The standard Enigma mapping format. 41 | * 42 | * @author Jamie Mansfield 43 | * @since 0.4.0 44 | */ 45 | public class EnigmaMappingFormat implements TextMappingFormat { 46 | 47 | @Override 48 | public String getIdentifier() { 49 | return "enigma"; 50 | } 51 | 52 | @Override 53 | public String getName() { 54 | return "Enigma"; 55 | } 56 | 57 | @Override 58 | public MappingsReader createReader(final Reader reader) { 59 | return new EnigmaReader(reader); 60 | } 61 | 62 | @Override 63 | public MappingsWriter createWriter(final Writer writer) { 64 | return new EnigmaWriter(writer); 65 | } 66 | 67 | @Override 68 | public Optional getStandardFileExtension() { 69 | return Optional.of(EnigmaConstants.FileExtensions.MAPPING); 70 | } 71 | 72 | @Override 73 | public Collection getFileExtensions() { 74 | return Collections.unmodifiableCollection(Arrays.asList( 75 | EnigmaConstants.FileExtensions.MAPPING, 76 | EnigmaConstants.FileExtensions.ENIGMA 77 | )); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/asm/AsmFieldTypeProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.asm; 27 | 28 | import org.cadixdev.bombe.provider.ClassProvider; 29 | import org.cadixdev.lorenz.model.FieldMapping; 30 | import org.cadixdev.lorenz.model.jar.FieldTypeProvider; 31 | import org.cadixdev.bombe.type.FieldType; 32 | import org.objectweb.asm.tree.ClassNode; 33 | import org.objectweb.asm.tree.FieldNode; 34 | 35 | import java.util.Objects; 36 | import java.util.Optional; 37 | 38 | /** 39 | * An implementation of {@link FieldTypeProvider} backed by a 40 | * {@link ClassProvider}. 41 | * 42 | * @author Jamie Mansfield 43 | * @since 0.4.0 44 | */ 45 | public class AsmFieldTypeProvider implements FieldTypeProvider { 46 | 47 | private final ClassProvider classProvider; 48 | 49 | public AsmFieldTypeProvider(final ClassProvider classProvider) { 50 | this.classProvider = classProvider; 51 | } 52 | 53 | @Override 54 | public Optional provide(final FieldMapping mapping) { 55 | final String owner = mapping.getParent().getFullObfuscatedName(); 56 | 57 | final ClassNode node = this.classProvider.getAsNode(owner); 58 | if (node == null) return Optional.empty(); 59 | 60 | final Optional fieldNode = node.fields.stream() 61 | .filter(field -> Objects.equals(field.name, mapping.getObfuscatedName())) 62 | .findAny(); 63 | if (fieldNode.isPresent()) { 64 | final FieldType type = FieldType.of(fieldNode.get().desc); 65 | return Optional.of(type); 66 | } 67 | 68 | return Optional.empty(); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/model/FieldMappingImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.impl.model; 27 | 28 | import org.cadixdev.lorenz.model.ClassMapping; 29 | import org.cadixdev.lorenz.model.FieldMapping; 30 | import org.cadixdev.bombe.type.signature.FieldSignature; 31 | 32 | import java.util.Objects; 33 | 34 | /** 35 | * A basic implementation of {@link FieldMapping}. 36 | * 37 | * @author Jamie Mansfield 38 | * @since 0.2.0 39 | */ 40 | public class FieldMappingImpl 41 | extends AbstractMemberMappingImpl 42 | implements FieldMapping { 43 | 44 | private final FieldSignature signature; 45 | 46 | /** 47 | * Creates a new field mapping, from the given parameters. 48 | * 49 | * @param parentClass The class mapping, this mapping belongs to 50 | * @param signature The obfuscated signature 51 | * @param deobfuscatedName The de-obfuscated name 52 | */ 53 | public FieldMappingImpl(final ClassMapping parentClass, final FieldSignature signature, final String deobfuscatedName) { 54 | super(parentClass, signature.getName(), deobfuscatedName); 55 | this.signature = signature; 56 | } 57 | 58 | @Override 59 | public FieldSignature getSignature() { 60 | return this.signature; 61 | } 62 | 63 | @Override 64 | public boolean equals(final Object obj) { 65 | if (this == obj) return true; 66 | if (!super.equals(obj) || !(obj instanceof FieldMapping)) return false; 67 | final FieldMapping that = (FieldMapping) obj; 68 | return Objects.equals(this.signature, that.getSignature()); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodParameterMappingImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.impl.model; 27 | 28 | import org.cadixdev.lorenz.model.MethodMapping; 29 | import org.cadixdev.lorenz.model.MethodParameterMapping; 30 | 31 | /** 32 | * A basic implementation of {@link MethodParameterMapping}. 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.4.0 36 | */ 37 | public class MethodParameterMappingImpl 38 | extends AbstractMemberMappingImpl 39 | implements MethodParameterMapping { 40 | 41 | private final int index; 42 | 43 | /** 44 | * Creates a new method parameter mapping, from the given parameters. 45 | * 46 | * @param parent The mapping, this mapping belongs to 47 | * @param index The index of the parameter 48 | * @param deobfuscatedName The de-obfuscated name 49 | */ 50 | public MethodParameterMappingImpl(final MethodMapping parent, final int index, String deobfuscatedName) { 51 | super(parent, String.valueOf(index), deobfuscatedName); 52 | this.index = index; 53 | } 54 | 55 | @Override 56 | public int getIndex() { 57 | return this.index; 58 | } 59 | 60 | @Override 61 | public String getFullObfuscatedName() { 62 | return this.getObfuscatedName(); 63 | } 64 | 65 | @Override 66 | public String getFullDeobfuscatedName() { 67 | return this.getDeobfuscatedName(); 68 | } 69 | 70 | @Override 71 | public boolean equals(final Object obj) { 72 | return this == obj || super.equals(obj) && obj instanceof MethodParameterMapping; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/ExtensionKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.model; 27 | 28 | import java.util.Objects; 29 | import java.util.StringJoiner; 30 | 31 | /** 32 | * The object used as a key in Lorenz's extension data system, simply 33 | * used to hold the type and identifier. 34 | * 35 | * @param The type of the data 36 | * @author Jamie Mansfield 37 | * @since 0.5.0 38 | */ 39 | public class ExtensionKey { 40 | 41 | private final Class type; 42 | private final String id; 43 | 44 | public ExtensionKey(final Class type, final String id) { 45 | this.type = type; 46 | this.id = id; 47 | } 48 | 49 | /** 50 | * @param obj Object to be cast 51 | * @return Object cast to {@code T} 52 | * @see Class#cast(Object) 53 | */ 54 | public T cast(final Object obj) { 55 | return this.type.cast(obj); 56 | } 57 | 58 | @Override 59 | public boolean equals(final Object obj) { 60 | if (this == obj) return true; 61 | if (!super.equals(obj) || !(obj instanceof ExtensionKey)) return false; 62 | final ExtensionKey that = (ExtensionKey) obj; 63 | return Objects.equals(this.type, that.type) && 64 | Objects.equals(this.id, that.id); 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return new StringJoiner(", ", this.getClass().getSimpleName() + "{", "}") 70 | .add("type=" + this.type) 71 | .add("id=" + this.id) 72 | .toString(); 73 | } 74 | 75 | @Override 76 | public int hashCode() { 77 | return Objects.hash(this.type, this.id); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/asm/AsmFieldTypeProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.asm; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | import static org.junit.jupiter.api.Assertions.assertTrue; 30 | 31 | import org.cadixdev.lorenz.MappingSet; 32 | import org.cadixdev.lorenz.asm.AsmFieldTypeProvider; 33 | import org.cadixdev.lorenz.model.FieldMapping; 34 | import org.cadixdev.bombe.type.FieldType; 35 | import org.cadixdev.bombe.type.ObjectType; 36 | import org.junit.jupiter.api.Test; 37 | import org.objectweb.asm.ClassWriter; 38 | import org.objectweb.asm.Opcodes; 39 | 40 | import java.util.Objects; 41 | import java.util.Optional; 42 | 43 | public final class AsmFieldTypeProviderTest { 44 | 45 | @Test 46 | public void fetchFieldType() { 47 | final MappingSet mappings = new MappingSet(); 48 | final FieldMapping field = mappings.getOrCreateTopLevelClassMapping("ght") 49 | .getOrCreateFieldMapping("op"); 50 | 51 | final ClassWriter writer = new ClassWriter(0); 52 | writer.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, "ght", null, "java/lang/Object", null); 53 | writer.visitField(Opcodes.ACC_PUBLIC, "op", "Ljava/util/logging/Logger;", null, null); 54 | 55 | mappings.addFieldTypeProvider(new AsmFieldTypeProvider(klass -> { 56 | if (Objects.equals("ght", klass)) return writer.toByteArray(); 57 | return null; 58 | })); 59 | 60 | final Optional type = field.getType(); 61 | assertTrue(type.isPresent()); 62 | assertTrue(type.get() instanceof ObjectType); 63 | assertEquals("java/util/logging/Logger", ((ObjectType) type.get()).getClassName()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/model/jar/CompositeFieldTypeProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.model.jar; 27 | 28 | import org.cadixdev.lorenz.model.FieldMapping; 29 | import org.cadixdev.bombe.type.FieldType; 30 | 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | import java.util.Optional; 34 | 35 | /** 36 | * An implementation of {@link FieldTypeProvider} that is backed by 37 | * many - allowing multiples sources to be used. 38 | * 39 | * @author Jamie Mansfield 40 | * @since 0.4.0 41 | */ 42 | public class CompositeFieldTypeProvider implements FieldTypeProvider { 43 | 44 | private final List providers = new ArrayList<>(); 45 | 46 | /** 47 | * Adds a {@link FieldTypeProvider} to the provider. 48 | * 49 | * @param provider The provider 50 | * @return {@code this}, for chaining 51 | */ 52 | public CompositeFieldTypeProvider add(final FieldTypeProvider provider) { 53 | this.providers.add(provider); 54 | return this; 55 | } 56 | 57 | /** 58 | * Removes a {@link FieldTypeProvider} from the provider. 59 | * 60 | * @param provider The provider 61 | * @return {@code this}, for chaining 62 | */ 63 | public CompositeFieldTypeProvider remove(final FieldTypeProvider provider) { 64 | this.providers.remove(provider); 65 | return this; 66 | } 67 | 68 | @Override 69 | public Optional provide(final FieldMapping mapping) { 70 | for (final FieldTypeProvider provider : this.providers) { 71 | final Optional type = provider.provide(mapping); 72 | if (type.isPresent()) return type; 73 | } 74 | return Optional.empty(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/io/srg/SrgReaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.io.srg; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertThrows; 29 | 30 | import org.cadixdev.lorenz.io.MappingFormats; 31 | import org.cadixdev.lorenz.io.srg.SrgReader; 32 | import org.junit.jupiter.api.Test; 33 | 34 | import java.io.IOException; 35 | 36 | public class SrgReaderTest extends AbstractSrgReaderTest { 37 | 38 | public SrgReaderTest() throws Exception { 39 | super(MappingFormats.SRG, "/test.srg"); 40 | } 41 | 42 | @Test 43 | public void ignoresPackages() throws IOException { 44 | // This test ensures that package mappings won't set off any exceptions 45 | // as they are valid input - even though Lorenz won't parse them :p 46 | final SrgReader.Processor parser = new SrgReader.Processor(); 47 | parser.accept("PK: abc uk/jamierocks/Example"); 48 | } 49 | 50 | @Test 51 | public void tooLongInput() throws IOException { 52 | // This test should set off the first case where IllegalArgumentException 53 | // is thrown 54 | final SrgReader.Processor parser = new SrgReader.Processor(); 55 | assertThrows(IllegalArgumentException.class, () -> { 56 | parser.accept("this is a faulty mapping because it is too long"); 57 | }); 58 | } 59 | 60 | @Test 61 | public void invalidInput() throws IOException { 62 | // This test should set off the first case where IllegalArgumentException 63 | // is thrown 64 | final SrgReader.Processor parser = new SrgReader.Processor(); 65 | assertThrows(IllegalArgumentException.class, () -> { 66 | parser.accept("PK: TooShort"); 67 | }); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/asm/LorenzRemapperInheritanceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.asm; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | import org.cadixdev.lorenz.MappingSet; 31 | import org.cadixdev.lorenz.asm.LorenzRemapper; 32 | import org.cadixdev.lorenz.model.TopLevelClassMapping; 33 | import org.cadixdev.bombe.analysis.InheritanceProvider; 34 | import org.cadixdev.bombe.analysis.ReflectionInheritanceProvider; 35 | import org.cadixdev.bombe.type.signature.MethodSignature; 36 | import org.junit.jupiter.api.Test; 37 | import org.objectweb.asm.ClassReader; 38 | import org.objectweb.asm.commons.ClassRemapper; 39 | import org.objectweb.asm.tree.ClassNode; 40 | 41 | import java.io.IOException; 42 | 43 | public class LorenzRemapperInheritanceTest { 44 | 45 | private static final MappingSet MAPPINGS = new MappingSet(); 46 | private static final InheritanceProvider INHERITANCE = new ReflectionInheritanceProvider(LorenzRemapperInheritanceTest.class.getClassLoader()); 47 | private static final LorenzRemapper REMAPPER = new LorenzRemapper(MAPPINGS, INHERITANCE); 48 | 49 | static { 50 | final TopLevelClassMapping baseClass = MAPPINGS.getOrCreateTopLevelClassMapping("test/inheritance/a/BaseClass"); 51 | baseClass.createMethodMapping(MethodSignature.of("helloWorld()V"), "bye"); 52 | } 53 | 54 | @Test 55 | public void testRemapIfSuperClassWithoutMappingsMakesInheritableMethodVisible() throws IOException { 56 | ClassReader reader = new ClassReader("test.inheritance.TestClass"); 57 | ClassNode node = new ClassNode(); 58 | reader.accept(new ClassRemapper(node, REMAPPER), 0); 59 | 60 | assertEquals("bye", node.methods.get(1).name); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/MappingFormats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import org.cadixdev.lorenz.util.Registry; 29 | 30 | import java.util.ServiceLoader; 31 | 32 | /** 33 | * A psuedo-enum of the mapping formats implemented within Lorenz. 34 | * 35 | * @author Jamie Mansfield 36 | * @since 0.4.0 37 | */ 38 | public final class MappingFormats { 39 | 40 | /** 41 | * The registry of {@link MappingFormat}s. 42 | */ 43 | public static final Registry REGISTRY = new Registry<>(); 44 | 45 | static { 46 | // Populate the registry 47 | for (final MappingFormat format : ServiceLoader.load(MappingFormat.class)) { 48 | REGISTRY.register(format.getIdentifier(), format); 49 | } 50 | } 51 | 52 | /** 53 | * The SRG mapping format. 54 | */ 55 | public static final TextMappingFormat SRG = (TextMappingFormat) byId("srg"); 56 | 57 | /** 58 | * The CSRG (compact SRG) mapping format. 59 | */ 60 | public static final TextMappingFormat CSRG = (TextMappingFormat) byId("csrg"); 61 | 62 | /** 63 | * The TSRG (tiny SRG) mapping format. 64 | */ 65 | public static final TextMappingFormat TSRG = (TextMappingFormat) byId("tsrg"); 66 | 67 | /** 68 | * The XSRG (SRG + field types) mapping format. 69 | */ 70 | public static final TextMappingFormat XSRG = (TextMappingFormat) byId("xsrg"); 71 | 72 | /** 73 | * @param id The identifier of the value 74 | * @return The value, or {@code null} if not present 75 | * @see Registry#byId(String) 76 | */ 77 | public static MappingFormat byId(final String id) { 78 | return REGISTRY.byId(id); 79 | } 80 | 81 | private MappingFormats() { 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/io/srg/XSrgReaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.io.srg; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertThrows; 29 | 30 | import org.cadixdev.lorenz.io.MappingFormats; 31 | import org.cadixdev.lorenz.io.srg.xsrg.XSrgReader; 32 | import org.junit.jupiter.api.Test; 33 | 34 | import java.io.IOException; 35 | 36 | public class XSrgReaderTest extends AbstractSrgReaderTest { 37 | 38 | public XSrgReaderTest() throws Exception { 39 | super(MappingFormats.XSRG, "/test.xsrg"); 40 | } 41 | 42 | @Test 43 | public void ignoresPackages() throws IOException { 44 | // This test ensures that package mappings won't set off any exceptions 45 | // as they are valid input - even though Lorenz won't parse them :p 46 | final XSrgReader.Processor parser = new XSrgReader.Processor(); 47 | parser.accept("PK: abc uk/jamierocks/Example"); 48 | } 49 | 50 | @Test 51 | public void tooLongInput() throws IOException { 52 | // This test should set off the first case where IllegalArgumentException 53 | // is thrown 54 | final XSrgReader.Processor parser = new XSrgReader.Processor(); 55 | assertThrows(IllegalArgumentException.class, () -> { 56 | parser.accept("this is a faulty mapping because it is too long"); 57 | }); 58 | } 59 | 60 | @Test 61 | public void invalidInput() throws IOException { 62 | // This test should set off the first case where IllegalArgumentException 63 | // is thrown 64 | final XSrgReader.Processor parser = new XSrgReader.Processor(); 65 | assertThrows(IllegalArgumentException.class, () -> { 66 | parser.accept("PK: TooShort"); 67 | }); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/src/main/java/org/cadixdev/lorenz/dsl/groovy/MappingDsl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.dsl.groovy; 27 | 28 | import org.cadixdev.lorenz.model.ExtensionKey; 29 | import org.cadixdev.lorenz.model.Mapping; 30 | import org.cadixdev.lorenz.util.MappingChangedListener; 31 | 32 | /** 33 | * A DSL to simplify the manipulation of {@link Mapping}s in Groovy. 34 | * 35 | * @param The type of the mapping 36 | * @author Jamie Mansfield 37 | * @since 0.6.0 38 | */ 39 | public class MappingDsl, P> { 40 | 41 | /** 42 | * The mapping manipulated by this DSL. 43 | */ 44 | protected final T mapping; 45 | 46 | public MappingDsl(final T mapping) { 47 | this.mapping = mapping; 48 | } 49 | 50 | /** 51 | * Sets the de-obfuscated name of the mapping. 52 | * 53 | * @param name The de-obfuscated name 54 | * @see Mapping#setDeobfuscatedName(String) 55 | */ 56 | public void setDeobf(final String name) { 57 | this.mapping.setDeobfuscatedName(name); 58 | } 59 | 60 | /** 61 | * Adds the given extension data to the mapping. 62 | * 63 | * @param key The extension key 64 | * @param value The value of the extension 65 | * @param The type of the extension data 66 | * @see Mapping#set(ExtensionKey, Object) 67 | */ 68 | public void extension(final ExtensionKey key, final K value) { 69 | this.mapping.set(key, value); 70 | } 71 | 72 | /** 73 | * Adds the given listener to the mapping. 74 | * 75 | * @param listener The mapping listener 76 | * @see Mapping#addListener(MappingChangedListener) 77 | */ 78 | public void listener(final MappingChangedListener listener) { 79 | this.mapping.addListener(listener); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /lorenz-dsl-groovy/src/main/java/org/cadixdev/lorenz/dsl/groovy/MappingSetDsl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.dsl.groovy; 27 | 28 | import groovy.lang.Closure; 29 | import groovy.lang.DelegatesTo; 30 | import org.cadixdev.lorenz.MappingSet; 31 | import org.cadixdev.lorenz.model.TopLevelClassMapping; 32 | 33 | /** 34 | * A DSL to simplify the creation of {@link MappingSet}s in Groovy. 35 | * 36 | * @author Jamie Mansfield 37 | * @since 0.6.0 38 | */ 39 | public class MappingSetDsl { 40 | 41 | /** 42 | * Creates a mapping set, and applies the given {@link Closure} to it. 43 | * 44 | * @param script The closure to use 45 | * @return The mapping set 46 | * @see MappingSet#MappingSet() 47 | */ 48 | public static MappingSet create(@DelegatesTo(strategy = DslUtil.RESOLVE_STRATEGY, value = MappingSetDsl.class) final Closure script) { 49 | return DslUtil.delegate(new MappingSet(), MappingSetDsl::new, script); 50 | } 51 | 52 | private final MappingSet mappings; 53 | 54 | public MappingSetDsl(final MappingSet mappings) { 55 | this.mappings = mappings; 56 | } 57 | 58 | /** 59 | * Creates a top-level class mapping of the given name, and applies 60 | * the given {@link Closure} to it. 61 | * 62 | * @param name The obfuscated name of the class 63 | * @param script The closure to use 64 | * @return The mapping 65 | * @see MappingSet#getOrCreateTopLevelClassMapping(String) 66 | */ 67 | public TopLevelClassMapping klass( 68 | final String name, 69 | @DelegatesTo(strategy = DslUtil.RESOLVE_STRATEGY, value = ClassMappingDsl.class) final Closure script) { 70 | return DslUtil.delegate( 71 | this.mappings.getOrCreateTopLevelClassMapping(name), 72 | ClassMappingDsl::new, script); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/main/java/org/cadixdev/lorenz/io/enigma/EnigmaConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.enigma; 27 | 28 | import java.util.regex.Pattern; 29 | 30 | /** 31 | * A collection of constants and utilities specific to 32 | * the Enigma mapping format. 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.4.0 36 | */ 37 | public final class EnigmaConstants { 38 | 39 | /** 40 | * A regex expression used to remove comments from lines. 41 | */ 42 | private static final Pattern HASH_COMMENT = Pattern.compile("#.*"); 43 | 44 | /** 45 | * Removes present comments, from the given {@link String} line. 46 | * 47 | * @param line The line 48 | * @return The comment-omitted line 49 | */ 50 | public static String removeComments(final String line) { 51 | return HASH_COMMENT.matcher(line).replaceAll(""); 52 | } 53 | 54 | private EnigmaConstants() { 55 | } 56 | 57 | /** 58 | * A collection of file extensions frequently used by 59 | * consumers of the Enigma format. 60 | * 61 | * @author Jamie Mansfield 62 | * @since 0.6.0 63 | */ 64 | public static final class FileExtensions { 65 | 66 | /** 67 | * The "mapping" file extension, as used by both 68 | * cuchaz's mapping project and Fabric's Yarn mappings. 69 | */ 70 | public static final String MAPPING = "mapping"; 71 | 72 | /** 73 | * The "enigma" file extension. 74 | *

75 | * This exists for largely historical reasons, as it was erroneously 76 | * used as the standard file extension for Enigma by Lorenz prior to 77 | * Lorenz 0.6. 78 | */ 79 | public static final String ENIGMA = "enigma"; 80 | 81 | private FileExtensions() { 82 | } 83 | 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /etc/codestyle-intellij.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 18 | 19 | 20 | 29 | 39 | 42 | 43 | 46 | 49 | 50 | 54 | 55 | 63 | 64 | 68 | 69 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/io/srg/CSrgReaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.io.srg; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | import static org.junit.jupiter.api.Assertions.assertThrows; 30 | 31 | import org.cadixdev.lorenz.io.MappingFormats; 32 | import org.cadixdev.lorenz.io.srg.csrg.CSrgReader; 33 | import org.junit.jupiter.api.Test; 34 | 35 | import java.io.IOException; 36 | 37 | public class CSrgReaderTest extends AbstractSrgReaderTest { 38 | 39 | public CSrgReaderTest() throws Exception { 40 | super(MappingFormats.CSRG, "/test.csrg"); 41 | } 42 | 43 | @Test 44 | public void ignoresPackages() throws IOException { 45 | // This test ensures that package mappings won't erroneously be read as 46 | // class mappings. No exceptions should be thrown either. 47 | final CSrgReader.Processor parser = new CSrgReader.Processor(); 48 | parser.accept("abc/ uk/jamierocks/Example"); 49 | 50 | assertEquals(0, parser.getMappings().getTopLevelClassMappings().size()); 51 | } 52 | 53 | @Test 54 | public void tooLongInput() throws IOException { 55 | // This test should set off the first case where IllegalArgumentException 56 | // is thrown 57 | final CSrgReader.Processor parser = new CSrgReader.Processor(); 58 | assertThrows(IllegalArgumentException.class, () -> { 59 | parser.accept("this is a faulty mapping because it is too long"); 60 | }); 61 | } 62 | 63 | @Test 64 | public void invalidInput() throws IOException { 65 | // This test should set off the first case where IllegalArgumentException 66 | // is thrown 67 | final CSrgReader.Processor parser = new CSrgReader.Processor(); 68 | assertThrows(IllegalArgumentException.class, () -> { 69 | parser.accept("cls"); 70 | }); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/io/srg/TSrgReaderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.io.srg; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | import static org.junit.jupiter.api.Assertions.assertThrows; 30 | 31 | import org.cadixdev.lorenz.io.MappingFormats; 32 | import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader; 33 | import org.junit.jupiter.api.Test; 34 | 35 | import java.io.IOException; 36 | 37 | public class TSrgReaderTest extends AbstractSrgReaderTest { 38 | 39 | public TSrgReaderTest() throws Exception { 40 | super(MappingFormats.TSRG, "/test.tsrg"); 41 | } 42 | 43 | @Test 44 | public void ignoresPackages() throws IOException { 45 | // This test ensures that package mappings won't erroneously be read as 46 | // class mappings. No exceptions should be thrown either. 47 | final TSrgReader.Processor parser = new TSrgReader.Processor(); 48 | parser.accept("abc/ uk/jamierocks/Example"); 49 | 50 | assertEquals(0, parser.getMappings().getTopLevelClassMappings().size()); 51 | } 52 | 53 | @Test 54 | public void tooLongInput() throws IOException { 55 | // This test should set off the first case where IllegalArgumentException 56 | // is thrown 57 | final TSrgReader.Processor parser = new TSrgReader.Processor(); 58 | assertThrows(IllegalArgumentException.class, () -> { 59 | parser.accept("this is a faulty mapping because it is too long"); 60 | }); 61 | } 62 | 63 | @Test 64 | public void invalidInput() throws IOException { 65 | // This test should set off the first case where IllegalArgumentException 66 | // is thrown 67 | final TSrgReader.Processor parser = new TSrgReader.Processor(); 68 | assertThrows(IllegalArgumentException.class, () -> { 69 | parser.accept("\t Hi"); 70 | }); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/impl/model/AbstractMemberMappingImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.impl.model; 27 | 28 | import org.cadixdev.lorenz.model.Mapping; 29 | import org.cadixdev.lorenz.model.MemberMapping; 30 | 31 | import java.util.Objects; 32 | 33 | /** 34 | * An abstract basic implementation of {@link MemberMapping}. 35 | * 36 | * @param The type of the mapping 37 | * @param

The type of the parent mapping 38 | * 39 | * @author Jamie Mansfield 40 | * @since 0.2.0 41 | */ 42 | public abstract class AbstractMemberMappingImpl, P extends Mapping> 43 | extends AbstractMappingImpl 44 | implements MemberMapping { 45 | 46 | private final P parent; 47 | 48 | /** 49 | * Creates a new member mapping, from the given parameters. 50 | * 51 | * @param parent The mapping, this mapping belongs to 52 | * @param obfuscatedName The obfuscated name 53 | * @param deobfuscatedName The de-obfuscated name 54 | */ 55 | protected AbstractMemberMappingImpl(final P parent, final String obfuscatedName, 56 | final String deobfuscatedName) { 57 | super(parent.getMappings(), obfuscatedName, deobfuscatedName); 58 | this.parent = parent; 59 | } 60 | 61 | @Override 62 | public P getParent() { 63 | return this.parent; 64 | } 65 | 66 | @Override 67 | public boolean equals(final Object obj) { 68 | if (this == obj) return true; 69 | if (!super.equals(obj)) return false; 70 | if (!(obj instanceof MemberMapping)) return false; 71 | 72 | final MemberMapping that = (MemberMapping) obj; 73 | return Objects.equals(this.parent, that.getParent()); 74 | } 75 | 76 | @Override 77 | public int hashCode() { 78 | return Objects.hash(super.hashCode(), this.parent.getFullObfuscatedName(), this.parent.getFullDeobfuscatedName()); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/merge/MethodMergeStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.merge; 27 | 28 | import org.cadixdev.lorenz.MappingSet; 29 | 30 | /** 31 | *

32 | * This enum represents a configuration value for determining how strictly method mappings will be merged via 33 | * {@link MappingSetMerger}. Use it with {@link MergeConfig} and {@link MappingSetMerger#create(MappingSet, MappingSet, MergeConfig)}. 34 | * 35 | * @author Kyle Wood 36 | * @since 0.5.4 37 | */ 38 | public enum MethodMergeStrategy { 39 | 40 | /** 41 | * Only match exactly. This either means: 42 | *

    43 | *
  • For continuation merges, the full deobfuscated output signature of the left mapping must match the 44 | * full obfuscated input signature of the right mapping.
  • 45 | *
  • For duplicate merges, the full obfuscated input signature of the left mapping must match the full 46 | * obfuscated input signature of the right mapping.
  • 47 | *
48 | * For more information regarding continuation and duplicate merges, see the Continuations and Duplicates 49 | * section of {@link MappingSetMergerHandler}. 50 | */ 51 | STRICT, 52 | 53 | /** 54 | * Match the same as {@link #STRICT}, but also match more broadly: 55 | *
    56 | *
  • For continuation merges, the deobfuscated output name and obfuscated input descriptor of the left mapping 57 | * can match the obfuscated input signature of the right mapping.
  • 58 | *
  • For duplicate merges, the obfuscated input name and deobfuscated output descriptor of the left mapping 59 | * can match the obfuscated input signature of the right mapping.
  • 60 | *
61 | * For more information regarding continuation and duplicate merges, see the Continuations and Duplicates 62 | * section of {@link MappingSetMergerHandler}. 63 | */ 64 | LOOSE 65 | 66 | } 67 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/merge/FieldMergeStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.merge; 27 | 28 | import org.cadixdev.lorenz.MappingSet; 29 | 30 | /** 31 | * This enum represents a configuration value for determining how strictly field mappings will be merged via 32 | * {@link MappingSetMerger}. Use it with {@link MergeConfig} and {@link MappingSetMerger#create(MappingSet, MappingSet, MergeConfig)}. 33 | * 34 | * @author Kyle Wood 35 | * @since 0.5.4 36 | */ 37 | public enum FieldMergeStrategy { 38 | 39 | /** 40 | * Only match exactly. This either means: 41 | *
    42 | *
  • For continuation merges, the full deobfuscated output signature of the left mapping must match the 43 | * full obfuscated input signature of the right mapping, including field type.
  • 44 | *
  • For duplicate merges, the full obfuscated input signature of the left mapping must match the full 45 | * obfuscated input signature of the right mapping, including field type.
  • 46 | *
47 | * For more information regarding continuation and duplicate merges, see the Continuations and Duplicates 48 | * section of {@link MappingSetMergerHandler}. 49 | */ 50 | STRICT, 51 | 52 | /** 53 | * Match the same as {@link #STRICT}, but also match more broadly: 54 | *
    55 | *
  • For continuation merges, only the deobfuscated output name of the left mapping must match the obfuscated 56 | * input name of the right mapping, ignoring the type.
  • 57 | *
  • For duplicate merges, only the obfuscated input name of the left mapping needs to match the obfuscated 58 | * input name of the right mapping, ignoring the type.
  • 59 | *
60 | * For more information regarding continuation and duplicate merges, see the Continuations and Duplicates 61 | * section of {@link MappingSetMergerHandler}. 62 | */ 63 | LOOSE 64 | 65 | } 66 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/MappingsWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import org.cadixdev.bombe.type.FieldType; 29 | import org.cadixdev.lorenz.MappingSet; 30 | import org.cadixdev.lorenz.model.FieldMapping; 31 | import org.cadixdev.lorenz.model.Mapping; 32 | import org.cadixdev.lorenz.model.MethodMapping; 33 | 34 | import java.io.Closeable; 35 | import java.io.IOException; 36 | import java.util.Comparator; 37 | import java.util.function.Function; 38 | 39 | /** 40 | * Represents a writer, that is capable of writing de-obfuscation 41 | * mappings. 42 | *

43 | * Each mappings writer will be designed for a specific mapping 44 | * format, and intended to be used with try-for-resources. 45 | * 46 | * @see TextMappingsWriter 47 | * @see BinaryMappingsWriter 48 | * 49 | * @author Jamie Mansfield 50 | * @since 0.4.0 51 | */ 52 | public abstract class MappingsWriter implements Closeable { 53 | 54 | protected MappingsWriterConfig config = MappingsWriterConfig.builder().build(); 55 | 56 | /** 57 | * Gets the active {@link MappingsWriterConfig writer configuration} for 58 | * this mappings writer. 59 | * 60 | * @return The writer configuration 61 | * @since 0.5.5 62 | */ 63 | public MappingsWriterConfig getConfig() { 64 | return this.config; 65 | } 66 | 67 | /** 68 | * Sets the active {@link MappingsWriterConfig writer configuration} for 69 | * this mappings writer - allowing the output of the writer to be fine-tuned 70 | * to fit the environment in use. 71 | * 72 | * @param config The writer configuration 73 | * @throws NullPointerException If {@code config} is {@code null} 74 | * @since 0.5.5 75 | */ 76 | public void setConfig(final MappingsWriterConfig config) { 77 | if (config == null) { 78 | throw new NullPointerException("config cannot be null!"); 79 | } 80 | 81 | this.config = config; 82 | } 83 | 84 | /** 85 | * Writes the given mappings to the previously given output. 86 | * 87 | * @param mappings The mapping set 88 | * @throws IOException Should an IO issue occur 89 | */ 90 | public abstract void write(final MappingSet mappings) throws IOException; 91 | 92 | } 93 | -------------------------------------------------------------------------------- /lorenz/src/test/java/org/cadixdev/lorenz/test/model/jar/CompositeFieldTypeProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test.model.jar; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | import static org.junit.jupiter.api.Assertions.assertTrue; 30 | 31 | import org.cadixdev.lorenz.MappingSet; 32 | import org.cadixdev.lorenz.model.jar.CompositeFieldTypeProvider; 33 | import org.cadixdev.bombe.type.FieldType; 34 | import org.cadixdev.bombe.type.ObjectType; 35 | import org.junit.jupiter.api.Test; 36 | 37 | import java.util.Optional; 38 | 39 | public final class CompositeFieldTypeProviderTest { 40 | 41 | private static final MappingSet MAPPINGS = new MappingSet(); 42 | private static final CompositeFieldTypeProvider PROVIDER = new CompositeFieldTypeProvider() 43 | .add(field -> { 44 | if ("demo".equals(field.getObfuscatedName())) { 45 | return Optional.of(new ObjectType("java/util/logging/Logger")); 46 | } 47 | return Optional.empty(); 48 | }) 49 | .add(field -> { 50 | if ("uiop".equals(field.getObfuscatedName())) { 51 | return Optional.of(new ObjectType("java/lang/String")); 52 | } 53 | return Optional.empty(); 54 | }); 55 | 56 | static { 57 | MAPPINGS.addFieldTypeProvider(PROVIDER); 58 | } 59 | 60 | @Test 61 | public void demo() { 62 | final Optional type = MAPPINGS.getOrCreateTopLevelClassMapping("Demo") 63 | .getOrCreateFieldMapping("demo") 64 | .getType(); 65 | assertTrue(type.isPresent()); 66 | assertTrue(type.get() instanceof ObjectType); 67 | assertEquals("java/util/logging/Logger", ((ObjectType) type.get()).getClassName()); 68 | } 69 | 70 | @Test 71 | public void uiop() { 72 | final Optional type = MAPPINGS.getOrCreateTopLevelClassMapping("Demo") 73 | .getOrCreateFieldMapping("uiop") 74 | .getType(); 75 | assertTrue(type.isPresent()); 76 | assertTrue(type.get() instanceof ObjectType); 77 | assertEquals("java/lang/String", ((ObjectType) type.get()).getClassName()); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/TextMappingFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io; 27 | 28 | import java.io.IOException; 29 | import java.io.InputStream; 30 | import java.io.InputStreamReader; 31 | import java.io.OutputStream; 32 | import java.io.OutputStreamWriter; 33 | import java.io.Reader; 34 | import java.io.Writer; 35 | import java.nio.charset.StandardCharsets; 36 | import java.nio.file.Files; 37 | import java.nio.file.Path; 38 | 39 | /** 40 | * A representation of a de-obfuscation mapping format serialised as text. 41 | * 42 | * @author Minecrell 43 | * @since 0.4.0 44 | */ 45 | public interface TextMappingFormat extends MappingFormat { 46 | 47 | /** 48 | * Creates a {@link MappingsReader} from the given {@link Reader} 49 | * for the mapping format. 50 | * 51 | * @param reader The reader 52 | * @return The mapping reader 53 | * @throws IOException Should an I/O issue occur 54 | * @throws UnsupportedOperationException If the format does not support reading 55 | */ 56 | MappingsReader createReader(final Reader reader) throws IOException; 57 | 58 | @Override 59 | default MappingsReader createReader(final InputStream stream) throws IOException { 60 | return this.createReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); 61 | } 62 | 63 | @Override 64 | default MappingsReader createReader(final Path path) throws IOException { 65 | return this.createReader(Files.newBufferedReader(path)); 66 | } 67 | 68 | /** 69 | * Creates a {@link MappingsWriter} from the given {@link Writer} 70 | * for the mapping format. 71 | * 72 | * @param writer The writer 73 | * @return The mapping writer 74 | * @throws IOException Should an I/O issue occur 75 | * @throws UnsupportedOperationException If the format does not support writing 76 | */ 77 | MappingsWriter createWriter(final Writer writer) throws IOException; 78 | 79 | @Override 80 | default MappingsWriter createWriter(final OutputStream stream) throws IOException { 81 | return this.createWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8)); 82 | } 83 | 84 | @Override 85 | default MappingsWriter createWriter(final Path path) throws IOException { 86 | return this.createWriter(Files.newBufferedWriter(path)); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Lorenz 2 | ====== 3 | 4 | Lorenz is a library intended for creating and altering de-obfuscation mappings for Java 5 | programs (compiled or otherwise), this is done independent of the format being used. Lorenz 6 | supports a variety of mapping formats: 7 | 8 | - SRG and its variants (CSRG, TSRG, and XSRG) 9 | - Enigma (through `lorenz-io-enigma`) 10 | - JAM (through `lorenz-io-jam`) 11 | - ProGuard (**reader only** through `lorenz-io-proguard`) 12 | 13 | ## Branches 14 | 15 | Lorenz makes use of the [git-flow] branching structure, briefly put: 16 | 17 | - **master** is the source for the latest released version 18 | - **develop** is the source of the latest developments 19 | 20 | All releases will also be tagged, with further descriptions in their GitHub release. 21 | These descriptions will include information such as migration advice. 22 | 23 | ## Usage 24 | 25 | Lorenz is centred around the `MappingSet`, the root container of mappings. A provided 26 | implementation can be constructed through `MappingSet.create()`. 27 | 28 | Lorenz releases can be obtained through Maven Central: 29 | 30 | ### Gradle 31 | 32 | ```groovy 33 | implementation 'org.cadixdev:lorenz:0.5.7' 34 | ``` 35 | 36 | ### Maven 37 | 38 | ```xml 39 | 40 | org.cadixdev 41 | lorenz 42 | 0.5.7 43 | 44 | ``` 45 | 46 | You may also find snapshot artifacts on [Sonatype's OSS repository]. 47 | 48 | Versions prior to `0.5.0` were made under the `me.jamiemansfield` group, and initial 49 | snapshot releases were made to my personal Maven (`repo.jamiemansfield.me`). 50 | 51 | ## License 52 | 53 | Lorenz is licensed under the MIT License, this was chosen for its permissive nature - 54 | giving developers the freedom to do as they please with it, with no assurances from myself. 55 | 56 | ``` 57 | The MIT License (MIT) 58 | 59 | Copyright (c) Jamie Mansfield 60 | Copyright (c) contributors 61 | 62 | Permission is hereby granted, free of charge, to any person obtaining a copy 63 | of this software and associated documentation files (the "Software"), to deal 64 | in the Software without restriction, including without limitation the rights 65 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 66 | copies of the Software, and to permit persons to whom the Software is 67 | furnished to do so, subject to the following conditions: 68 | 69 | The above copyright notice and this permission notice shall be included in 70 | all copies or substantial portions of the Software. 71 | 72 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 73 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 74 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 75 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 76 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 77 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 78 | THE SOFTWARE. 79 | ``` 80 | 81 | ## Discuss 82 | 83 | **Found an issue with Lorenz?** [Make an issue]! We'd rather close invalid 84 | reports than have bugs go unreported :) 85 | 86 | We have an IRC channel on [EsperNet], `#cadix`, which is available for all 87 | [registered](https://esper.net/getting_started.php#registration) users to join 88 | and discuss Lorenz and other Cadix projects. 89 | 90 | [git-flow]: https://nvie.com/posts/a-successful-git-branching-model/ 91 | [Sonatype's OSS repository]: https://oss.sonatype.org/content/repositories/snapshots/ 92 | [Make an issue]: https://github.com/CadixDev/Lorenz/issues/new 93 | [EsperNet]: https://esper.net/ 94 | -------------------------------------------------------------------------------- /lorenz-io-enigma/src/main/java/org/cadixdev/lorenz/io/enigma/FabricEnigmaWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.enigma; 27 | 28 | import org.cadixdev.bombe.type.FieldType; 29 | import org.cadixdev.bombe.type.MethodDescriptor; 30 | import org.cadixdev.bombe.type.Type; 31 | import org.cadixdev.lorenz.io.MappingsWriter; 32 | import org.cadixdev.lorenz.model.ClassMapping; 33 | 34 | import java.io.Writer; 35 | 36 | /** 37 | * A {@link MappingsWriter mappings writer} for Fabric's fork of the Enigma 38 | * format. 39 | * 40 | * @author Jamie Mansfield 41 | * @since 0.6.0 42 | */ 43 | public class FabricEnigmaWriter extends EnigmaWriter { 44 | 45 | public FabricEnigmaWriter(final Writer writer) { 46 | super(writer); 47 | } 48 | 49 | @Override 50 | protected void printClassMapping(final ClassMapping klass, final int indent) { 51 | // Fabric's fork of the Enigma format doesn't use full de-obfuscated 52 | // names when printing classes (practically this affects inner classes). 53 | final String obfName = klass.getObfuscatedName(); 54 | 55 | if (klass.hasDeobfuscatedName()) { 56 | final String deobfName = klass.getDeobfuscatedName(); 57 | this.printIndentedLine(indent, "CLASS " + obfName + " " + deobfName); 58 | } 59 | else { 60 | this.printIndentedLine(indent, "CLASS " + obfName); 61 | } 62 | } 63 | 64 | @Override 65 | protected String convertClassName(final String descriptor) { 66 | // Fabric's fork of the Enigma format doesn't add a 'none/' prefix 67 | // to un-packaged classes. 68 | return descriptor; 69 | } 70 | 71 | @Override 72 | protected Type convertType(final Type type) { 73 | // Fabric's fork of the Enigma format doesn't add a 'none/' prefix 74 | // to un-packaged classes. 75 | return type; 76 | } 77 | 78 | @Override 79 | protected FieldType convertFieldType(final FieldType type) { 80 | // Fabric's fork of the Enigma format doesn't add a 'none/' prefix 81 | // to un-packaged classes. 82 | return type; 83 | } 84 | 85 | @Override 86 | protected String convertDescriptor(final MethodDescriptor descriptor) { 87 | // Fabric's fork of the Enigma format doesn't add a 'none/' prefix 88 | // to un-packaged classes. 89 | return descriptor.toString(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/io/srg/SrgConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.io.srg; 27 | 28 | import java.util.regex.Pattern; 29 | 30 | /** 31 | * A collection of constants and utilities specific to 32 | * the SRG mapping format and its variants. 33 | * 34 | * @author Jamie Mansfield 35 | * @since 0.4.0 36 | */ 37 | public final class SrgConstants { 38 | 39 | /** 40 | * A regex expression used to remove comments from lines. 41 | */ 42 | private static final Pattern HASH_COMMENT = Pattern.compile("#.*"); 43 | 44 | /** 45 | * The standard file extension used with the SRG format. 46 | */ 47 | public static final String STANDARD_EXTENSION = "srg"; 48 | 49 | /** 50 | * Removes present comments, from the given {@link String} line. 51 | * 52 | * @param line The line 53 | * @return The comment-omitted line 54 | */ 55 | public static String removeComments(final String line) { 56 | return HASH_COMMENT.matcher(line).replaceAll(""); 57 | } 58 | 59 | /** 60 | * A collection of constants specific to the CSRG 61 | * mapping format. 62 | */ 63 | public static final class CSrg { 64 | 65 | /** 66 | * The standard file extension used with the CSRG format. 67 | */ 68 | public static final String STANDARD_EXTENSION = "csrg"; 69 | 70 | private CSrg() { 71 | } 72 | 73 | } 74 | 75 | /** 76 | * A collection of constants specific to the TSRG 77 | * mapping format. 78 | */ 79 | public static final class TSrg { 80 | 81 | /** 82 | * The standard file extension used with the TSRG format. 83 | */ 84 | public static final String STANDARD_EXTENSION = "tsrg"; 85 | 86 | private TSrg() { 87 | } 88 | 89 | } 90 | 91 | /** 92 | * A collection of constants specific to the XSRG 93 | * mapping format. 94 | * 95 | * @since 0.5.3 96 | */ 97 | public static final class XSrg { 98 | 99 | /** 100 | * The standard file extension used with the TSRG format. 101 | */ 102 | public static final String STANDARD_EXTENSION = "xsrg"; 103 | 104 | private XSrg() { 105 | } 106 | 107 | } 108 | 109 | private SrgConstants() { 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /lorenz/src/test/groovy/org/cadixdev/lorenz/test/MappingReverseSpec.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.test 27 | 28 | import org.cadixdev.lorenz.MappingSet 29 | import spock.lang.Specification 30 | 31 | class MappingReverseSpec extends Specification { 32 | 33 | def 'reverses top level mapping'() { 34 | given: 35 | def originalClass = new MappingSet().getOrCreateTopLevelClassMapping('ab') 36 | .setDeobfuscatedName('Demo') 37 | def mappings = new MappingSet() 38 | 39 | when: 40 | originalClass.reverse(mappings) 41 | 42 | then: 43 | def copiedClass = mappings.getTopLevelClassMapping('Demo') 44 | copiedClass.isPresent() 45 | copiedClass.get().deobfuscatedName == 'ab' 46 | } 47 | 48 | def 'reverses field mapping'() { 49 | given: 50 | def originalField = new MappingSet().getOrCreateTopLevelClassMapping('ab') 51 | .getOrCreateFieldMapping('ui') 52 | .setDeobfuscatedName('log') 53 | def klassMapping = new MappingSet().getOrCreateTopLevelClassMapping('ab') 54 | 55 | when: 56 | originalField.reverse(klassMapping) 57 | 58 | then: 59 | def copiedField = klassMapping.getFieldMapping('log') 60 | copiedField.isPresent() 61 | copiedField.get().deobfuscatedName == 'ui' 62 | } 63 | 64 | def 'reverses method mapping'() { 65 | given: 66 | def originalMethod = new MappingSet().getOrCreateTopLevelClassMapping('ab') 67 | .getOrCreateMethodMapping('hhyg', '()V') 68 | .setDeobfuscatedName('main') 69 | def klassMapping = new MappingSet().getOrCreateTopLevelClassMapping('ab') 70 | 71 | when: 72 | originalMethod.reverse(klassMapping) 73 | 74 | then: 75 | def copiedMethod = klassMapping.getMethodMapping('main', '()V') 76 | copiedMethod.isPresent() 77 | copiedMethod.get().deobfuscatedName == 'hhyg' 78 | } 79 | 80 | def 'reverses inner mapping'() { 81 | given: 82 | def originalClass = new MappingSet().getOrCreateTopLevelClassMapping('ab') 83 | .getOrCreateInnerClassMapping('gh') 84 | .setDeobfuscatedName('Boop') 85 | def klassMapping = new MappingSet().getOrCreateTopLevelClassMapping('ab') 86 | 87 | when: 88 | originalClass.reverse(klassMapping) 89 | 90 | then: 91 | def copiedClass = klassMapping.getInnerClassMapping('Boop') 92 | copiedClass.isPresent() 93 | copiedClass.get().deobfuscatedName == 'gh' 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /lorenz/src/main/java/org/cadixdev/lorenz/util/Registry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Lorenz, licensed under the MIT License (MIT). 3 | * 4 | * Copyright (c) Jamie Mansfield 5 | * Copyright (c) contributors 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | package org.cadixdev.lorenz.util; 27 | 28 | import java.util.Collection; 29 | import java.util.Collections; 30 | import java.util.HashMap; 31 | import java.util.Map; 32 | import java.util.Set; 33 | import java.util.function.BiConsumer; 34 | 35 | /** 36 | * A registry of identifiable objects. 37 | * 38 | * @param The type of the registered objects 39 | * @author Jamie Mansfield 40 | * @since 0.5.0 41 | */ 42 | public class Registry { 43 | 44 | private final Map map = new HashMap<>(); 45 | 46 | /** 47 | * Registers the given value, with the given identifier. 48 | * 49 | * @param id The identifier of the value 50 | * @param value The value 51 | * @return {@code this}, for chaining 52 | */ 53 | public Registry register(final String id, final T value) { 54 | this.map.put(id.toLowerCase(), value); 55 | return this; 56 | } 57 | 58 | /** 59 | * Gets the value of the given identifier. 60 | * 61 | * @param id The identifier of the value 62 | * @return The value, or {@code null} if not present 63 | */ 64 | public T byId(final String id) { 65 | return this.map.get(id.toLowerCase()); 66 | } 67 | 68 | /** 69 | * Gets an immutable-view of value keys registered into 70 | * the registry. 71 | * 72 | * @return The keys 73 | * @since 0.5.3 74 | * 75 | * @see Map#keySet() 76 | */ 77 | public Set keys() { 78 | return Collections.unmodifiableSet(this.map.keySet()); 79 | } 80 | 81 | /** 82 | * Gets an immutable-view of all values registered into 83 | * the registry. 84 | * 85 | * @return The values 86 | * 87 | * @see Map#values() 88 | */ 89 | public Collection values() { 90 | return Collections.unmodifiableCollection(this.map.values()); 91 | } 92 | 93 | /** 94 | * Gets an immutable-view of all entries (key + value) 95 | * registered into the registry. 96 | * 97 | * @return The entries 98 | * @since 0.5.3 99 | * 100 | * @see Map#entrySet() 101 | */ 102 | public Set> entries() { 103 | return Collections.unmodifiableSet(this.map.entrySet()); 104 | } 105 | 106 | /** 107 | * @param consumer The action to be performed for each entry 108 | * @see Map#forEach(BiConsumer) 109 | */ 110 | public void forEach(final BiConsumer consumer) { 111 | this.map.forEach(consumer); 112 | } 113 | 114 | } 115 | --------------------------------------------------------------------------------