mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-21 11:43:27 +00:00
switch to slimjar
This commit is contained in:
parent
2e2ea8f1e4
commit
6b193f695a
@ -30,7 +30,7 @@ buildscript {
|
|||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
`java-library`
|
`java-library`
|
||||||
id("com.gradleup.shadow") version "8.3.6"
|
id("com.gradleup.shadow") version "9.0.0-rc1"
|
||||||
id("de.undercouch.download") version "5.0.1"
|
id("de.undercouch.download") version "5.0.1"
|
||||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||||
id("io.sentry.jvm.gradle") version "5.7.0"
|
id("io.sentry.jvm.gradle") version "5.7.0"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
import io.github.slimjar.func.slimjar
|
||||||
|
import io.github.slimjar.resolver.data.Mirror
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
@ -21,14 +25,11 @@ plugins {
|
|||||||
`java-library`
|
`java-library`
|
||||||
id("com.gradleup.shadow")
|
id("com.gradleup.shadow")
|
||||||
id("io.sentry.jvm.gradle")
|
id("io.sentry.jvm.gradle")
|
||||||
|
id("de.crazydev22.slimjar") version "2.0.6"
|
||||||
}
|
}
|
||||||
|
|
||||||
val apiVersion = "1.19"
|
val apiVersion = "1.19"
|
||||||
val main = "com.volmit.iris.Iris"
|
val main = "com.volmit.iris.Iris"
|
||||||
val loader = "com.volmit.iris.IrisPluginLoader"
|
|
||||||
|
|
||||||
val dynamic: Configuration by configurations.creating
|
|
||||||
configurations.compileOnly { extendsFrom(dynamic) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependencies.
|
* Dependencies.
|
||||||
@ -64,30 +65,32 @@ dependencies {
|
|||||||
//implementation files("libs/CustomItems.jar")
|
//implementation files("libs/CustomItems.jar")
|
||||||
|
|
||||||
// Shaded
|
// Shaded
|
||||||
implementation("com.dfsek:paralithic:0.8.1")
|
implementation(slimjar())
|
||||||
implementation("io.papermc:paperlib:1.0.5")
|
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.17.0")
|
|
||||||
implementation("net.kyori:adventure-platform-bukkit:4.3.4")
|
|
||||||
implementation("net.kyori:adventure-api:4.17.0")
|
|
||||||
implementation("org.bstats:bstats-bukkit:3.1.0")
|
|
||||||
implementation(project(":core:paper-loader"))
|
|
||||||
|
|
||||||
// Dynamically Loaded
|
// Dynamically Loaded
|
||||||
dynamic("commons-io:commons-io:2.13.0")
|
slim("com.dfsek:paralithic:0.8.1")
|
||||||
dynamic("commons-lang:commons-lang:2.6")
|
slim("io.papermc:paperlib:1.0.5")
|
||||||
dynamic("com.github.oshi:oshi-core:6.6.5")
|
slim("net.kyori:adventure-text-minimessage:4.17.0")
|
||||||
dynamic("org.lz4:lz4-java:1.8.0")
|
slim("net.kyori:adventure-platform-bukkit:4.3.4")
|
||||||
dynamic("it.unimi.dsi:fastutil:8.5.8")
|
slim("net.kyori:adventure-api:4.17.0")
|
||||||
dynamic("com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2")
|
slim("org.bstats:bstats-bukkit:3.1.0")
|
||||||
dynamic("org.zeroturnaround:zt-zip:1.14")
|
slim("io.sentry:sentry:8.12.0")
|
||||||
dynamic("com.google.code.gson:gson:2.10.1")
|
|
||||||
dynamic("org.ow2.asm:asm:9.8")
|
slim("commons-io:commons-io:2.13.0")
|
||||||
dynamic("bsf:bsf:2.4.0")
|
slim("commons-lang:commons-lang:2.6")
|
||||||
dynamic("rhino:js:1.7R2")
|
slim("com.github.oshi:oshi-core:6.6.5")
|
||||||
dynamic("com.github.ben-manes.caffeine:caffeine:3.0.6")
|
slim("org.lz4:lz4-java:1.8.0")
|
||||||
dynamic("org.apache.commons:commons-lang3:3.12.0")
|
slim("it.unimi.dsi:fastutil:8.5.8")
|
||||||
dynamic("net.bytebuddy:byte-buddy:1.17.5")
|
slim("com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2")
|
||||||
dynamic("net.bytebuddy:byte-buddy-agent:1.17.5")
|
slim("org.zeroturnaround:zt-zip:1.14")
|
||||||
|
slim("com.google.code.gson:gson:2.10.1")
|
||||||
|
slim("org.ow2.asm:asm:9.8")
|
||||||
|
slim("bsf:bsf:2.4.0")
|
||||||
|
slim("rhino:js:1.7R2")
|
||||||
|
slim("com.github.ben-manes.caffeine:caffeine:3.0.6")
|
||||||
|
slim("org.apache.commons:commons-lang3:3.12.0")
|
||||||
|
slim("net.bytebuddy:byte-buddy:1.17.5")
|
||||||
|
slim("net.bytebuddy:byte-buddy-agent:1.17.5")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@ -95,6 +98,7 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sentry {
|
sentry {
|
||||||
|
autoInstallation.enabled = false
|
||||||
includeSourceContext = true
|
includeSourceContext = true
|
||||||
|
|
||||||
org = "volmit-software"
|
org = "volmit-software"
|
||||||
@ -102,6 +106,20 @@ sentry {
|
|||||||
authToken = findProperty("sentry.auth.token") as String? ?: System.getenv("SENTRY_AUTH_TOKEN")
|
authToken = findProperty("sentry.auth.token") as String? ?: System.getenv("SENTRY_AUTH_TOKEN")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slimJar {
|
||||||
|
mirrors = listOf(Mirror(
|
||||||
|
URI.create("https://maven-central.storage-download.googleapis.com/maven2").toURL(),
|
||||||
|
URI.create("https://repo.maven.apache.org/maven2/").toURL()
|
||||||
|
))
|
||||||
|
|
||||||
|
val libs = "com.volmit.iris.util"
|
||||||
|
relocate("com.dfsek.paralithic", "$libs.paralithic")
|
||||||
|
relocate("io.papermc.lib", "$libs.paper")
|
||||||
|
relocate("net.kyori", "$libs.kyori")
|
||||||
|
relocate("org.bstats", "$libs.metrics")
|
||||||
|
relocate("io.sentry", "$libs.sentry")
|
||||||
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
/**
|
/**
|
||||||
* We need parameter meta for the decree command system
|
* We need parameter meta for the decree command system
|
||||||
@ -120,8 +138,6 @@ tasks {
|
|||||||
"version" to rootProject.version,
|
"version" to rootProject.version,
|
||||||
"apiVersion" to apiVersion,
|
"apiVersion" to apiVersion,
|
||||||
"main" to main,
|
"main" to main,
|
||||||
"loader" to loader,
|
|
||||||
"libraries" to dynamic.allDependencies.map { "\n - $it" }.sorted().joinToString("")
|
|
||||||
)
|
)
|
||||||
filesMatching("**/plugin.yml") {
|
filesMatching("**/plugin.yml") {
|
||||||
expand(inputs.properties)
|
expand(inputs.properties)
|
||||||
@ -130,17 +146,7 @@ tasks {
|
|||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
relocate("com.dfsek.paralithic", "com.volmit.iris.util.paralithic")
|
|
||||||
relocate("io.papermc.lib", "com.volmit.iris.util.paper")
|
|
||||||
relocate("net.kyori", "com.volmit.iris.util.kyori")
|
|
||||||
relocate("org.bstats", "com.volmit.iris.util.metrics")
|
|
||||||
relocate("io.sentry", "com.volmit.iris.util.sentry")
|
|
||||||
|
|
||||||
//minimize()
|
//minimize()
|
||||||
dependencies {
|
|
||||||
exclude(dependency("org.ow2.asm:asm:"))
|
|
||||||
exclude(dependency("org.jetbrains:"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
dependencies {
|
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package com.volmit.iris;
|
|
||||||
|
|
||||||
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
|
|
||||||
import io.papermc.paper.plugin.loader.PluginLoader;
|
|
||||||
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
|
||||||
import org.eclipse.aether.graph.Dependency;
|
|
||||||
import org.eclipse.aether.repository.RemoteRepository;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public class IrisPluginLoader implements PluginLoader {
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
@Override
|
|
||||||
public void classloader(@NotNull PluginClasspathBuilder builder) {
|
|
||||||
var pluginUri = URI.create("jar:file:" + builder.getContext().getPluginSource().toAbsolutePath() + "!/plugin.yml");
|
|
||||||
var plugin = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(pluginUri.toURL().openStream())));
|
|
||||||
var repository = "https://maven-central.storage-download.googleapis.com/maven2";
|
|
||||||
|
|
||||||
try {
|
|
||||||
var field = MavenLibraryResolver.class.getDeclaredField("MAVEN_CENTRAL_DEFAULT_MIRROR");
|
|
||||||
repository = (String) field.get(null);
|
|
||||||
} catch (Throwable e) {}
|
|
||||||
|
|
||||||
var resolver = new MavenLibraryResolver();
|
|
||||||
resolver.addRepository(new RemoteRepository.Builder("central", "default", repository).build());
|
|
||||||
plugin.getStringList("libraries").forEach(library -> resolver.addDependency(new Dependency(new DefaultArtifact(library), null)));
|
|
||||||
builder.addLibrary(resolver);
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,7 +30,6 @@ import com.volmit.iris.core.loader.IrisData;
|
|||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
import com.volmit.iris.core.nms.v1X.NMSBinding1X;
|
||||||
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
||||||
import com.volmit.iris.core.safeguard.ServerBootSFG;
|
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.engine.EnginePanic;
|
import com.volmit.iris.engine.EnginePanic;
|
||||||
@ -39,11 +38,9 @@ import com.volmit.iris.engine.object.IrisDimension;
|
|||||||
import com.volmit.iris.engine.object.IrisWorld;
|
import com.volmit.iris.engine.object.IrisWorld;
|
||||||
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||||
import com.volmit.iris.core.safeguard.IrisSafeguard;
|
import com.volmit.iris.core.safeguard.IrisSafeguard;
|
||||||
import com.volmit.iris.core.safeguard.UtilsSFG;
|
|
||||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.context.IrisContext;
|
|
||||||
import com.volmit.iris.util.exceptions.IrisException;
|
import com.volmit.iris.util.exceptions.IrisException;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
@ -52,30 +49,19 @@ import com.volmit.iris.util.io.FileWatcher;
|
|||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.io.InstanceState;
|
import com.volmit.iris.util.io.InstanceState;
|
||||||
import com.volmit.iris.util.io.JarScanner;
|
import com.volmit.iris.util.io.JarScanner;
|
||||||
import com.volmit.iris.util.json.JSONException;
|
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.misc.Bindings;
|
||||||
import com.volmit.iris.util.misc.getHardware;
|
import com.volmit.iris.util.misc.getHardware;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
import com.volmit.iris.util.plugin.IrisService;
|
||||||
import com.volmit.iris.util.plugin.VolmitPlugin;
|
import com.volmit.iris.util.plugin.VolmitPlugin;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.reflect.ShadeFix;
|
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.Queue;
|
import com.volmit.iris.util.scheduling.Queue;
|
||||||
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
||||||
import com.volmit.iris.util.sentry.Attachments;
|
import io.github.slimjar.app.builder.ApplicationBuilder;
|
||||||
import com.volmit.iris.util.sentry.IrisLogger;
|
|
||||||
import com.volmit.iris.util.sentry.ServerID;
|
|
||||||
import io.papermc.lib.PaperLib;
|
|
||||||
import io.sentry.Sentry;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
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.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -91,17 +77,13 @@ import org.bukkit.plugin.IllegalPluginAccessException;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import oshi.SystemInfo;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.NumberFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static com.volmit.iris.core.safeguard.IrisSafeguard.*;
|
import static com.volmit.iris.core.safeguard.IrisSafeguard.*;
|
||||||
import static com.volmit.iris.core.safeguard.ServerBootSFG.passedserversoftware;
|
import static com.volmit.iris.core.safeguard.ServerBootSFG.passedserversoftware;
|
||||||
@ -111,7 +93,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
|
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
|
||||||
|
|
||||||
public static Iris instance;
|
public static Iris instance;
|
||||||
public static BukkitAudiences audiences;
|
public static Bindings.Adventure audiences;
|
||||||
public static MultiverseCoreLink linkMultiverseCore;
|
public static MultiverseCoreLink linkMultiverseCore;
|
||||||
public static MythicMobsLink linkMythicMobs;
|
public static MythicMobsLink linkMythicMobs;
|
||||||
public static IrisCompat compat;
|
public static IrisCompat compat;
|
||||||
@ -120,7 +102,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
fixShading();
|
|
||||||
InstanceState.updateInstanceId();
|
InstanceState.updateInstanceId();
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
|
|
||||||
@ -397,7 +378,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void reportError(Throwable e) {
|
public static void reportError(Throwable e) {
|
||||||
Sentry.captureException(e);
|
Bindings.capture(e);
|
||||||
if (IrisSettings.get().getGeneral().isDebug()) {
|
if (IrisSettings.get().getGeneral().isDebug()) {
|
||||||
String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber();
|
String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber();
|
||||||
|
|
||||||
@ -455,14 +436,21 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
EnginePanic.add(s, v);
|
EnginePanic.add(s, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fixShading() {
|
public Iris() {
|
||||||
ShadeFix.fix(ComponentSerializer.class);
|
ApplicationBuilder.appending("Iris")
|
||||||
|
.downloadDirectoryPath(getDataFolder("cache", "libraries").toPath())
|
||||||
|
.logger((message, args) -> {
|
||||||
|
if (!message.startsWith("Loaded library ")) return;
|
||||||
|
getLogger().info(message.formatted(args));
|
||||||
|
})
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enable() {
|
private void enable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
services = new KMap<>();
|
services = new KMap<>();
|
||||||
setupAudience();
|
setupAudience();
|
||||||
setupSentry();
|
Bindings.setupSentry();
|
||||||
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
|
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
|
||||||
IO.delete(new File("iris"));
|
IO.delete(new File("iris"));
|
||||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||||
@ -476,7 +464,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
services.values().forEach(IrisService::onEnable);
|
services.values().forEach(IrisService::onEnable);
|
||||||
services.values().forEach(this::registerListener);
|
services.values().forEach(this::registerListener);
|
||||||
J.s(() -> {
|
J.s(() -> {
|
||||||
J.a(() -> PaperLib.suggestPaper(this));
|
J.a(IrisSafeguard::suggestPaper);
|
||||||
J.a(() -> IO.delete(getTemp()));
|
J.a(() -> IO.delete(getTemp()));
|
||||||
J.a(LazyPregenerator::loadLazyGenerators, 100);
|
J.a(LazyPregenerator::loadLazyGenerators, 100);
|
||||||
J.a(this::bstats);
|
J.a(this::bstats);
|
||||||
@ -556,7 +544,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
|
|
||||||
private void setupAudience() {
|
private void setupAudience() {
|
||||||
try {
|
try {
|
||||||
audiences = BukkitAudiences.create(this);
|
audiences = new Bindings.Adventure(this);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
IrisSettings.get().getGeneral().setUseConsoleCustomColors(false);
|
IrisSettings.get().getGeneral().setUseConsoleCustomColors(false);
|
||||||
@ -689,50 +677,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
|
|
||||||
private void bstats() {
|
private void bstats() {
|
||||||
if (IrisSettings.get().getGeneral().isPluginMetrics()) {
|
if (IrisSettings.get().getGeneral().isPluginMetrics()) {
|
||||||
J.s(() -> {
|
Bindings.setupBstats(this);
|
||||||
var metrics = new Metrics(Iris.instance, 24220);
|
|
||||||
metrics.addCustomChart(new SingleLineChart("custom_dimensions", () -> Bukkit.getWorlds()
|
|
||||||
.stream()
|
|
||||||
.filter(IrisToolbelt::isIrisWorld)
|
|
||||||
.mapToInt(w -> 1)
|
|
||||||
.sum()));
|
|
||||||
|
|
||||||
metrics.addCustomChart(new DrilldownPie("used_packs", () -> Bukkit.getWorlds().stream()
|
|
||||||
.map(IrisToolbelt::access)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(PlatformChunkGenerator::getEngine)
|
|
||||||
.collect(Collectors.toMap(engine -> engine.getDimension().getLoadKey(), engine -> {
|
|
||||||
var hash32 = engine.getHash32().getNow(null);
|
|
||||||
if (hash32 == null) return Map.of();
|
|
||||||
int version = engine.getDimension().getVersion();
|
|
||||||
String checksum = Long.toHexString(hash32);
|
|
||||||
|
|
||||||
return Map.of("v" + version + " (" + checksum + ")", 1);
|
|
||||||
}, (a, b) -> {
|
|
||||||
Map<String, Integer> merged = new HashMap<>(a);
|
|
||||||
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));
|
|
||||||
}));
|
|
||||||
|
|
||||||
postShutdown.add(metrics::shutdown);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,43 +882,4 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean suppress(Throwable e) {
|
|
||||||
return (e instanceof IllegalStateException ex && "zip file closed".equals(ex.getMessage())) || e instanceof JSONException;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setupSentry() {
|
|
||||||
var settings = IrisSettings.get().getSentry();
|
|
||||||
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);
|
|
||||||
Sentry.init(options -> {
|
|
||||||
options.setDsn("https://b16ecc222e9c1e0c48faecacb906fd89@o4509451052646400.ingest.de.sentry.io/4509452722765904");
|
|
||||||
if (settings.debug) {
|
|
||||||
options.setLogger(new IrisLogger());
|
|
||||||
options.setDebug(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.setAttachServerName(false);
|
|
||||||
options.setEnableUncaughtExceptionHandler(false);
|
|
||||||
options.setRelease(Iris.instance.getDescription().getVersion());
|
|
||||||
options.setBeforeSend((event, hint) -> {
|
|
||||||
if (suppress(event.getThrowable())) return null;
|
|
||||||
event.setTag("iris.safeguard", IrisSafeguard.mode());
|
|
||||||
event.setTag("iris.nms", INMS.get().getClass().getCanonicalName());
|
|
||||||
var context = IrisContext.get();
|
|
||||||
if (context != null) event.getContexts().set("engine", context.asContext());
|
|
||||||
event.getContexts().set("safeguard", IrisSafeguard.asContext());
|
|
||||||
return event;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Sentry.configureScope(scope -> {
|
|
||||||
if (settings.includeServerId) scope.setUser(ServerID.asUser());
|
|
||||||
scope.addAttachment(Attachments.PLUGINS);
|
|
||||||
scope.setTag("server", Bukkit.getVersion());
|
|
||||||
scope.setTag("server.type", Bukkit.getName());
|
|
||||||
scope.setTag("server.api", Bukkit.getBukkitVersion());
|
|
||||||
});
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(Sentry::close));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ -38,6 +39,10 @@ public class IrisSafeguard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void suggestPaper() {
|
||||||
|
PaperLib.suggestPaper(Iris.instance);
|
||||||
|
}
|
||||||
|
|
||||||
public static KMap<String, Object> asContext() {
|
public static KMap<String, Object> asContext() {
|
||||||
KMap<String, Object> m = new KMap<>();
|
KMap<String, Object> m = new KMap<>();
|
||||||
m.put("diskSpace", !ServerBootSFG.hasEnoughDiskSpace);
|
m.put("diskSpace", !ServerBootSFG.hasEnoughDiskSpace);
|
||||||
|
146
core/src/main/java/com/volmit/iris/util/misc/Bindings.java
Normal file
146
core/src/main/java/com/volmit/iris/util/misc/Bindings.java
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
package com.volmit.iris.util.misc;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
|
import com.volmit.iris.core.nms.INMS;
|
||||||
|
import com.volmit.iris.core.safeguard.IrisSafeguard;
|
||||||
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
|
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||||
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
|
import com.volmit.iris.util.json.JSONException;
|
||||||
|
import com.volmit.iris.util.reflect.ShadeFix;
|
||||||
|
import com.volmit.iris.util.scheduling.J;
|
||||||
|
import com.volmit.iris.util.sentry.Attachments;
|
||||||
|
import com.volmit.iris.util.sentry.IrisLogger;
|
||||||
|
import com.volmit.iris.util.sentry.ServerID;
|
||||||
|
import io.sentry.Sentry;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
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.entity.Player;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class Bindings {
|
||||||
|
|
||||||
|
public static void capture(Throwable throwable) {
|
||||||
|
Sentry.captureException(throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupSentry() {
|
||||||
|
var settings = IrisSettings.get().getSentry();
|
||||||
|
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);
|
||||||
|
Sentry.init(options -> {
|
||||||
|
options.setDsn("https://b16ecc222e9c1e0c48faecacb906fd89@o4509451052646400.ingest.de.sentry.io/4509452722765904");
|
||||||
|
if (settings.debug) {
|
||||||
|
options.setLogger(new IrisLogger());
|
||||||
|
options.setDebug(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
options.setAttachServerName(false);
|
||||||
|
options.setEnableUncaughtExceptionHandler(false);
|
||||||
|
options.setRelease(Iris.instance.getDescription().getVersion());
|
||||||
|
options.setBeforeSend((event, hint) -> {
|
||||||
|
if (suppress(event.getThrowable())) return null;
|
||||||
|
event.setTag("iris.safeguard", IrisSafeguard.mode());
|
||||||
|
event.setTag("iris.nms", INMS.get().getClass().getCanonicalName());
|
||||||
|
var context = IrisContext.get();
|
||||||
|
if (context != null) event.getContexts().set("engine", context.asContext());
|
||||||
|
event.getContexts().set("safeguard", IrisSafeguard.asContext());
|
||||||
|
return event;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Sentry.configureScope(scope -> {
|
||||||
|
if (settings.includeServerId) scope.setUser(ServerID.asUser());
|
||||||
|
scope.addAttachment(Attachments.PLUGINS);
|
||||||
|
scope.setTag("server", Bukkit.getVersion());
|
||||||
|
scope.setTag("server.type", Bukkit.getName());
|
||||||
|
scope.setTag("server.api", Bukkit.getBukkitVersion());
|
||||||
|
});
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(Sentry::close));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean suppress(Throwable e) {
|
||||||
|
return (e instanceof IllegalStateException ex && "zip file closed".equals(ex.getMessage())) || e instanceof JSONException;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setupBstats(Iris plugin) {
|
||||||
|
J.s(() -> {
|
||||||
|
var metrics = new Metrics(plugin, 24220);
|
||||||
|
metrics.addCustomChart(new SingleLineChart("custom_dimensions", () -> Bukkit.getWorlds()
|
||||||
|
.stream()
|
||||||
|
.filter(IrisToolbelt::isIrisWorld)
|
||||||
|
.mapToInt(w -> 1)
|
||||||
|
.sum()));
|
||||||
|
|
||||||
|
metrics.addCustomChart(new DrilldownPie("used_packs", () -> Bukkit.getWorlds().stream()
|
||||||
|
.map(IrisToolbelt::access)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(PlatformChunkGenerator::getEngine)
|
||||||
|
.collect(Collectors.toMap(engine -> engine.getDimension().getLoadKey(), engine -> {
|
||||||
|
var hash32 = engine.getHash32().getNow(null);
|
||||||
|
if (hash32 == null) return Map.of();
|
||||||
|
int version = engine.getDimension().getVersion();
|
||||||
|
String checksum = Long.toHexString(hash32);
|
||||||
|
|
||||||
|
return Map.of("v" + version + " (" + checksum + ")", 1);
|
||||||
|
}, (a, b) -> {
|
||||||
|
Map<String, Integer> merged = new HashMap<>(a);
|
||||||
|
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));
|
||||||
|
}));
|
||||||
|
|
||||||
|
plugin.postShutdown(metrics::shutdown);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Adventure {
|
||||||
|
private final BukkitAudiences audiences;
|
||||||
|
|
||||||
|
public Adventure(Iris plugin) {
|
||||||
|
ShadeFix.fix(ComponentSerializer.class);
|
||||||
|
this.audiences = BukkitAudiences.create(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Audience player(Player player) {
|
||||||
|
return audiences.player(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Audience sender(CommandSender sender) {
|
||||||
|
return audiences.sender(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,12 +5,7 @@ load: STARTUP
|
|||||||
authors: [ cyberpwn, NextdoorPsycho, Vatuu ]
|
authors: [ cyberpwn, NextdoorPsycho, Vatuu ]
|
||||||
website: volmit.com
|
website: volmit.com
|
||||||
description: More than a Dimension!
|
description: More than a Dimension!
|
||||||
libraries: ${libraries}
|
|
||||||
commands:
|
commands:
|
||||||
iris:
|
iris:
|
||||||
aliases: [ ir, irs ]
|
aliases: [ ir, irs ]
|
||||||
api-version: '${apiVersion}'
|
api-version: '${apiVersion}'
|
||||||
hotload-dependencies: false
|
|
||||||
|
|
||||||
paper-plugin-loader: ${loader}
|
|
||||||
paper-skip-libraries: true
|
|
@ -21,7 +21,7 @@ plugins {
|
|||||||
|
|
||||||
rootProject.name = "Iris"
|
rootProject.name = "Iris"
|
||||||
|
|
||||||
include(":core", ":core:agent", ":core:paper-loader")
|
include(":core", ":core:agent")
|
||||||
include(
|
include(
|
||||||
":nms:v1_21_R5",
|
":nms:v1_21_R5",
|
||||||
":nms:v1_21_R4",
|
":nms:v1_21_R4",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user