mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-29 14:06:30 +01:00
Add ContentFilter to commands, and some cleanup.
This commit is contained in:
parent
c8432b9b57
commit
ef073b0403
@ -55,6 +55,7 @@ public class MVCommandContexts extends PaperCommandContexts {
|
|||||||
registerIssuerAwareContext(Location.class, this::deriveLocation);
|
registerIssuerAwareContext(Location.class, this::deriveLocation);
|
||||||
registerIssuerAwareContext(PasteServiceType.class, this::derivePasteServiceType);
|
registerIssuerAwareContext(PasteServiceType.class, this::derivePasteServiceType);
|
||||||
registerOptionalContext(String.class, this::deriveString);
|
registerOptionalContext(String.class, this::deriveString);
|
||||||
|
registerIssuerAwareContext(ContentFilter.class, this::deriveContentFilter);
|
||||||
registerOptionalContext(PageFilter.class, this::derivePageFilter);
|
registerOptionalContext(PageFilter.class, this::derivePageFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,12 +413,16 @@ public class MVCommandContexts extends PaperCommandContexts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private ContentFilter deriveContentFilter(@NotNull BukkitCommandExecutionContext context) {
|
||||||
|
return new ContentFilter(context.popFirstArg());
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private PageFilter derivePageFilter(@NotNull BukkitCommandExecutionContext context) {
|
private PageFilter derivePageFilter(@NotNull BukkitCommandExecutionContext context) {
|
||||||
final int argLength = context.getArgs().size();
|
final int argLength = context.getArgs().size();
|
||||||
if (argLength == 0) {
|
if (argLength == 0) {
|
||||||
return new PageFilter(new ContentFilter(null), 1);
|
return new PageFilter(ContentFilter.EMPTY, 1);
|
||||||
}
|
}
|
||||||
if (argLength == 1) {
|
if (argLength == 1) {
|
||||||
String pageOrFilter = context.popFirstArg();
|
String pageOrFilter = context.popFirstArg();
|
||||||
|
@ -14,6 +14,11 @@ public class ContentFilter {
|
|||||||
private boolean exactMatch;
|
private boolean exactMatch;
|
||||||
|
|
||||||
private static final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
|
private static final Pattern REGEX_SPECIAL_CHARS = Pattern.compile("[.+*?\\[^\\]$(){}=!<>|:-\\\\]");
|
||||||
|
public static ContentFilter EMPTY = new ContentFilter();
|
||||||
|
|
||||||
|
public ContentFilter() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
public ContentFilter(@Nullable String filterString) {
|
public ContentFilter(@Nullable String filterString) {
|
||||||
this(filterString, false);
|
this(filterString, false);
|
||||||
@ -66,10 +71,6 @@ public class ContentFilter {
|
|||||||
: filterPattern.matcher(text).find();
|
: filterPattern.matcher(text).find();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExactMatch(boolean exactMatch) {
|
|
||||||
this.exactMatch = exactMatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasFilter() {
|
public boolean hasFilter() {
|
||||||
return filterString != null;
|
return filterString != null;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,8 @@ public class ShowKeyValue extends ShowRunnable<Map<String, Object>> {
|
|||||||
.append(ChatColor.WHITE)
|
.append(ChatColor.WHITE)
|
||||||
.append(this.display.getOperator())
|
.append(this.display.getOperator())
|
||||||
.append(this.display.getColours().getColorThat())
|
.append(this.display.getColours().getColorThat())
|
||||||
.append(entry.getValue());
|
.append(entry.getValue())
|
||||||
|
.append(ChatColor.WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,14 +39,17 @@ public class ConfigCommand extends MultiverseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("list")
|
@Subcommand("list")
|
||||||
|
@Syntax("[filter]")
|
||||||
@Description("Show multiverse config values.")
|
@Description("Show multiverse config values.")
|
||||||
public void onShowCommand(@NotNull CommandSender sender) {
|
public void onShowCommand(@NotNull CommandSender sender,
|
||||||
|
@NotNull ContentFilter filter) {
|
||||||
|
|
||||||
KeyValueDisplay display = new KeyValueDisplay(
|
KeyValueDisplay display = new KeyValueDisplay(
|
||||||
this.plugin,
|
this.plugin,
|
||||||
sender,
|
sender,
|
||||||
ChatColor.LIGHT_PURPLE + "===[ Multiverse Config ]===",
|
ChatColor.LIGHT_PURPLE + "===[ Multiverse Config ]===",
|
||||||
getConfigMap(),
|
getConfigMap(),
|
||||||
new ContentFilter("first"),
|
filter,
|
||||||
new ColourAlternator(ChatColor.GREEN, ChatColor.GOLD),
|
new ColourAlternator(ChatColor.GREEN, ChatColor.GOLD),
|
||||||
" = "
|
" = "
|
||||||
);
|
);
|
||||||
|
@ -43,21 +43,23 @@ public class GameRuleCommand extends MultiverseCommand {
|
|||||||
|
|
||||||
@Subcommand("list")
|
@Subcommand("list")
|
||||||
@CommandPermission("multiverse.core.gamerule.list")
|
@CommandPermission("multiverse.core.gamerule.list")
|
||||||
@Syntax("[world]")
|
@Syntax("[world] [filter]")
|
||||||
@CommandCompletion("@MVWorlds")
|
@CommandCompletion("@MVWorlds")
|
||||||
@Description("See the list gamerules values for a given world.")
|
@Description("See the list gamerules values for a given world.")
|
||||||
public void onGameRulesCommand(@NotNull CommandSender sender,
|
public void onGameRulesCommand(@NotNull CommandSender sender,
|
||||||
|
|
||||||
@Syntax("[world]")
|
@Syntax("[world]")
|
||||||
@Description("World you want to see game rule info.")
|
@Description("World you want to see game rule info.")
|
||||||
@NotNull @Flags("other,defaultself") MultiverseWorld world) {
|
@NotNull @Flags("other,defaultself, fallbackself") MultiverseWorld world,
|
||||||
|
|
||||||
|
@NotNull ContentFilter filter) {
|
||||||
|
|
||||||
KeyValueDisplay display = new KeyValueDisplay(
|
KeyValueDisplay display = new KeyValueDisplay(
|
||||||
this.plugin,
|
this.plugin,
|
||||||
sender,
|
sender,
|
||||||
"=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ===",
|
"=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ===",
|
||||||
getGameRuleMap(world),
|
getGameRuleMap(world),
|
||||||
new ContentFilter(null),
|
filter,
|
||||||
new ColourAlternator(ChatColor.GREEN, ChatColor.GOLD),
|
new ColourAlternator(ChatColor.GREEN, ChatColor.GOLD),
|
||||||
": "
|
": "
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user