mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Updated Upstream (Paper & Pufferfish)
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@e0b3f3f Adventure 4.10.1 Pufferfish Changes: pufferfish-gg/Pufferfish@cc69d6c Update flare pufferfish-gg/Pufferfish@bf3b9b9 Updated Upstream (Paper)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
group = org.purpurmc.purpur
|
||||
version = 1.18.2-R0.1-SNAPSHOT
|
||||
|
||||
paperCommit = c34fb0942a73b932dc182c063e398ed47182fa61
|
||||
paperCommit = e0b3f3f8cbcce581cc3cc3334b09f6165f964270
|
||||
|
||||
org.gradle.caching = true
|
||||
org.gradle.parallel = true
|
||||
|
||||
@@ -19,8 +19,10 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Based on pufferfish-gg/Pufferfish#bf3b9b977dbf387a2bdf2a5930a680630a843fe0
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index b71c38473c3a9fddbb26dcc06df0c1adcdc871f6..20df1ad509f2b5d6204d3ff550af0078a7268537 100644
|
||||
index 01798255d45f2a642df00156f11dd2bcd8108079..9d7bd0f965c7dc3a60246310688aa5f93a4594a4 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -41,6 +41,7 @@ dependencies {
|
||||
|
||||
@@ -19,8 +19,10 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Based on pufferfish-gg/Pufferfish#bf3b9b977dbf387a2bdf2a5930a680630a843fe0
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 4beb35d1e5b013395f5df101e843f41c2ce174ad..ecb65e75d19d2f7b72410c89251e56566b7b6dc0 100644
|
||||
index 4beb35d1e5b013395f5df101e843f41c2ce174ad..5b10c880ac9daa66badf199bddd2653a0f7c0c08 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -18,8 +18,12 @@ repositories {
|
||||
@@ -48,7 +50,7 @@ index 4beb35d1e5b013395f5df101e843f41c2ce174ad..ecb65e75d19d2f7b72410c89251e5656
|
||||
+ exclude(group="org.yaml", module="snakeyaml")
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+ implementation("com.github.technove:Flare:2c4a2114a0") // Pufferfish - flare
|
||||
+ implementation("com.github.technove:Flare:34637f3f87") // Pufferfish - flare
|
||||
+
|
||||
testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
@@ -555,7 +557,7 @@ index 0000000000000000000000000000000000000000..a7f297ebb569f7c1f205e967ca485be7
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishCommand.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e164237e749bcc43466d4ed7aeada5ab9fddf8a6
|
||||
index 0000000000000000000000000000000000000000..020368da69b9a492155f6de6297f74732f4ab6ea
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishCommand.java
|
||||
@@ -0,0 +1,68 @@
|
||||
@@ -583,7 +585,7 @@ index 0000000000000000000000000000000000000000..e164237e749bcc43466d4ed7aeada5ab
|
||||
+ this.usageMessage = "/pufferfish [reload | version]";
|
||||
+ this.setPermission("bukkit.command.pufferfish");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static void init() {
|
||||
+ MinecraftServer.getServer().server.getCommandMap().register("pufferfish", "Pufferfish", new PufferfishCommand());
|
||||
+ }
|
||||
@@ -629,7 +631,7 @@ index 0000000000000000000000000000000000000000..e164237e749bcc43466d4ed7aeada5ab
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b8bd567d0
|
||||
index 0000000000000000000000000000000000000000..56330536c52fa327ef89d7a08e72557c6633c8bb
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
|
||||
@@ -0,0 +1,291 @@
|
||||
@@ -665,10 +667,10 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+import java.util.Collections;
|
||||
+
|
||||
+public class PufferfishConfig {
|
||||
+
|
||||
+
|
||||
+ private static final YamlFile config = new YamlFile();
|
||||
+ private static int updates = 0;
|
||||
+
|
||||
+
|
||||
+ private static ConfigurationSection convertToBukkit(org.simpleyaml.configuration.ConfigurationSection section) {
|
||||
+ ConfigurationSection newSection = new MemoryConfiguration();
|
||||
+ for (String key : section.getKeys(false)) {
|
||||
@@ -680,18 +682,18 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ }
|
||||
+ return newSection;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static ConfigurationSection getConfigCopy() {
|
||||
+ return convertToBukkit(config);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static int getUpdates() {
|
||||
+ return updates;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static void load() throws IOException {
|
||||
+ File configFile = new File("pufferfish.yml");
|
||||
+
|
||||
+
|
||||
+ if (configFile.exists()) {
|
||||
+ try {
|
||||
+ config.load(configFile);
|
||||
@@ -699,14 +701,14 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ throw new IOException(e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ getString("info.version", "1.0");
|
||||
+ setComment("info",
|
||||
+ "Pufferfish Configuration",
|
||||
+ "Check out Pufferfish Host for maximum performance server hosting: https://pufferfish.host",
|
||||
+ "Join our Discord for support: https://discord.gg/reZw4vQV9H",
|
||||
+ "Download new builds at https://ci.pufferfish.host/job/Pufferfish");
|
||||
+
|
||||
+
|
||||
+ for (Method method : PufferfishConfig.class.getDeclaredMethods()) {
|
||||
+ if (Modifier.isStatic(method.getModifiers()) && Modifier.isPrivate(method.getModifiers()) && method.getParameterCount() == 0 &&
|
||||
+ method.getReturnType() == Void.TYPE && !method.getName().startsWith("lambda")) {
|
||||
@@ -718,17 +720,17 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ updates++;
|
||||
+
|
||||
+
|
||||
+ config.save(configFile);
|
||||
+
|
||||
+
|
||||
+ // Attempt to detect vectorization
|
||||
+ try {
|
||||
+ SIMDDetection.isEnabled = SIMDDetection.canEnable();
|
||||
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17;
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {}
|
||||
+
|
||||
+
|
||||
+ if (SIMDDetection.isEnabled) {
|
||||
+ PufferfishLogger.LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
|
||||
+ } else if (SIMDDetection.versionLimited) {
|
||||
@@ -738,76 +740,76 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ PufferfishLogger.LOGGER.warning("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static void setComment(String key, String... comment) {
|
||||
+ if (config.contains(key)) {
|
||||
+ config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static void ensureDefault(String key, Object defaultValue, String... comment) {
|
||||
+ if (!config.contains(key)) {
|
||||
+ config.set(key, defaultValue);
|
||||
+ config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static boolean getBoolean(String key, boolean defaultValue, String... comment) {
|
||||
+ return getBoolean(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static boolean getBoolean(String key, @Nullable String oldKey, boolean defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getBoolean(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static int getInt(String key, int defaultValue, String... comment) {
|
||||
+ return getInt(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static int getInt(String key, @Nullable String oldKey, int defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getInt(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static double getDouble(String key, double defaultValue, String... comment) {
|
||||
+ return getDouble(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static double getDouble(String key, @Nullable String oldKey, double defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getDouble(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static String getString(String key, String defaultValue, String... comment) {
|
||||
+ return getOldString(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static String getOldString(String key, @Nullable String oldKey, String defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getString(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static List<String> getStringList(String key, List<String> defaultValue, String... comment) {
|
||||
+ return getStringList(key, null, defaultValue, comment);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static List<String> getStringList(String key, @Nullable String oldKey, List<String> defaultValue, String... comment) {
|
||||
+ ensureDefault(key, defaultValue, comment);
|
||||
+ return config.getStringList(key);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static String sentryDsn;
|
||||
+ private static void sentry() {
|
||||
+ String sentryEnvironment = System.getenv("SENTRY_DSN");
|
||||
+ String sentryConfig = getString("sentry-dsn", "", "Sentry DSN for improved error logging, leave blank to disable", "Obtain from https://sentry.io/");
|
||||
+
|
||||
+
|
||||
+ sentryDsn = sentryEnvironment == null ? sentryConfig : sentryEnvironment;
|
||||
+ if (sentryDsn != null && !sentryDsn.isBlank()) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryManager.init();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean enableBooks;
|
||||
+ private static void books() {
|
||||
+ enableBooks = getBoolean("enable-books", true,
|
||||
@@ -816,7 +818,7 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ "disabling this option.",
|
||||
+ "This can be overridden per-player with the permission pufferfish.usebooks");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean enableSuffocationOptimization;
|
||||
+ private static void suffocationOptimization() {
|
||||
+ enableSuffocationOptimization = getBoolean("enable-suffocation-optimization", true,
|
||||
@@ -825,7 +827,7 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ "be left enabled on most servers, but is provided as a",
|
||||
+ "configuration option if the vanilla deviation is undesirable.");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean enableAsyncMobSpawning;
|
||||
+ public static boolean asyncMobSpawningInitialized;
|
||||
+ private static void asyncMobSpawning() {
|
||||
@@ -835,14 +837,14 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+ "paper's per-player-mob-spawns setting set to true for this to work.",
|
||||
+ "One quick note - this does not actually spawn mobs async (that would be very unsafe).",
|
||||
+ "This just offloads some expensive calculations that are required for mob spawning.");
|
||||
+
|
||||
+
|
||||
+ // This prevents us from changing the value during a reload.
|
||||
+ if (!asyncMobSpawningInitialized) {
|
||||
+ asyncMobSpawningInitialized = true;
|
||||
+ enableAsyncMobSpawning = temp;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static int maxProjectileLoadsPerTick;
|
||||
+ public static int maxProjectileLoadsPerProjectile;
|
||||
+ private static void projectileLoading() {
|
||||
@@ -884,7 +886,7 @@ index 0000000000000000000000000000000000000000..cd03fed32807fd943fdeee8571c1648b
|
||||
+
|
||||
+ setComment("dab", "Optimizes entity brains when", "they're far away from the player");
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static boolean throttleInactiveGoalSelectorTick;
|
||||
+ private static void inactiveGoalSelectorThrottle() {
|
||||
+ getBoolean("inactive-goal-selector-throttle", "inactive-goal-selector-disable", true,
|
||||
@@ -948,7 +950,7 @@ index 0000000000000000000000000000000000000000..53f2df00c6809618a9ee3d2ea72e85e8
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684d291c628
|
||||
index 0000000000000000000000000000000000000000..adafc4fd661cf080b004b86c3eaed231a0133101
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishVersionFetcher.java
|
||||
@@ -0,0 +1,136 @@
|
||||
@@ -980,46 +982,46 @@ index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class PufferfishVersionFetcher implements VersionFetcher {
|
||||
+
|
||||
+
|
||||
+ private static final Logger LOGGER = Logger.getLogger("PufferfishVersionFetcher");
|
||||
+ private static final HttpClient client = HttpClient.newHttpClient();
|
||||
+
|
||||
+
|
||||
+ private static final URI JENKINS_URI = URI.create("https://ci.pufferfish.host/job/Pufferfish-1.18/lastSuccessfulBuild/buildNumber");
|
||||
+ private static final String GITHUB_FORMAT = "https://api.github.com/repos/pufferfish-gg/Pufferfish/compare/ver/1.18...%s";
|
||||
+
|
||||
+
|
||||
+ private static final HttpResponse.BodyHandler<JsonObject> JSON_OBJECT_BODY_HANDLER = responseInfo -> HttpResponse.BodySubscribers
|
||||
+ .mapping(
|
||||
+ HttpResponse.BodySubscribers.ofString(StandardCharsets.UTF_8),
|
||||
+ string -> new Gson().fromJson(string, JsonObject.class)
|
||||
+ );
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public long getCacheTime() {
|
||||
+ return TimeUnit.MINUTES.toMillis(30);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Component getVersionMessage(final @NotNull String serverVersion) {
|
||||
+ final String[] parts = CraftServer.class.getPackage().getImplementationVersion().split("-");
|
||||
+ @NotNull Component component;
|
||||
+
|
||||
+
|
||||
+ if (parts.length != 3) {
|
||||
+ component = text("Unknown server version.", RED);
|
||||
+ } else {
|
||||
+ final String versionString = parts[2];
|
||||
+
|
||||
+
|
||||
+ try {
|
||||
+ component = this.fetchJenkinsVersion(Integer.parseInt(versionString));
|
||||
+ } catch (NumberFormatException e) {
|
||||
+ component = this.fetchGithubVersion(versionString.substring(1, versionString.length() - 1));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final @Nullable Component history = this.getHistory();
|
||||
+ return history != null ? Component
|
||||
+ .join(JoinConfiguration.noSeparators(), component, Component.newline(), this.getHistory()) : component;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private @NotNull Component fetchJenkinsVersion(final int versionNumber) {
|
||||
+ final HttpRequest request = HttpRequest.newBuilder(JENKINS_URI).build();
|
||||
+ try {
|
||||
@@ -1027,7 +1029,7 @@ index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684
|
||||
+ if (response.statusCode() != 200) {
|
||||
+ return text("Received invalid status code (" + response.statusCode() + ") from server.", RED);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ int latestVersionNumber;
|
||||
+ try {
|
||||
+ latestVersionNumber = Integer.parseInt(response.body());
|
||||
@@ -1035,7 +1037,7 @@ index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684
|
||||
+ LOGGER.log(Level.WARNING, "Received invalid response from Jenkins \"" + response.body() + "\".");
|
||||
+ return text("Received invalid response from server.", RED);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final int versionDiff = latestVersionNumber - versionNumber;
|
||||
+ return this.getResponseMessage(versionDiff);
|
||||
+ } catch (IOException | InterruptedException e) {
|
||||
@@ -1043,7 +1045,7 @@ index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684
|
||||
+ return text("Failed to retrieve version from server.", RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ // Based off code contributed by Techcable <Techcable@outlook.com> in Paper/GH-65
|
||||
+ private @NotNull Component fetchGithubVersion(final @NotNull String hash) {
|
||||
+ final URI uri = URI.create(String.format(GITHUB_FORMAT, hash));
|
||||
@@ -1053,17 +1055,17 @@ index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684
|
||||
+ if (response.statusCode() != 200) {
|
||||
+ return text("Received invalid status code (" + response.statusCode() + ") from server.", RED);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final JsonObject obj = response.body();
|
||||
+ final int versionDiff = obj.get("behind_by").getAsInt();
|
||||
+
|
||||
+
|
||||
+ return this.getResponseMessage(versionDiff);
|
||||
+ } catch (IOException | InterruptedException e) {
|
||||
+ LOGGER.log(Level.WARNING, "Failed to look up version from GitHub", e);
|
||||
+ return text("Failed to retrieve version from server.", RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private @NotNull Component getResponseMessage(final int versionDiff) {
|
||||
+ return switch (Math.max(-1, Math.min(1, versionDiff))) {
|
||||
+ case -1 -> text("You are running an unsupported version of Pufferfish.", RED);
|
||||
@@ -1073,18 +1075,18 @@ index 0000000000000000000000000000000000000000..461022af9ad85fe00329678f0f61d684
|
||||
+ RED);
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private @Nullable Component getHistory() {
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ if (data == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final String oldVersion = data.getOldVersion();
|
||||
+ if (oldVersion == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ }
|
||||
+}
|
||||
@@ -1784,7 +1786,7 @@ index 0000000000000000000000000000000000000000..db15d3fbe2b65fc8035573f5fdbea382
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff43e003fa8
|
||||
index 0000000000000000000000000000000000000000..731ef11c7a025ae95ed8a757b530d834733d0621
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/PufferfishSentryAppender.java
|
||||
@@ -0,0 +1,135 @@
|
||||
@@ -1808,14 +1810,14 @@ index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff4
|
||||
+import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||
+
|
||||
+public class PufferfishSentryAppender extends AbstractAppender {
|
||||
+
|
||||
+
|
||||
+ private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(PufferfishSentryAppender.class);
|
||||
+ private static final Gson GSON = new Gson();
|
||||
+
|
||||
+
|
||||
+ public PufferfishSentryAppender() {
|
||||
+ super("PufferfishSentryAdapter", new SentryFilter(), null);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public void append(LogEvent logEvent) {
|
||||
+ if (logEvent.getThrown() != null && logEvent.getLevel().isMoreSpecificThan(Level.WARN)) {
|
||||
@@ -1832,55 +1834,55 @@ index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff4
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private void logException(LogEvent e) {
|
||||
+ SentryEvent event = new SentryEvent(e.getThrown());
|
||||
+
|
||||
+
|
||||
+ Message sentryMessage = new Message();
|
||||
+ sentryMessage.setMessage(e.getMessage().getFormattedMessage());
|
||||
+
|
||||
+
|
||||
+ event.setThrowable(e.getThrown());
|
||||
+ event.setLevel(getLevel(e.getLevel()));
|
||||
+ event.setLogger(e.getLoggerName());
|
||||
+ event.setTransaction(e.getLoggerName());
|
||||
+ event.setExtra("thread_name", e.getThreadName());
|
||||
+
|
||||
+
|
||||
+ boolean hasContext = e.getContextData() != null;
|
||||
+
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_playerid")) {
|
||||
+ User user = new User();
|
||||
+ user.setId(e.getContextData().getValue("pufferfishsentry_playerid"));
|
||||
+ user.setUsername(e.getContextData().getValue("pufferfishsentry_playername"));
|
||||
+ event.setUser(user);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_pluginname")) {
|
||||
+ event.setExtra("plugin.name", e.getContextData().getValue("pufferfishsentry_pluginname"));
|
||||
+ event.setExtra("plugin.version", e.getContextData().getValue("pufferfishsentry_pluginversion"));
|
||||
+ event.setTransaction(e.getContextData().getValue("pufferfishsentry_pluginname"));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (hasContext && e.getContextData().containsKey("pufferfishsentry_eventdata")) {
|
||||
+ Map<String, String> eventFields = GSON.fromJson((String) e.getContextData().getValue("pufferfishsentry_eventdata"), new TypeToken<Map<String, String>>() {}.getType());
|
||||
+ if (eventFields != null) {
|
||||
+ event.setExtra("event", eventFields);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ Sentry.captureEvent(event);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private void logBreadcrumb(LogEvent e) {
|
||||
+ Breadcrumb breadcrumb = new Breadcrumb();
|
||||
+
|
||||
+
|
||||
+ breadcrumb.setLevel(getLevel(e.getLevel()));
|
||||
+ breadcrumb.setCategory(e.getLoggerName());
|
||||
+ breadcrumb.setType(e.getLoggerName());
|
||||
+ breadcrumb.setMessage(e.getMessage().getFormattedMessage());
|
||||
+
|
||||
+
|
||||
+ Sentry.addBreadcrumb(breadcrumb);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private SentryLevel getLevel(Level level) {
|
||||
+ switch (level.getStandardLevel()) {
|
||||
+ case TRACE:
|
||||
@@ -1897,35 +1899,35 @@ index 0000000000000000000000000000000000000000..d04a8a4336566dbe6e1b9ec0d574cff4
|
||||
+ return SentryLevel.INFO;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static class SentryFilter extends AbstractFilter {
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(Logger logger, org.apache.logging.log4j.Level level, Marker marker, String msg,
|
||||
+ Object... params) {
|
||||
+ return this.filter(logger.getName());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(Logger logger, org.apache.logging.log4j.Level level, Marker marker, Object msg, Throwable t) {
|
||||
+ return this.filter(logger.getName());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public Result filter(LogEvent event) {
|
||||
+ return this.filter(event == null ? null : event.getLoggerName());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private Result filter(String loggerName) {
|
||||
+ return loggerName != null && loggerName.startsWith("gg.castaway.pufferfish.sentry") ? Result.DENY
|
||||
+ : Result.NEUTRAL;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b011abbeb80b42de6be3785e47c7ba3c0f6dc161
|
||||
index 0000000000000000000000000000000000000000..1b29210ad0bbb4ada150f23357f0c80d331c996d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryManager.java
|
||||
@@ -0,0 +1,40 @@
|
||||
@@ -1937,27 +1939,27 @@ index 0000000000000000000000000000000000000000..b011abbeb80b42de6be3785e47c7ba3c
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
+public class SentryManager {
|
||||
+
|
||||
+
|
||||
+ private static final Logger logger = LogManager.getLogger(SentryManager.class);
|
||||
+
|
||||
+
|
||||
+ private SentryManager() {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static boolean initialized = false;
|
||||
+
|
||||
+
|
||||
+ public static synchronized void init() {
|
||||
+ if (initialized) {
|
||||
+ return;
|
||||
+ }
|
||||
+ try {
|
||||
+ initialized = true;
|
||||
+
|
||||
+
|
||||
+ Sentry.init(options -> {
|
||||
+ options.setDsn(PufferfishConfig.sentryDsn);
|
||||
+ options.setMaxBreadcrumbs(100);
|
||||
+ });
|
||||
+
|
||||
+
|
||||
+ PufferfishSentryAppender appender = new PufferfishSentryAppender();
|
||||
+ appender.start();
|
||||
+ ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addAppender(appender);
|
||||
@@ -1967,11 +1969,11 @@ index 0000000000000000000000000000000000000000..b011abbeb80b42de6be3785e47c7ba3c
|
||||
+ initialized = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/AsyncExecutor.java b/src/main/java/gg/pufferfish/pufferfish/util/AsyncExecutor.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0772fbc77a198b3571b4ed1e8cc85e90ccd6e38a
|
||||
index 0000000000000000000000000000000000000000..9d6dc2c80945bec9bea74714c657c7a2e0bdde9e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/AsyncExecutor.java
|
||||
@@ -0,0 +1,51 @@
|
||||
@@ -1985,29 +1987,29 @@ index 0000000000000000000000000000000000000000..0772fbc77a198b3571b4ed1e8cc85e90
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public class AsyncExecutor implements Runnable {
|
||||
+
|
||||
+
|
||||
+ private Queue<Runnable> jobs = Queues.newConcurrentLinkedQueue();
|
||||
+ private final Thread thread;
|
||||
+ private final BooleanSupplier shouldRun;
|
||||
+ private volatile boolean killswitch = false;
|
||||
+
|
||||
+
|
||||
+ public AsyncExecutor(String threadName, BooleanSupplier shouldRun) {
|
||||
+ this.thread = new Thread(this, threadName);
|
||||
+ this.shouldRun = shouldRun;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void start() {
|
||||
+ thread.start();
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void kill() {
|
||||
+ killswitch = true;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void submit(Runnable runnable) {
|
||||
+ jobs.offer(runnable);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ while (!killswitch) {
|
||||
@@ -2024,11 +2026,11 @@ index 0000000000000000000000000000000000000000..0772fbc77a198b3571b4ed1e8cc85e90
|
||||
+ LockSupport.parkNanos("executing tasks", 1000L);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java b/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a93ee99c2399def1e221260547a3e6bce2d621fa
|
||||
index 0000000000000000000000000000000000000000..fdcb62d12164024a5f354d60cc863821a18d1b2a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/AsyncPlayerAreaMap.java
|
||||
@@ -0,0 +1,31 @@
|
||||
@@ -2040,22 +2042,22 @@ index 0000000000000000000000000000000000000000..a93ee99c2399def1e221260547a3e6bc
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+
|
||||
+public final class AsyncPlayerAreaMap extends PlayerAreaMap {
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap() {
|
||||
+ super();
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets) {
|
||||
+ super(pooledHashSets);
|
||||
+ this.areaMap = new Long2ObjectOpenHashMapWrapper<>(new ConcurrentHashMap<>(1024, 0.7f));
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets, final ChangeCallback<ServerPlayer> addCallback,
|
||||
+ final ChangeCallback<ServerPlayer> removeCallback) {
|
||||
+ this(pooledHashSets, addCallback, removeCallback, null);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public AsyncPlayerAreaMap(final PooledLinkedHashSets<ServerPlayer> pooledHashSets, final ChangeCallback<ServerPlayer> addCallback,
|
||||
+ final ChangeCallback<ServerPlayer> removeCallback, final ChangeSourceCallback<ServerPlayer> changeSourceCallback) {
|
||||
+ super(pooledHashSets, addCallback, removeCallback, changeSourceCallback);
|
||||
@@ -2091,7 +2093,7 @@ index 0000000000000000000000000000000000000000..c1929840254a3e6d721816f4a20415be
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java b/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..42cdc43d6b739973a0944f502089757247ee6c61
|
||||
index 0000000000000000000000000000000000000000..facd55463d44cb7e3d2ca6892982f5497b8dded1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/util/Long2ObjectOpenHashMapWrapper.java
|
||||
@@ -0,0 +1,40 @@
|
||||
@@ -2102,34 +2104,34 @@ index 0000000000000000000000000000000000000000..42cdc43d6b739973a0944f5020897572
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class Long2ObjectOpenHashMapWrapper<V> extends Long2ObjectOpenHashMap<V> {
|
||||
+
|
||||
+
|
||||
+ private final Map<Long, V> backingMap;
|
||||
+
|
||||
+
|
||||
+ public Long2ObjectOpenHashMapWrapper(Map<Long, V> map) {
|
||||
+ backingMap = map;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public V put(Long key, V value) {
|
||||
+ return backingMap.put(key, value);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public V get(Object key) {
|
||||
+ return backingMap.get(key);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public V remove(Object key) {
|
||||
+ return backingMap.remove(key);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Nullable
|
||||
+ @Override
|
||||
+ public V putIfAbsent(Long key, V value) {
|
||||
+ return backingMap.putIfAbsent(key, value);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return backingMap.size();
|
||||
@@ -2149,18 +2151,18 @@ index 7bddc7517356cc74104dcc5c7c55522a53f2596f..d6a57cdad2c92521a800cb18d060d9d6
|
||||
|
||||
public static long getCoordinateKey(final ChunkPos pair) {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 39b7c78b032ed6fc29ac765020d5a38858bf2a3a..f66a255d88ea582b2c831a577dee445b486cc37d 100644
|
||||
index 39b7c78b032ed6fc29ac765020d5a38858bf2a3a..56f437b0e1ad5b167cdcbaaaf83b49d27e37b904 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -311,6 +311,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -310,6 +310,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
public volatile Thread shutdownThread; // Paper
|
||||
public volatile boolean abnormalExit = false; // Paper
|
||||
|
||||
+
|
||||
+ public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning", () -> true); // Pufferfish - optimize mob spawning
|
||||
+
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -1697,7 +1699,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
@@ -2252,19 +2254,19 @@ index edc6235288f0843608dae4552e05915e4067cbf2..d13b53c5497cece27ce06d43401e4f3b
|
||||
return this.scaledRange(i);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 5793154c0deca7fc570bbe858c6bea0d640db941..7b855e53b3730ad82bdef5b5d06baa4e4eee5b42 100644
|
||||
index 5793154c0deca7fc570bbe858c6bea0d640db941..f33ae29fd86fbfb2a94748fbf9515e3b4ae01753 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -75,6 +75,9 @@ public class ServerChunkCache extends ChunkSource {
|
||||
@@ -74,6 +74,9 @@ public class ServerChunkCache extends ChunkSource {
|
||||
final it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<LevelChunk> loadedChunkMap = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(8192, 0.5f);
|
||||
|
||||
private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4];
|
||||
|
||||
+
|
||||
+ public boolean firstRunSpawnCounts = true; // Pufferfish
|
||||
+ public final java.util.concurrent.atomic.AtomicBoolean _pufferfish_spawnCountsReady = new java.util.concurrent.atomic.AtomicBoolean(false); // Pufferfish - optimize countmobs
|
||||
+
|
||||
|
||||
private static int getChunkCacheKey(int x, int z) {
|
||||
return x & 3 | ((z & 3) << 2);
|
||||
}
|
||||
@@ -969,6 +972,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
|
||||
@@ -2320,7 +2322,7 @@ index 5793154c0deca7fc570bbe858c6bea0d640db941..7b855e53b3730ad82bdef5b5d06baa4e
|
||||
}
|
||||
// Paper end - controlled flush for entity tracker packets
|
||||
}
|
||||
+
|
||||
+
|
||||
+ // Pufferfish start - optimize mob spawning
|
||||
+ if (gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning) {
|
||||
+ for (ServerPlayer player : this.level.players) {
|
||||
@@ -2549,7 +2551,7 @@ index 7437f01ca8f416e2c9150250e324af4725a4efb6..7ac51dbfce18a2bc52faa7a915abeccc
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 84fce7dccf9232209f939a32acfc3131e62eb27c..c9c444c119a010112d4176f095eee57f0ac888f9 100644
|
||||
index 84fce7dccf9232209f939a32acfc3131e62eb27c..59ec3d56e88cf6cee218422481457b944ff25998 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -230,7 +230,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
@@ -2569,7 +2571,7 @@ index 84fce7dccf9232209f939a32acfc3131e62eb27c..c9c444c119a010112d4176f095eee57f
|
||||
+ public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // golf score
|
||||
+ public final BlockPos.MutableBlockPos cachedBlockPos = new BlockPos.MutableBlockPos(); // used where needed
|
||||
+ // Pufferfish end
|
||||
+
|
||||
+
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
@@ -3560,14 +3562,14 @@ index 13eded53a64d0f36f8c9bce2077de4f1c1ed2d56..303ad9eab2e0a9b73597ca4ee9d70bea
|
||||
return new BlockPos(i, l, j);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
index 0422d787593cc65aadcae9f7517ec67a52f1f72b..248da8962a460fe41876bbe8670e8909864b40bc 100644
|
||||
index 0422d787593cc65aadcae9f7517ec67a52f1f72b..e3a917480d0fe81d9b6cb24a4cf207c5e66388b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
@@ -37,6 +37,36 @@ import net.minecraft.world.level.material.Fluids;
|
||||
public final class Biome {
|
||||
public static final Codec<Biome> DIRECT_CODEC;
|
||||
public static final Codec<Biome> NETWORK_CODEC;
|
||||
+
|
||||
+
|
||||
+ // Pufferfish start - decompile fixes
|
||||
+ static {
|
||||
+ DIRECT_CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -3596,7 +3598,7 @@ index 0422d787593cc65aadcae9f7517ec67a52f1f72b..248da8962a460fe41876bbe8670e8909
|
||||
+ });
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
+
|
||||
+
|
||||
public static final Codec<Holder<Biome>> CODEC = RegistryFileCodec.create(Registry.BIOME_REGISTRY, DIRECT_CODEC);
|
||||
public static final Codec<HolderSet<Biome>> LIST_CODEC = RegistryCodecs.homogeneousList(Registry.BIOME_REGISTRY, DIRECT_CODEC);
|
||||
private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(1234L)), ImmutableList.of(0));
|
||||
@@ -4174,7 +4176,7 @@ index b1992ed5136cc7dcf04219868b94b3c37ae36b4b..5b5339cba819368f4d6b7eaf404fa59b
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 7343bd96a4a15f4abc081e565175db8df930a470..cc88eb1247bafb65999e1ca5624c87b038b27866 100644
|
||||
index 55c981f2c8070fc1bd9ecd4f4df140d9d0c68319..f266ee28bae60cf938bf2769df71af7ffd3e5bfe 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -248,7 +248,7 @@ import javax.annotation.Nullable; // Paper
|
||||
|
||||
Reference in New Issue
Block a user