Skip to content

Commit d6cabe1

Browse files
authored
[2.7.0 target] Disable Timings for 1.19.4+ 5917 (#5926)
Disable Timings for 1.19.4+ (#5917) * Disable Timings for 1.19.4+ * Update SkriptConfig.java (cherry picked from commit 7f38b86)
1 parent 2968954 commit d6cabe1

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/main/java/ch/njol/skript/SkriptConfig.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import ch.njol.skript.util.chat.ChatMessages;
4242
import ch.njol.skript.util.chat.LinkParseMode;
4343
import ch.njol.skript.variables.Variables;
44+
import co.aikar.timings.Timings;
4445
import org.bukkit.event.EventPriority;
4546
import org.eclipse.jdt.annotation.Nullable;
4647

@@ -196,15 +197,22 @@ public static String formatDate(final long timestamp) {
196197

197198
public static final Option<Boolean> enableTimings = new Option<>("enable timings", false)
198199
.setter(t -> {
199-
if (Skript.classExists("co.aikar.timings.Timings")) { // Check for Paper server
200-
if (t)
201-
Skript.info("Timings support enabled!");
202-
SkriptTimings.setEnabled(t); // Config option will be used
203-
} else { // Not running Paper
200+
if (!Skript.classExists("co.aikar.timings.Timings")) { // Check for Timings
204201
if (t) // Warn the server admin that timings won't work
205202
Skript.warning("Timings cannot be enabled! You are running Bukkit/Spigot, but Paper is required.");
206203
SkriptTimings.setEnabled(false); // Just to be sure, deactivate timings support completely
204+
return;
207205
}
206+
if (Timings.class.isAnnotationPresent(Deprecated.class)) { // check for deprecated Timings
207+
if (t) // Warn the server admin that timings won't work
208+
Skript.warning("Timings cannot be enabled! Paper no longer supports Timings as of 1.19.4.");
209+
SkriptTimings.setEnabled(false); // Just to be sure, deactivate timings support completely
210+
return;
211+
}
212+
// If we get here, we can safely enable timings
213+
if (t)
214+
Skript.info("Timings support enabled!");
215+
SkriptTimings.setEnabled(t); // Config option will be used
208216
});
209217

210218
public static final Option<String> parseLinks = new Option<>("parse links in chat messages", "disabled")

src/main/resources/config.sk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ soft api exceptions: false
159159

160160
enable timings: false
161161
# When enabled, triggers in scripts will be present in timings reports.
162-
# Note that this requires Paper (https://paper.readthedocs.io/en/paper-1.11/) to work; on Bukkit/Spigot this option has no effect.
162+
# Note that this requires Paper (https://papermc.io/downloads/paper) to work; on Bukkit/Spigot this option has no effect.
163+
# Warning: Paper no longer supports Timings as of 1.19.4. This option has no effect on versions 1.19.4 and above.
163164
# When false, timings are not enabled for scripts even if you're running Paper.
164165

165166
parse links in chat messages: disabled

0 commit comments

Comments
 (0)