mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
move additional build data in its own constants class
This commit is contained in:
@@ -162,15 +162,6 @@ tasks {
|
||||
"version" to rootProject.version,
|
||||
"apiVersion" to apiVersion,
|
||||
"main" to main,
|
||||
"environment" to if (project.hasProperty("release")) "production" else "development",
|
||||
"commit" to provider {
|
||||
val res = runCatching { project.extensions.getByType<Grgit>().head().id }
|
||||
res.getOrDefault("")
|
||||
.takeIf { it.length == 40 } ?: {
|
||||
logger.error("Git commit hash not found", res.exceptionOrNull())
|
||||
"unknown"
|
||||
}()
|
||||
},
|
||||
)
|
||||
filesMatching("**/plugin.yml") {
|
||||
expand(inputs.properties)
|
||||
@@ -185,9 +176,31 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gradle is weird sometimes, we need to delete the plugin yml from the build folder to actually filter properly.
|
||||
*/
|
||||
afterEvaluate {
|
||||
layout.buildDirectory.file("resources/main/plugin.yml").get().asFile.delete()
|
||||
val templateSource = file("src/main/templates")
|
||||
val templateDest = layout.buildDirectory.dir("generated/sources/templates")
|
||||
val generateTemplates = tasks.register<Copy>("generateTemplates") {
|
||||
inputs.properties(
|
||||
"environment" to if (project.hasProperty("release")) "production" else "development",
|
||||
"commit" to provider {
|
||||
val res = runCatching { project.extensions.getByType<Grgit>().head().id }
|
||||
res.getOrDefault("")
|
||||
.takeIf { it.length == 40 } ?: {
|
||||
logger.error("Git commit hash not found", res.exceptionOrNull())
|
||||
"unknown"
|
||||
}()
|
||||
},
|
||||
)
|
||||
|
||||
from(templateSource)
|
||||
into(templateDest)
|
||||
rename { "com/volmit/iris/$it" }
|
||||
expand(inputs.properties)
|
||||
}
|
||||
|
||||
rootProject.tasks.named("prepareKotlinBuildScriptModel") {
|
||||
dependsOn(generateTemplates)
|
||||
}
|
||||
|
||||
sourceSets.main {
|
||||
java.srcDir(generateTemplates.map { it.outputs })
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||
.thenRunAsync(() -> {
|
||||
c.removePluginChunkTicket(Iris.instance);
|
||||
c.unload();
|
||||
engine.getWorldManager().onChunkLoad(c, true);
|
||||
}, syncExecutor)
|
||||
.get();
|
||||
Iris.debug("Regenerated " + x + " " + z);
|
||||
@@ -354,16 +354,16 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
@Override
|
||||
public void generateNoise(@NotNull WorldInfo world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData d) {
|
||||
try {
|
||||
getEngine(world);
|
||||
Engine engine = getEngine(world);
|
||||
computeStudioGenerator();
|
||||
TerrainChunk tc = TerrainChunk.create(d, new IrisBiomeStorage());
|
||||
this.world.bind(world);
|
||||
if (studioGenerator != null) {
|
||||
studioGenerator.generateChunk(getEngine(), tc, x, z);
|
||||
studioGenerator.generateChunk(engine, tc, x, z);
|
||||
} else {
|
||||
ChunkDataHunkHolder blocks = new ChunkDataHunkHolder(tc);
|
||||
BiomeGridHunkHolder biomes = new BiomeGridHunkHolder(tc, tc.getMinHeight(), tc.getMaxHeight());
|
||||
getEngine().generate(x << 4, z << 4, blocks, biomes, IrisSettings.get().getGenerator().useMulticore);
|
||||
engine.generate(x << 4, z << 4, blocks, biomes, IrisSettings.get().getGenerator().useMulticore);
|
||||
blocks.apply();
|
||||
biomes.apply();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.volmit.iris.util.misc;
|
||||
|
||||
import com.volmit.iris.BuildConstants;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
@@ -19,19 +20,12 @@ import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.DrilldownPie;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.charts.SingleLineChart;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import oshi.SystemInfo;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -47,8 +41,6 @@ public class Bindings {
|
||||
if (settings.disableAutoReporting || Sentry.isEnabled() || Boolean.getBoolean("iris.suppressReporting")) return;
|
||||
Iris.info("Enabling Sentry for anonymous error reporting. You can disable this in the settings.");
|
||||
Iris.info("Your server ID is: " + ServerID.ID);
|
||||
var resource = Iris.instance.getResource("plugin.yml");
|
||||
YamlConfiguration desc = resource != null ? YamlConfiguration.loadConfiguration(new InputStreamReader(resource)) : new YamlConfiguration();
|
||||
|
||||
Sentry.init(options -> {
|
||||
options.setDsn("http://4cdbb9ac953306529947f4ca1e8e6b26@sentry.volmit.com:8080/2");
|
||||
@@ -60,7 +52,7 @@ public class Bindings {
|
||||
options.setAttachServerName(false);
|
||||
options.setEnableUncaughtExceptionHandler(false);
|
||||
options.setRelease(Iris.instance.getDescription().getVersion());
|
||||
options.setEnvironment(desc.getString("environment", "production"));
|
||||
options.setEnvironment(BuildConstants.ENVIRONMENT);
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (suppress(event.getThrowable())) return null;
|
||||
event.setTag("iris.safeguard", IrisSafeguard.mode());
|
||||
@@ -77,7 +69,7 @@ public class Bindings {
|
||||
scope.setTag("server", Bukkit.getVersion());
|
||||
scope.setTag("server.type", Bukkit.getName());
|
||||
scope.setTag("server.api", Bukkit.getBukkitVersion());
|
||||
scope.setTag("iris.commit", desc.getString("commit", "unknown"));
|
||||
scope.setTag("iris.commit", BuildConstants.COMMIT);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,6 +91,7 @@ public class Bindings {
|
||||
.map(IrisToolbelt::access)
|
||||
.filter(Objects::nonNull)
|
||||
.map(PlatformChunkGenerator::getEngine)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(engine -> engine.getDimension().getLoadKey(), engine -> {
|
||||
var hash32 = engine.getHash32().getNow(null);
|
||||
if (hash32 == null) return Map.of();
|
||||
@@ -111,23 +104,7 @@ public class Bindings {
|
||||
b.forEach((k, v) -> merged.merge(k, v, Integer::sum));
|
||||
return merged;
|
||||
}))));
|
||||
|
||||
|
||||
var info = new SystemInfo().getHardware();
|
||||
var cpu = info.getProcessor().getProcessorIdentifier();
|
||||
var mem = info.getMemory();
|
||||
metrics.addCustomChart(new SimplePie("cpu_model", cpu::getName));
|
||||
|
||||
var nf = NumberFormat.getInstance(Locale.ENGLISH);
|
||||
nf.setMinimumFractionDigits(0);
|
||||
nf.setMaximumFractionDigits(2);
|
||||
nf.setRoundingMode(RoundingMode.HALF_UP);
|
||||
|
||||
metrics.addCustomChart(new DrilldownPie("memory", () -> {
|
||||
double total = mem.getTotal() * 1E-9;
|
||||
double alloc = Math.min(total, Runtime.getRuntime().maxMemory() * 1E-9);
|
||||
return Map.of(nf.format(alloc), Map.of(nf.format(total), 1));
|
||||
}));
|
||||
metrics.addCustomChart(new DrilldownPie("environment", () -> Map.of(BuildConstants.ENVIRONMENT, Map.of(BuildConstants.COMMIT, 1))));
|
||||
|
||||
plugin.postShutdown(metrics::shutdown);
|
||||
});
|
||||
|
||||
@@ -5,8 +5,6 @@ load: STARTUP
|
||||
authors: [ cyberpwn, NextdoorPsycho, Vatuu ]
|
||||
website: volmit.com
|
||||
description: More than a Dimension!
|
||||
environment: '${environment}'
|
||||
commit: '${commit}'
|
||||
commands:
|
||||
iris:
|
||||
aliases: [ ir, irs ]
|
||||
|
||||
7
core/src/main/templates/BuildConstants.java
Normal file
7
core/src/main/templates/BuildConstants.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.volmit.iris;
|
||||
|
||||
// The constants are replaced before compilation
|
||||
public interface BuildConstants {
|
||||
String ENVIRONMENT = "${environment}";
|
||||
String COMMIT = "${commit}";
|
||||
}
|
||||
Reference in New Issue
Block a user