mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
Merge remote-tracking branch 'origin/ver/6.0.0' into ver/6.0.0
# Conflicts: # build.gradle.kts # buildSrc/src/main/kotlin/DependencyConfig.kt # buildSrc/src/main/kotlin/DistributionConfig.kt # common/addons/biome-provider-image/build.gradle.kts # common/addons/biome-provider-pipeline/build.gradle.kts # common/addons/biome-provider-single/build.gradle.kts # common/addons/chunk-generator-noise-3d/build.gradle.kts # common/addons/command-addons/build.gradle.kts # common/addons/command-packs/build.gradle.kts # common/addons/command-profiler/build.gradle.kts # common/addons/command-structures/build.gradle.kts # common/addons/config-biome/build.gradle.kts # common/addons/config-distributors/build.gradle.kts # common/addons/config-feature/build.gradle.kts # common/addons/config-flora/build.gradle.kts # common/addons/config-locators/build.gradle.kts # common/addons/config-noise-function/build.gradle.kts # common/addons/config-ore/build.gradle.kts # common/addons/config-palette/build.gradle.kts # common/addons/config-structure/build.gradle.kts # common/addons/generation-stage-feature/build.gradle.kts # common/addons/generation-stage-structure/build.gradle.kts # common/addons/language-yaml/build.gradle.kts # common/addons/manifest-addon-loader/build.gradle.kts # common/addons/palette-block-shortcut/build.gradle.kts # common/addons/structure-block-shortcut/build.gradle.kts # common/addons/structure-mutator/build.gradle.kts # common/addons/structure-sponge-loader/build.gradle.kts # common/addons/structure-terrascript-loader/build.gradle.kts # common/addons/terrascript-function-check-noise-3d/build.gradle.kts # common/addons/terrascript-function-sampler/build.gradle.kts # common/api/build.gradle.kts # common/implementation/base/build.gradle.kts # common/implementation/bootstrap-addon-loader/build.gradle.kts # platforms/bukkit/build.gradle.kts # platforms/cli/build.gradle.kts # platforms/merged/build.gradle.kts
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
preRelease(true)
|
||||
|
||||
versionProjects(":common:api", version("6.0.0"))
|
||||
@@ -46,18 +44,16 @@ afterEvaluate {
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"(project(":common:api"))
|
||||
"implementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"(project(":common:api"))
|
||||
}
|
||||
val libPackage = "com.dfsek.terra.addons.${this.name.replace('-', '_')}.lib"
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "$libPackage.jafama")
|
||||
}
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,23 @@ fun Project.configureDependencies() {
|
||||
val testImplementation by configurations.getting
|
||||
val compileOnly by configurations.getting
|
||||
|
||||
val api by configurations.getting
|
||||
val implementation by configurations.getting
|
||||
|
||||
val shaded by configurations.creating
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val shadedApi by configurations.creating {
|
||||
shaded.extendsFrom(this)
|
||||
api.extendsFrom(this)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val shadedImplementation by configurations.creating {
|
||||
shaded.extendsFrom(this)
|
||||
implementation.extendsFrom(this)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
@@ -121,14 +121,14 @@ fun Project.configureDistribution() {
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
// Tell shadow to download the packs
|
||||
dependsOn(downloadDefaultPacks)
|
||||
|
||||
configurations = listOf(project.configurations["shaded"])
|
||||
archiveClassifier.set("shaded")
|
||||
setVersion(project.version)
|
||||
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
|
||||
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
|
||||
relocate("org.json", "com.dfsek.terra.lib.json")
|
||||
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
|
||||
}
|
||||
|
||||
configure<BasePluginExtension> {
|
||||
@@ -147,10 +147,4 @@ fun downloadPack(packUrl: URL, project: Project) {
|
||||
file.outputStream().write(packUrl.readBytes())
|
||||
}
|
||||
|
||||
fun Project.getJarTask(): Jar {
|
||||
return if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(tasks.named("jar").get() as Jar)
|
||||
}
|
||||
}
|
||||
fun Project.getJarTask() = tasks.named("shadowJar").get() as ShadowJar
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
object Versions {
|
||||
object Libraries {
|
||||
const val tectonic = "4.2.0"
|
||||
const val paralithic = "0.6.0"
|
||||
const val paralithic = "0.6.1"
|
||||
const val strata = "1.1.1"
|
||||
|
||||
const val cloud = "1.6.2"
|
||||
@@ -13,7 +13,6 @@ object Versions {
|
||||
const val apacheText = "1.9"
|
||||
const val jafama = "2.3.2"
|
||||
const val apacheIO = "2.6"
|
||||
const val asm = "9.2"
|
||||
const val fastutil = "8.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addon.loader;
|
||||
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
|
||||
public class ApiAddon implements BaseAddon {
|
||||
private final Version version;
|
||||
private final String id;
|
||||
|
||||
public ApiAddon(Version version, String id) {
|
||||
this.version = version;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addon.loader;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
|
||||
public class ApiAddonClassLoader extends URLClassLoader {
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
public ApiAddonClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
|
||||
@@ -21,7 +22,8 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
@Override
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -2,16 +2,12 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
}
|
||||
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.noise.lib.paralithic")
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractal
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.AdditionSampler;
|
||||
@@ -90,6 +91,7 @@ public class NoiseAddon implements AddonInitializer {
|
||||
noiseRegistry.register(addon.key("CLAMP"), ClampNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("SCALE"), ScaleNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("POSTERIZATION"), PosterizationNormalizerTemplate::new);
|
||||
|
||||
noiseRegistry.register(addon.key("IMAGE"), ImageSamplerTemplate::new);
|
||||
|
||||
@@ -121,7 +123,6 @@ public class NoiseAddon implements AddonInitializer {
|
||||
|
||||
noiseRegistry.register(addon.key("LINEAR_HEIGHTMAP"), LinearHeightmapSamplerTemplate::new);
|
||||
|
||||
|
||||
noiseRegistry.register(addon.key("ADD"), () -> new BinaryArithmeticTemplate<>(AdditionSampler::new));
|
||||
noiseRegistry.register(addon.key("SUB"), () -> new BinaryArithmeticTemplate<>(SubtractionSampler::new));
|
||||
noiseRegistry.register(addon.key("MUL"), () -> new BinaryArithmeticTemplate<>(MultiplicationSampler::new));
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.config.templates.normalizer;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.noise.normalizer.PosterizationNormalizer;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
public class PosterizationNormalizerTemplate extends NormalizerTemplate<PosterizationNormalizer> {
|
||||
@Value("steps")
|
||||
private @Meta int steps;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
return new PosterizationNormalizer(function, steps);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.normalizer;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public class PosterizationNormalizer extends Normalizer {
|
||||
private final double stepSize;
|
||||
|
||||
public PosterizationNormalizer(NoiseSampler sampler, int steps) {
|
||||
super(sampler);
|
||||
this.stepSize = 2.0 / (steps - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double normalize(double in) {
|
||||
return FastMath.roundToInt((in + 1) / stepSize) * stepSize - 1;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
api("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.6")
|
||||
api("commons-io:commons-io:2.7")
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ import ca.solostudios.strata.version.VersionRange;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -72,13 +75,9 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
throw new AddonException("Addon " + manifest.getID() + " has unknown schema version: " + manifest.getSchemaVersion());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed", "resource" })
|
||||
ManifestAddonClassLoader childLoader = new ManifestAddonClassLoader(new URL[]{ addonPath.toUri().toURL() },
|
||||
loader);
|
||||
|
||||
List<AddonInitializer> initializers = manifest.getEntryPoints().stream().map(entryPoint -> {
|
||||
try {
|
||||
Object in = childLoader.loadClass(entryPoint).getConstructor().newInstance();
|
||||
Object in = loader.loadClass(entryPoint).getConstructor().newInstance();
|
||||
if(!(in instanceof AddonInitializer)) {
|
||||
throw new AddonException(in.getClass() + " does not extend " + AddonInitializer.class);
|
||||
}
|
||||
@@ -103,7 +102,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ManifestAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
public Iterable<ManifestAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
|
||||
logger.debug("Loading addons...");
|
||||
|
||||
try(Stream<Path> files = Files.walk(addonsFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
|
||||
@@ -114,16 +113,16 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
.filter(path -> path.toString().endsWith(".jar"))
|
||||
.toList();
|
||||
|
||||
ManifestAddonClassLoader loader = new ManifestAddonClassLoader(addons.stream().map(path -> {
|
||||
addons.stream().map(path -> {
|
||||
try {
|
||||
return path.toUri().toURL();
|
||||
} catch(MalformedURLException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}).toArray(URL[]::new), getClass().getClassLoader());
|
||||
}).forEach(parent::addURL);
|
||||
|
||||
return addons.stream()
|
||||
.map(jar -> loadAddon(jar, loader))
|
||||
.map(jar -> loadAddon(jar, parent))
|
||||
.collect(Collectors.toList());
|
||||
} catch(IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url = uri("https://jitpack.io/") }
|
||||
}
|
||||
@@ -13,9 +9,9 @@ repositories {
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.7")
|
||||
api("com.github.Querz:NBT:6.1")
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons")
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,9 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.7")
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
api(project(":common:addons:chunk-generator-noise-3d"))
|
||||
api(project(":common:addons:structure-terrascript-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:chunk-generator-noise-3d"))
|
||||
compileOnlyApi(project(":common:addons:structure-terrascript-loader"))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":common:addons:manifest-addon-loader"))
|
||||
api(project(":common:addons:config-noise-function"))
|
||||
api(project(":common:addons:structure-terrascript-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:config-noise-function"))
|
||||
compileOnlyApi(project(":common:addons:structure-terrascript-loader"))
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
dependencies {
|
||||
compileOnlyApi("ca.solo-studios", "strata", Versions.Libraries.strata)
|
||||
compileOnlyApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
compileOnlyApi("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
|
||||
api("ca.solo-studios", "strata", Versions.Libraries.strata)
|
||||
api("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
api("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
|
||||
|
||||
compileOnlyApi("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
|
||||
api("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
|
||||
|
||||
compileOnlyApi("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.dfsek.terra.api.addon.bootstrap;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
|
||||
|
||||
public class BootstrapAddonClassLoader extends URLClassLoader {
|
||||
public BootstrapAddonClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
}
|
||||
|
||||
public BootstrapAddonClassLoader(URL[] urls) {
|
||||
super(urls);
|
||||
}
|
||||
|
||||
public BootstrapAddonClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
|
||||
super(urls, parent, factory);
|
||||
}
|
||||
|
||||
public BootstrapAddonClassLoader(String name, URL[] urls, ClassLoader parent) {
|
||||
super(name, urls, parent);
|
||||
}
|
||||
|
||||
public BootstrapAddonClassLoader(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
|
||||
super(name, urls, parent, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(URL url) {
|
||||
super.addURL(url);
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,5 @@ public interface BootstrapBaseAddon<T extends BaseAddon> extends BaseAddon {
|
||||
*
|
||||
* @return Loaded addons
|
||||
*/
|
||||
Iterable<T> loadAddons(Path addonsFolder, ClassLoader parent);
|
||||
Iterable<T> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent);
|
||||
}
|
||||
|
||||
@@ -3,22 +3,11 @@ dependencies {
|
||||
api(project(":common:implementation:bootstrap-addon-loader"))
|
||||
|
||||
implementation("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
|
||||
implementation("org.apache.commons", "commons-text", Versions.Libraries.Internal.apacheText)
|
||||
|
||||
implementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic)
|
||||
implementation("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
|
||||
|
||||
implementation("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
|
||||
implementation("ca.solo-studios", "strata", Versions.Libraries.strata)
|
||||
|
||||
implementation("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
|
||||
implementation("org.ow2.asm", "asm", Versions.Libraries.Internal.asm)
|
||||
|
||||
|
||||
|
||||
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
implementation("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
package com.dfsek.terra;
|
||||
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,6 +34,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@@ -162,12 +166,14 @@ public abstract class AbstractPlatform implements Platform {
|
||||
|
||||
Injector<Platform> platformInjector = new InjectorImpl<>(this);
|
||||
platformInjector.addExplicitTarget(Platform.class);
|
||||
|
||||
BootstrapAddonClassLoader bootstrapAddonClassLoader = new BootstrapAddonClassLoader(new URL[] {}, getClass().getClassLoader());
|
||||
|
||||
bootstrapAddonLoader.loadAddons(addonsFolder, getClass().getClassLoader())
|
||||
bootstrapAddonLoader.loadAddons(addonsFolder, bootstrapAddonClassLoader)
|
||||
.forEach(bootstrapAddon -> {
|
||||
platformInjector.inject(bootstrapAddon);
|
||||
|
||||
bootstrapAddon.loadAddons(addonsFolder, getClass().getClassLoader())
|
||||
bootstrapAddon.loadAddons(addonsFolder, bootstrapAddonClassLoader)
|
||||
.forEach(addonList::add);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
dependencies {
|
||||
"api"(project(":common:api"))
|
||||
compileOnlyApi(project(":common:api"))
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addon;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
|
||||
public class AddonClassLoader extends URLClassLoader {
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
public AddonClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package com.dfsek.terra.addon;
|
||||
|
||||
import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
||||
|
||||
public BootstrapAddonLoader() { }
|
||||
|
||||
private BootstrapBaseAddon<?> loadAddon(Path addonPath, ClassLoader parent) {
|
||||
private BootstrapBaseAddon<?> loadAddon(Path addonPath, BootstrapAddonClassLoader parent) {
|
||||
logger.debug("Loading bootstrap addon from JAR {}", addonPath);
|
||||
try(JarFile jar = new JarFile(addonPath.toFile())) {
|
||||
String entry = jar.getManifest().getMainAttributes().getValue("Terra-Bootstrap-Addon-Entry-Point");
|
||||
@@ -54,10 +55,8 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
||||
|
||||
//noinspection NestedTryStatement
|
||||
try {
|
||||
@SuppressWarnings({ "resource", "IOResourceOpenedButNotSafelyClosed" })
|
||||
AddonClassLoader loader = new AddonClassLoader(new URL[]{ addonPath.toUri().toURL() }, parent);
|
||||
|
||||
Object addonObject = loader.loadClass(entry).getConstructor().newInstance();
|
||||
parent.addURL(addonPath.toUri().toURL());
|
||||
Object addonObject = parent.loadClass(entry).getConstructor().newInstance();
|
||||
|
||||
if(!(addonObject instanceof BootstrapBaseAddon<?> addon)) {
|
||||
throw new AddonLoadException(
|
||||
@@ -81,7 +80,7 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<BootstrapBaseAddon<?>> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
public Iterable<BootstrapBaseAddon<?>> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
|
||||
Path bootstrapFolder = addonsFolder.resolve("bootstrap");
|
||||
logger.debug("Loading bootstrap addons from {}", bootstrapFolder);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ val paperURL = "https://papermc.io/api/v2/projects/paper/versions/%version%/buil
|
||||
val purpurURL = "https://api.pl3x.net/v2/purpur/%version%/latest/download"
|
||||
|
||||
dependencies {
|
||||
api(project(":common:implementation:base"))
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
api("org.slf4j:slf4j-api:1.8.0-beta4") {
|
||||
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
|
||||
@@ -24,11 +24,11 @@ dependencies {
|
||||
}
|
||||
|
||||
compileOnly("io.papermc.paper", "paper-api", Versions.Bukkit.paper)
|
||||
implementation("io.papermc", "paperlib", Versions.Bukkit.paperLib)
|
||||
shadedApi("io.papermc", "paperlib", Versions.Bukkit.paperLib)
|
||||
|
||||
api("com.google.guava:guava:30.0-jre")
|
||||
shadedApi("com.google.guava:guava:30.0-jre")
|
||||
|
||||
api("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
|
||||
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
|
||||
}
|
||||
|
||||
val jvmFlags = listOf(
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
@@ -29,6 +30,8 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
private final LimitedRegion delegate;
|
||||
private final BlockState air;
|
||||
|
||||
private static final AtomicBoolean warn = new AtomicBoolean(true);
|
||||
|
||||
public BukkitProtoWorld(LimitedRegion delegate, BlockState air) {
|
||||
this.delegate = delegate;
|
||||
this.air = air;
|
||||
@@ -114,19 +117,25 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
private <T> Optional<T> access(int x, int y, int z, Supplier<T> action) {
|
||||
if(delegate.isInRegion(x, y, z)) {
|
||||
return Optional.of(action.get());
|
||||
} else {
|
||||
} else if(warn.getAndSet(false)) {
|
||||
LOGGER.warn("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
return Optional.empty();
|
||||
} else {
|
||||
LOGGER.debug("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private void access(int x, int y, int z, Runnable action) {
|
||||
if(delegate.isInRegion(x, y, z)) {
|
||||
action.run();
|
||||
} else {
|
||||
} else if(warn.getAndSet(false)) {
|
||||
LOGGER.warn("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
} else {
|
||||
LOGGER.debug("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.6")
|
||||
api("com.github.Querz:NBT:6.1")
|
||||
api(project(":common:implementation:base"))
|
||||
shadedApi("commons-io:commons-io:2.7")
|
||||
shadedApi("com.github.Querz:NBT:6.1")
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
implementation("com.google.guava:guava:31.0.1-jre")
|
||||
shadedImplementation("com.google.guava:guava:31.0.1-jre")
|
||||
|
||||
implementation("ch.qos.logback:logback-classic:1.2.7")
|
||||
shadedImplementation("ch.qos.logback:logback-classic:1.2.9")
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
@Mixin(DataPackContents.class)
|
||||
public class DataPackContentsMixin {
|
||||
|
||||
/*
|
||||
* #refresh populates all tags in the registries
|
||||
*/
|
||||
@Inject(method = "refresh(Lnet/minecraft/util/registry/DynamicRegistryManager;)V", at = @At("RETURN"))
|
||||
private void injectReload(DynamicRegistryManager dynamicRegistryManager, CallbackInfo ci) {
|
||||
FabricUtil.registerTags(dynamicRegistryManager.get(Registry.BIOME_KEY));
|
||||
|
||||
@@ -3,7 +3,7 @@ val platformOverrides = mapOf(
|
||||
)
|
||||
|
||||
dependencies {
|
||||
api(project(":common:implementation"))
|
||||
api(project(":common:implementation:base"))
|
||||
}
|
||||
|
||||
val taskSet = HashSet<AbstractArchiveTask>()
|
||||
|
||||
Reference in New Issue
Block a user