Skip to content

Commit

Permalink
1.9.4 mdk, extract dir no longer in /mdk/, pom builds to plugin dir
Browse files Browse the repository at this point in the history
  • Loading branch information
1fxe committed Mar 29, 2021
1 parent b0516c7 commit 4ae45ee
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The mappings are stored in this jar file, so you don't have to manually find the

The mappings currently work for 1.8, 1.8.9 and 1.9.4

The Forge MDK export works for 1.8.9 currently
The Forge MDK export works for 1.8.9 and 1.9.4

### Example Usage

Expand All @@ -38,7 +38,7 @@ The Forge MDK export works for 1.8.9 currently

## TODO

- Add more warnings/notifications
- Notifications
- Add support for other versions
- Add translations?

Expand Down
35 changes: 34 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,32 @@
<!-- Your personal package -->
<groupId>dev.fxe</groupId>
<artifactId>recaf4forge</artifactId>
<version>1.0.5</version>
<version>1.0.9</version>
<name>Recaf4Forge</name>
<profiles>
<profile>
<id>Windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<pluginDir>${user.home}/AppData/Roaming/Recaf/plugins</pluginDir>
</properties>
</profile>
<profile>
<id>Linux</id>
<activation>
<os>
<family>Linux</family>
</os>
</activation>
<properties>
<pluginDir>${user.home}/Library/Preferences/Recaf/plugins</pluginDir>
</properties>
</profile>
</profiles>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down Expand Up @@ -34,6 +58,15 @@
<target>1.8</target>
</configuration>
</plugin>
<!-- Move built jar into plugin dir -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>${pluginDir}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
2 changes: 1 addition & 1 deletion src/main/java/dev/fxe/recaf_forge/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ public static void saveFile(Path path, byte[] data) {
private static Path getExportDir() {
File file = dirChooser.showDialog(null);
if (file == null) return null;
return Paths.get(file.getPath() + "/mdk/");
return Paths.get(file.getPath() + "/");
}
}
10 changes: 6 additions & 4 deletions src/main/java/dev/fxe/recaf_forge/Recaf4Forge.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
/**
* @author Filip
*/
@SuppressWarnings("unused")
@Plugin(name = "Recaf4Forge")
public class Recaf4Forge implements ConfigurablePlugin, MenuProviderPlugin, WorkspacePlugin, StartupPlugin {

private final String[] versions = {"1.8", "1.8.9", "1.9.4"};
private final ExecutorService executor = Executors.newSingleThreadExecutor();
private Workspace currentWorkspace = null;
private Controller controller;
private String currentVersion = "";
private Controller controller;

@Conf(value = "Automatically apply mappings", noTranslate = true)
private boolean autoApply = false;
Expand Down Expand Up @@ -101,15 +102,15 @@ private void exportMDK() {
CompletableFuture.runAsync(() -> {
exportResources(extractedMDK);
exportSrc(extractedMDK);
}, executor);
});
}
}


private void exportResources(Path extractedMDK) {
for (Map.Entry<String, byte[]> resources : currentWorkspace.getPrimary().getFiles().entrySet()) {
String resourcePath =
extractedMDK.toString() + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + resources.getKey();
extractedMDK.toString() + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + resources.getKey();
Extractor.saveFile(Paths.get(resourcePath), resources.getValue());
}
}
Expand All @@ -118,7 +119,7 @@ private void exportSrc(Path extractedMDK) {
for (Map.Entry<String, byte[]> resources : currentWorkspace.getPrimary().getClasses().entrySet()) {
final String className = resources.getKey();
String resourcePath =
extractedMDK.toString() + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator + className + ".java";
extractedMDK.toString() + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator + className + ".java";
byte[] code = DecompileImpl.CFR.create(this.controller).decompile(className).getBytes(StandardCharsets.UTF_8);
Extractor.saveFile(Paths.get(resourcePath), code);
}
Expand Down Expand Up @@ -167,5 +168,6 @@ public String getConfigTabTitle() {
@Override
public void onStart(Controller controller) {
this.controller = controller;

}
}
Binary file added src/main/resources/mdks/1_9_4/mdk.zip
Binary file not shown.

0 comments on commit 4ae45ee

Please sign in to comment.