Fixed velocity builder using wrong method for appending

This commit is contained in:
Risto Lahtela 2020-10-11 14:53:21 +03:00
parent 5a64799e5e
commit 58e674badb
4 changed files with 17 additions and 18 deletions

View File

@ -136,6 +136,7 @@ public class PlanCommand {
command.getAliases().add("planbungee"); command.getAliases().add("planbungee");
command.getAliases().add("planvelocity"); command.getAliases().add("planvelocity");
command.getAliases().add("planproxy"); command.getAliases().add("planproxy");
command.getAliases().add("planp");
} }
return command; return command;
} }
@ -367,10 +368,10 @@ public class PlanCommand {
} }
Optional<String> firstArgument = arguments.get(0); Optional<String> firstArgument = arguments.get(0);
if (!firstArgument.isPresent()) { if (!firstArgument.isPresent()) {
return tabCompleteCache.getMatchingPlayerIdentifiers(null); return tabCompleteCache.getMatchingBackupFilenames(null);
} }
String part = firstArgument.get(); String part = firstArgument.get();
return tabCompleteCache.getMatchingPlayerIdentifiers(part); return tabCompleteCache.getMatchingBackupFilenames(part);
} }
private Subcommand moveCommand() { private Subcommand moveCommand() {

View File

@ -46,7 +46,7 @@ public class HelpFormatter {
String asString = subcommands.stream() String asString = subcommands.stream()
.map(cmd -> .map(cmd ->
m + mainCommand + " " + cmd.getPrimaryAlias() + m + mainCommand + " " + cmd.getPrimaryAlias() +
(sender.supportsChatEvents() ? "" : " " + cmd.getArgumentsAsString()) + "***" + (sender.supportsChatEvents() ? " " : " " + cmd.getArgumentsAsString()) + "***" +
s + cmd.getDescription() + "\n" s + cmd.getDescription() + "\n"
).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append) ).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
.toString(); .toString();

View File

@ -42,8 +42,7 @@ public class NukkitMessageBuilder implements MessageBuilder {
@Override @Override
public MessageBuilder link(String link) { public MessageBuilder link(String link) {
addPart(link); return addPart(link);
return this;
} }
@Override @Override

View File

@ -26,7 +26,7 @@ import java.util.Collection;
public class VelocityMessageBuilder implements MessageBuilder { public class VelocityMessageBuilder implements MessageBuilder {
private final VelocityCMDSender sender; private final VelocityCMDSender sender;
private final TextComponent.Builder builder; private TextComponent.Builder builder;
public VelocityMessageBuilder(VelocityCMDSender sender) { public VelocityMessageBuilder(VelocityCMDSender sender) {
this.sender = sender; this.sender = sender;
@ -35,31 +35,31 @@ public class VelocityMessageBuilder implements MessageBuilder {
@Override @Override
public MessageBuilder addPart(String content) { public MessageBuilder addPart(String content) {
builder.content(content); builder = builder.append(content);
return this; return this;
} }
@Override @Override
public MessageBuilder newLine() { public MessageBuilder newLine() {
builder.content("\n"); builder = builder.append("\n");
return this; return this;
} }
@Override @Override
public MessageBuilder link(String url) { public MessageBuilder link(String url) {
builder.clickEvent(ClickEvent.openUrl(url)); builder = builder.clickEvent(ClickEvent.openUrl(url));
return this; return this;
} }
@Override @Override
public MessageBuilder command(String command) { public MessageBuilder command(String command) {
builder.clickEvent(ClickEvent.runCommand(command)); builder = builder.clickEvent(ClickEvent.runCommand(command));
return this; return this;
} }
@Override @Override
public MessageBuilder hover(String s) { public MessageBuilder hover(String s) {
builder.hoverEvent(HoverEvent.showText(TextComponent.of(s))); builder = builder.hoverEvent(HoverEvent.showText(TextComponent.of(s)));
return this; return this;
} }
@ -67,32 +67,31 @@ public class VelocityMessageBuilder implements MessageBuilder {
public MessageBuilder hover(String... strings) { public MessageBuilder hover(String... strings) {
TextComponent.Builder hoverText = TextComponent.builder(); TextComponent.Builder hoverText = TextComponent.builder();
for (String string : strings) { for (String string : strings) {
hoverText.content(string); hoverText.append(string);
} }
builder.hoverEvent(HoverEvent.showText(hoverText.build())); builder = builder.hoverEvent(HoverEvent.showText(hoverText.build()));
return this; return this;
} }
@Override @Override
public MessageBuilder hover(Collection<String> lines) { public MessageBuilder hover(Collection<String> lines) {
TextComponent.Builder hoverText = TextComponent.builder(); TextComponent.Builder hoverText = TextComponent.builder();
hoverText.content(new TextStringBuilder().appendWithSeparators(lines, "\n").build()); hoverText.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build());
builder.hoverEvent(HoverEvent.showText(hoverText.build())); builder = builder.hoverEvent(HoverEvent.showText(hoverText.build()));
return this; return this;
} }
@Override @Override
public MessageBuilder indent(int amount) { public MessageBuilder indent(int amount) {
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
builder.content(" "); builder = builder.append(" ");
} }
return this; return this;
} }
@Override @Override
public MessageBuilder tabular(CharSequence charSequence) { public MessageBuilder tabular(CharSequence charSequence) {
addPart(sender.getFormatter().table(charSequence.toString(), ":")); return addPart(sender.getFormatter().table(charSequence.toString(), ":"));
return this;
} }
@Override @Override