Search in sources :

Example 11 with TextComponent

use of com.sk89q.worldedit.util.formatting.text.TextComponent in project WorldGuard by EngineHub.

the class RegionPrintoutBuilder method appendBounds.

/**
 * Add information about coordinates.
 */
public void appendBounds() {
    BlockVector3 min = region.getMinimumPoint();
    BlockVector3 max = region.getMaximumPoint();
    builder.append(TextComponent.of("Bounds:", TextColor.BLUE));
    TextComponent bound = TextComponent.of(" " + min + " -> " + max, TextColor.YELLOW);
    if (perms != null && perms.maySelect(region)) {
        bound = bound.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 = FlagValueCalculator.getEffectiveFlagOf(region, Flags.TELE_LOC, perms != null && perms.getSender() instanceof RegionAssociable ? (RegionAssociable) perms.getSender() : null);
    if (teleFlag != null && perms != null && perms.mayTeleportTo(region)) {
        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.getBlockX() + ", " + teleFlag.getBlockY() + ", " + teleFlag.getBlockZ())))).clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg tp -w \"" + world + "\" " + region.getId()))));
    } else if (perms != null && perms.mayTeleportToCenter(region) && region.isPhysicalArea()) {
        builder.append(TextComponent.space().append(TextComponent.of("[Center Teleport]", TextColor.GRAY).hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to teleport to the center of the region"))).clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/rg tp -c -w \"" + world + "\" " + region.getId()))));
    }
    newline();
}
Also used : TextComponent(com.sk89q.worldedit.util.formatting.text.TextComponent) RegionAssociable(com.sk89q.worldguard.protection.association.RegionAssociable) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Location(com.sk89q.worldedit.util.Location)

Aggregations

TextComponent (com.sk89q.worldedit.util.formatting.text.TextComponent)11 UUID (java.util.UUID)3 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)2 Component (com.sk89q.worldedit.util.formatting.text.Component)2 TranslatableComponent (com.sk89q.worldedit.util.formatting.text.TranslatableComponent)2 TextColor (com.sk89q.worldedit.util.formatting.text.format.TextColor)2 World (com.sk89q.worldedit.world.World)2 LocalPlayer (com.sk89q.worldguard.LocalPlayer)2 IOException (java.io.IOException)2 RollbackDatabase (com.fastasyncworldedit.core.database.RollbackDatabase)1 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)1 RollbackOptimizedHistory (com.fastasyncworldedit.core.history.RollbackOptimizedHistory)1 MutableFullBlockChange (com.fastasyncworldedit.core.history.change.MutableFullBlockChange)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Command (com.sk89q.minecraft.util.commands.Command)1 CommandException (com.sk89q.minecraft.util.commands.CommandException)1 CommandPermissions (com.sk89q.minecraft.util.commands.CommandPermissions)1