Fixed in-game links not working in 1.8

This commit is contained in:
Rsl1122 2020-11-07 13:25:15 +02:00
parent a9fa739c2a
commit 912850f1ab

View File

@ -22,6 +22,8 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.HoverEvent;
import org.apache.commons.text.TextStringBuilder; import org.apache.commons.text.TextStringBuilder;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -133,6 +135,11 @@ class BukkitPartBuilder implements MessageBuilder {
} }
// CommandSender#spigot#sendMessage(BaseComponent[]) is not supported on 1.8 // CommandSender#spigot#sendMessage(BaseComponent[]) is not supported on 1.8
current.sender.sender.sendMessage(BaseComponent.toLegacyText(components.toArray(new BaseComponent[0]))); CommandSender commandSender = current.sender.sender;
if (commandSender instanceof Player) {
((Player) commandSender).spigot().sendMessage(components.toArray(new BaseComponent[0]));
} else {
commandSender.sendMessage(BaseComponent.toLegacyText(components.toArray(new BaseComponent[0])));
}
} }
} }