Skip to content

Commit

Permalink
Disable Timings for 1.19.4+ (SkriptLang#5917)
Browse files Browse the repository at this point in the history
* Disable Timings for 1.19.4+

* Update SkriptConfig.java
  • Loading branch information
sovdeeth authored Aug 19, 2023
1 parent cdfbb91 commit 7f38b86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import ch.njol.skript.util.chat.ChatMessages;
import ch.njol.skript.util.chat.LinkParseMode;
import ch.njol.skript.variables.Variables;
import co.aikar.timings.Timings;
import org.bukkit.event.EventPriority;
import org.eclipse.jdt.annotation.Nullable;

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

public static final Option<Boolean> enableTimings = new Option<>("enable timings", false)
.setter(t -> {
if (Skript.classExists("co.aikar.timings.Timings")) { // Check for Paper server
if (t)
Skript.info("Timings support enabled!");
SkriptTimings.setEnabled(t); // Config option will be used
} else { // Not running Paper
if (!Skript.classExists("co.aikar.timings.Timings")) { // Check for Timings
if (t) // Warn the server admin that timings won't work
Skript.warning("Timings cannot be enabled! You are running Bukkit/Spigot, but Paper is required.");
SkriptTimings.setEnabled(false); // Just to be sure, deactivate timings support completely
return;
}
if (Timings.class.isAnnotationPresent(Deprecated.class)) { // check for deprecated Timings
if (t) // Warn the server admin that timings won't work
Skript.warning("Timings cannot be enabled! Paper no longer supports Timings as of 1.19.4.");
SkriptTimings.setEnabled(false); // Just to be sure, deactivate timings support completely
return;
}
// If we get here, we can safely enable timings
if (t)
Skript.info("Timings support enabled!");
SkriptTimings.setEnabled(t); // Config option will be used
});

public static final Option<String> parseLinks = new Option<>("parse links in chat messages", "disabled")
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/config.sk
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ soft api exceptions: false

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

parse links in chat messages: disabled
Expand Down

0 comments on commit 7f38b86

Please sign in to comment.