Skip to content

Commit

Permalink
Preserve cases in command on flags
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Dec 7, 2023
1 parent bf87a41 commit 5bd60d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public final class Flags
public final static LocationFlag TELEPORT_ON_ENTRY = new LocationFlag("teleport-on-entry");
public final static LocationFlag TELEPORT_ON_EXIT = new LocationFlag("teleport-on-exit");

public final static SetFlag<String> COMMAND_ON_ENTRY = new CustomSetFlag("command-on-entry", new CommandStringFlag(null));
public final static SetFlag<String> COMMAND_ON_EXIT = new CustomSetFlag("command-on-exit", new CommandStringFlag(null));
public final static SetFlag<String> COMMAND_ON_ENTRY = new CustomSetFlag("command-on-entry", new CommandStringCaseSensitiveFlag(null));
public final static SetFlag<String> COMMAND_ON_EXIT = new CustomSetFlag("command-on-exit", new CommandStringCaseSensitiveFlag(null));

public final static SetFlag<String> CONSOLE_COMMAND_ON_ENTRY = new CustomSetFlag("console-command-on-entry", new CommandStringFlag(null));
public final static SetFlag<String> CONSOLE_COMMAND_ON_EXIT = new CustomSetFlag("console-command-on-exit", new CommandStringFlag(null));
public final static SetFlag<String> CONSOLE_COMMAND_ON_ENTRY = new CustomSetFlag("console-command-on-entry", new CommandStringCaseSensitiveFlag(null));
public final static SetFlag<String> CONSOLE_COMMAND_ON_EXIT = new CustomSetFlag("console-command-on-exit", new CommandStringCaseSensitiveFlag(null));

public final static DoubleFlag WALK_SPEED = new DoubleFlag("walk-speed");
public final static DoubleFlag FLY_SPEED = new DoubleFlag("fly-speed");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.goldtreeservers.worldguardextraflags.flags.helpers;

import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.FlagContext;

public class CommandStringCaseSensitiveFlag extends Flag<String>
{
public CommandStringCaseSensitiveFlag(String name)
{
super(name);
}

public Object marshal(String o)
{
return o;
}

public String parseInput(FlagContext context)
{
String input = context.getUserInput().trim();
if (!input.startsWith("/"))
{
input = "/" + input;
}

return input;
}

public String unmarshal(Object o)
{
return o instanceof String string ? string : null;
}
}

0 comments on commit 5bd60d3

Please sign in to comment.