Skip to content

Commit

Permalink
Add case-insensitive commands toggle in config.sk (#6577)
Browse files Browse the repository at this point in the history
add case-insensitive commands toggle
  • Loading branch information
sovdeeth committed May 8, 2024
1 parent adac6e1 commit 9e8a5ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ public static String formatDate(final long timestamp) {

public static final Option<Boolean> caseInsensitiveVariables = new Option<>("case-insensitive variables", true)
.setter(t -> Variables.caseInsensitiveVariables = t);

public static final Option<Boolean> caseInsensitiveCommands = new Option<>("case-insensitive commands", false)
.optional(true);

public static final Option<Boolean> colorResetCodes = new Option<>("color codes reset formatting", true)
.setter(t -> {
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/ch/njol/skript/command/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,18 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
String arguments = cmd.length == 1 ? "" : "" + cmd[1];
ScriptCommand command = commands.get(label);

// if so, check permissions
if (command != null && !command.checkPermissions(event.getPlayer(), label, arguments))
event.setCancelled(true);
// is it a skript command?
if (command != null) {
// if so, check permissions to handle ourselves
if (!command.checkPermissions(event.getPlayer(), label, arguments))
event.setCancelled(true);

// we can also handle case sensitivity here:
if (SkriptConfig.caseInsensitiveCommands.value()) {
cmd[0] = event.getMessage().charAt(0) + label;
event.setMessage(String.join(" ", cmd));
}
}
}

@SuppressWarnings("null")
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/config.sk
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ case-insensitive variables: true
# Whether Skript's variables should be case sensitive or not.
# When set to true, all variable names and indices case will be ignored.

case-insensitive commands: false
# Whether Skript should accept custom commands regardless of case.
# When set to true, /test, /Test, and /TEST will all be equivalent.
# This does not affect non-Skript commands.

disable variable will not be saved warnings: false
# Disables the "... i.e contents cannot be saved ..." warning when reloading and something in your scripts sets a variable(non local) to a value that is not serializable.
# By Mirre.
Expand Down

0 comments on commit 9e8a5ce

Please sign in to comment.