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