]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/commands/CommandHelper.java
c7cbb0dd11625949d95a3dff4afb9b263b30b819
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / commands / CommandHelper.java
1 package com.irtimaled.bbor.client.commands;
2
3 import com.mojang.brigadier.context.CommandContext;
4 import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
5 import net.minecraft.command.CommandSource;
6 import net.minecraft.util.text.ITextComponent;
7 import net.minecraft.util.text.TextComponentTranslation;
8
9 class CommandHelper {
10     static void feedback(CommandContext<CommandSource> context, String format, Object... values) {
11         context.getSource().sendFeedback(new TextComponentTranslation(format, values), false);
12     }
13
14     static SimpleCommandExceptionType getException(String message, String... values) {
15         ITextComponent textComponent = new TextComponentTranslation(message);
16
17         int length = values.length;
18         if (length > 0) {
19             textComponent.appendText(" (");
20             for (int idx = 0; idx < length; idx++) {
21                 if (idx > 0) textComponent.appendText(", ");
22                 ITextComponent suggestion = new TextComponentTranslation(values[idx]);
23                 textComponent.appendSibling(suggestion);
24             }
25             textComponent.appendText(")");
26         }
27         return new SimpleCommandExceptionType(textComponent);
28     }
29 }