Search in sources :

Example 1 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project Sentinel by mcmonkey4eva.

the class SentinelFactions method isTarget.

@Override
public boolean isTarget(LivingEntity ent, String prefix, String value) {
    try {
        if (prefix.equals("factions") && ent instanceof Player) {
            Faction faction = FactionColl.get().getByName(value);
            for (MPlayer pl : faction.getMPlayers()) {
                if (pl.getPlayer() != null && pl.getPlayer().getUniqueId() != null && pl.getPlayer().getUniqueId().equals(ent.getUniqueId())) {
                    return true;
                }
            }
        } else if (prefix.equals("factionsenemy") && ent instanceof Player) {
            Faction faction = FactionColl.get().getByName(value);
            Faction plf = MPlayer.get(((Player) ent).getUniqueId()).getFaction();
            if (faction.getRelationTo(plf).equals(Rel.ENEMY)) {
                return true;
            }
        } else if (prefix.equals("factionsally") && ent instanceof Player) {
            Faction faction = FactionColl.get().getByName(value);
            Faction plf = MPlayer.get(((Player) ent).getUniqueId()).getFaction();
            if (faction.getRelationTo(plf).equals(Rel.ALLY)) {
                return true;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) MPlayer(com.massivecraft.factions.entity.MPlayer) MPlayer(com.massivecraft.factions.entity.MPlayer) Faction(com.massivecraft.factions.entity.Faction)

Example 2 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project WildLoaders by BG-Software-LLC.

the class ClaimsProvider_MassiveFactions method hasClaimAccess.

@Override
public boolean hasClaimAccess(UUID player, Chunk chunk) {
    MPlayer mPlayer = MPlayer.get(player);
    Faction faction = BoardColl.get().getFactionAt(PS.valueOf(chunk));
    return !faction.getId().equals(Factions.ID_NONE) && faction.getMPlayers().contains(mPlayer);
}
Also used : MPlayer(com.massivecraft.factions.entity.MPlayer) Faction(com.massivecraft.factions.entity.Faction)

Example 3 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project UltimateChat by FabioZumbi12.

the class UCFactionsHook method formatFac.

@Override
public String formatFac(String text, Player sender, Object receiver) {
    MPlayer mp = MPlayer.get(sender.getUniqueId());
    if (!mp.getFaction().isNone()) {
        Faction fac = mp.getFaction();
        text = text.replace("{fac-id}", fac.getId()).replace("{fac-name}", fac.getName());
        if (fac.hasMotd()) {
            text = text.replace("{fac-motd}", fac.getMotd());
        }
        if (fac.hasDescription()) {
            text = text.replace("{fac-description}", fac.getDescription());
        }
        if (receiver instanceof Player) {
            MPlayer recmp = MPlayer.get(((Player) receiver).getUniqueId());
            text = text.replace("{fac-relation-name}", fac.getName(recmp)).replace("{fac-relation-color}", fac.getColorTo(recmp).toString());
        }
    }
    return text;
}
Also used : Player(org.bukkit.entity.Player) MPlayer(com.massivecraft.factions.entity.MPlayer) MPlayer(com.massivecraft.factions.entity.MPlayer) Faction(com.massivecraft.factions.entity.Faction)

Example 4 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project SilkSpawners by timbru31.

the class SilkSpawnersPlayerListener method checkIfFactionsPermitsBlockInteractions.

public boolean checkIfFactionsPermitsBlockInteractions(final Player player, final Block block) {
    if (plugin.config.getBoolean("factionsSupport", false) && su.isPluginEnabled("Factions")) {
        try {
            final MPlayer mp = MPlayer.get(player);
            final Faction blockFaction = BoardColl.get().getFactionAt(PS.valueOf(block.getLocation()));
            if (!blockFaction.isNone() && !mp.isInOwnTerritory()) {
                su.sendMessage(player, ChatColor.translateAlternateColorCodes('\u0026', plugin.localization.getString("changingDeniedFactions")));
                return false;
            }
        } catch (@SuppressWarnings("unused") final NoClassDefFoundError e) {
            // Try for legacy 1.6 factions, e.g. FactionsUUID
            final FPlayers fPlayers = FPlayers.getInstance();
            final FPlayer fPlayer = fPlayers.getByPlayer(player);
            final Board board = Board.getInstance();
            final com.massivecraft.factions.Faction blockFaction = board.getFactionAt(new FLocation(block.getLocation()));
            if (!blockFaction.isWilderness() && !fPlayer.isInOwnTerritory()) {
                su.sendMessage(player, ChatColor.translateAlternateColorCodes('\u0026', plugin.localization.getString("changingDeniedFactions")));
                return false;
            }
        }
    }
    return true;
}
Also used : FPlayer(com.massivecraft.factions.FPlayer) FPlayers(com.massivecraft.factions.FPlayers) Board(com.massivecraft.factions.Board) FLocation(com.massivecraft.factions.FLocation) MPlayer(com.massivecraft.factions.entity.MPlayer) Faction(com.massivecraft.factions.entity.Faction)

Example 5 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project UltimateChat by FabioZumbi12.

the class UCFactionsHook method formatFac.

public static String formatFac(String text, Player sender, Object receiver) {
    MPlayer mp = MPlayer.get(sender.getUniqueId());
    if (!mp.getFaction().isNone()) {
        Faction fac = mp.getFaction();
        text = text.replace("{fac-id}", fac.getId()).replace("{fac-name}", fac.getName());
        if (fac.hasMotd()) {
            text = text.replace("{fac-motd}", fac.getMotd());
        }
        if (fac.hasDescription()) {
            text = text.replace("{fac-description}", fac.getDescription());
        }
        if (receiver instanceof Player) {
            MPlayer recmp = MPlayer.get(((Player) receiver).getUniqueId());
            text = text.replace("{fac-relation-name}", fac.getName(recmp)).replace("{fac-relation-color}", fac.getColorTo(recmp).toString());
        }
    }
    return text;
}
Also used : Player(org.bukkit.entity.Player) MPlayer(com.massivecraft.factions.entity.MPlayer) MPlayer(com.massivecraft.factions.entity.MPlayer) Faction(com.massivecraft.factions.entity.Faction)

Aggregations

MPlayer (com.massivecraft.factions.entity.MPlayer)8 Faction (com.massivecraft.factions.entity.Faction)6 Player (org.bukkit.entity.Player)5 Hologram (com.gmail.filoghost.holographicdisplays.api.Hologram)1 Board (com.massivecraft.factions.Board)1 FLocation (com.massivecraft.factions.FLocation)1 FPlayer (com.massivecraft.factions.FPlayer)1 FPlayers (com.massivecraft.factions.FPlayers)1 Invitation (com.massivecraft.factions.entity.Invitation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1