Skip to content
Permalink
Browse files

Apparently world names are allowed to have spaces.

  • Loading branch information...
wizjany committed Aug 19, 2019
1 parent 96d15d6 commit 179c324c80ab2b99eaf964005e511727aa024919
@@ -83,7 +83,7 @@
private boolean monoSpace;

FlagHelperBox(World world, ProtectedRegion region, RegionPermissionModel perms) {
super("Flags for " + region.getId(), "/rg flags -w " + world.getName() + " -p %page% " + region.getId());
super("Flags for " + region.getId(), "/rg flags -w \"" + world.getName() + "\" -p %page% " + region.getId());
this.world = world;
this.region = region;
this.perms = perms;
@@ -301,7 +301,7 @@ private void appendFlagValue(TextComponent.Builder builder, Flag<?> flag) {
}

private String makeCommand(Flag<?> flag, Object choice) {
return "/rg flag -w " + world.getName() + " -h " + getCurrentPage()
return "/rg flag -w \"" + world.getName() + "\" -h " + getCurrentPage()
+ " " + region.getId() + " " + flag.getName() + " " + choice;
}

@@ -378,7 +378,7 @@ public void info(CommandContext args, Actor sender) throws CommandException {
}

existing = checkRegionStandingIn(manager, (LocalPlayer) sender, true,
"/rg info -w " + world.getName() + " %id%" + (args.hasFlag('u') ? " -u" : "") + (args.hasFlag('s') ? " -s" : ""));
"/rg info -w \"" + world.getName() + "\" %id%" + (args.hasFlag('u') ? " -u" : "") + (args.hasFlag('s') ? " -s" : ""));
} else { // Get region from the ID
existing = checkExistingRegion(manager, args.getString(0), true);
}
@@ -635,7 +635,7 @@ public void flagHelper(CommandContext args, Actor sender) throws CommandExceptio
}

region = checkRegionStandingIn(manager, (LocalPlayer) sender, true,
"/rg flags -w " + world.getName() + " %id%");
"/rg flags -w \"" + world.getName() + "\" %id%");
} else { // Get region from the ID
region = checkExistingRegion(manager, args.getString(0), true);
}
@@ -1139,7 +1139,7 @@ public Component call() {

builder.append(TextComponent.of(flag, i % 2 == 0 ? TextColor.GRAY : TextColor.WHITE)
.hoverEvent(clickToSet).clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
"/rg flag -w " + world.getName() + " " + regionId + " " + flag + " ")));
"/rg flag -w \"" + world.getName() + "\" " + regionId + " " + flag + " ")));
if (i < flagList.size() + 1) {
builder.append(TextComponent.of(", "));
}
@@ -1152,7 +1152,7 @@ public Component call() {
return ret.append(TextComponent.of("Or use the command ", TextColor.LIGHT_PURPLE)
.append(TextComponent.of("/rg flags " + regionId, TextColor.AQUA)
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
"/rg flags -w " + world.getName() + " " + regionId))));
"/rg flags -w \"" + world.getName() + "\" " + regionId))));
}
return ret;
}
@@ -86,7 +86,7 @@ public void newline() {
public void appendBasics() {
builder.append(TextComponent.of("Region: ", TextColor.BLUE));
builder.append(TextComponent.of(region.getId(), TextColor.YELLOW)
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg info -w " + world + " " + region.getId())));
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg info -w \"" + world + "\" " + region.getId())));

builder.append(TextComponent.of(" (type=", TextColor.GRAY));
builder.append(TextComponent.of(region.getType().getName()));
@@ -148,7 +148,7 @@ public void appendFlagsList(boolean useColors) {
if (perms != null && perms.maySetFlag(region, flag)) {
flagText = flagText.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set flag")))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
"/rg flag -w " + world + " " + region.getId() + " " + flag.getName() + " "));
"/rg flag -w \"" + world + "\" " + region.getId() + " " + flag.getName() + " "));
}
builder.append(flagText);

