Updated for Text3

This commit is contained in:
Matthew Miller 2019-05-06 16:49:33 +10:00
parent 461f3e1faf
commit 8c345cb64b
7 changed files with 82 additions and 85 deletions

View File

@ -30,7 +30,6 @@
import com.sk89q.worldedit.util.formatting.component.CodeFormat;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
@ -125,13 +124,13 @@ public void stopLag(CommandContext args, Actor sender) throws CommandException {
.append(ErrorFormat.wrap("PERMANENTLY")
.decoration(TextDecoration.BOLD, TextDecoration.State.TRUE))
.append(ErrorFormat.wrap(" erase ALL animals in ALL loaded chunks in ALL loaded worlds. "))
.append(Component.newline())
.append(TextComponent.newline())
.append(TextComponent.of("[Click]", TextColor.GREEN)
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, confirmCommand))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to confirm /" + args.getCommand()))))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, confirmCommand))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to confirm /" + args.getCommand()))))
.append(ErrorFormat.wrap(" or type "))
.append(CodeFormat.wrap(confirmCommand)
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, confirmCommand)))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, confirmCommand)))
.append(ErrorFormat.wrap(" to confirm."))
.build();

View File

@ -117,19 +117,19 @@ private void appendFlagName(TextComponent.Builder builder, Flag<?> flag, TextCol
int length = FlagFontInfo.getPxLength(name);
builder.append(TextComponent.of(name, color));
if (flag.usesMembershipAsDefault()) {
builder.append(Component.empty().append(TextComponent.of("*", TextColor.AQUA))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
builder.append(TextComponent.empty().append(TextComponent.of("*", TextColor.AQUA))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT,
TextComponent.of("This is a special flag which defaults to allow for members, and deny for non-members"))));
length += FlagFontInfo.getPxLength('*');
}
if (flag == Flags.PASSTHROUGH) {
builder.append(Component.empty().append(TextComponent.of("*", TextColor.AQUA))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
builder.append(TextComponent.empty().append(TextComponent.of("*", TextColor.AQUA))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT,
TextComponent.of("This is a special flag which overrides build checks. (Not movement related!)"))));
length += FlagFontInfo.getPxLength('*');
}
int leftover = PAD_PX_SIZE - length;
builder.append(Component.space());
builder.append(TextComponent.space());
leftover -= 4;
if (leftover > 0) {
builder.append(TextComponent.of(Strings.repeat(".", leftover / 2), TextColor.DARK_GRAY));
@ -194,7 +194,7 @@ private <V> void appendValueChoices(TextComponent.Builder builder, Flag<V> flag,
TextColor col = isExplicitSet ? TextColor.WHITE : inherited && currVal == choice ? TextColor.GRAY : TextColor.DARK_GRAY;
Set<TextDecoration> styles = choice == defVal ? ImmutableSet.of(TextDecoration.UNDERLINED) : Collections.emptySet();
Component choiceComponent = Component.empty().append(TextComponent.of(capitalize(String.valueOf(choice)), col, styles));
Component choiceComponent = TextComponent.empty().append(TextComponent.of(capitalize(String.valueOf(choice)), col, styles));
List<Component> hoverTexts = new ArrayList<>();
if (maySet) {
@ -214,26 +214,26 @@ private <V> void appendValueChoices(TextComponent.Builder builder, Flag<V> flag,
for (Iterator<Component> hovIt = hoverTexts.iterator(); hovIt.hasNext(); ) {
hoverBuilder.append(hovIt.next());
if (hovIt.hasNext()) {
hoverBuilder.append(Component.newline());
hoverBuilder.append(TextComponent.newline());
}
}
choiceComponent = choiceComponent.hoverEvent(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverBuilder.build()));
HoverEvent.of(HoverEvent.Action.SHOW_TEXT, hoverBuilder.build()));
}
if (maySet) {
builder.append(choiceComponent.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
builder.append(choiceComponent.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
makeCommand(flag, isExplicitSet ? "" : choice))));
} else {
builder.append(choiceComponent);
}
builder.append(Component.space());
builder.append(TextComponent.space());
}
if (suggestChoice != null && perms.maySetFlag(region, flag)) {
builder.append(TextComponent.of(suggestChoice, TextColor.DARK_GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT,
TextComponent.of("Click to set custom value", TextColor.GOLD)))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, makeCommand(flag, ""))));
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, makeCommand(flag, ""))));
}
}
@ -255,7 +255,7 @@ private <V> void appendValueText(TextComponent.Builder builder, Flag<V> flag, St
TextColor col = isExplicitSet ? TextColor.WHITE : inherited ? TextColor.GRAY : TextColor.DARK_GRAY;
Set<TextDecoration> styles = currVal == defVal ? ImmutableSet.of(TextDecoration.UNDERLINED) : Collections.emptySet();
Component displayComponent = Component.empty().append(TextComponent.of(display, col, styles));
Component displayComponent = TextComponent.empty().append(TextComponent.of(display, col, styles));
List<Component> hoverTexts = new ArrayList<>();
if (maySet) {
@ -275,24 +275,24 @@ private <V> void appendValueText(TextComponent.Builder builder, Flag<V> flag, St
for (Iterator<Component> hovIt = hoverTexts.iterator(); hovIt.hasNext(); ) {
hoverBuilder.append(hovIt.next());
if (hovIt.hasNext()) {
hoverBuilder.append(Component.newline());
hoverBuilder.append(TextComponent.newline());
}
}
if (hover != null) {
hoverBuilder.append(Component.newline());
hoverBuilder.append(TextComponent.newline());
hoverBuilder.append(hover);
}
displayComponent = displayComponent.hoverEvent(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverBuilder.build()));
HoverEvent.of(HoverEvent.Action.SHOW_TEXT, hoverBuilder.build()));
}
if (maySet) {
builder.append(displayComponent.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
builder.append(displayComponent.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
makeCommand(flag, ""))));
} else {
builder.append(displayComponent);
}
builder.append(Component.space());
builder.append(TextComponent.space());
}
private String makeCommand(Flag<?> flag, Object choice) {
@ -322,7 +322,7 @@ private <V> Component getToolTipHint(V defVal, V currVal, boolean inherited) {
}
} else {
if (currVal == defVal) {
valType = Component.empty()
valType = TextComponent.empty()
.append(TextComponent.of("Default")
.decoration(TextDecoration.UNDERLINED, true))
.append(TextComponent.of(" value"));
@ -362,7 +362,7 @@ private <V> void appendSetFlagValue(TextComponent.Builder builder, SetFlag<V> fl
TextComponent hoverComp = TextComponent.of("");
if (currVal != null) {
hoverComp = hoverComp.append(TextComponent.of("Current values:"))
.append(Component.newline()).append(TextComponent.of(stringValue));
.append(TextComponent.newline()).append(TextComponent.of(stringValue));
}
appendValueText(builder, flag, display, hoverComp);
}
@ -389,11 +389,11 @@ private void appendLocationFlagValue(TextComponent.Builder builder, LocationFlag
appendValueText(builder, flag, "unset location", null);
} else {
appendValueText(builder, flag, defVal.toString(), TextComponent.of("Default value:")
.append(Component.newline()).append(TextComponent.of(defVal.toString())));
.append(TextComponent.newline()).append(TextComponent.of(defVal.toString())));
}
} else {
appendValueText(builder, flag, currVal.toString(), TextComponent.of("Current value:")
.append(Component.newline()).append(TextComponent.of(currVal.toString())));
.append(TextComponent.newline()).append(TextComponent.of(currVal.toString())));
}
}
@ -448,7 +448,7 @@ private void appendStringFlagValue(TextComponent.Builder builder, StringFlag fla
display = display.substring(0, 20) + "...";
}
appendValueText(builder, flag, display, TextComponent.of("Default value:")
.append(Component.newline()).append(defComp));
.append(TextComponent.newline()).append(defComp));
}
} else {
TextComponent currComp = LegacyComponentSerializer.INSTANCE.deserialize(currVal);
@ -458,7 +458,7 @@ private void appendStringFlagValue(TextComponent.Builder builder, StringFlag fla
display = display.substring(0, 20) + "...";
}
appendValueText(builder, flag, display, TextComponent.of("Current value:")
.append(Component.newline()).append(currComp));
.append(TextComponent.newline()).append(currComp));
}
}

