Skip to content

Commit

Permalink
Use legacy bungeecord hover components
Browse files Browse the repository at this point in the history
Allows us to support 1.13 and up. On versions such as 1.16 the hover text component doesn't exist so instead we can just use legacy text.
  • Loading branch information
virustotalop committed Jul 20, 2024
1 parent 56046b0 commit 966a1ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/magicmq/pyspigot/PluginListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import dev.magicmq.pyspigot.config.PluginConfig;
import dev.magicmq.pyspigot.util.StringUtils;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.*;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -55,9 +55,9 @@ private BaseComponent[] buildMessage(String version) {
pluginPage.setColor(net.md_5.bungee.api.ChatColor.RED);
pluginPage.setUnderlined(true);
pluginPage.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://spigotmc.org/resources/pyspigot.111006/"));
pluginPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(net.md_5.bungee.api.ChatColor.GOLD + "Click to go to the PySpigot plugin page")));
pluginPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6Click to go to the PySpigot plugin page"))));

ComponentBuilder builder = new ComponentBuilder();
ComponentBuilder builder = new ComponentBuilder("");
builder.append("You're running an outdated version of PySpigot. The latest version is " + version + ". ").color(net.md_5.bungee.api.ChatColor.RED).append(pluginPage);
return builder.create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import dev.magicmq.pyspigot.config.PluginConfig;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.*;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

Expand All @@ -48,27 +47,27 @@ public class HelpCommand implements SubCommand {
documentation.setColor(ChatColor.AQUA);
documentation.setUnderlined(true);
documentation.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://pyspigot-docs.magicmq.dev"));
documentation.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.GOLD + "Click to go to the documentation for PySpigot")));
documentation.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6Click to go to the documentation for PySpigot"))));

TextComponent pluginPage = new TextComponent("Spigot Plugin Page");
pluginPage.setColor(ChatColor.AQUA);
pluginPage.setUnderlined(true);
pluginPage.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://spigotmc.org/resources/pyspigot.111006/"));
pluginPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.GOLD + "Click to go to the PySpigot plugin page")));
pluginPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6Click to go to the PySpigot plugin page"))));

TextComponent discord = new TextComponent("PySpigot Discord");
discord.setColor(ChatColor.AQUA);
discord.setUnderlined(true);
discord.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://discord.gg/f2u7nzRwuk"));
discord.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.GOLD + "Click to join the PySpigot Discord server")));
discord.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6Click to join the PySpigot Discord server"))));

TextComponent github = new TextComponent("PySpigot GitHub Repo");
github.setColor(ChatColor.AQUA);
github.setUnderlined(true);
github.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/magicmq/pyspigot/issues"));
github.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(ChatColor.GOLD + "Click to go to the PySpigot GitHub Repo")));
github.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6Click to go to the PySpigot GitHub Repo"))));

ComponentBuilder builder = new ComponentBuilder();
ComponentBuilder builder = new ComponentBuilder("");
builder
.append("\n")
.appendLegacy(PluginConfig.getPrefix() + ChatColor.GREEN + "Some helpful links:").append("\n").reset()
Expand Down

0 comments on commit 966a1ec

Please sign in to comment.