Search in sources :

Example 6 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project Conquer by xXAndrew28Xx.

the class MSFaction method invite.

@Override
public void invite(ConquerPlayer player) {
    MPlayer mPlayer = ((MSPlayer) player).getRawPlayer();
    Invitation invitation = new Invitation("@console", System.currentTimeMillis());
    faction.invite(mPlayer.getId(), invitation);
}
Also used : Invitation(com.massivecraft.factions.entity.Invitation) MPlayer(com.massivecraft.factions.entity.MPlayer)

Example 7 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project PvPManager by ChanceSD.

the class FactionsHook method canAttack.

@Override
public final boolean canAttack(final Player attacker, final Player defender) {
    final MPlayer fAttacker = MPlayer.get(attacker);
    final MPlayer fDefender = MPlayer.get(defender);
    final Rel rel = fAttacker.getRelationTo(fDefender);
    // Two players without faction are RECRUIT to each other for some weird reason
    return rel.isLessThan(Rel.TRUCE) || rel == Rel.RECRUIT;
}
Also used : Rel(com.massivecraft.factions.Rel) MPlayer(com.massivecraft.factions.entity.MPlayer)

Example 8 with MPlayer

use of com.massivecraft.factions.entity.MPlayer in project ChatBubbles by DrkMatr1984.

the class HandleThreeHD method handleThree.

public static void handleThree(ChatBubbles plugin, String message, Player p) {
    boolean sendOriginal = plugin.getConfig().getBoolean("ChatBubble_Send_Original_Message");
    boolean requirePerm = plugin.getConfig().getBoolean("ConfigOne_Require_Permissions");
    String usePerm = plugin.getConfig().getString("ConfigOne_Use_Permission");
    new BukkitRunnable() {

        @Override
        public void run() {
            if (requirePerm && !p.hasPermission(usePerm))
                return;
            if (plugin.hdHandler.existingHolograms.containsKey(p.getUniqueId())) {
                for (Hologram h : plugin.hdHandler.existingHolograms.get(p.getUniqueId())) {
                    if (!h.isDeleted())
                        h.delete();
                }
            }
            MPlayer mPlayer = MPlayer.get(p);
            String faction = mPlayer.getFactionName();
            final Hologram hologram = HologramsAPI.createHologram(plugin, p.getLocation().add(0.0, plugin.getCBConfig().bubbleOffset, 0.0));
            List<Hologram> hList = new ArrayList<Hologram>();
            hList.add(hologram);
            plugin.hdHandler.existingHolograms.put(p.getUniqueId(), hList);
            hologram.getVisibilityManager().setVisibleByDefault(false);
            for (Player oP : Bukkit.getOnlinePlayers()) {
                if (((plugin.getCBConfig().seeOwnBubble) || (!plugin.getCBConfig().seeOwnBubble && oP.getName() != p.getName())) && (oP.getWorld().getName().equals(p.getWorld().getName()) && oP.getLocation().distance(p.getLocation()) <= plugin.getCBConfig().distance) && (MPlayer.get(oP).getFactionName().equals(faction)) && oP.canSee(p))
                    hologram.getVisibilityManager().showTo(oP);
            }
            int lines = plugin.hdHandler.formatHologramLines(p, hologram, message);
            if (sendOriginal)
                p.chat(message);
            new BukkitRunnable() {

                int ticksRun = 0;

                @Override
                public void run() {
                    ticksRun++;
                    if (!hologram.isDeleted())
                        hologram.teleport(p.getLocation().add(0.0, plugin.getCBConfig().bubbleOffset + .25 * lines, 0.0));
                    if (ticksRun > plugin.getCBConfig().life) {
                        hologram.delete();
                        cancel();
                    }
                }
            }.runTaskTimer(plugin, 1L, 1L);
            if (plugin.getConfig().getBoolean("ChatBubble_Play_Sound")) {
                String sound = plugin.getConfig().getString("ChatBubble_Sound_Name").toLowerCase();
                float volume = (float) plugin.getConfig().getDouble("ChatBubble_Sound_Volume");
                if (!sound.equals("")) {
                    try {
                        p.getWorld().playSound(p.getLocation(), sound, volume, 1.0f);
                    } catch (Exception e) {
                        plugin.getServer().getConsoleSender().sendMessage("Something is wrong in your ChatBubble config.yml sound settings!");
                        plugin.getServer().getConsoleSender().sendMessage("Please ensure that 'ChatBubble_Sound_Name' works in a '/playsound' command test.");
                    }
                }
            }
        }
    }.runTask(plugin);
}
Also used : Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram) Player(org.bukkit.entity.Player) MPlayer(com.massivecraft.factions.entity.MPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) List(java.util.List) ArrayList(java.util.ArrayList) MPlayer(com.massivecraft.factions.entity.MPlayer)

Aggregations

MPlayer (com.massivecraft.factions.entity.MPlayer)8 Faction (com.massivecraft.factions.entity.Faction)5 Player (org.bukkit.entity.Player)4 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 Rel (com.massivecraft.factions.Rel)1 Invitation (com.massivecraft.factions.entity.Invitation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1