aboutsummaryrefslogtreecommitdiff
path: root/spark-bungeecord/src
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2020-11-07 17:41:39 +0000
committerLuck <git@lucko.me>2020-11-07 17:41:39 +0000
commit8cc92ff83634dffacfe1f25a135bc9ac665ff68b (patch)
tree35efc9d9131c7ceb1db3822fbb6a0707535f7c18 /spark-bungeecord/src
parent70a468e114316a98f6d7f7e91afa8d50639762c9 (diff)
downloadspark-8cc92ff83634dffacfe1f25a135bc9ac665ff68b.tar.gz
spark-8cc92ff83634dffacfe1f25a135bc9ac665ff68b.tar.bz2
spark-8cc92ff83634dffacfe1f25a135bc9ac665ff68b.zip
Update from text to adventure
Diffstat (limited to 'spark-bungeecord/src')
-rw-r--r--spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java13
-rw-r--r--spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java10
2 files changed, 14 insertions, 9 deletions
diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java
index 27d3811..51d1a7d 100644
--- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java
+++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordCommandSender.java
@@ -20,18 +20,21 @@
package me.lucko.spark.bungeecord;
-
import me.lucko.spark.common.command.sender.AbstractCommandSender;
-import net.kyori.text.Component;
-import net.kyori.text.adapter.bungeecord.TextAdapter;
+import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
+import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.UUID;
public class BungeeCordCommandSender extends AbstractCommandSender<CommandSender> {
- public BungeeCordCommandSender(CommandSender sender) {
+ private final Audience audience;
+
+ public BungeeCordCommandSender(CommandSender sender, BungeeAudiences audienceFactory) {
super(sender);
+ this.audience = audienceFactory.sender(sender);
}
@Override
@@ -49,7 +52,7 @@ public class BungeeCordCommandSender extends AbstractCommandSender<CommandSender
@Override
public void sendMessage(Component message) {
- TextAdapter.sendMessage(super.delegate, message);
+ this.audience.sendMessage(message);
}
@Override
diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java
index 5a3ad23..c3be5f4 100644
--- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java
+++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java
@@ -23,6 +23,7 @@ package me.lucko.spark.bungeecord;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.SparkPlugin;
import me.lucko.spark.common.platform.PlatformInfo;
+import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin;
@@ -32,11 +33,12 @@ import java.nio.file.Path;
import java.util.stream.Stream;
public class BungeeCordSparkPlugin extends Plugin implements SparkPlugin {
-
+ private BungeeAudiences audienceFactory;
private SparkPlatform platform;
@Override
public void onEnable() {
+ this.audienceFactory = BungeeAudiences.create(this);
this.platform = new SparkPlatform(this);
this.platform.enable();
getProxy().getPluginManager().registerCommand(this, new SparkCommand(this));
@@ -67,7 +69,7 @@ public class BungeeCordSparkPlugin extends Plugin implements SparkPlugin {
return Stream.concat(
getProxy().getPlayers().stream().filter(player -> player.hasPermission(permission)),
Stream.of(getProxy().getConsole())
- ).map(BungeeCordCommandSender::new);
+ ).map(sender -> new BungeeCordCommandSender(sender, this.audienceFactory));
}
@Override
@@ -90,12 +92,12 @@ public class BungeeCordSparkPlugin extends Plugin implements SparkPlugin {
@Override
public void execute(CommandSender sender, String[] args) {
- this.plugin.platform.executeCommand(new BungeeCordCommandSender(sender), args);
+ this.plugin.platform.executeCommand(new BungeeCordCommandSender(sender, this.plugin.audienceFactory), args);
}
@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
- return this.plugin.platform.tabCompleteCommand(new BungeeCordCommandSender(sender), args);
+ return this.plugin.platform.tabCompleteCommand(new BungeeCordCommandSender(sender, this.plugin.audienceFactory), args);
}
}
}