use of net.md_5.bungee.api.chat.HoverEvent in project solinia3-core by mixxit.
the class Solinia3CoreItemPickupListener method PickupItem.
@EventHandler
public void PickupItem(PlayerPickupItemEvent e) {
ItemStack pickedUpItemStack = e.getItem().getItemStack();
// Replace oxygen items with durability items
if (pickedUpItemStack.getEnchantmentLevel(Enchantment.OXYGEN) > 999) {
e.getPlayer().sendMessage("Detected an item in the old format, converting to the new format. Please drop all your old items and pick them up if you are having problems with them");
try {
ISoliniaItem latestitem = StateManager.getInstance().getConfigurationManager().getItemByOxygen(pickedUpItemStack);
if (pickedUpItemStack != null) {
if (latestitem != null) {
ItemStack latestitemstack = latestitem.asItemStack();
pickedUpItemStack.setItemMeta(latestitemstack.getItemMeta());
} else {
// this is an item that is broken
e.getPlayer().sendMessage("This item is no longer implemented");
Utils.CancelEvent(e);
e.getItem().remove();
}
}
} catch (CoreStateInitException eOxy) {
}
}
String temporaryGuid = null;
Integer augmentationItemId = null;
try {
if (Utils.IsSoliniaItem(pickedUpItemStack) && pickedUpItemStack.getType().equals(Material.ENCHANTED_BOOK)) {
e.getPlayer().sendMessage(ChatColor.GRAY + "You have picked up an ability! To use it, hold it in your hand and right click!");
ISoliniaItem latestitem = StateManager.getInstance().getConfigurationManager().getItem(pickedUpItemStack);
if (pickedUpItemStack != null) {
if (latestitem != null) {
ItemStack latestitemstack = latestitem.asItemStack();
pickedUpItemStack.setItemMeta(latestitemstack.getItemMeta());
} else {
// this is an item that is broken
e.getPlayer().sendMessage("This item is no longer implemented");
Utils.CancelEvent(e);
e.getItem().remove();
}
}
if (latestitem.getDiscoverer() == null || latestitem.getDiscoverer().equals("")) {
latestitem.setDiscoverer(e.getPlayer().getCustomName());
e.getPlayer().getServer().broadcastMessage(ChatColor.YELLOW + "* " + latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
StateManager.getInstance().getChannelManager().sendToDiscordMC(null, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
}
}
if (Utils.IsSoliniaItem(pickedUpItemStack) && !(pickedUpItemStack.getType().equals(Material.ENCHANTED_BOOK))) {
Map<Enchantment, Integer> oldenchantments = pickedUpItemStack.getEnchantments();
ISoliniaItem latestitem = StateManager.getInstance().getConfigurationManager().getItem(pickedUpItemStack);
if (latestitem.getDiscoverer() == null || latestitem.getDiscoverer().equals("")) {
latestitem.setDiscoverer(e.getPlayer().getCustomName());
e.getPlayer().getServer().broadcastMessage(ChatColor.YELLOW + "* " + latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
StateManager.getInstance().getChannelManager().sendToDiscordMC(null, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
}
if (pickedUpItemStack != null) {
ItemStack latestitemstack = latestitem.asItemStack();
// We need to store this information before we change the itemmeta, so we can update it afterwards
if (latestitem.isTemporary()) {
temporaryGuid = ItemStackUtils.getTemporaryItemGuid(pickedUpItemStack);
}
augmentationItemId = ItemStackUtils.getAugmentationItemId(pickedUpItemStack);
// Now go and replace the itemmeta
pickedUpItemStack.setItemMeta(latestitemstack.getItemMeta());
// Now re-apply enchantments that it had before
for (Map.Entry<Enchantment, Integer> entry : oldenchantments.entrySet()) {
Enchantment key = entry.getKey();
Integer value = entry.getValue();
if (value < 1000) {
pickedUpItemStack.addUnsafeEnchantment(key, value);
}
}
// Since the item is temporary, attempt to apply the temporary timestamp it had prior to this
if (latestitem.isTemporary()) {
pickedUpItemStack.setItemMeta(ItemStackUtils.applyTemporaryStamp(pickedUpItemStack, temporaryGuid));
}
if (augmentationItemId != null && augmentationItemId != 0) {
pickedUpItemStack.setItemMeta(ItemStackUtils.applyAugmentationToItemStack(pickedUpItemStack, augmentationItemId));
}
}
}
// group messages
if (Utils.IsSoliniaItem(pickedUpItemStack)) {
ISoliniaItem item;
try {
item = SoliniaItemAdapter.Adapt(pickedUpItemStack);
if (item.getAllowedClassNames().size() > 0) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(e.getPlayer());
if (solPlayer.getGroup() != null && solPlayer.getGroup().getMembers() != null)
for (UUID playerUuid : solPlayer.getGroup().getMembers()) {
if (playerUuid.equals(e.getPlayer().getUniqueId()))
continue;
Player groupMember = Bukkit.getPlayer(playerUuid);
ISoliniaPlayer groupSolPlayer = SoliniaPlayerAdapter.Adapt(groupMember);
if (groupSolPlayer != null) {
if (groupSolPlayer.getClassObj() != null)
if (item.getAllowedClassNames().contains(groupSolPlayer.getClassObj().getName().toUpperCase())) {
TextComponent tc = new TextComponent();
tc.setText("* " + groupSolPlayer.getFullName() + " picked up an item of interest to your class: [" + ChatColor.AQUA + item.getDisplayname() + ChatColor.RESET + "]");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(item.asJsonString()).create()));
groupSolPlayer.getBukkitPlayer().spigot().sendMessage(tc);
}
}
}
}
} catch (SoliniaItemException e1) {
}
}
} catch (CoreStateInitException coreException) {
// do nothing
}
}
use of net.md_5.bungee.api.chat.HoverEvent in project solinia3-core by mixxit.
the class CommandCharacter method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
if (args.length == 0) {
player.sendMessage("Your Characters: ");
String main = "ALT";
if (solplayer.isMain()) {
main = "MAIN";
}
player.sendMessage("- " + ChatColor.LIGHT_PURPLE + solplayer.getFullNameWithTitle() + ChatColor.RESET + " " + main + " - " + ChatColor.GREEN + "ACTIVE" + ChatColor.RESET);
for (ISoliniaPlayer character : StateManager.getInstance().getPlayerManager().getCharactersByPlayerUUID(player.getUniqueId())) {
if (character.getCharacterId().equals(solplayer.getCharacterId()))
continue;
if (character.isMain()) {
main = "MAIN";
} else {
main = "ALT";
}
TextComponent tc = new TextComponent();
tc.setText("- " + ChatColor.LIGHT_PURPLE + character.getFullNameWithTitle() + ChatColor.RESET + " " + main + " - ");
String details = ChatColor.GOLD + character.getFullNameWithTitle() + " Level: " + character.getLevel() + ChatColor.RESET;
TextComponent tc2 = new TextComponent();
String changetext = "/character load " + character.getCharacterId().toString();
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
tc2.setText(ChatColor.RED + "Already changed this session" + ChatColor.RESET);
} else {
tc2.setText(ChatColor.AQUA + "[Click to Switch]" + ChatColor.RESET);
tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, changetext));
}
tc.addExtra(tc2);
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
sender.spigot().sendMessage(tc);
}
player.sendMessage("Note, new characters may not be visible for up to 15 minutes");
player.sendMessage("Use '/character new' to create a new character");
} else {
switch(args[0].toUpperCase()) {
case "NEW":
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
player.sendMessage("You can only change your character once per server session. Please wait for the next 4 hourly restart");
return true;
}
ISoliniaPlayer newPlayer = StateManager.getInstance().getPlayerManager().createNewPlayerAlt(plugin, player);
if (newPlayer != null) {
player.sendMessage("Your character has been stored and a new character created");
player.sendMessage("Please check you have not dropped any items due to your character change");
} else {
player.sendMessage("Problem creating your new character");
}
break;
case "LOAD":
if (args.length < 2) {
player.sendMessage("You must provide the character UUID");
return true;
}
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
player.sendMessage("You can only change your character once per server session. Please wait for the next 4 hourly restart");
return true;
}
UUID characterUUID = UUID.fromString(args[1]);
ISoliniaPlayer loadedPlayer = StateManager.getInstance().getPlayerManager().loadPlayerAlt(plugin, player, characterUUID);
if (loadedPlayer != null) {
player.sendMessage("Your character has been stored and your new character loaded");
player.sendMessage("Please check you have not dropped any items due to your character change");
} else {
player.sendMessage("Problem loading requested character");
}
break;
default:
player.sendMessage("Unknown character subcommand");
break;
}
}
} catch (CoreStateInitException e) {
}
return true;
}
use of net.md_5.bungee.api.chat.HoverEvent in project solinia3-core by mixxit.
the class Utils method sendRaceInfo.
public static void sendRaceInfo(CommandSender sender) throws CoreStateInitException {
List<ISoliniaClass> classes = StateManager.getInstance().getConfigurationManager().getClasses();
for (ISoliniaRace race : StateManager.getInstance().getConfigurationManager().getRaces()) {
if (race.isAdmin())
continue;
String classBuilder = "";
for (ISoliniaClass solclass : classes) {
if (solclass.getValidRaces().contains(race.getId()))
classBuilder += solclass.getName() + " ";
}
TextComponent tc = new TextComponent();
tc.setText(ChatColor.RED + "~ RACE: " + ChatColor.GOLD + race.getName().toUpperCase() + ChatColor.GRAY + " [" + race.getId() + "] - " + ChatColor.RESET);
TextComponent tc2 = new TextComponent();
tc2.setText("Hover for more details");
String details = ChatColor.GOLD + race.getName() + ChatColor.RESET + "\nRecommended Alignment: " + ChatColor.GOLD + race.getAlignment() + ChatColor.RESET + "\n" + race.getDescription() + "\nSTR: " + ChatColor.GOLD + race.getStrength() + ChatColor.RESET + " STA: " + ChatColor.GOLD + race.getStamina() + ChatColor.RESET + " AGI: " + ChatColor.GOLD + race.getAgility() + ChatColor.RESET + " DEX: " + ChatColor.GOLD + race.getDexterity() + ChatColor.RESET + " INT: " + ChatColor.GOLD + race.getIntelligence() + ChatColor.RESET + " WIS: " + ChatColor.GOLD + race.getWisdom() + ChatColor.RESET + " CHA: " + ChatColor.GOLD + race.getCharisma() + ChatColor.GOLD + " \nClasses: " + ChatColor.RESET + classBuilder;
tc2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
tc.addExtra(tc2);
sender.spigot().sendMessage(tc);
}
}
use of net.md_5.bungee.api.chat.HoverEvent in project Ublisk by Derkades.
the class PlayerInteractEntity method onPlayerInteractEntityEvent.
@EventHandler
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getHand() != EquipmentSlot.HAND)
return;
Entity entity = event.getRightClicked();
final UPlayer player = new UPlayer(event);
if (entity instanceof ArmorStand && player.getGameMode() != GameMode.CREATIVE) {
event.setCancelled(true);
}
if (entity instanceof Player && player.isSneaking()) {
UPlayer target = new UPlayer(entity);
BaseComponent[] stats = new ComponentBuilder("View statistics").bold(true).color(DARK_AQUA).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to open website").color(GOLD).create())).event(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://ublisk.robinmc.com/stats/player.php?player=" + target.getName())).create();
BaseComponent[] addAsFriend = new ComponentBuilder("Add as friend").bold(true).color(DARK_AQUA).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to run /friend add " + target.getName()).color(GOLD).create())).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend add " + target.getName())).create();
BaseComponent[] inviteToGuild = new ComponentBuilder("Invite to guild").bold(true).color(DARK_AQUA).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to run /guild invite " + target.getName()).color(GOLD).create())).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/guild invite " + target.getName())).create();
player.sendSpacers(2);
player.sendMessage(stats);
player.sendMessage(addAsFriend);
player.sendMessage(inviteToGuild);
}
}
use of net.md_5.bungee.api.chat.HoverEvent in project Ublisk by Derkades.
the class Guild method invitePlayer.
public synchronized void invitePlayer(final UPlayer source, final UPlayer target) {
if (!this.exists())
throw new UnsupportedOperationException("Cannot invite player to non-existent guild.");
final GuildInvite invite = new GuildInvite(this, source);
// Add invite to list of invites, and remove it after 60 seconds (if it hasn't been accepted)
GUILD_INVITES.put(target.getName(), invite);
new BukkitRunnable() {
public void run() {
if (GUILD_INVITES.containsKey(target.getName())) {
GUILD_INVITES.remove(target.getName());
}
}
}.runTaskLater(Main.getInstance(), 60 * 20);
TextComponent inviteMessage = new TextComponent(source.getName() + " has invited you to join " + this.getName() + ". ");
inviteMessage.setColor(ChatColor.DARK_AQUA);
inviteMessage.setBold(true);
BaseComponent[] hoverText = new ComponentBuilder("Click me!").color(ChatColor.YELLOW).create();
TextComponent clickToAccept = new TextComponent("Click here to accept.");
clickToAccept.setColor(ChatColor.AQUA);
clickToAccept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText));
clickToAccept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/guild accept"));
BaseComponent[] components = new BaseComponent[] { inviteMessage, clickToAccept };
target.sendMessage(components);
}
Aggregations