mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Fixed issues related to sponge message building
This commit is contained in:
parent
2cf7725b58
commit
98931566a1
@ -71,7 +71,7 @@ subprojects {
|
||||
ext.bukkitVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
ext.spigotVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
ext.paperVersion = "1.13.2-R0.1-SNAPSHOT"
|
||||
ext.spongeVersion = "7.1.0"
|
||||
ext.spongeVersion = "7.3.0"
|
||||
ext.nukkitVersion = "1.0-SNAPSHOT"
|
||||
ext.bungeeVersion = "1.16-R0.3"
|
||||
ext.velocityVersion = "1.0.0-SNAPSHOT"
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.commands.use;
|
||||
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.action.TextActions;
|
||||
import plan.org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@ -27,16 +28,23 @@ public class SpongeMessageBuilder implements MessageBuilder {
|
||||
|
||||
private final SpongeCMDSender sender;
|
||||
private final Text.Builder builder;
|
||||
private final SpongeMessageBuilder previous;
|
||||
|
||||
public SpongeMessageBuilder(SpongeCMDSender sender) {
|
||||
this(sender, null);
|
||||
}
|
||||
|
||||
SpongeMessageBuilder(SpongeCMDSender sender, SpongeMessageBuilder previous) {
|
||||
this.sender = sender;
|
||||
builder = Text.builder();
|
||||
this.builder = Text.builder();
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageBuilder addPart(String s) {
|
||||
builder.append(Text.of(s));
|
||||
return this;
|
||||
SpongeMessageBuilder newBuilder = new SpongeMessageBuilder(sender, this);
|
||||
newBuilder.builder.append(Text.of(s));
|
||||
return newBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,7 +65,7 @@ public class SpongeMessageBuilder implements MessageBuilder {
|
||||
|
||||
@Override
|
||||
public MessageBuilder command(String command) {
|
||||
builder.onClick(TextActions.runCommand(command.charAt(0) == '/' ? command.substring(1) : command));
|
||||
builder.onClick(TextActions.runCommand(command.charAt(0) == '/' ? command : '/' + command));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -68,14 +76,14 @@ public class SpongeMessageBuilder implements MessageBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageBuilder hover(String... strings) {
|
||||
builder.onHover(TextActions.showText(Text.of((Object[]) strings)));
|
||||
public MessageBuilder hover(String... lines) {
|
||||
builder.onHover(TextActions.showText(Text.of(new TextStringBuilder().appendWithSeparators(lines, "\n"))));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageBuilder hover(Collection<String> collection) {
|
||||
builder.onHover(TextActions.showText(Text.of(collection.toArray())));
|
||||
public MessageBuilder hover(Collection<String> lines) {
|
||||
builder.onHover(TextActions.showText(Text.of(new TextStringBuilder().appendWithSeparators(lines, "\n"))));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -95,6 +103,11 @@ public class SpongeMessageBuilder implements MessageBuilder {
|
||||
|
||||
@Override
|
||||
public void send() {
|
||||
sender.source.sendMessage(builder.build());
|
||||
if (previous == null) {
|
||||
sender.source.sendMessage(builder.build());
|
||||
} else {
|
||||
previous.builder.append(builder.build());
|
||||
previous.send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user