Update info tool to components.

Dieser Commit ist enthalten in:
wizjany 2019-06-28 18:02:06 -04:00
Ursprung 9136139cfd
Commit b5e895c37e

Datei anzeigen

@ -22,15 +22,20 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.OptionalInt;
/**
* Looks up information about a block.
*/
@ -49,16 +54,21 @@ public class QueryTool implements BlockTool {
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
BaseBlock block = editSession.getFullBlock(blockPoint);
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
+ block.getBlockType().getName() + "\u00A77" + " ("
+ block.toString() + ") "
+ "\u00A7f"
+ " (" + world.getBlockLightLevel(blockPoint) + "/" + world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")");
if (block instanceof MobSpawnerBlock) {
player.printRaw("\u00A7e" + "Mob Type: "
+ ((MobSpawnerBlock) block).getMobType());
TextComponent.Builder builder = TextComponent.builder();
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
if (internalId.isPresent()) {
builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID"))));
}
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
player.print(builder.build());
return true;
}