Update Text to 3

This commit is contained in:
Kenzie Togami 2019-05-05 01:37:11 -07:00 committed by Kenzie Togami
parent 4355f8cbf7
commit 1c54a04fd1
7 changed files with 36 additions and 23 deletions

View File

@ -32,7 +32,7 @@ import org.enginehub.piston.inject.InjectedValueAccess;
import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.sk89q.worldedit.util.formatting.text.Component.space;
import static com.sk89q.worldedit.util.formatting.text.TextComponent.space;
public class CommaSeparatedValuesConverter<T> implements ArgumentConverter<T> {
@ -61,7 +61,7 @@ public class CommaSeparatedValuesConverter<T> implements ArgumentConverter<T> {
TextComponent.Builder result = TextComponent.builder("");
if (maximum > -1) {
result.append(TextComponent.of("up to "))
.append(Component.of(maximum))
.append(TextComponent.of(maximum))
.append(space());
}
result.append(TextComponent.of("comma separated values of: "))

View File

@ -87,16 +87,16 @@ public class CommandListBox extends PaginationBox {
TextComponentProducer line = new TextComponentProducer();
if (!hideHelp) {
line.append(SubtleFormat.wrap("? ")
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "//help " + insertion))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Additional Help"))));
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//help " + insertion))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Additional Help"))));
}
TextComponent command = TextComponent.of(alias, TextColor.GOLD);
if (insertion == null) {
line.append(command);
} else {
line.append(command
.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, insertion))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select"))));
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, insertion))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select"))));
}
return line.append(TextComponent.of(": ")).append(description).create();
}

View File

@ -55,11 +55,11 @@ public class MessageBox extends TextComponentProducer {
if (side > 1) {
line.append(createBorder(side - 1));
}
line.append(Component.space());
line.append(TextComponent.space());
}
line.append(text);
if (side > 0) {
line.append(Component.space());
line.append(TextComponent.space());
if (side > 1) {
line.append(createBorder(side - 1));
}

View File

@ -105,15 +105,15 @@ public abstract class PaginationBox extends MessageBox {
TextComponentProducer navProducer = new TextComponentProducer();
if (page > 1) {
TextComponent prevComponent = TextComponent.of("<<< ", TextColor.GOLD)
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, pageCommand.replace("%page%", String.valueOf(page - 1))))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to navigate")));
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, pageCommand.replace("%page%", String.valueOf(page - 1))))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to navigate")));
navProducer.append(prevComponent);
}
navProducer.append(pageNumberComponent);
if (page < pageCount) {
TextComponent nextComponent = TextComponent.of(" >>>", TextColor.GOLD)
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, pageCommand.replace("%page%", String.valueOf(page + 1))))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to navigate")));
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, pageCommand.replace("%page%", String.valueOf(page + 1))))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to navigate")));
navProducer.append(nextComponent);
}
getContents().append(centerAndBorder(navProducer.create()));

View File

@ -59,12 +59,12 @@ public class SchematicPaginationBox extends PaginationBox {
.content("")
.append(TextComponent.of("[L]")
.color(TextColor.GOLD)
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + path))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to load"))))
.append(Component.space())
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/schem load " + path))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to load"))))
.append(TextComponent.space())
.append(TextComponent.of(path)
.color(TextColor.DARK_GREEN)
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of(format))))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(format))))
.build();
}

View File

@ -58,7 +58,7 @@ public class TextComponentProducer {
* @return The producer, for chaining
*/
public TextComponentProducer newline() {
getBuilder().append(Component.newline());
getBuilder().append(TextComponent.newline());
return this;
}

View File

@ -88,13 +88,14 @@ configure(subprojects + project("core:ap")) {
build.dependsOn(jar, sourcesJar)
}
def textVersion = "3.0.0"
project("core") {
def pistonVersion = '0.1.2'
def pistonVersion = '0.2.0'
dependencies {
shade 'net.kyori:text-api:2.0.0'
shade 'net.kyori:text-serializer-gson:2.0.0'
shade 'net.kyori:text-serializer-legacy:2.0.0'
shade "net.kyori:text-api:$textVersion"
shade "net.kyori:text-serializer-gson:$textVersion"
shade "net.kyori:text-serializer-legacy:$textVersion"
shade('com.sk89q:jchronic:0.2.4a') {
exclude(group: "junit", module: "junit")
}
@ -113,13 +114,25 @@ project("core") {
}
}
project("bukkit") {
repositories {
maven {
name = "SpigotMC"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
}
dependencies {
shade 'net.kyori:text-adapter-bukkit:2.0.0-SNAPSHOT'
shade "net.kyori:text-adapter-bukkit:$textVersion"
}
}
project("sponge") {
repositories {
maven {
name = "Sponge"
url = "https://repo.spongepowered.org/maven"
}
}
dependencies {
shade 'net.kyori:text-adapter-spongeapi:2.0.0-SNAPSHOT'
shade "net.kyori:text-adapter-spongeapi:$textVersion"
}
}