@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 + ">"); } }