-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests using JUnit and share Coverage + Results to Sonar
- Loading branch information
1 parent
f2fe4cd
commit 2d1c51c
Showing
8 changed files
with
134 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ run/ | |
|
||
./ModLoader* | ||
jars/ | ||
mod-remapping-api |
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
68 changes: 68 additions & 0 deletions
68
src/main/java/io/github/fabriccompatibiltylayers/modremappingapi/impl/RemapUtils.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,68 @@ | ||
package io.github.fabriccompatibiltylayers.modremappingapi.impl; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.fabricmc.loader.api.ObjectShare; | ||
import net.fabricmc.loader.impl.launch.FabricLauncherBase; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class RemapUtils { | ||
public static List<Path> getRemapClasspath() throws IOException { | ||
String remapClasspathFile = System.getProperty("fabric.remapClasspathFile"); | ||
|
||
if (remapClasspathFile == null) { | ||
System.out.println("remapClasspathFile is null! Falling back to ObjectShare."); | ||
return getClassPathFromObjectShare(); | ||
} | ||
|
||
String content = new String(Files.readAllBytes(Paths.get(remapClasspathFile)), StandardCharsets.UTF_8); | ||
|
||
return Arrays.stream(content.split(File.pathSeparator)) | ||
.map(Paths::get) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public static @NotNull List<Path> getClassPathFromObjectShare() { | ||
ObjectShare share = FabricLoader.getInstance().getObjectShare(); | ||
Object inputs = share.get("fabric-loader:inputGameJars"); | ||
List<Path> list = new ArrayList<>(); | ||
|
||
Object oldJar = FabricLoader.getInstance().getObjectShare().get("fabric-loader:inputGameJar"); | ||
|
||
List<Path> classPaths = FabricLauncherBase.getLauncher().getClassPath(); | ||
|
||
if (inputs instanceof List) { | ||
List<Path> paths = (List<Path>) inputs; | ||
|
||
if (oldJar instanceof Path) { | ||
if (paths.get(0).toString().equals(oldJar.toString())) { | ||
list.addAll(paths); | ||
} else { | ||
list.add((Path) oldJar); | ||
} | ||
} else { | ||
list.addAll(paths); | ||
} | ||
} else { | ||
list.add((Path) oldJar); | ||
} | ||
|
||
list.addAll(classPaths); | ||
|
||
Object realmsJar = share.get("fabric-loader:inputRealmsJar"); | ||
|
||
if (realmsJar instanceof Path) list.add((Path) realmsJar); | ||
|
||
return list; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/java/io/github/fabriccompatibiltylayers/modremappingapi/test/ModRemapperTests.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,25 @@ | ||
package io.github.fabriccompatibiltylayers.modremappingapi.test; | ||
|
||
import io.github.fabriccompatibiltylayers.modremappingapi.api.MappingUtils; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ModRemapperTests { | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
// MixinBootstrap.init(); | ||
} | ||
|
||
@Test | ||
public void differentSourceNamespace() { | ||
Assertions.assertEquals( | ||
MappingUtils.mapClass("net/minecraft/unmapped/C_0760609"), | ||
FabricLoader.getInstance().isDevelopmentEnvironment() ? | ||
"net/minecraft/client/class_785" | ||
: "net/minecraft/class_785" | ||
); | ||
} | ||
} |
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