How would I go about setting prefixes for certain players to each individual on the server like faction's enemy/ally system? Thanks.
@Areoace Not sure what this system does, but if you mean prefixes on their names above their heads, you need to use Scoreboard Teams. Speaking of chat names, you need to setDisplayName of the player.
@mine-care I mean like this, If a faction 'A' is enemied to faction 'B' they will show up as red for the players in factions 'B' However if the faction is allied to faction 'C' it will show up us green for faction 'A'
@Areoace Instead of using scoreboard teams, you would have to use Packets and send them to players, depending if they're allied or not.
@FabeGabeMC doubtful, I think I have another way, will get back to you. @mine-care this is what I was going for, @FabeGabeMC this is how I was gonna do it. My issue is I only have 2 people online and if I'm in a clan itll show up blue, and if theyre not in a clan it will show up fine, however when they make a clan it will show up blue for me too. Code: public String getRelation(Player getrelation, Player player) { if(isEnemy(plugin.getplayermanager().getClan(getrelation.getUniqueId().toString()), plugin.getplayermanager().getClan(player.getUniqueId().toString()))) { System.out.println("enemy"); return ChatColor.DARK_RED + plugin.getplayermanager().getClan(player.getUniqueId().toString()) + " " + ChatColor.RED + player.getName() + "" + ChatColor.DARK_RED + " > "; } if(isAlly(plugin.getplayermanager().getClan(getrelation.getUniqueId().toString()), plugin.getplayermanager().getClan(player.getUniqueId().toString()))) { System.out.println("ally"); return ChatColor.DARK_GREEN + plugin.getplayermanager().getClan(player.getUniqueId().toString()) + " " + ChatColor.GREEN + player.getName() + "" + ChatColor.DARK_GREEN + " > "; } if(isTrusted(plugin.getplayermanager().getClan(getrelation.getUniqueId().toString()), plugin.getplayermanager().getClan(player.getUniqueId().toString()))) { System.out.println("trusted"); return ChatColor.AQUA + "*" + ChatColor.DARK_GREEN + plugin.getplayermanager().getClan(player.getUniqueId().toString()) + " " + ChatColor.GREEN + player.getName() + "" + ChatColor.DARK_GREEN + " > "; } if(!plugin.getplayermanager().isInClan(player.getUniqueId().toString())) { System.out.println("neutral"); return ChatColor.YELLOW + player.getName() + "" + ChatColor.GOLD + " > "; } System.out.println("clan"); return ChatColor.DARK_AQUA + plugin.getplayermanager().getClan(player.getUniqueId().toString()) + " " + ChatColor.AQUA + player.getName() + "" + ChatColor.DARK_AQUA + " > "; } EDIT by Moderator: merged posts, please use the edit button instead of double posting. EDIT: Here's my class that I use to send the message Code: @EventHandler public void chatFormat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); for(Player online: plugin.getServer().getOnlinePlayers()) { Player playersonline = (Player) online; event.setCancelled(true); playersonline.sendMessage(plugin.getclanmanager().getRelation(playersonline, player) + ChatColor.RESET + event.getMessage() + ""); } }
@Areoace You said factions so I'm guessing youre hooking into it. I dont know the method but I'm 100% sure there is something that allows you to check who your ally is, then I would loop through online players and set their display name to blue or what ever. or use TagAPI.
@Irantwomiles I'm making my own, I wanna know how they send ChatColor.RED, green, blue ect to each player depending on the relation, so in short getting the relation of whoever says something in chat and sending a message to all online players with the chatcolor of their name being set to their relation
Each player needs there own individual scoreboard, and all the teams needed to be loaded into that scoreboard. Its kind of ridiculous, but you can blame mojang for that. ^ thats for tags above head For ChatColors in the chatbox, Cancel the event, and send the message manually to each player and set the chat color depending on there faction / clans relationship