@@ -164,7 +164,7 @@ public void appendFlagsList(boolean useColors) {
builder.append(TextComponent.space())
.append(TextComponent.of("[Flags]", useColors ? TextColor.GREEN : TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set a flag")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg flags -w " + world + " " + region.getId())));
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg flags -w \"" + world + "\" " + region.getId())));
}
}

@@ -217,7 +217,7 @@ public void appendParentTree(boolean useColors) {
if (perms != null && perms.mayLookup(cur)) {
builder.append(TextComponent.of(cur.getId(), useColors ? TextColor.GREEN : TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for info")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg info -w " + world + " " + cur.getId())));
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg info -w \"" + world + "\" " + cur.getId())));
} else {
builder.append(TextComponent.of(cur.getId(), useColors ? TextColor.GREEN : TextColor.WHITE));
}
@@ -232,7 +232,7 @@ public void appendParentTree(boolean useColors) {
builder.append(TextComponent.space());
builder.append(TextComponent.of("[X]", TextColor.RED)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to unlink parent")))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/rg setparent -w " + world + " " + cur.getId())));
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/rg setparent -w \"" + world + "\" " + cur.getId())));
}

last = cur;
@@ -272,17 +272,17 @@ private void addDomainString(DefaultDomain domain, String addCommand, String rem
builder.append(TextComponent.space().append(TextComponent.of("[Add]", TextColor.GREEN)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to add a player or group")))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
"/rg " + addCommand + " -w " + world + " " + region.getId() + " "))));
"/rg " + addCommand + " -w \"" + world + "\" " + region.getId() + " "))));
}
if (removeCommand != null && domain.size() > 0) {
builder.append(TextComponent.space().append(TextComponent.of("[Rem]", TextColor.RED)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to remove a player or group")))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
"/rg " + removeCommand + " -w " + world + " " + region.getId() + " "))));
"/rg " + removeCommand + " -w \"" + world + "\" " + region.getId() + " "))));
builder.append(TextComponent.space().append(TextComponent.of("[Clr]", TextColor.RED)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to clear")))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
"/rg " + removeCommand + " -w " + world + " -a " + region.getId()))));
"/rg " + removeCommand + " -w \"" + world + "\" -a " + region.getId()))));
}
}

@@ -310,7 +310,7 @@ public void appendBounds() {
+ teleFlag.getBlockY() + ", "
+ teleFlag.getBlockZ()))))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
"/rg tp -w " + world + " " + region.getId()))));
"/rg tp -w \"" + world + "\" " + region.getId()))));
}

newline();
@@ -321,7 +321,7 @@ private void appendPriorityComponent(ProtectedRegion rg) {
if (perms != null && perms.maySetPriority(rg)) {
builder.append(TextComponent.of(content, TextColor.GOLD)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to change")))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/rg setpriority -w " + world + " " + rg.getId() + " ")));
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/rg setpriority -w \"" + world + "\" " + rg.getId() + " ")));
} else {
builder.append(TextComponent.of(content, TextColor.WHITE));
}
@@ -176,7 +176,7 @@ public Integer call() throws Exception {

RegionPermissionModel perms = sender.isPlayer() ? new RegionPermissionModel(sender) : null;
String title = ownerMatcher == null ? "Regions" : "Regions for " + ownerMatcher.getName();
String cmd = "/rg list -w " + world
String cmd = "/rg list -w \"" + world + "\""
+ (playerName != null ? " -p " + playerName : "")
+ (nameOnly ? " -n" : "")
+ " %page%";
@@ -259,13 +259,13 @@ public Component getComponent(int number) {
builder.append(TextComponent.space().append(TextComponent.of("[Info]", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for info")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
"/rg info -w " + world + " " + entry.region.getId()))));
"/rg info -w \"" + world + "\" " + entry.region.getId()))));
}
if (perms != null && entry.region.getFlag(Flags.TELE_LOC) != null && perms.mayTeleportTo(entry.region)) {
builder.append(TextComponent.space().append(TextComponent.of("[TP]", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to teleport")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
"/rg tp -w " + world + " " + entry.region.getId()))));
"/rg tp -w \"" + world + "\" " + entry.region.getId()))));
}
return builder.build();
}

0 comments on commit 179c324

Please sign in to comment.
You can’t perform that action at this time.