Skip to content

Commit

Permalink
More of a perfect mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Ran-Mewo committed Dec 16, 2021
1 parent 85876aa commit 8a314ee
Showing 8 changed files with 38 additions and 24 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
Make an issue if you are having troubles!

We won't bite you for making useless issues
## How to download this?
Well uhm I don't really know how to publish a gradle plugin/dependency (psst someone publish this for me and then make an issue letting me know)

So for now you'll have to be scuffed just like me!

You'll first need to [download](https://github.com/PacifistMC/pacifist-remapper/releases) this
then in your project make a folder named libs and paste the jar file in that
then in your project make a folder named plugins and paste the jar file in that
and then add this to your build.gradle file without breaking the entire universe
```groovy
import me.rancraftplayz.pacifist.remapper.RemapperPlugin
buildscript {
dependencies{
classpath files('libs/pacifist-remapper.jar')
classpath files('plugins/pacifist-remapper.jar')
}
}
apply plugin: RemapperPlugin
@@ -24,14 +22,14 @@ If something goes wrong then you can look at my project [PacifistOptimizations's
## How to use
```groovy
dependencies {
mojangProguardMappings "org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:maps-mojang@txt"
spigotCsrgMappings "org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:maps-spigot@csrg"
remapLib "org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:remapped-mojang"
}
```
The **mojangProguardMappings** is the mojang mappings
The **spigotCsrgMappings** is the spigot mappings
spigot {
version = "1.17.1"
}
```
Remember to change the version numbers

The **remapLib** is where it'll remap from

@@ -63,7 +61,7 @@ To actually apply the accsss wideners you need to run the task **applyAccessWide
The **-obf** must be added after the name of the access widener because the actual example.accesswidener is not an access widener that Ignite understands! (unless if you're making it in spigot mappings)

## ShadowJar configuration (Required for now)
If you're using shadow or something simillar then you'll need to set the path & name to where the original jar task makes it's jar
If you're using shadow or something similar then you'll need to set the path & name to where the original jar task makes its jar
If you're using default build stuff then you can add this to your shadowJar
```groovy
shadowJar {
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ plugins {
}

group 'me.rancraftplayz.pacifist'
version '0.1'
version '0.2'

repositories {
mavenCentral()
@@ -24,6 +24,7 @@ dependencies {
shadowJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
configurations = [project.configurations.getByName("shadowMe")]
archiveClassifier.set(null)
}

gradlePlugin {
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Binary file modified libs/mappingsconverter-0.1-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -17,17 +17,14 @@
public class ApplyAccessWidenerTask extends DefaultTask {
@TaskAction
void applyAccessWidenerTask() throws IOException {
File inputJar = ((AbstractArchiveTask) getProject().getTasks().getByName("jar")).getArchiveFile().get().getAsFile();

Set<File> alibFiles = getProject().getConfigurations().named("accessWidenerLib").get().getFiles();
List<Path> alibs = new ArrayList<>();

for (File file : alibFiles) {
alibs.add(file.toPath());
}

Optional<File> proguardMappings = getProject().getConfigurations().named("mojangProguardMappings").get().getFiles().stream().findFirst();
Optional<File> csrgMappings = getProject().getConfigurations().named("spigotCsrgMappings").get().getFiles().stream().findFirst();
String mcVersion = RemapperPlugin.extension.getVersion();

Optional<File> accessWidener = getProject().getConfigurations().named("accessWidener").get().getFiles().stream().findFirst();

@@ -36,8 +33,8 @@ void applyAccessWidenerTask() throws IOException {
return;
}

if (proguardMappings.isPresent() && csrgMappings.isPresent()) {
MojangSpigotAccessWidenerRemapper.remap(accessWidener.get().toPath(), proguardMappings.get().toPath(), csrgMappings.get().toPath(), alibs, inputJar.toPath());
if (!mcVersion.isEmpty()) {
MojangSpigotAccessWidenerRemapper.remap(accessWidener.get().toPath(), RemapperPlugin.mappingsDir, mcVersion, alibs);
} else {
System.out.println("Mappings not found! Applying access wideners without mappings");
applyAccessWidenersWithoutMaps(accessWidener.get(), alibs);
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@ void remapJarTask() throws IOException {
alibs.add(file.toPath());
}

Optional<File> proguardMappings = getProject().getConfigurations().named("mojangProguardMappings").get().getFiles().stream().findFirst();
Optional<File> csrgMappings = getProject().getConfigurations().named("spigotCsrgMappings").get().getFiles().stream().findFirst();
String mcVersion = RemapperPlugin.extension.getVersion();

Optional<File> accessWidener = getProject().getConfigurations().named("accessWidener").get().getFiles().stream().findFirst();

@@ -47,8 +46,8 @@ void remapJarTask() throws IOException {
accessWidenerPath = accessWidener.get().toPath();
}

if (proguardMappings.isPresent() && csrgMappings.isPresent()) {
MojangSpigotRemapper.remapAll(inputJar.toPath(), proguardMappings.get().toPath(), csrgMappings.get().toPath(), libs, accessWidenerPath, alibs);
if (!mcVersion.isEmpty()) {
MojangSpigotRemapper.remapAll(inputJar.toPath(), RemapperPlugin.mappingsDir, mcVersion, libs, accessWidenerPath, alibs);
} else {
System.out.println("Mappings not found!");
}
Original file line number Diff line number Diff line change
@@ -3,11 +3,17 @@
import org.gradle.api.Plugin;
import org.gradle.api.Project;

import java.io.File;

public class RemapperPlugin implements Plugin<Project> {
static SpigotMappingExtension extension;
static File mappingsDir;

@Override
public void apply(Project project) {
project.getConfigurations().create("mojangProguardMappings");
project.getConfigurations().create("spigotCsrgMappings");
extension = project.getExtensions().create("spigot", SpigotMappingExtension.class);
mappingsDir = new File(project.getRootDir(), ".gradle" + File.separator + "mappings");

project.getConfigurations().create("remapLib");

project.getConfigurations().create("accessWidener");
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package me.rancraftplayz.pacifist.remapper;

public class SpigotMappingExtension {
private String version;

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}
}

0 comments on commit 8a314ee

Please sign in to comment.