-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/mojmap' into dev/next
- Loading branch information
Showing
10 changed files
with
410 additions
and
77 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import lambdynamiclights.Constants | ||
import net.fabricmc.loom.LoomGradleExtension | ||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace | ||
import net.fabricmc.loom.task.RemapJarTask | ||
import net.fabricmc.loom.task.RemapSourcesJarTask | ||
|
||
plugins { | ||
id("lambdynamiclights-common") | ||
} | ||
|
||
base.archivesName.set(Constants.NAME + "-api-mojmap") | ||
|
||
dependencies { | ||
mappings(loom.officialMojangMappings()) | ||
} | ||
|
||
val apiProject = project(":api") | ||
|
||
tasks.remapJar { | ||
val remapJar = apiProject.tasks.named("remapJar", RemapJarTask::class) | ||
dependsOn(remapJar) | ||
|
||
classpath.setFrom((loom as LoomGradleExtension).getMinecraftJarsCollection(MappingsNamespace.INTERMEDIARY)) | ||
inputFile.convention(remapJar.flatMap { it.archiveFile }) | ||
sourceNamespace = "intermediary" | ||
targetNamespace = "named" | ||
} | ||
|
||
// Add the remapped JAR artifact | ||
apiProject.configurations["mojmapApiElements"].artifacts.removeIf{ | ||
true | ||
} | ||
apiProject.artifacts.add("mojmapApiElements", tasks.remapJar) { | ||
classifier = "mojmap" | ||
} | ||
apiProject.configurations["mojmapRuntimeElements"].artifacts.removeIf{ | ||
true | ||
} | ||
apiProject.artifacts.add("mojmapRuntimeElements", tasks.remapJar) { | ||
classifier = "mojmap" | ||
} | ||
|
||
tasks.remapSourcesJar { | ||
val remapJar = apiProject.tasks.named("remapSourcesJar", RemapSourcesJarTask::class) | ||
dependsOn(remapJar) | ||
|
||
classpath.setFrom((loom as LoomGradleExtension).getMinecraftJarsCollection(MappingsNamespace.INTERMEDIARY)) | ||
inputFile.convention(remapJar.flatMap { it.archiveFile }) | ||
archiveClassifier = "sources" | ||
sourceNamespace = "intermediary" | ||
targetNamespace = "named" | ||
} | ||
|
||
// Add the remapped sources artifact | ||
apiProject.configurations["mojmapSourcesElements"].artifacts.removeIf { | ||
true | ||
} | ||
apiProject.artifacts.add("mojmapSourcesElements", tasks.remapSourcesJar) { | ||
classifier = "mojmap-sources" | ||
} |
43 changes: 43 additions & 0 deletions
43
build_logic/src/main/java/lambdynamiclights/data/Contact.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,43 @@ | ||
package lambdynamiclights.data; | ||
|
||
import java.io.Serializable; | ||
|
||
public final class Contact implements Serializable { | ||
private String homepage; | ||
private String sources; | ||
private String issues; | ||
|
||
public Contact withHomepage(String homepage) { | ||
this.homepage = homepage; | ||
return this; | ||
} | ||
|
||
public Contact withSources(String sources) { | ||
this.sources = sources; | ||
return this; | ||
} | ||
|
||
public Contact withIssues(String issues) { | ||
this.issues = issues; | ||
return this; | ||
} | ||
|
||
public String homepage() { | ||
return this.homepage; | ||
} | ||
|
||
public String sources() { | ||
return this.sources; | ||
} | ||
|
||
public String issues() { | ||
return this.issues; | ||
} | ||
|
||
public Contact copy() { | ||
return new Contact() | ||
.withHomepage(this.homepage) | ||
.withSources(this.sources) | ||
.withIssues(this.issues); | ||
} | ||
} |
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
63 changes: 40 additions & 23 deletions
63
build_logic/src/main/java/lambdynamiclights/data/ModBase.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 |
---|---|---|
@@ -1,43 +1,60 @@ | ||
package lambdynamiclights.data; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.io.Serializable; | ||
|
||
public class ModBase<SELF extends ModBase<SELF>> implements Serializable { | ||
@SerializedName("id") | ||
protected String namespace; | ||
protected String name; | ||
protected String description; | ||
protected String icon; | ||
|
||
public ModBase(String namespace, String name) { | ||
this.namespace = namespace; | ||
this.name = name; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public class ModBase<SELF extends ModBase<SELF>> extends ModShell<SELF> { | ||
protected final String version; | ||
protected final List<String> authors = new ArrayList<>(); | ||
protected Contact contact; | ||
protected String license; | ||
|
||
public ModBase(String namespace, String name, String version) { | ||
super(namespace, name); | ||
this.version = version; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private SELF $self() { | ||
return (SELF) this; | ||
} | ||
|
||
public SELF withNamespace(String namespace) { | ||
this.namespace = namespace; | ||
public SELF withAuthors(List<String> authors) { | ||
this.authors.addAll(authors); | ||
return this.$self(); | ||
} | ||
|
||
public SELF withName(String name) { | ||
this.name = name; | ||
return this.$self(); | ||
public SELF withAuthors(String... authors) { | ||
return this.withAuthors(Arrays.asList(authors)); | ||
} | ||
|
||
private Contact useContact() { | ||
if (this.contact == null) this.contact = new Contact(); | ||
return this.contact; | ||
} | ||
|
||
public SELF withDescription(String description) { | ||
this.description = description; | ||
public SELF withContact(Consumer<Contact> action) { | ||
action.accept(this.useContact()); | ||
return this.$self(); | ||
} | ||
|
||
public SELF withIcon(String icon) { | ||
this.icon = icon; | ||
public SELF withLicense(String license) { | ||
this.license = license; | ||
return this.$self(); | ||
} | ||
|
||
public <VARIANT extends ModBase<VARIANT>> VARIANT derive(ModBaseFactory<VARIANT> factory) { | ||
var variant = factory.create(this.namespace, this.name, this.version); | ||
this.copyTo(variant); | ||
variant.authors.addAll(this.authors); | ||
variant.contact = this.contact != null ? this.contact.copy() : null; | ||
variant.license = this.license; | ||
return variant; | ||
} | ||
|
||
public interface ModBaseFactory<SELF extends ModBase<SELF>> { | ||
SELF create(String namespace, String name, String version); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
build_logic/src/main/java/lambdynamiclights/data/ModShell.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,50 @@ | ||
package lambdynamiclights.data; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.io.Serializable; | ||
|
||
public class ModShell<SELF extends ModShell<SELF>> implements Serializable { | ||
@SerializedName("id") | ||
protected String namespace; | ||
protected String name; | ||
protected String description; | ||
protected String icon; | ||
|
||
public ModShell(String namespace, String name) { | ||
this.namespace = namespace; | ||
this.name = name; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private SELF $self() { | ||
return (SELF) this; | ||
} | ||
|
||
public SELF withNamespace(String namespace) { | ||
this.namespace = namespace; | ||
return this.$self(); | ||
} | ||
|
||
public SELF withName(String name) { | ||
this.name = name; | ||
return this.$self(); | ||
} | ||
|
||
public SELF withDescription(String description) { | ||
this.description = description; | ||
return this.$self(); | ||
} | ||
|
||
public SELF withIcon(String icon) { | ||
this.icon = icon; | ||
return this.$self(); | ||
} | ||
|
||
public void copyTo(ModShell<?> target) { | ||
target.namespace = this.namespace; | ||
target.name = this.name; | ||
target.description = this.description; | ||
target.icon = this.icon; | ||
} | ||
} |
Oops, something went wrong.