Replace the message system

This commit is contained in:
Matthew Miller
2019-04-19 23:06:00 +10:00
parent d56cd96282
commit 5b1573a24e
20 changed files with 82 additions and 1180 deletions

View File

@ -58,15 +58,16 @@ import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
import com.sk89q.worldedit.util.formatting.Style;
import com.sk89q.worldedit.util.formatting.StyledFragment;
import com.sk89q.worldedit.util.formatting.component.Code;
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
import com.sk89q.worldedit.util.formatting.component.Error;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import java.util.ArrayList;
import java.util.List;
@ -669,17 +670,17 @@ public class UtilityCommands {
// Box
CommandListBox box = new CommandListBox(String.format("Help: page %d/%d ", page + 1, pageTotal));
StyledFragment contents = box.getContents();
StyledFragment tip = contents.createFragment(Style.GRAY);
Component contents = box.getContents();
Component tip = contents.append(TextComponent.of("", TextColor.GRAY));
if (offset >= aliases.size()) {
tip.createFragment(Style.RED).append(String.format("There is no page %d (total number of pages is %d).", page + 1, pageTotal)).newLine();
tip.append(new Error(String.format("There is no page %d (total number of pages is %d).", page + 1, pageTotal))).append(Component.newline());
} else {
List<CommandMapping> list = aliases.subList(offset, Math.min(offset + perPage, aliases.size()));
tip.append("Type ");
tip.append(new Code().append("//help ").append("<command> [<page>]"));
tip.append(" for more information.").newLine();
tip.append(TextComponent.of("Type "));
tip.append(new Code("//help ").append(TextComponent.of("<command> [<page>]")));
tip.append(TextComponent.of(" for more information.")).append(Component.newline());
// Add each command
for (CommandMapping mapping : list) {
@ -696,10 +697,10 @@ public class UtilityCommands {
}
}
actor.printRaw(ColorCodeBuilder.asColorCodes(box));
actor.print(box);
} else {
CommandUsageBox box = new CommandUsageBox(callable, Joiner.on(" ").join(visited));
actor.printRaw(ColorCodeBuilder.asColorCodes(box));
actor.print(box);
}
}