diff options
author | Luck <git@lucko.me> | 2021-04-23 17:48:51 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2021-04-23 17:48:51 +0100 |
commit | d834329f17be3da03d8ecfd1338cb90eacb2ef84 (patch) | |
tree | 1b3ad6ed1d6b8c6b1052bf3e83e25de985020ce3 /spark-sponge/src/main/java/me/lucko | |
parent | ad1e24084dc3d4783aed71f359fac649275aea63 (diff) | |
download | spark-d834329f17be3da03d8ecfd1338cb90eacb2ef84.tar.gz spark-d834329f17be3da03d8ecfd1338cb90eacb2ef84.tar.bz2 spark-d834329f17be3da03d8ecfd1338cb90eacb2ef84.zip |
Switch to adventure-platform without ViaVersion integration (#109)
Diffstat (limited to 'spark-sponge/src/main/java/me/lucko')
-rw-r--r-- | spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java | 11 | ||||
-rw-r--r-- | spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java | 12 |
2 files changed, 8 insertions, 15 deletions
diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java index f4636b7..b2c4b8c 100644 --- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeCommandSender.java @@ -22,21 +22,18 @@ package me.lucko.spark.sponge; import me.lucko.spark.common.command.sender.AbstractCommandSender; -import net.kyori.adventure.audience.Audience; -import net.kyori.adventure.platform.spongeapi.SpongeAudiences; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.text.serializer.TextSerializers; import java.util.UUID; public class SpongeCommandSender extends AbstractCommandSender<CommandSource> { - private final Audience audience; - - public SpongeCommandSender(CommandSource source, SpongeAudiences audienceFactory) { + public SpongeCommandSender(CommandSource source) { super(source); - this.audience = audienceFactory.receiver(source); } @Override @@ -54,7 +51,7 @@ public class SpongeCommandSender extends AbstractCommandSender<CommandSource> { @Override public void sendMessage(Component message) { - this.audience.sendMessage(message); + super.delegate.sendMessage(TextSerializers.JSON.deserialize(GsonComponentSerializer.gson().serialize(message))); } @Override diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java index bfd0c3f..5d11c03 100644 --- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java @@ -29,8 +29,6 @@ import me.lucko.spark.common.platform.PlatformInfo; import me.lucko.spark.common.sampler.ThreadDumper; import me.lucko.spark.common.tick.TickHook; -import net.kyori.adventure.platform.spongeapi.SpongeAudiences; - import org.spongepowered.api.Game; import org.spongepowered.api.command.CommandCallable; import org.spongepowered.api.command.CommandResult; @@ -73,7 +71,6 @@ public class SpongeSparkPlugin implements SparkPlugin { private final Path configDirectory; private final SpongeExecutorService asyncExecutor; - private SpongeAudiences audienceFactory; private SparkPlatform platform; private final ThreadDumper.GameThread threadDumper = new ThreadDumper.GameThread(); @@ -87,7 +84,6 @@ public class SpongeSparkPlugin implements SparkPlugin { @Listener public void onEnable(GameStartedServerEvent event) { - this.audienceFactory = SpongeAudiences.create(this.pluginContainer, this.game); this.platform = new SparkPlatform(this); this.platform.enable(); this.game.getCommandManager().register(this, new SparkCommand(this), "spark"); @@ -118,7 +114,7 @@ public class SpongeSparkPlugin implements SparkPlugin { return Stream.concat( this.game.getServer().getOnlinePlayers().stream(), Stream.of(this.game.getServer().getConsole()) - ).map(source -> new SpongeCommandSender(source, this.audienceFactory)); + ).map(SpongeCommandSender::new); } @Override @@ -156,18 +152,18 @@ public class SpongeSparkPlugin implements SparkPlugin { @Override public CommandResult process(CommandSource source, String arguments) { this.plugin.threadDumper.ensureSetup(); - this.plugin.platform.executeCommand(new SpongeCommandSender(source, this.plugin.audienceFactory), arguments.split(" ")); + this.plugin.platform.executeCommand(new SpongeCommandSender(source), arguments.split(" ")); return CommandResult.empty(); } @Override public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) { - return this.plugin.platform.tabCompleteCommand(new SpongeCommandSender(source, this.plugin.audienceFactory), arguments.split(" ")); + return this.plugin.platform.tabCompleteCommand(new SpongeCommandSender(source), arguments.split(" ")); } @Override public boolean testPermission(CommandSource source) { - return this.plugin.platform.hasPermissionForAnyCommand(new SpongeCommandSender(source, this.plugin.audienceFactory)); + return this.plugin.platform.hasPermissionForAnyCommand(new SpongeCommandSender(source)); } @Override |