Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add case-insensitive commands toggle in config.sk #6577

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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