Factions Api Help / Directions To Help Needed

Discussion in 'Plugin Development' started by bendbassett, Feb 25, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    bendbassett

    Ive started on a new plugin where, it gets all the players in 2 opposing factions, and it teleports them to an arena, then at the end it counts up how many kills each player got, then determines the winning faction. I haven't found any tutorials/article that explain the api in detail, if you could point me to an article or video then that would be much appreciated. If not here is what i need.

    -Checks Players In A Factions
    -Suppresses Players Power Loss
    -Getting The Faction Name.

    I do not need basic plugin tutorials, i am every experienced just have no clue how to implement the factions API
     
  2. Offline

    nj2miami

    Well, there is no Factions API to begin with, you have to dig in the JAR or docs to see what it is you are looking for.

    Going here first: http://www.massivecraft.com/factions-develop

    Iterate over all Factions:
    Code:
    // Iterating over all Factions
    for (Faction faction : FactionColl.get().getAll())
    {
        // Do something fancy here
    }
    This easily shows you how to get the players factions.

    Code:
    // The faction data class is simply called "Faction".
    Faction faction = null;
    
    // If you have an MPlayer you can get the Faction it belongs to.
    // NOTE: If the player has no faction Wilderness/None will be returned.
    MPlayer mplayer = MPlayer.get(<Player object>);
    faction = mplayer.getFaction();
    EDIT: I thought about the power suppressing and while I do not think there is a direct Faction event you could listen to in order to prevent it, you could listen to the player death event and simply add back the lost power for those who you want to preserve loss.

    That is simply done through the MPlayer method mplayer.setPower(<double>)
     
    Last edited: Feb 25, 2015
Thread Status:
Not open for further replies.

Share This Page