Skip to content

Commit

Permalink
Disable Timings if Parallel World Ticking is enabled
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
MrPowerGamerBR committed Nov 23, 2023
1 parent 320fce2 commit 5fe6f9d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-without-pwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Delete Parallel world ticking patch
run: rm patches/server/*-Parallel-world-ticking.patch
run: rm patches/server/*-Parallel-world-ticking.patch patches/api/*-Parallel-world-ticking.patch
- name: Apply Patches
run: ./gradlew -PsparklypaperImplementationVersionSuffix=without-pwt applyPatches
- name: Build
Expand Down
66 changes: 66 additions & 0 deletions patches/api/0001-Parallel-world-ticking.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrPowerGamerBR <[email protected]>
Date: Thu, 23 Nov 2023 12:08:39 -0300
Subject: [PATCH] Parallel world ticking


diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java
index 9812d668ad945aba486fbf6d5bf83c4292cb5d03..c82b9188c79a0671ca9d09d7cd31e63d5a378e9b 100644
--- a/src/main/java/co/aikar/timings/Timings.java
+++ b/src/main/java/co/aikar/timings/Timings.java
@@ -55,6 +55,7 @@ public final class Timings {
private static int historyInterval = -1;
private static int historyLength = -1;
private static boolean warnedAboutDeprecationOnEnable;
+ private static boolean warnedAboutParallelWorldTickingOnEnable; // SparklyPaper - parallel world ticking

private Timings() {}

@@ -145,6 +146,12 @@ public final class Timings {
* @param enabled Should timings be reported
*/
public static void setTimingsEnabled(boolean enabled) {
+ // SparklyPaper - parallel world ticking
+ if (enabled) {
+ warnAboutParallelWorldTickingOnEnable();
+ return;
+ }
+ // SparklyPaper end
timingsEnabled = enabled;
warnAboutDeprecationOnEnable();
reset();
@@ -180,6 +187,34 @@ public final class Timings {
.build();
}

+ // SparklyPaper start - parallel world ticking
+ private static void warnAboutParallelWorldTickingOnEnable() {
+ if (!warnedAboutParallelWorldTickingOnEnable) {
+ Bukkit.getLogger().warning(PlainTextComponentSerializer.plainText().serialize(parallelWorldTickingMessage()));
+ warnedAboutParallelWorldTickingOnEnable = true;
+ }
+ }
+
+ public static Component parallelWorldTickingMessage() {
+ return Component.text()
+ .color(TextColor.color(0xf3ef91))
+ .append(Component.text("[!] The timings profiler attempted to be enabled, but was disabled because timings is not compatible with " + Bukkit.getName() + "'s Parallel World Ticking feature."))
+ .append(Component.newline())
+ .append(
+ Component.text(" We recommend installing the spark profiler as a replacement: ")
+ .append(
+ Component.text()
+ .content("https://spark.lucko.me/")
+ .clickEvent(ClickEvent.openUrl("https://spark.lucko.me/")))
+ )
+ .append(Component.newline())
+ .append(
+ Component.text(" Or, if you really need timings, get a build without the Parallel World Ticking feature")
+ )
+ .build();
+ }
+ // SparklyPaper end
+
/**
* <p>Sets whether or not the Timings should monitor at Verbose level.</p>
*

0 comments on commit 5fe6f9d

Please sign in to comment.