use of net.minecraft.command.CommandSource in project Bookshelf by Darkhax-Minecraft.
the class CommandHand method hand.
private int hand(CommandContext<CommandSource> context) throws CommandSyntaxException {
final OutputType type = context.getArgument("type", OutputType.class);
final ServerPlayerEntity player = context.getSource().getPlayerOrException();
final String outputText = type.converter.apply(player.getMainHandItem());
final ITextComponent component = TextComponentUtils.wrapInSquareBrackets(new StringTextComponent(outputText).withStyle((style) -> {
return style.withColor(TextFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, outputText)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent("chat.copy.click"))).withInsertion(outputText);
}));
context.getSource().sendSuccess(component, false);
return 0;
}
Aggregations