Hello guys, I need your experience! I have to create a placeholder in my plugin, it should work everywhere. For example, i create the placeholder %time% and it should work both in chat and in the scoreboard. For the chat can be used Code (Text): @EventHandler public void onChat(AsyncPlayerChatEvent e){ String message = e.getMessage(); //get the message e.setCancelled(true); //cancel the event, so no message is sent (yet) for(Player on : Bukkit.getOnlinePlayers()){ //loop threw all online players if(message.contains(on.getName())){ //check if the message contains the player's name String newMessage = message.replaceAll(on.getName(), ChatColor.BLUE + ChatColor.UNDERLINE + on.getName() + ChatColor.WHITE); //format the message //change ChatColor.BLUE + ChatColor.UNDERLINE to the formatting you want on.sendMessage(newMessage); //send the player the message on.playNote(on.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A)); //send the player the music } else{ on.sendMessage(message); //else send the player the regular message } } } But for the scoreboard? It should work in any scoreboard, not in my plugin. For example, the player can put the placeholder where he want and it must be replaced everywhere it is. Thanks!
Ah ok, another question? With AsyncPlayerChatEvent I can get all messages sent in chat by player and console or only player? Thanks! For the console what? Because most popular broadcast plugin message use Bukkit.broadcastMessage () so I want to manipulate it when sent. Inviato dal mio SM-G930F utilizzando Tapatalk
Obviously, the asyncplayerchatevent is only for players. To get the messages of the consolesender, you would use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/server/ServerCommandEvent.html