View File

@ -38,7 +38,6 @@
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.LabelFormat;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
@ -523,12 +522,12 @@ public void flag(CommandContext args, Actor sender) throws CommandException {
final TextComponent.Builder builder = TextComponent.builder("Available flags: ");
final HoverEvent clickToSet = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set"));
final HoverEvent clickToSet = HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set"));
for (int i = 0; i < flagList.size(); i++) {
String flag = flagList.get(i);
builder.append(TextComponent.of(flag, i % 2 == 0 ? TextColor.GRAY : TextColor.WHITE)
.hoverEvent(clickToSet).clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
.hoverEvent(clickToSet).clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND,
"/rg flag -w " + world.getName() + " " + existing.getId() + " " + flag + " ")));
if (i < flagList.size() + 1) {
builder.append(TextComponent.of(", "));
@ -541,27 +540,27 @@ public void flag(CommandContext args, Actor sender) throws CommandException {
return;
} else if (value != null) {
if (foundFlag == Flags.BUILD || foundFlag == Flags.BLOCK_BREAK || foundFlag == Flags.BLOCK_PLACE) {
sender.print(Component.empty().append(TextComponent.of("WARNING:", TextColor.RED, Sets.newHashSet(TextDecoration.BOLD)))
sender.print(TextComponent.empty().append(TextComponent.of("WARNING:", TextColor.RED, Sets.newHashSet(TextDecoration.BOLD)))
.append(ErrorFormat.wrap(" Setting the " + foundFlag.getName() + " flag is not required for protection."))
.append(Component.newline())
.append(TextComponent.newline())
.append(TextComponent.of("Setting this flag will completely override default protection, and apply" +
" to members, non-members, pistons, and everything else that can modify blocks."))
.append(Component.newline())
.append(TextComponent.newline())
.append(TextComponent.of("Only set this flag if you are sure you know what you are doing. See ")
.append(TextComponent.of("[this documentation page]", TextColor.AQUA)
.clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
.clickEvent(ClickEvent.of(ClickEvent.Action.OPEN_URL,
"https://worldguard.readthedocs.io/en/latest/regions/flags/#protection-related")))
.append(TextComponent.of(" for more info."))));
if (!sender.isPlayer()) {
sender.printRaw("https://worldguard.readthedocs.io/en/latest/regions/flags/#protection-related");
}
} else if (foundFlag == Flags.PASSTHROUGH) {
sender.print(Component.empty().append(TextComponent.of("WARNING:", TextColor.RED, Sets.newHashSet(TextDecoration.BOLD)))
sender.print(TextComponent.empty().append(TextComponent.of("WARNING:", TextColor.RED, Sets.newHashSet(TextDecoration.BOLD)))
.append(ErrorFormat.wrap(" This flag is unrelated to moving through regions."))
.append(Component.newline())
.append(TextComponent.newline())
.append(TextComponent.of("It overrides build checks. If you're unsure what this means, see ")
.append(TextComponent.of("[this documentation page]", TextColor.AQUA)
.clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
.clickEvent(ClickEvent.of(ClickEvent.Action.OPEN_URL,
"https://worldguard.readthedocs.io/en/latest/regions/flags/#overrides")))
.append(TextComponent.of(" for more info."))));
if (!sender.isPlayer()) {

View File

@ -203,8 +203,8 @@ protected static ProtectedRegion checkRegionStandingIn(RegionManager regionManag
first = false;
TextComponent regionComp = TextComponent.of(region.getId(), TextColor.AQUA);
if (rgCmd != null && rgCmd.contains("%id%")) {
regionComp = regionComp.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to pick this region")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, rgCmd.replace("%id%", region.getId())));
regionComp = regionComp.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to pick this region")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, rgCmd.replace("%id%", region.getId())));
}
builder.append(regionComp);
}

View File

@ -28,7 +28,6 @@
import com.sk89q.worldedit.util.formatting.component.MessageBox;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
@ -78,7 +77,7 @@ public RegionPrintoutBuilder(String world, ProtectedRegion region, @Nullable Pro
* Add a new line.
*/
public void newline() {
builder.append(Component.newline());
builder.append(TextComponent.newline());
}
/**
@ -87,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(new ClickEvent(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()));
@ -147,8 +146,8 @@ public void appendFlagsList(boolean useColors) {
TextComponent flagText = TextComponent.of(flagString, useColors ? TextColor.GOLD : TextColor.WHITE)
.append(TextComponent.of(String.valueOf(val), useColors? TextColor.YELLOW : TextColor.WHITE));
if (perms != null && perms.maySetFlag(region, flag)) {
flagText = flagText.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set flag")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
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() + " "));
}
builder.append(flagText);
@ -162,10 +161,10 @@ public void appendFlagsList(boolean useColors) {
}
if (perms != null && perms.maySetFlag(region)) {
builder.append(Component.space())
builder.append(TextComponent.space())
.append(TextComponent.of("[Flags]", useColors ? TextColor.GREEN : TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to set a flag")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rg flags -w " + world + " " + region.getId())));
.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())));
}
}
@ -217,8 +216,8 @@ public void appendParentTree(boolean useColors) {
builder.append(TextComponent.of(namePrefix.toString(), useColors ? TextColor.GREEN : TextColor.WHITE));
if (perms != null && perms.mayLookup(cur)) {
builder.append(TextComponent.of(cur.getId(), useColors ? TextColor.GREEN : TextColor.WHITE)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for info")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rg info -w " + world + " " + cur.getId())));
.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())));
} else {
builder.append(TextComponent.of(cur.getId(), useColors ? TextColor.GREEN : TextColor.WHITE));
}
@ -230,10 +229,10 @@ public void appendParentTree(boolean useColors) {
builder.append(TextComponent.of(")", useColors ? TextColor.GRAY : TextColor.WHITE));
}
if (last != null && cur.equals(region) && perms != null && perms.maySetParent(cur, last)) {
builder.append(Component.space());
builder.append(TextComponent.space());
builder.append(TextComponent.of("[X]", TextColor.RED)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to unlink parent")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/rg setparent -w " + world + " " + cur.getId())));
.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())));
}
last = cur;
@ -270,19 +269,19 @@ private void addDomainString(DefaultDomain domain, String addCommand, String rem
}
}
if (addCommand != null) {
builder.append(Component.space().append(TextComponent.of("[Add]", TextColor.GREEN)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to add a player or group")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
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() + " "))));
}
if (removeCommand != null && domain.size() > 0) {
builder.append(Component.space().append(TextComponent.of("[Rem]", TextColor.RED)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to remove a player or group")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
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() + " "))));
builder.append(Component.space().append(TextComponent.of("[Clr]", TextColor.RED)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to clear")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
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()))));
}
}
@ -298,19 +297,19 @@ public void appendBounds() {
+ " -> (" + max.getBlockX() + "," + max.getBlockY() + "," + max.getBlockZ() + ")", TextColor.YELLOW);
if (perms != null && perms.maySelect(region)) {
bound = bound
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rg select " + region.getId()));
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg select " + region.getId()));
}
builder.append(bound);
final Location teleFlag = region.getFlag(Flags.TELE_LOC);
if (perms != null && perms.mayTeleportTo(region) && teleFlag != null) {
builder.append(Component.space().append(TextComponent.of("[Teleport]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
TextComponent.of("Click to teleport").append(Component.newline()).append(
builder.append(TextComponent.space().append(TextComponent.of("[Teleport]", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT,
TextComponent.of("Click to teleport").append(TextComponent.newline()).append(
TextComponent.of(teleFlag.getBlockY() + ", "
+ teleFlag.getBlockY() + ", "
+ teleFlag.getBlockZ()))))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND,
"/rg tp -w " + world + " " + region.getId()))));
}
@ -321,8 +320,8 @@ private void appendPriorityComponent(ProtectedRegion rg) {
final String content = String.valueOf(rg.getPriority());
if (perms != null && perms.maySetPriority(rg)) {
builder.append(TextComponent.of(content, TextColor.GOLD)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to change")))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/rg setpriority -w " + world + " " + rg.getId() + " ")));
.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() + " ")));
} else {
builder.append(TextComponent.of(content, TextColor.WHITE));
}

View File

@ -247,17 +247,17 @@ public Component getComponent(int number) {
final RegionListEntry entry = entries.get(number);
final TextComponent.Builder builder = TextComponent.builder(number + 1 + ".").color(TextColor.LIGHT_PURPLE);
if (entry.isOwner()) {
builder.append(Component.space()).append(TextComponent.of("+", TextColor.DARK_AQUA)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Region Owner", TextColor.GOLD))));
builder.append(TextComponent.space()).append(TextComponent.of("+", TextColor.DARK_AQUA)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Region Owner", TextColor.GOLD))));
} else if (entry.isMember()) {
builder.append(Component.space()).append(TextComponent.of("-", TextColor.AQUA)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Region Member", TextColor.GOLD))));
builder.append(TextComponent.space()).append(TextComponent.of("-", TextColor.AQUA)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Region Member", TextColor.GOLD))));
}
builder.append(Component.space()).append(TextComponent.of(entry.getRegion().getId(), TextColor.GOLD));
builder.append(TextComponent.space()).append(TextComponent.of(entry.getRegion().getId(), TextColor.GOLD));
if (perms != null && perms.mayLookup(entry.region)) {
builder.append(Component.space().append(TextComponent.of("[Info]", TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click for info")))
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
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()))));
}
return builder.build();

View File

@ -378,7 +378,7 @@ private Component toGroupsComponent() {
builder.append(TextComponent.of(", "));
}
}
return builder.build().hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Groups")));
return builder.build().hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Groups")));
}
private Component toPlayersComponent(ProfileCache cache) {
@ -409,14 +409,14 @@ private Component toPlayersComponent(ProfileCache cache) {
final Iterator<TextComponent> profiles = profileMap.keySet().stream().sorted().map(name -> {
final UUID uuid = profileMap.get(name);
final TextComponent component = TextComponent.of(name, TextColor.YELLOW)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, uuid == null
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, uuid == null
? TextComponent.of("Name only", TextColor.GRAY)
: TextComponent.of("Last known name of uuid: ", TextColor.GRAY)
.append(TextComponent.of(uuid.toString(), TextColor.WHITE))));
if (uuid == null) {
return component;
}
return component.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, uuid.toString()));
return component.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, uuid.toString()));
}).iterator();
while (profiles.hasNext()) {
builder.append(profiles.next());
@ -427,9 +427,9 @@ private Component toPlayersComponent(ProfileCache cache) {
if (!uuids.isEmpty()) {
builder.append(TextComponent.of(uuids.size() + " unknown uuid" + (uuids.size() == 1 ? "" : "s"), TextColor.GRAY)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of(String.join("\n", uuids))
.append(Component.newline().append(TextComponent.of("Click to select")))))
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.join(",", uuids))));
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(String.join("\n", uuids))
.append(TextComponent.newline().append(TextComponent.of("Click to select")))))
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, String.join(",", uuids))));
}