@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { if (!(Settings.CHAT_ENABLED)) { return; } if (!(Settings.CHAT_COMPATIBILITY)) { Player player = event.getPlayer(); ChatColor color = ChatColor.WHITE; if (Settings.CHAT_COLORED) { if (player.hasPermission("bending.admin.avatarstate")) { color = PluginTools.getColor(Settings.getColor(BendingElement.ENERGY)); } else { BendingPlayer bender = BendingPlayer.getBendingPlayer(player); List<BendingElement> els = bender.getBendingTypes(); if ((els != null) && els.isEmpty()) { color = PluginTools.getColor(Settings.getColor(els.get(0))); } } } String format = Settings.CHAT_FORMAT; format = format.replace("<message>", "%2$s"); format = format.replace("<name>", color + player.getDisplayName() + ChatColor.RESET); event.setFormat(format); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); Bending.getInstance().getBendingDatabase().lease(player.getUniqueId()); BendingPlayer bender = BendingPlayer.getBendingPlayer(player); if (!(Settings.CHAT_COMPATIBILITY) && (Settings.CHAT_ENABLED)) { player.setDisplayName(player.getName()); } if ((Settings.CHAT_COMPATIBILITY) && (Settings.CHAT_ENABLED)) { ChatColor color = ChatColor.WHITE; if (Settings.CHAT_COLORED) { if (player.hasPermission("bending.avatar")) { color = PluginTools.getColor(Settings.getColor(BendingElement.ENERGY)); } else { List<BendingElement> els = bender.getBendingTypes(); if ((els != null) && !els.isEmpty()) { color = PluginTools.getColor(Settings.getColor(els.get(0))); } } } player.setDisplayName("<" + color + player.getName() + ChatColor.WHITE + ">"); } }
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerDeath(PlayerDeathEvent event) { EntityDamageEvent ede = event.getEntity().getLastDamageCause(); if ((ede != null) && (ede.getCause() != null) && (ede.getCause() == DamageCause.LAVA)) { Player player = event.getEntity(); Location loc = player.getLocation(); LavaTrain lT = LavaTrain.getLavaTrain(loc.getBlock()); if (lT != null) { event.setDeathMessage( player.getName() + " died swimming in " + lT.getPlayer().getName() + "'s lava train"); } } if (ede instanceof BendingDamageEvent) { Player player = event.getEntity(); BendingDamageEvent bede = (BendingDamageEvent) ede; if (bede.getAbility() == null) { event.setDeathMessage(player.getName() + " died from unknown bending"); } else { event.setDeathMessage( ChatColor.DARK_RED + player.getName() + ChatColor.RESET + " died from " + ChatColor.DARK_GREEN + bede.getAbility().getPlayer().getName() + ChatColor.RESET + "'s " + PluginTools.getColor(Settings.getColor(bede.getAbility().getElement())) + bede.getAbility().getName()); } } // Fireblade & Suffocate List<ItemStack> toRemove = new LinkedList<ItemStack>(); for (ItemStack item : event.getDrops()) { if (Suffocate.isTempHelmet(item)) { toRemove.add(item); } } event.getDrops().removeAll(toRemove); if (EntityTools.isGrabed(event.getEntity())) { EntityTools.unGrab(event.getEntity()); } }