Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. @EventHandler
  2. public void newChatFormat(AsyncPlayerChatEvent e) {
  3. final Player p = e.getPlayer();
  4. if (e.getMessage().startsWith("@")) {
  5. String[] arr = e.getMessage().split(" ", 2);
  6. if (arr[0].substring(1) != null) {
  7. String playerMark = arr[0].substring(1);
  8. @SuppressWarnings("deprecation")
  9. Player marcado = p.getServer().getPlayer(playerMark);
  10. if (marcado == p) {
  11. p.sendMessage(ChatColor.RED + "Voce nao pode se marcar.");
  12. e.setCancelled(true);
  13. return;
  14. }
  15. if (marcado == null) {
  16. p.sendMessage(ChatColor.RED + "Player inválido.");
  17. e.setCancelled(true);
  18. return;
  19. }
  20.  
  21.  
  22. e.setFormat(p.getDisplayName() + ": §e" + marcado.getName() + " §f" + e.getMessage().replaceAll("@", "").replaceAll(marcado.getName(), ""));
  23. marcado.playSound(marcado.getLocation(),Sound.SUCCESSFUL_HIT, 1.0F, 0.0F);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement