Added tooltips for clickable commands in lookup results
This commit is contained in:
parent
2c8e289c43
commit
70f74ced0f
5 changed files with 62 additions and 6 deletions
|
|
@ -45,7 +45,12 @@ public class SpigotAdapter implements SpigotInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setHoverComponent(Object message, String[] data) {
|
||||
public void addHoverComponent(Object message, String[] data) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHoverEvent(Object message, String text) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class SpigotHandler extends SpigotAdapter implements SpigotInterface {
|
|||
public static ChatColor DARK_AQUA = ChatColor.DARK_AQUA;
|
||||
|
||||
@Override
|
||||
public void setHoverComponent(Object message, String[] data) {
|
||||
public void addHoverComponent(Object message, String[] data) {
|
||||
((TextComponent) message).addExtra(data[2]);
|
||||
}
|
||||
|
||||
|
|
@ -41,10 +41,11 @@ public class SpigotHandler extends SpigotAdapter implements SpigotInterface {
|
|||
if (data[0].equals(Chat.COMPONENT_COMMAND)) {
|
||||
TextComponent component = new TextComponent(TextComponent.fromLegacyText(data[2]));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, data[1]));
|
||||
SpigotAdapter.ADAPTER.setHoverEvent(component, Util.hoverCommandFilter(data[1]));
|
||||
message.addExtra(component);
|
||||
}
|
||||
else if (data[0].equals(Chat.COMPONENT_POPUP)) {
|
||||
SpigotAdapter.ADAPTER.setHoverComponent(message, data);
|
||||
SpigotAdapter.ADAPTER.addHoverComponent(message, data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import org.bukkit.command.CommandSender;
|
|||
|
||||
public interface SpigotInterface {
|
||||
|
||||
public void setHoverComponent(Object message, String[] data);
|
||||
public void addHoverComponent(Object message, String[] data);
|
||||
|
||||
public void setHoverEvent(Object message, String text);
|
||||
|
||||
public void sendComponent(CommandSender sender, String string, String bypass);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class Spigot_v1_16 extends SpigotHandler implements SpigotInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setHoverComponent(Object message, String[] data) {
|
||||
public void addHoverComponent(Object message, String[] data) {
|
||||
try {
|
||||
if (Config.getGlobal().HOVER_EVENTS) {
|
||||
TextComponent component = new TextComponent(TextComponent.fromLegacyText(data[2]));
|
||||
|
|
@ -23,7 +23,7 @@ public class Spigot_v1_16 extends SpigotHandler implements SpigotInterface {
|
|||
((TextComponent) message).addExtra(component);
|
||||
}
|
||||
else {
|
||||
super.setHoverComponent(message, data);
|
||||
super.addHoverComponent(message, data);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
@ -31,4 +31,11 @@ public class Spigot_v1_16 extends SpigotHandler implements SpigotInterface {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHoverEvent(Object component, String text) {
|
||||
if (Config.getGlobal().HOVER_EVENTS) {
|
||||
((TextComponent) component).setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextComponent.fromLegacyText(text))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue