-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update jar processors, add exceptions jar processor
- Loading branch information
1 parent
65ce0b0
commit 0d9e112
Showing
14 changed files
with
650 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/net/ornithemc/ploceus/exceptions/ExceptionPatcherProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package net.ornithemc.ploceus.exceptions; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import javax.inject.Inject; | ||
|
||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace; | ||
import net.fabricmc.loom.api.processor.MinecraftJarProcessor; | ||
import net.fabricmc.loom.api.processor.ProcessorContext; | ||
import net.fabricmc.loom.api.processor.SpecContext; | ||
import net.fabricmc.mappingio.tree.MappingTree; | ||
|
||
import net.ornithemc.exceptor.Exceptor; | ||
import net.ornithemc.exceptor.io.ExceptionsFile; | ||
import net.ornithemc.ploceus.PloceusGradleExtension; | ||
|
||
public class ExceptionPatcherProcessor implements MinecraftJarProcessor<ExceptionPatcherProcessor.Spec> { | ||
|
||
private final PloceusGradleExtension ploceus; | ||
|
||
@Inject | ||
public ExceptionPatcherProcessor(PloceusGradleExtension ploceus) { | ||
this.ploceus = ploceus; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ploceus:exception_patcher"; | ||
} | ||
|
||
@Override | ||
public Spec buildSpec(SpecContext context) { | ||
ExceptionsProvider excs = ploceus.getExceptionsProvider(); | ||
return excs.isPresent() ? new Spec(excs) : null; | ||
} | ||
|
||
@Override | ||
public void processJar(Path jar, Spec spec, ProcessorContext ctx) throws IOException { | ||
try { | ||
MappingTree mappings = ctx.getMappings(); | ||
ExceptionsFile excs = ploceus.getExceptionsProvider().get(mappings, MappingsNamespace.NAMED); | ||
|
||
Exceptor.apply(jar, excs); | ||
} catch (IOException e) { | ||
throw new IOException("failed to patch exceptions!", e); | ||
} | ||
} | ||
|
||
public static class Spec implements MinecraftJarProcessor.Spec { | ||
|
||
private final ExceptionsProvider excs; | ||
|
||
private Integer hashCode; | ||
|
||
public Spec(ExceptionsProvider excs) { | ||
this.excs = excs; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
if (hashCode == null) { | ||
hashCode = excs.hashCode(); | ||
} | ||
|
||
return hashCode; | ||
} | ||
} | ||
} |
Oops, something went wrong.