Hi ! i try to get the relation of a player faction to another faction but i don't know how to do :/ here is my code MPlayer up =MPlayer.get(sender); Faction faction =???; if(faction.getRelationTo(up)==Rel.ENEMY){ NameTag.OnTag((Player) sender,"§C[Enemy]"); }
and after : MPlayer up = MPlayer.get(sender); Faction getfaction = up.getFaction(); if(getfaction.getRelationTo(up) == Rel.ENEMY){ NameTag.SetTag((Player) sender, "§C[Enemy]"); }
Code (Text): MPlayer p1 = MPlayer.get(player1); MPlayer p2 = MPlayer.get(player2); Faction faction1 = p1.getFaction(); Faction faction2 = p2.getFaction(); if(faction1.getRelationTo(faction2) == Rel.ENEMY){ // set the nametage for these two players }
Code (Text): for(Player player2 : Bukkit.getOnlinePlayers()){ MPlayer p2 = MPlayer.get(player2); Faction faction2 = p2.getFaction(); MPlayer p1 = MPlayer.get(player1); Faction faction1 = p1.getFaction(); if(faction1.getRelationTo(faction2) == Rel.ENEMY){ NameTag.SetTag(player2, "§c Enemy "); } if(faction1.getRelationTo(faction2) == Rel.NEUTRAL){ NameTag.SetTag(player2, "§f Neutral "); } if(faction1.getRelationTo(faction2) == Rel.ALLY){ NameTag.SetTag(player2, "§a Ally "); } } Work but the player2 prefix return to the Faction1 relation to faction2
That should not be done... ever... Can you first tell us what you're trying to do exactly? Make a command that checks for the factions relations? Something completely irrelevant?
Make a command that checks for the factions relations? Yes exactly and want to change the NameTag of all player connected like this plugin http://dev.bukkit.org/bukkit-plugins/battletags/
If you're making a command I'm assuming you're going to input the faction names. If so you can use the FactionColl utility class. Code (Java): Faction faction = FactionColl.get().getByName("factionName");
i don't want to get by name i want to get all the player faction connected and after put a prefix [Ally], [Enemy] ...
Quite easy to achieve. The FactionColl class provides a method for fetching all factions that are currently on the server. Code (Java): FactionColl.get().getAll()