Coded: L2j clean interlude project
I decided to share with you my faction system(i created from 0), I had planned to open a server but it never happens because of my work.
In the Faction.java class it got in some actions-checks that you can do(setpoints in teams,tele the teams,sethero the teams,remove hero from the teams,clear the points,get the points size,check points and reward the teams,setTeamsColors anyway you will see the code :P)
it got random places to avoid stuck characters(the most shity think in factions when the chars tp all together in a place and get stucked!)
now about the checks: i didn't add any check i think this is easy part you can add it by your self. what i mean? for example teams can't hit teams can't trade etc.
here is the code: http://pastebin.com/ahf9wb04
i forgot to add the method updateNameTitleColor() you can delete it and add this Faction.setTeamsColors(this); and change the public void setTeamsColors(L2PcInstance a) to public static void setTeamsColors(L2PcInstance a) sorry for that i forgot it :P
second: add this in L2World.java
private final Map<Integer, L2PcInstance> _allPlayers;
+private final Map<Integer, L2PcInstance> _allEvils;
+private final Map<Integer, L2PcInstance> _allGoods;
private L2World()
{
_allPlayers = new FastMap<Integer, L2PcInstance>().shared();
+_allEvils = new FastMap<Integer, L2PcInstance>().shared();
+_allGoods = new FastMap<Integer, L2PcInstance>().shared();
and now add the methods
/**
* @return a collection containing all evils in game.
*/
public Map<Integer, L2PcInstance> getAllEvils()
{
return _allEvils;
}
/**
* @return a collection containing all goods in game.
*/
public Map<Integer, L2PcInstance> getAllGoods()
{
return _allGoods;
}
/**
* Return how many players are online.<BR>
* <BR>
* @return number of online players.
*/
public int getAllEvilsCount()
{
return _allEvils.size();
}
/**
* Return how many players are online.<BR>
* <BR>
* @return number of online players.
*/
public int getAllGoodsCount()
{
return _allGoods.size();
}
and now go to public void addVisibleObject find this: _allPlayers.put(player.getObjectId(), player); and make it:
if(player.isEvil())
_allEvils.put(player.getObjectId(), player);
else if(player.isGood())
_allGoods.put(player.getObjectId(), player);
else
_allPlayers.put(player.getObjectId(), player);
Credits Me(Mr.Anonymous)