Search in sources :

Example 26 with FPlayer

use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.

the class Command_mp44 method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (!ConfigEntry.MP44_ENABLED.getBoolean()) {
        msg("The mp44 is currently disabled.", ChatColor.GREEN);
        return true;
    }
    if (args.length == 0) {
        return false;
    }
    FPlayer playerdata = plugin.pl.getPlayer(playerSender);
    if (args[0].equalsIgnoreCase("draw")) {
        playerdata.armMP44();
        msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN);
        msg("Type /mp44 sling to disable.  -by Madgeek1450", ChatColor.GREEN);
        playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.SULPHUR, 1));
    } else {
        playerdata.disarmMP44();
        sender.sendMessage(ChatColor.GREEN + "mp44 Disarmed.");
    }
    return true;
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) ItemStack(org.bukkit.inventory.ItemStack)

Example 27 with FPlayer

use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.

the class Fuckoff method onPlayerMove.

@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove(PlayerMoveEvent event) {
    final Player fuckoffPlayer = event.getPlayer();
    if (plugin.al.isAdmin(fuckoffPlayer)) {
        return;
    }
    for (Player onlinePlayer : server.getOnlinePlayers()) {
        final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
        if (!fPlayer.isFuckOff() || fuckoffPlayer.equals(onlinePlayer)) {
            continue;
        }
        double fuckoffRange = fPlayer.getFuckoffRadius();
        Location opLocation = onlinePlayer.getLocation();
        Location foLocation = fuckoffPlayer.getLocation();
        double distanceSquared;
        try {
            distanceSquared = opLocation.distanceSquared(foLocation);
        } catch (IllegalArgumentException ex) {
            continue;
        }
        if (distanceSquared < (fuckoffRange * fuckoffRange)) {
            event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
            break;
        }
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 28 with FPlayer

use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.

the class AntiNuke method onBlockBreak.

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
    if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean()) {
        return;
    }
    final Player player = event.getPlayer();
    final Location location = event.getBlock().getLocation();
    final FPlayer fPlayer = plugin.pl.getPlayer(player);
    final Location playerLocation = player.getLocation();
    final double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
    boolean outOfRange = false;
    if (!playerLocation.getWorld().equals(location.getWorld())) {
        outOfRange = true;
    } else if (playerLocation.distanceSquared(location) > (nukeMonitorRange * nukeMonitorRange)) {
        outOfRange = true;
    }
    if (outOfRange) {
        if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger()) {
            FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
            plugin.ae.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
            fPlayer.resetFreecamDestroyCount();
            event.setCancelled(true);
            return;
        }
    }
    if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger()) {
        FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
        plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
        fPlayer.resetBlockDestroyCount();
        event.setCancelled(true);
        return;
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 29 with FPlayer

use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.

the class AntiSpam method onAsyncPlayerChat.

@EventHandler(priority = EventPriority.LOW)
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
    final Player player = event.getPlayer();
    String message = event.getMessage().trim();
    final FPlayer playerdata = plugin.pl.getPlayerSync(player);
    // Check for spam
    if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE) {
        FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
        FSync.autoEject(player, "Kicked for spamming chat.");
        playerdata.resetMsgCount();
        event.setCancelled(true);
        return;
    }
    // Check for message repeat
    if (playerdata.getLastMessage().equalsIgnoreCase(message)) {
        FSync.playerMsg(player, "Please do not repeat messages.");
        event.setCancelled(true);
        return;
    }
    playerdata.setLastMessage(message);
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 30 with FPlayer

use of me.totalfreedom.totalfreedommod.player.FPlayer in project TotalFreedomMod by TotalFreedom.

the class AntiSpam method cycle.

private void cycle() {
    for (Player player : server.getOnlinePlayers()) {
        final FPlayer playerdata = plugin.pl.getPlayer(player);
        // TODO: Move each to their own section
        playerdata.resetMsgCount();
        playerdata.resetBlockDestroyCount();
        playerdata.resetBlockPlaceCount();
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player)

Aggregations

FPlayer (me.totalfreedom.totalfreedommod.player.FPlayer)31 Player (org.bukkit.entity.Player)20 EventHandler (org.bukkit.event.EventHandler)15 Location (org.bukkit.Location)6 Vector (org.bukkit.util.Vector)3 ItemStack (org.bukkit.inventory.ItemStack)2 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Admin (me.totalfreedom.totalfreedommod.admin.Admin)1 Material (org.bukkit.Material)1 Sound (org.bukkit.Sound)1 Block (org.bukkit.block.Block)1 Command (org.bukkit.command.Command)1 EntityType (org.bukkit.entity.EntityType)1 LivingEntity (org.bukkit.entity.LivingEntity)1 TNTPrimed (org.bukkit.entity.TNTPrimed)1 PotionEffect (org.bukkit.potion.PotionEffect)1