use of net.md_5.bungee.api.chat.hover.content.Text in project Denizen-For-Bukkit by DenizenScript.
the class HoverFormatHelper method processHoverInput.
public static boolean processHoverInput(HoverEvent.Action action, TextComponent hoverableText, String input) {
Content content;
if (action == HoverEvent.Action.SHOW_ITEM) {
ItemTag item = ItemTag.valueOf(FormattedTextHelper.unescape(input), CoreUtilities.noDebugContext);
if (item == null) {
return true;
}
// TODO: Why is there not a direct conversion method for Spigot ItemStack -> BungeeChat Item?
String itemNbt = NMSHandler.getItemHelper().getRawHoverText(item.getItemStack());
content = new Item(item.getBukkitMaterial().getKey().toString(), item.getAmount(), net.md_5.bungee.api.chat.ItemTag.ofNbt(itemNbt));
} else if (action == HoverEvent.Action.SHOW_ENTITY) {
EntityTag entity = EntityTag.valueOf(FormattedTextHelper.unescape(input), CoreUtilities.basicContext);
if (entity == null) {
return true;
}
BaseComponent name = null;
if (entity.getBukkitEntity() != null && entity.getBukkitEntity().isCustomNameVisible()) {
name = new TextComponent();
for (BaseComponent component : FormattedTextHelper.parse(entity.getBukkitEntity().getCustomName(), ChatColor.WHITE)) {
name.addExtra(component);
}
}
content = new Entity(entity.getBukkitEntityType().getKey().toString(), entity.getUUID().toString(), name);
} else {
content = new Text(FormattedTextHelper.parse(FormattedTextHelper.unescape(input), ChatColor.WHITE));
}
hoverableText.setHoverEvent(new HoverEvent(action, content));
return false;
}
use of net.md_5.bungee.api.chat.hover.content.Text in project VotingPlugin by Ben12345rocks.
the class VoteCache method addVote.
public void addVote(String server, int num, OfflineBungeeVote voteData) {
Configuration section = getData().getSection("VoteCache." + server + "." + num);
section.set("Name", voteData.getPlayerName());
section.set("Service", voteData.getService());
section.set("UUID", voteData.getUuid());
section.set("Time", voteData.getTime());
section.set("Real", voteData.isRealVote());
section.set("Text", voteData.getText());
}
use of net.md_5.bungee.api.chat.hover.content.Text in project VotingPlugin by Ben12345rocks.
the class VoteCache method addVoteOnline.
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
Configuration section = getData().getSection("OnlineCache." + player + "." + num);
section.set("Name", voteData.getPlayerName());
section.set("Service", voteData.getService());
section.set("UUID", voteData.getUuid());
section.set("Time", voteData.getTime());
section.set("Real", voteData.isRealVote());
section.set("Text", voteData.getText());
}
use of net.md_5.bungee.api.chat.hover.content.Text in project VotingPlugin by Ben12345rocks.
the class AdminVoteHelp method adminHelpText.
/**
* Admin help text.
*
* @param sender the sender
* @return the array list
*/
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
if (!requirePerms || cmdHandle.hasPerm(sender)) {
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
msg.add(unsorted.get(cmd));
}
return msg;
}
use of net.md_5.bungee.api.chat.hover.content.Text in project solinia3-core by mixxit.
the class PlayerUtils method sendCharCreationNoMod.
private static void sendCharCreationNoMod(Player sender) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) book.getItemMeta();
bookMeta.setTitle("Creation");
bookMeta.setAuthor("Server");
try {
CharacterCreation choices = StateManager.getInstance().getConfigurationManager().getCharacterCreationChoices();
String pageText = "";
BaseComponent[] introPage = new ComponentBuilder(ChatColor.RED + "Race/Class Selection\n" + ChatColor.RESET + "---------------\n" + "\n" + "Please cycle through\n" + "our choice of races\n" + "and classes\n" + "\n" + "When you are ready \n" + "click " + ChatColor.BLUE + "SELECT" + ChatColor.RESET + " on the page\n").create();
bookMeta.spigot().addPage(introPage);
for (String choiceKey : choices.raceChoices.keySet()) {
RaceChoice choice = choices.raceChoices.get(choiceKey);
int passiveId = StateManager.getInstance().getConfigurationManager().getRace(choice.RaceId).getPassiveAbilityId();
ISoliniaSpell passiveSpell = StateManager.getInstance().getConfigurationManager().getSpell(passiveId);
String header = ChatColor.RED + "" + choice.RaceName + " " + choice.ClassName + ChatColor.RESET + "\n";
String hover = "[" + ChatColor.RED + "Hover for More Info" + ChatColor.RESET + "]\n";
String text = "";
text += "\n";
text += "STR " + ChatColor.BLUE + choice.STR + ChatColor.RESET + " STA " + ChatColor.BLUE + choice.STA + ChatColor.RESET + " AGI " + ChatColor.BLUE + choice.AGI + ChatColor.RESET + "\n";
text += "DEX " + ChatColor.BLUE + choice.DEX + ChatColor.RESET + " INT " + ChatColor.BLUE + choice.INT + ChatColor.RESET + " WIS " + ChatColor.BLUE + choice.WIS + ChatColor.RESET + "\n";
text += "CHA " + ChatColor.BLUE + choice.CHA + ChatColor.RESET + "\n";
text += "\n";
text += "Racial Benefit: " + ChatColor.RED + passiveSpell.getName() + ChatColor.RESET + "\n";
text += "\n";
String details = ChatColor.GOLD + choice.RaceName + ChatColor.RESET + System.lineSeparator() + "Recommended Alignment: " + ChatColor.GOLD + choice.Alignment + ChatColor.RESET + System.lineSeparator() + choice.RaceDescription + System.lineSeparator() + ChatColor.GOLD + choice.ClassName + ChatColor.RESET + System.lineSeparator() + choice.ClassDescription;
String click = "\n[" + ChatColor.BLUE + "SELECT" + ChatColor.RESET + "]\n";
BaseComponent[] racePage = new ComponentBuilder(header).append(new ComponentBuilder(hover).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create())).create()).append(new ComponentBuilder(text).create()).append(new ComponentBuilder(click).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/createcharactershort " + choice.RaceId + " " + choice.ClassId)).create()).create();
//
// )
bookMeta.spigot().addPage(racePage);
}
/* .event(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://spigotmc.org"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Go to the spigot website!").create()))
.create();*/
book.setItemMeta(bookMeta);
sender.openBook(book);
} catch (CoreStateInitException e) {
}
}
Aggregations