Skip to content

Commit 0feae25

Browse files
authored
Merge pull request #318 from PolyhedralDev/dev/1.19
Update to 1.19
2 parents cec83ae + d0069ff commit 0feae25

38 files changed

+556
-720
lines changed

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
preRelease(true)
22

3-
versionProjects(":common:api", version("6.0.1"))
4-
versionProjects(":common:implementation", version("6.0.1"))
5-
versionProjects(":platforms", version("6.0.1"))
3+
versionProjects(":common:api", version("6.1.0"))
4+
versionProjects(":common:implementation", version("6.1.0"))
5+
versionProjects(":platforms", version("6.1.0"))
66

77

88
allprojects {

buildSrc/build.gradle.kts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ plugins {
33
kotlin("jvm") version embeddedKotlinVersion
44
}
55

6+
buildscript {
7+
configurations.all {
8+
resolutionStrategy {
9+
force("org.ow2.asm:asm:9.3") // TODO: remove when ShadowJar updates ASM version
10+
force("org.ow2.asm:asm-commons:9.3")
11+
}
12+
}
13+
}
14+
615
repositories {
716
mavenCentral()
817
gradlePluginPortal()
@@ -11,8 +20,8 @@ repositories {
1120

1221
dependencies {
1322
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+")
14-
implementation("org.ow2.asm:asm:9.2")
15-
implementation("org.ow2.asm:asm-tree:9.2")
23+
implementation("org.ow2.asm:asm:9.3")
24+
implementation("org.ow2.asm:asm-tree:9.3")
1625
implementation("com.dfsek.tectonic:common:4.2.0")
1726
implementation("org.yaml:snakeyaml:1.27")
1827
}

buildSrc/src/main/kotlin/AddonConfig.kt

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import java.io.File
33
import java.util.function.Predicate
44
import org.gradle.api.Project
55
import org.gradle.api.Task
6-
import org.gradle.jvm.tasks.Jar
76
import org.gradle.kotlin.dsl.extra
87
import kotlin.streams.asStream
98

@@ -12,28 +11,33 @@ import kotlin.streams.asStream
1211
* Configures a directory where addons will be put.
1312
*/
1413
fun Project.addonDir(dir: File, task: Task) {
15-
task.dependsOn("compileAddons")
16-
task.doFirst {
17-
dir.parentFile.mkdirs()
18-
matchingAddons(dir) {
19-
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
20-
}.forEach {
21-
println("Deleting old addon: " + it.absolutePath)
22-
it.delete()
23-
}
24-
forSubProjects(":common:addons") {
25-
val jar = tasks.named("shadowJar").get() as ShadowJar
26-
27-
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
28-
val target = File(dir, boot + jar.archiveFileName.get())
29-
30-
val base = "${jar.archiveBaseName.get()}-${version}"
31-
32-
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
14+
val moveAddons = tasks.register("moveAddons" + task.name) {
15+
dependsOn("compileAddons")
16+
doLast {
17+
dir.parentFile.mkdirs()
18+
matchingAddons(dir) {
19+
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
20+
}.forEach {
21+
println("Deleting old addon: " + it.absolutePath)
22+
it.delete()
23+
}
24+
forSubProjects(":common:addons") {
25+
val jar = tasks.named("shadowJar").get() as ShadowJar
26+
27+
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
28+
val target = File(dir, boot + jar.archiveFileName.get())
29+
30+
val base = "${jar.archiveBaseName.get()}-${version}"
31+
32+
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
33+
34+
jar.archiveFile.orNull?.asFile?.copyTo(target)
35+
}
36+
}
3337

34-
jar.archiveFile.orNull?.asFile?.copyTo(target)
3538
}
36-
}
39+
40+
task.dependsOn(moveAddons)
3741
}
3842

3943
fun matchingAddons(dir: File, matcher: Predicate<File>): Set<File> {

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ object Versions {
1919

2020
object Fabric {
2121
const val fabricLoader = "0.14.2"
22-
const val fabricAPI = "0.53.4+1.18.2"
23-
const val minecraft = "1.18.2"
24-
const val yarn = "$minecraft+build.3"
22+
const val fabricAPI = "0.55.1+1.19"
23+
const val minecraft = "1.19"
24+
const val yarn = "$minecraft+build.1"
2525
const val permissionsAPI = "0.1-SNAPSHOT"
26+
const val mixin = "0.11.2+mixin.0.8.5"
27+
const val loom = "0.11-SNAPSHOT"
2628
}
2729

2830
object Bukkit {

common/implementation/base/src/main/java/com/dfsek/terra/AbstractPlatform.java

Lines changed: 55 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,6 @@
1919

2020
import com.dfsek.tectonic.api.TypeRegistry;
2121

22-
import com.dfsek.terra.api.util.generic.pair.Pair;
23-
24-
import org.apache.commons.io.FileUtils;
25-
import org.apache.commons.io.IOUtils;
26-
import org.jetbrains.annotations.NotNull;
27-
import org.slf4j.Logger;
28-
import org.slf4j.LoggerFactory;
29-
import org.yaml.snakeyaml.Yaml;
30-
31-
import java.io.File;
32-
import java.io.FileOutputStream;
33-
import java.io.IOException;
34-
import java.io.InputStream;
35-
import java.io.OutputStream;
36-
import java.io.UncheckedIOException;
37-
import java.net.URL;
38-
import java.nio.charset.StandardCharsets;
39-
import java.nio.file.Files;
40-
import java.nio.file.Path;
41-
import java.util.ArrayList;
42-
import java.util.Collections;
43-
import java.util.Comparator;
44-
import java.util.List;
45-
import java.util.Map;
46-
import java.util.Set;
47-
import java.util.stream.Collectors;
48-
4922
import com.dfsek.terra.addon.BootstrapAddonLoader;
5023
import com.dfsek.terra.addon.DependencySorter;
5124
import com.dfsek.terra.addon.EphemeralAddon;
@@ -64,6 +37,7 @@
6437
import com.dfsek.terra.api.registry.CheckedRegistry;
6538
import com.dfsek.terra.api.registry.Registry;
6639
import com.dfsek.terra.api.registry.key.StringIdentifiable;
40+
import com.dfsek.terra.api.util.generic.pair.Pair;
6741
import com.dfsek.terra.api.util.mutable.MutableBoolean;
6842
import com.dfsek.terra.api.util.reflection.TypeKey;
6943
import com.dfsek.terra.config.GenericLoaders;
@@ -75,6 +49,21 @@
7549
import com.dfsek.terra.registry.OpenRegistryImpl;
7650
import com.dfsek.terra.registry.master.ConfigRegistry;
7751

52+
import org.apache.commons.io.FileUtils;
53+
import org.apache.commons.io.IOUtils;
54+
import org.jetbrains.annotations.NotNull;
55+
import org.slf4j.Logger;
56+
import org.slf4j.LoggerFactory;
57+
import org.yaml.snakeyaml.Yaml;
58+
59+
import java.io.*;
60+
import java.net.URL;
61+
import java.nio.charset.StandardCharsets;
62+
import java.nio.file.Files;
63+
import java.nio.file.Path;
64+
import java.util.*;
65+
import java.util.stream.Collectors;
66+
7867

7968
/**
8069
* Skeleton implementation of {@link Platform}
@@ -119,8 +108,10 @@ protected void load() {
119108
logger.info("Initializing Terra...");
120109

121110
try(InputStream stream = getClass().getResourceAsStream("/config.yml")) {
111+
logger.info("Loading config.yml");
122112
File configFile = new File(getDataFolder(), "config.yml");
123113
if(!configFile.exists()) {
114+
logger.info("Writing new config.yml...");
124115
FileUtils.copyInputStreamToFile(stream, configFile);
125116
}
126117
} catch(IOException e) {
@@ -222,6 +213,7 @@ protected void dumpResources() {
222213
Path data = getDataFolder().toPath();
223214

224215
Path addonsPath = data.resolve("addons");
216+
Files.createDirectories(addonsPath);
225217
Set<Pair<Path, String>> paths = Files
226218
.walk(addonsPath)
227219
.map(path -> Pair.of(path, data.relativize(path).toString()))
@@ -249,7 +241,6 @@ protected void dumpResources() {
249241
.collect(Collectors.toSet());
250242

251243

252-
// Terra-aaa-aaa-1.2.3-BETA+1e6af8923d.jar
253244
String resourceYaml = IOUtils.toString(resourcesConfig, StandardCharsets.UTF_8);
254245
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
255246
resources.forEach((dir, entries) -> entries.forEach(entry -> {
@@ -258,42 +249,44 @@ protected void dumpResources() {
258249
if(resource.exists())
259250
return; // dont overwrite
260251

261-
paths
262-
.stream()
263-
.filter(Pair.testRight(resourcePath::startsWith))
264-
.forEach(Pair.consumeLeft(path -> {
265-
logger.info("Removing outdated resource {}, replacing with {}", path, resourcePath);
266-
try {
267-
Files.delete(path);
268-
} catch(IOException e) {
269-
throw new UncheckedIOException(e);
270-
}
271-
}));
272-
273-
if(pathsNoMajor
274-
.stream()
275-
.anyMatch(resourcePath::startsWith) && // if any share name
276-
paths
277-
.stream()
278-
.map(Pair.unwrapRight())
279-
.noneMatch(resourcePath::startsWith)) { // but dont share major version
280-
logger.warn(
281-
"Addon {} has a new major version available. It will not be automatically updated; you will need to ensure " +
282-
"compatibility and update manually.",
283-
resourcePath);
284-
}
285-
286-
logger.info("Dumping resource {}...", resource.getAbsolutePath());
287-
try {
252+
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath)) {
253+
if(is == null) {
254+
logger.error("Resource {} doesn't exist on the classpath!", resourcePath);
255+
return;
256+
}
257+
258+
paths
259+
.stream()
260+
.filter(Pair.testRight(resourcePath::startsWith))
261+
.forEach(Pair.consumeLeft(path -> {
262+
logger.info("Removing outdated resource {}, replacing with {}", path, resourcePath);
263+
try {
264+
Files.delete(path);
265+
} catch(IOException e) {
266+
throw new UncheckedIOException(e);
267+
}
268+
}));
269+
270+
if(pathsNoMajor
271+
.stream()
272+
.anyMatch(resourcePath::startsWith) && // if any share name
273+
paths
274+
.stream()
275+
.map(Pair.unwrapRight())
276+
.noneMatch(resourcePath::startsWith)) { // but dont share major version
277+
logger.warn(
278+
"Addon {} has a new major version available. It will not be automatically updated; you will need to " +
279+
"ensure " +
280+
"compatibility and update manually.",
281+
resourcePath);
282+
}
283+
284+
logger.info("Dumping resource {}...", resource.getAbsolutePath());
288285
resource.getParentFile().mkdirs();
289286
resource.createNewFile();
290-
} catch(IOException e) {
291-
throw new UncheckedIOException(e);
292-
}
293-
logger.debug("Copying resource {}", resourcePath);
294-
try(InputStream is = getClass().getResourceAsStream("/" + resourcePath);
295-
OutputStream os = new FileOutputStream(resource)) {
296-
IOUtils.copy(is, os);
287+
try(OutputStream os = new FileOutputStream(resource)) {
288+
IOUtils.copy(is, os);
289+
}
297290
} catch(IOException e) {
298291
throw new UncheckedIOException(e);
299292
}

common/implementation/bootstrap-addon-loader/src/main/java/com/dfsek/terra/addon/BootstrapAddonLoader.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,24 @@ private BootstrapBaseAddon<?> loadAddon(Path addonPath, BootstrapAddonClassLoade
7474
}
7575

7676
} catch(IOException e) {
77-
throw new UncheckedIOException(e);
77+
throw new AddonLoadException("Failed to load addon from path " + addonPath, e);
7878
}
7979
}
8080

8181
@Override
8282
public Iterable<BootstrapBaseAddon<?>> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
83-
Path bootstrapFolder = addonsFolder.resolve("bootstrap");
84-
logger.debug("Loading bootstrap addons from {}", bootstrapFolder);
85-
86-
try(Stream<Path> bootstrapAddons = Files.walk(bootstrapFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
87-
return bootstrapAddons.filter(path -> path.toFile().isFile())
88-
.filter(path -> path.toFile().canRead())
89-
.filter(path -> path.toString().endsWith(".jar"))
90-
.map(path -> loadAddon(path, parent))
91-
.collect(Collectors.toList());
83+
try {
84+
Path bootstrapFolder = addonsFolder.resolve("bootstrap");
85+
Files.createDirectories(bootstrapFolder);
86+
logger.debug("Loading bootstrap addons from {}", bootstrapFolder);
87+
88+
try(Stream<Path> bootstrapAddons = Files.walk(bootstrapFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
89+
return bootstrapAddons.filter(path -> path.toFile().isFile())
90+
.filter(path -> path.toFile().canRead())
91+
.filter(path -> path.toString().endsWith(".jar"))
92+
.map(path -> loadAddon(path, parent))
93+
.collect(Collectors.toList());
94+
}
9295
} catch(IOException e) {
9396
throw new UncheckedIOException(e);
9497
}

platforms/fabric/build.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import com.modrinth.minotaur.TaskModrinthUpload
33
import net.fabricmc.loom.task.RemapJarTask
44

55
plugins {
6-
id("fabric-loom").version("0.11-SNAPSHOT")
6+
id("fabric-loom").version(Versions.Fabric.loom)
77
id("com.modrinth.minotaur").version("1.1.0")
88
}
99

@@ -15,7 +15,7 @@ dependencies {
1515

1616
modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}")
1717

18-
setOf("fabric-command-api-v1", "fabric-lifecycle-events-v1", "fabric-resource-loader-v0", "fabric-api-base").forEach { apiModule ->
18+
setOf("fabric-lifecycle-events-v1", "fabric-resource-loader-v0", "fabric-api-base").forEach { apiModule ->
1919
val module = fabricApi.module(apiModule, Versions.Fabric.fabricAPI)
2020
modImplementation(module)
2121
include(module)
@@ -24,8 +24,12 @@ dependencies {
2424
include(modImplementation("me.lucko", "fabric-permissions-api", Versions.Fabric.permissionsAPI))
2525
include("me.lucko", "fabric-permissions-api", Versions.Fabric.permissionsAPI)
2626

27-
include(modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud))
28-
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
27+
"compileOnly"("net.fabricmc:sponge-mixin:${Versions.Fabric.mixin}")
28+
"annotationProcessor"("net.fabricmc:sponge-mixin:${Versions.Fabric.mixin}")
29+
"annotationProcessor"("net.fabricmc:fabric-loom:${Versions.Fabric.loom}")
30+
31+
//include(modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud))
32+
//include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
2933
}
3034

3135
loom {

platforms/fabric/src/main/java/com/dfsek/terra/fabric/FabricEntryPoint.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717

1818
package com.dfsek.terra.fabric;
1919

20-
import cloud.commandframework.execution.CommandExecutionCoordinator;
21-
import cloud.commandframework.fabric.FabricServerCommandManager;
2220
import net.fabricmc.api.ModInitializer;
23-
import net.minecraft.server.command.ServerCommandSource;
2421
import net.minecraft.util.Identifier;
2522
import net.minecraft.util.registry.Registry;
23+
import net.minecraft.world.gen.WorldPresets;
2624
import org.slf4j.Logger;
2725
import org.slf4j.LoggerFactory;
2826

29-
import com.dfsek.terra.api.command.CommandSender;
30-
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
3127
import com.dfsek.terra.fabric.data.Codecs;
3228

3329

@@ -49,7 +45,7 @@ public static void register() { // register the things
4945
@Override
5046
public void onInitialize() {
5147
logger.info("Initializing Terra Fabric mod...");
52-
48+
/*
5349
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
5450
CommandExecutionCoordinator.simpleCoordinator(),
5551
serverCommandSource -> (CommandSender) serverCommandSource,
@@ -60,5 +56,7 @@ public void onInitialize() {
6056
manager.brigadierManager().setNativeNumberSuggestions(false);
6157
6258
TERRA_PLUGIN.getEventManager().callEvent(new CommandRegistrationEvent(manager));
59+
TODO: re-enable when Cloud updates
60+
*/
6361
}
6462
}

0 commit comments

Comments
 (0)