use of net.minecraft.text.Style in project AdvancedChatBox by DarkKronicle.
the class ChatSuggestorGui method showUsages.
private void showUsages(Formatting formatting) {
CommandContextBuilder<CommandSource> commandContextBuilder = this.suggestor.getParse().getContext();
SuggestionContext<CommandSource> suggestionContext = commandContextBuilder.findSuggestionContext(this.textField.getCursor());
Map<CommandNode<CommandSource>, String> map = this.client.player.networkHandler.getCommandDispatcher().getSmartUsage(suggestionContext.parent, this.client.player.networkHandler.getCommandSource());
List<OrderedText> list = new ArrayList<>();
int i = 0;
Style style = Style.EMPTY.withColor(formatting);
for (Map.Entry<CommandNode<CommandSource>, String> commandNodeStringEntry : map.entrySet()) {
if (!(commandNodeStringEntry.getKey() instanceof LiteralCommandNode)) {
list.add(OrderedText.styledForwardsVisitedString(commandNodeStringEntry.getValue(), style));
i = Math.max(i, this.textRenderer.getWidth(commandNodeStringEntry.getValue()));
}
}
if (!list.isEmpty()) {
this.messages.addAll(list);
this.x = MathHelper.clamp(this.textField.getCharacterX(suggestionContext.startPos), 0, this.textField.getCharacterX(0) + this.textField.getInnerWidth() - i);
this.width = i;
}
}
Aggregations