Skip to content

Commit

Permalink
Add config toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth committed May 9, 2024
1 parent 389dbf9 commit db57f84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ public static String formatDate(final long timestamp) {
}
});

/**
* Determines whether `on <event>` will be triggered by cancelled events or not.
*/
public static final Option<Boolean> listenCancelledByDefault = new Option<>("listen to cancelled events by default", false)
.optional(true);


/**
* Maximum number of digits to display after the period for floats and doubles
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/njol/skript/lang/SkriptEventInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ch.njol.skript.lang;

import ch.njol.skript.SkriptAPIException;
import ch.njol.skript.SkriptConfig;
import org.bukkit.event.Event;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -74,8 +75,8 @@ public SkriptEventInfo(String name, String[] patterns, Class<E> eventClass, Stri
// uses the name without 'on ' or '*'
this.id = "" + name.toLowerCase(Locale.ENGLISH).replaceAll("[#'\"<>/&]", "").replaceAll("\\s+", "_");

// default listening behavior should be to listen to uncancelled events
this.listeningBehavior = ListeningBehavior.UNCANCELLED;
// default listening behavior should be dependent on config setting
this.listeningBehavior = SkriptConfig.listenCancelledByDefault.value() ? ListeningBehavior.ANY : ListeningBehavior.UNCANCELLED;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.sk
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ plugin priority: high
# - effects 'remove ... from drops'/'clear drops': Drops added by other plugins are not removed => increase priority
# Skript removes drops it shouldn't => decrease priority or specify which item types to remove

listen to cancelled events by default: false
# Determines whether `on <event>` will be triggered by all events (true) or only cancelled events (false).
# The default is false, which maintains traditional Skript behavior.

number accuracy: 2
# How many digits should be displayed after the dot at maximum when displaying numbers.
Expand Down

0 comments on commit db57f84

Please sign in to comment.