Solved Factions 2.13.7 help

Discussion in 'Spigot Plugin Development' started by MehBoss, Feb 14, 2019 at 4:06 AM.

  1. Could anyone help direct me towards an API or assist me?

    Code:
    Code (Text):
            public P factions;

            if (Bukkit.getPluginManager().getPlugin("Factions") != null) {
                this.factions = (P) Bukkit.getPluginManager().getPlugin("Factions");
            } else {
                Bukkit.getPluginManager().disablePlugin(this);
            }
     
    RED-LINED:
    Code (Text):

                Faction currentLoc = Board.getInstance().getFactionAt(new FLocation(p.getLocation()));
                FPlayer fp = FPlayers.getInstance().getByPlayer(p);
                Faction playersFaction = fp.getFaction();
                if (currentLoc.isSafeZone() || currentLoc.isWarZone() || currentLoc.isWilderness()
                        || currentLoc != playersFaction) {
                    p.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Must-Be-Own-Faction")));
                    return false;
                }
     
    I started making this plugin for an older version of factions and have since then updated it and the following above is now redlined.
     
    #1 MehBoss, Feb 14, 2019 at 4:06 AM
    Last edited: Feb 14, 2019 at 4:29 AM
  2. What you want is:
    Code (Text):

    Faction currentLoc = BoardColl.get().getFactionAt(PS.valueOf(p));
    MPlayer mplayer = MPlayer.get(p);
    Faction playersFaction = mplayer.getFaction();
    if (currentLoc.isNone() || currentLoc != playersFaction) {
       p.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Must-Be-Own-Faction")));
       return false;
    }
     
    Faction#isNone returns true if the faction is the wilderness faction (it can be renamed by server admins, so checking if the name is "Wilderness" isn't helpul). The only difference is, that I didn't include the safezone or warzone check. If you want to reimplement those you can do
    Code (Java):
    faction.getId().equals(Factions.ID_SAFEZONE)
    and
    Code (Java):
    faction.getId().equals(Factions.ID_WARZONE)
    , but will a player ever be a member of one of those Factions?

    Also keep in mind that the latest version of MassiveCore Factions is 2.14. Also keep in mind that MassiveCore Factions is discontinued with my own Factions3 being the only continuation.
     
  3. Thank you! I wasn't too far off, when I updated it myself the import com.massivecraft.factions.entity.Faction; would never import itself so I had to do it manually.
     

Share This Page