Update to Piston 0.5.2 + Doctools/Deprecation improvements (#523)

* Update to Piston 0.5.2

* [Doctools] Fix output, be verbose about deprecations

* Improve deprecation system, doctools output
This commit is contained in:
Kenzie Togami
2019-10-05 02:06:18 -07:00
committed by Matthew Miller
parent d8d25fbff1
commit 03c0cce53e
19 changed files with 205 additions and 67 deletions

View File

@ -0,0 +1,45 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting;
import com.sk89q.worldedit.util.formatting.text.Component;
import org.enginehub.piston.config.ConfigHolder;
import org.enginehub.piston.config.TextConfig;
import org.enginehub.piston.util.TextHelper;
public class WorldEditText {
public static final ConfigHolder CONFIG_HOLDER = ConfigHolder.create();
static {
CONFIG_HOLDER.getConfig(TextConfig.commandPrefix()).setValue("/");
}
public static Component format(Component component) {
return CONFIG_HOLDER.replace(component);
}
public static String reduceToText(Component component) {
return TextHelper.reduceToText(format(component));
}
private WorldEditText() {
}
}

View File

@ -24,9 +24,9 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
import org.enginehub.piston.ColorConfig;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandParameters;
import org.enginehub.piston.config.ColorConfig;
import org.enginehub.piston.util.HelpGenerator;
import javax.annotation.Nullable;
@ -72,15 +72,13 @@ public class CommandUsageBox extends TextComponentProducer {
.append(HelpGenerator.create(commands).getFullHelp());
if (getSubCommands(Iterables.getLast(commands)).size() > 0) {
boxContent.append(TextComponent.newline())
.append(TextComponent.builder("> ")
.color(ColorConfig.getHelpText())
.append(TextComponent.builder("List Subcommands")
.color(ColorConfig.getMainText())
.append(ColorConfig.helpText().wrap(TextComponent.builder("> ")
.append(ColorConfig.mainText().wrap(TextComponent.builder("List Subcommands")
.decoration(TextDecoration.ITALIC, true)
.clickEvent(ClickEvent.runCommand(helpRootCommand + " -s " + commandString))
.hoverEvent(HoverEvent.showText(TextComponent.of("List all subcommands of this command")))
.build())
.build());
.build()))
.build()));
}
MessageBox box = new MessageBox("Help for " + commandString,
boxContent);