Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Get it all working
Dieser Commit ist enthalten in:
Ursprung
5a18ed275f
Commit
c52eb59d7f
@ -86,6 +86,7 @@ subprojects {
|
||||
mavenCentral()
|
||||
maven { url "http://maven.sk89q.com/repo/" }
|
||||
maven { url "http://repo.maven.apache.org/maven2" }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,6 @@ shadowJar {
|
||||
include(dependency(':worldedit-core'))
|
||||
include(dependency('org.slf4j:slf4j-api'))
|
||||
include(dependency("org.slf4j:slf4j-jdk14"))
|
||||
include(dependency("net.kyori:text-adapter-bukkit:1.0.3"))
|
||||
relocate ("org.bstats", "com.sk89q.worldedit.bukkit.bstats") {
|
||||
include(dependency("org.bstats:bstats-bukkit:1.4"))
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.Subtle;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -753,18 +754,18 @@ public class SelectionCommands {
|
||||
limit.ifPresent(integer -> player.print(integer + " points maximum."));
|
||||
} else {
|
||||
CommandListBox box = new CommandListBox("Selection modes");
|
||||
Component contents = box.getContents();
|
||||
contents.append(new Subtle("Select one of the modes below:").append(Component.newline()));
|
||||
TextComponentProducer contents = box.getContents();
|
||||
contents.append(new Subtle("Select one of the modes below:").append(Component.newline()).create());
|
||||
|
||||
box.appendCommand("cuboid", "Select two corners of a cuboid");
|
||||
box.appendCommand("extend", "Fast cuboid selection mode");
|
||||
box.appendCommand("poly", "Select a 2D polygon with height");
|
||||
box.appendCommand("ellipsoid", "Select an ellipsoid");
|
||||
box.appendCommand("sphere", "Select a sphere");
|
||||
box.appendCommand("cyl", "Select a cylinder");
|
||||
box.appendCommand("convex", "Select a convex polyhedral");
|
||||
box.appendCommand("cuboid", "Select two corners of a cuboid", "//sel cuboid");
|
||||
box.appendCommand("extend", "Fast cuboid selection mode", "//sel extend");
|
||||
box.appendCommand("poly", "Select a 2D polygon with height", "//sel poly");
|
||||
box.appendCommand("ellipsoid", "Select an ellipsoid", "//sel ellipsoid");
|
||||
box.appendCommand("sphere", "Select a sphere", "//sel sphere");
|
||||
box.appendCommand("cyl", "Select a cylinder", "//sel cyl");
|
||||
box.appendCommand("convex", "Select a convex polyhedral", "//sel convex");
|
||||
|
||||
player.print(box);
|
||||
player.print(box.create());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,12 +62,13 @@ 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.util.formatting.component.Subtle;
|
||||
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -670,16 +671,16 @@ public class UtilityCommands {
|
||||
|
||||
// Box
|
||||
CommandListBox box = new CommandListBox(String.format("Help: page %d/%d ", page + 1, pageTotal));
|
||||
Component contents = box.getContents();
|
||||
Component tip = contents.append(TextComponent.of("", TextColor.GRAY));
|
||||
TextComponentProducer tip = new Subtle("");
|
||||
TextComponentProducer contents = box.getContents();
|
||||
|
||||
if (offset >= aliases.size()) {
|
||||
tip.append(new Error(String.format("There is no page %d (total number of pages is %d).", page + 1, pageTotal))).append(Component.newline());
|
||||
tip.append(new Error(String.format("There is no page %d (total number of pages is %d).", page + 1, pageTotal)).create()).append(Component.newline());
|
||||
} else {
|
||||
List<CommandMapping> list = aliases.subList(offset, Math.min(offset + perPage, aliases.size()));
|
||||
|
||||
tip.append(TextComponent.of("Type "));
|
||||
tip.append(new Code("//help ").append(TextComponent.of("<command> [<page>]")));
|
||||
tip.append(new Code("//help ").append(TextComponent.of("<command> [<page>]")).create());
|
||||
tip.append(TextComponent.of(" for more information.")).append(Component.newline());
|
||||
|
||||
// Add each command
|
||||
@ -697,10 +698,11 @@ public class UtilityCommands {
|
||||
}
|
||||
}
|
||||
|
||||
actor.print(box);
|
||||
contents.append(tip.create());
|
||||
actor.print(box.create());
|
||||
} else {
|
||||
CommandUsageBox box = new CommandUsageBox(callable, Joiner.on(" ").join(visited));
|
||||
actor.print(box);
|
||||
actor.print(box.create());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ public final class CommandManager {
|
||||
actor.printError("You are not permitted to do that. Are you in the right mode?");
|
||||
} catch (InvalidUsageException e) {
|
||||
if (e.isFullHelpSuggested()) {
|
||||
actor.print(new CommandUsageBox(e.getCommand(), e.getCommandUsed("/", ""), locals));
|
||||
actor.print(new CommandUsageBox(e.getCommand(), e.getCommandUsed("/", ""), locals).create());
|
||||
String message = e.getMessage();
|
||||
if (message != null) {
|
||||
actor.printError(message);
|
||||
|
@ -19,19 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a command that is to be typed.
|
||||
*/
|
||||
public class Code extends TextComponent {
|
||||
public class Code extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Code(String message) {
|
||||
super(builder(message).color(TextColor.AQUA));
|
||||
getBuilder().content(message).color(TextColor.AQUA);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
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.TextColor;
|
||||
|
||||
public class CommandListBox extends MessageBox {
|
||||
@ -33,14 +35,24 @@ public class CommandListBox extends MessageBox {
|
||||
* @param title the title
|
||||
*/
|
||||
public CommandListBox(String title) {
|
||||
super(title);
|
||||
super(title, new TextComponentProducer());
|
||||
}
|
||||
|
||||
public CommandListBox appendCommand(String alias, String description) {
|
||||
return appendCommand(alias, description, null);
|
||||
}
|
||||
|
||||
public CommandListBox appendCommand(String alias, String description, String insertion) {
|
||||
if (!first) {
|
||||
getContents().append(Component.newline());
|
||||
}
|
||||
getContents().append(TextComponent.of(alias, TextColor.GOLD).append(TextComponent.of(": ")));
|
||||
TextComponent commandName = TextComponent.of(alias, TextColor.GOLD);
|
||||
if (insertion != null) {
|
||||
commandName = commandName
|
||||
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, insertion))
|
||||
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")));
|
||||
}
|
||||
getContents().append(commandName.append(TextComponent.of(": ")));
|
||||
getContents().append(TextComponent.of(description));
|
||||
first = false;
|
||||
return this;
|
||||
|
@ -39,7 +39,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* A box to describe usage of a command.
|
||||
*/
|
||||
public class CommandUsageBox extends TextComponent {
|
||||
public class CommandUsageBox extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new usage box.
|
||||
@ -59,7 +59,6 @@ public class CommandUsageBox extends TextComponent {
|
||||
* @param locals list of locals to use
|
||||
*/
|
||||
public CommandUsageBox(CommandCallable command, String commandString, @Nullable CommandLocals locals) {
|
||||
super(builder());
|
||||
checkNotNull(command);
|
||||
checkNotNull(commandString);
|
||||
if (command instanceof Dispatcher) {
|
||||
@ -82,18 +81,17 @@ public class CommandUsageBox extends TextComponent {
|
||||
}
|
||||
}
|
||||
|
||||
append(box);
|
||||
append(box.create());
|
||||
}
|
||||
|
||||
private void attachCommandUsage(Description description, String commandString) {
|
||||
MessageBox box = new MessageBox("Help for " + commandString);
|
||||
Component contents = box.getContents();
|
||||
TextComponentProducer contents = new TextComponentProducer();
|
||||
|
||||
if (description.getUsage() != null) {
|
||||
contents.append(new Label("Usage: "));
|
||||
contents.append(new Label("Usage: ").create());
|
||||
contents.append(TextComponent.of(description.getUsage()));
|
||||
} else {
|
||||
contents.append(new Subtle("Usage information is not available."));
|
||||
contents.append(new Subtle("Usage information is not available.").create());
|
||||
}
|
||||
|
||||
contents.append(Component.newline());
|
||||
@ -103,10 +101,11 @@ public class CommandUsageBox extends TextComponent {
|
||||
} else if (description.getDescription() != null) {
|
||||
contents.append(TextComponent.of(description.getDescription()));
|
||||
} else {
|
||||
contents.append(new Subtle("No further help is available."));
|
||||
contents.append(new Subtle("No further help is available.").create());
|
||||
}
|
||||
|
||||
append(box);
|
||||
MessageBox box = new MessageBox("Help for " + commandString, contents);
|
||||
append(box.create());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,19 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing an error.
|
||||
*/
|
||||
public class Error extends TextComponent {
|
||||
public class Error extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Error(String message) {
|
||||
super(builder(message).color(TextColor.RED));
|
||||
getBuilder().content(message).color(TextColor.RED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,19 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a label.
|
||||
*/
|
||||
public class Label extends TextComponent {
|
||||
public class Label extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Label(String message) {
|
||||
super(builder(message).color(TextColor.YELLOW));
|
||||
getBuilder().content(message).color(TextColor.YELLOW);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,17 +28,16 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
/**
|
||||
* Makes for a box with a border above and below.
|
||||
*/
|
||||
public class MessageBox extends TextComponent {
|
||||
public class MessageBox extends TextComponentProducer {
|
||||
|
||||
public static final int GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH = 47;
|
||||
private static final int GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH = 47;
|
||||
|
||||
private final Component contents = Component.empty();
|
||||
private final TextComponentProducer contents;
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*/
|
||||
public MessageBox(String title) {
|
||||
super(builder());
|
||||
public MessageBox(String title, TextComponentProducer contents) {
|
||||
checkNotNull(title);
|
||||
|
||||
int leftOver = GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - title.length() - 2;
|
||||
@ -54,7 +53,7 @@ public class MessageBox extends TextComponent {
|
||||
append(TextComponent.of(createBorder(rightSide), TextColor.YELLOW));
|
||||
}
|
||||
append(Component.newline());
|
||||
append(contents);
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
private String createBorder(int count) {
|
||||
@ -66,12 +65,17 @@ public class MessageBox extends TextComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the internal contents.
|
||||
* Gets the message box contents producer.
|
||||
*
|
||||
* @return the contents
|
||||
* @return The contents producer
|
||||
*/
|
||||
public Component getContents() {
|
||||
public TextComponentProducer getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextComponent create() {
|
||||
append(contents.create());
|
||||
return super.create();
|
||||
}
|
||||
}
|
||||
|
@ -19,19 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Represents a subtle part of the message.
|
||||
*/
|
||||
public class Subtle extends TextComponent {
|
||||
public class Subtle extends TextComponentProducer {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Subtle(String message) {
|
||||
super(builder(message).color(TextColor.GRAY));
|
||||
getBuilder().color(TextColor.GRAY).content(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.component;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
|
||||
public class TextComponentProducer {
|
||||
|
||||
private TextComponent.Builder builder = TextComponent.builder().content("");
|
||||
|
||||
public TextComponent.Builder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a component as a child to this Producer
|
||||
*
|
||||
* @param component The component
|
||||
* @return The producer, for chaining
|
||||
*/
|
||||
public TextComponentProducer append(Component component) {
|
||||
getBuilder().append(component);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TextComponent create() {
|
||||
return builder.build();
|
||||
}
|
||||
}
|
@ -102,12 +102,12 @@ project("core") {
|
||||
}
|
||||
project("bukkit") {
|
||||
dependencies {
|
||||
shade 'net.kyori:text-adapter-bukkit:1.0.3'
|
||||
shade 'net.kyori:text-adapter-bukkit:2.0.0-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
project("sponge") {
|
||||
dependencies {
|
||||
shade 'net.kyori:text-adapter-spongeapi:1.0.3'
|
||||
shade 'net.kyori:text-adapter-spongeapi:2.0.0-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren