Factions

Discussion in 'Plugin Development' started by hanahouhanah, Jul 9, 2014.

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

    hanahouhanah

    I've been trying to get this thing to work with factions. For the most part, everything works, but I'm very confused on how to find if the location is in the Wilderness faction.

    I've read through this: http://www.massivecraft.com/faction...m_medium=DocsDeveloper&utm_campaign=BukkitDev

    And figured this would be the best way to go about solving the issue, with the goal being to find out if the faction at the location is neutral, and the faction that is neutral is also not the Wilderness faction and if so, return true.

    Code:java
    1. public boolean inNeutral(Player p, Location loc)
    2. {
    3. UPlayer up = UPlayer.get(p);
    4. Faction faction = BoardColls.get().getFactionAt(PS.valueOf(loc));
    5. if(up.getFaction().getRelationTo(faction) == Rel.NEUTRAL && !FactionColls.get().getForUniverse(faction.getUniverse()).getByName("Wilderness").isNone())
    6. {
    7. return true;
    8. }
    9. return false;
    10. }

    Turns out it doesn't work and it returns false.

    So then I tried this:

    Code:java
    1. public boolean inNeutral(Player p, Location loc)
    2. {
    3. UPlayer up = UPlayer.get(p);
    4. Faction faction = BoardColls.get().getFactionAt(PS.valueOf(loc));
    5. if(up.getFaction().getRelationTo(faction) == Rel.NEUTRAL && !faction.getName().equalsIgnoreCase("wilderness"))
    6. {
    7. return true;
    8. }
    9. return false;
    10. }
    11.  

    This only returns true for some reason. The location would be located in the wilderness, but for some reason will still return as true.
    -
    If anybody can assist on this issue, it'd be great.
    Thanks.
     
  2. Aren't you meant to do:
    Code:
    && faction.getName().equalsIgnoreCase("wilderness"))
    Not
    Code:
    && !faction.getName().equalsIgnoreCase("wilderness"))
     
  3. Offline

    caderape

    i think for wilderness, u have to do like this
    up.getFactionName().contains("wilderness")
     
  4. Offline

    fireblast709

    KingFaris11 not according to the question.
    caderape Would break with a similar name, i.e. '2ndwilderness'. That aside, Wilderness has a name dedicated to it, so equals would be fine (even better as my example shows)
     
    KingFaris11 likes this.
Thread Status:
Not open for further replies.

Share This Page