Make use of updated spigot api to send command-messages in a better way

This commit is contained in:
Lukas Rieger (Blue) 2024-03-29 13:39:12 +01:00
parent 498a4f3190
commit ee3ab6ff9a
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -30,12 +30,12 @@
import de.bluecolored.bluemap.common.serverinterface.CommandSource; import de.bluecolored.bluemap.common.serverinterface.CommandSource;
import de.bluecolored.bluemap.common.serverinterface.ServerWorld; import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.world.World; import de.bluecolored.bluemap.core.world.World;
import net.md_5.bungee.chat.ComponentSerializer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.BlockCommandSender; import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.Optional; import java.util.Optional;
@ -51,17 +51,7 @@ public BukkitCommandSource(Plugin plugin, CommandSender delegate) {
@Override @Override
public void sendMessage(Text text) { public void sendMessage(Text text) {
Bukkit.getScheduler().runTask(BukkitPlugin.getInstance(), () -> { delegate.spigot().sendMessage(ComponentSerializer.parse(text.toJSONString()));
if (delegate instanceof Player) {
Player player = (Player) delegate;
//kinda hacky but works
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tellraw " + player.getName() + " " + text.toJSONString());
return;
}
delegate.sendMessage(text.toPlainString());
});
} }
@Override @Override