Skip to content

Commit

Permalink
Override setLocalVariable of namespaced LVT
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoPangxie732 committed Oct 28, 2024
1 parent c0af09a commit 9c793b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public static class Namespaced extends LocalVariableTable<NamespacedMapping> imp
private String mappedNamespace;
private String fallbackNamespace;

@Override
public void setLocalVariable(@Range(from = 0, to = 255) int index, @Nullable("To remove the previous mapping") NamespacedMapping mapping) {
if (mapping != null) {
if (unmappedNamespace != null) mapping.setUnmappedNamespace(unmappedNamespace);
if (mappedNamespace != null) mapping.setMappedNamespace(mappedNamespace);
if (fallbackNamespace != null) mapping.setFallbackNamespace(fallbackNamespace);
}
super.setLocalVariable(index, mapping);
}

public void swapAll(@NotNull String fromNamespace, @NotNull String toNamespace, DescriptorRemapper remapper) {
lvt.values().forEach(value -> value.swap(remapper, fromNamespace, toNamespace));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
import cn.maxpixel.rewh.logging.Logger;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.nio.channels.FileChannel;
import java.nio.file.Path;

public class FunctionTest {
private static final Logger LOGGER = LogManager.getLogger();

Expand Down Expand Up @@ -88,12 +84,10 @@ public class FunctionTest {
// }

public static void main(String[] args) throws Throwable {
FileChannel.open(Path.of("")).size();
new File("").length();
// ClassifiedMapping<NamespacedMapping> obf2srg = MappingFormats.TSRG_V2.read(new FileInputStream("downloads/1.19.2/joined.tsrg"));
// ClassifiedMapping<NamespacedMapping> obf2srg = MappingFormats.TSRG_V2.read(new FileInputStream("downloads/1.19/joined.tsrg"));
// obf2srg.getTrait(NamespacedTrait.class).setMappedNamespace("srg");
// obf2srg.updateCollection();
// ClassifiedMapping<PairedMapping> official = MappingFormats.PROGUARD.read(new FileInputStream("downloads/1.19.2/client_mappings.txt"));
// ClassifiedMapping<PairedMapping> official = MappingFormats.PROGUARD.read(new FileInputStream("downloads/1.19/client_mappings.txt"));
// var obf2off = new ClassifiedMappingRemapper(official);
// var out = new ClassifiedMapping<PairedMapping>();
// for (ClassMapping<NamespacedMapping> cm : obf2srg.classes) {
Expand All @@ -107,9 +101,10 @@ public static void main(String[] args) throws Throwable {
// }
// out.classes.add(ncm);
// }
// try (var writer = Files.newBufferedWriter(FileUtil.ensureFileExist(Path.of("downloads/1.19.2/obf2srg.tsrg")))) {
// try (var writer = Files.newBufferedWriter(Path.of("downloads/1.19/obf2srg.tsrg"))) {
// MappingFormats.TSRG_V1.write(out, writer);
// }

// for (ClassMapping<NamespacedMapping> cm : obf2srg.classes) {
// String obfClassName = cm.mapping.getUnmappedName();
// ClassMapping<PairedMapping> ncm = new ClassMapping<>(new PairedMapping(obf2off.mapClass(obfClassName), obf2off.mapClass(obfClassName)));
Expand All @@ -122,7 +117,7 @@ public static void main(String[] args) throws Throwable {
// }
// out.classes.add(ncm);
// }
// try (var writer = Files.newBufferedWriter(FileUtil.ensureFileExist(Path.of("downloads/1.19.2/srg2moj.tsrg")))) {
// try (var writer = Files.newBufferedWriter(Path.of("downloads/1.19/srg2moj.tsrg"))) {
// MappingFormats.TSRG_V1.write(out, writer);
// }

Expand Down

0 comments on commit 9c793b0

Please sign in to comment.