Search in sources :

Example 6 with FPlayer

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

the class Command_stfu method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (args.length == 0) {
        return false;
    }
    if (args[0].equals("list")) {
        msg("Muted players:");
        FPlayer info;
        int count = 0;
        for (Player mp : server.getOnlinePlayers()) {
            info = plugin.pl.getPlayer(mp);
            if (info.isMuted()) {
                msg("- " + mp.getName());
                count++;
            }
        }
        if (count == 0) {
            msg("- none");
        }
        return true;
    }
    if (args[0].equals("purge")) {
        FUtil.adminAction(sender.getName(), "Unmuting all players.", true);
        FPlayer info;
        int count = 0;
        for (Player mp : server.getOnlinePlayers()) {
            info = plugin.pl.getPlayer(mp);
            if (info.isMuted()) {
                info.setMuted(false);
                count++;
            }
        }
        msg("Unmuted " + count + " players.");
        return true;
    }
    if (args[0].equals("all")) {
        FUtil.adminAction(sender.getName(), "Muting all non-Superadmins", true);
        FPlayer playerdata;
        int counter = 0;
        for (Player player : server.getOnlinePlayers()) {
            if (!plugin.al.isAdmin(player)) {
                playerdata = plugin.pl.getPlayer(player);
                playerdata.setMuted(true);
                counter++;
            }
        }
        msg("Muted " + counter + " players.");
        return true;
    }
    // -s option (smite)
    boolean smite = args[0].equals("-s");
    if (smite) {
        args = ArrayUtils.subarray(args, 1, args.length);
        if (args.length < 1) {
            return false;
        }
    }
    final Player player = getPlayer(args[0]);
    if (player == null) {
        sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
        return true;
    }
    String reason = null;
    if (args.length > 1) {
        reason = StringUtils.join(args, " ", 1, args.length);
    }
    FPlayer playerdata = plugin.pl.getPlayer(player);
    if (playerdata.isMuted()) {
        FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
        playerdata.setMuted(false);
        msg("Unmuted " + player.getName());
        msg(player, "You have been unmuted.", ChatColor.RED);
    } else {
        if (plugin.al.isAdmin(player)) {
            msg(player.getName() + " is a superadmin, and can't be muted.");
            return true;
        }
        FUtil.adminAction(sender.getName(), "Muting " + player.getName(), true);
        playerdata.setMuted(true);
        if (smite) {
            Command_smite.smite(player);
        }
        if (reason != null) {
            msg(player, "You have been muted. Reason: " + reason, ChatColor.RED);
        } else {
            msg(player, "You have been muted.", ChatColor.RED);
        }
        msg("Muted " + player.getName());
    }
    return true;
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player)

Example 7 with FPlayer

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

the class Muter method onPlayerCommandPreprocess.

@EventHandler(priority = EventPriority.LOW)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();
    FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
    // Block commands if player is muted
    if (!fPlayer.isMuted()) {
        return;
    }
    String message = event.getMessage();
    if (plugin.al.isAdmin(player)) {
        fPlayer.setMuted(false);
        return;
    }
    String cmdName = message.split(" ")[0].toLowerCase();
    if (cmdName.startsWith("/")) {
        cmdName = cmdName.substring(1);
    }
    Command command = server.getPluginCommand(cmdName);
    if (command != null) {
        cmdName = command.getName().toLowerCase();
    }
    if (MUTE_COMMANDS.contains(cmdName)) {
        player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
        event.setCancelled(true);
        return;
    }
    // TODO: Should this go here?
    if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean()) {
        FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) Command(org.bukkit.command.Command) EventHandler(org.bukkit.event.EventHandler)

Example 8 with FPlayer

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

the class Orbiter method onPlayerMove.

@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove(PlayerMoveEvent event) {
    final Player player = event.getPlayer();
    final FPlayer fPlayer = plugin.pl.getPlayer(player);
    if (!fPlayer.isOrbiting()) {
        return;
    }
    if (player.getVelocity().length() < fPlayer.orbitStrength() * (2.0 / 3.0)) {
        player.setVelocity(new Vector(0, fPlayer.orbitStrength(), 0));
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) Vector(org.bukkit.util.Vector) EventHandler(org.bukkit.event.EventHandler)

Example 9 with FPlayer

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

the class AntiSpam method onPlayerCommandPreprocess.

@EventHandler(priority = EventPriority.LOW)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    String command = event.getMessage();
    final Player player = event.getPlayer();
    final FPlayer fPlayer = plugin.pl.getPlayer(player);
    fPlayer.setLastCommand(command);
    if (fPlayer.allCommandsBlocked()) {
        FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
        event.setCancelled(true);
        return;
    }
    if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE) {
        FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
        plugin.ae.autoEject(player, "Kicked for spamming commands.");
        fPlayer.resetMsgCount();
        event.setCancelled(true);
    }
}
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 10 with FPlayer

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

the class ChatManager method handleChatEvent.

private void handleChatEvent(AsyncPlayerChatEvent event) {
    final Player player = event.getPlayer();
    String message = event.getMessage().trim();
    // Strip color from messages
    message = ChatColor.stripColor(message);
    // Truncate messages that are too long - 100 characters is vanilla client max
    if (message.length() > 100) {
        message = message.substring(0, 100);
        FSync.playerMsg(player, "Message was shortened because it was too long to send.");
    }
    // Check for caps
    if (message.length() >= 6) {
        int caps = 0;
        for (char c : message.toCharArray()) {
            if (Character.isUpperCase(c)) {
                caps++;
            }
        }
        if (//Compute a ratio so that longer sentences can have more caps.
        ((float) caps / (float) message.length()) > 0.65) {
            message = message.toLowerCase();
        }
    }
    // Check for adminchat
    final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
    if (fPlayer.inAdminChat()) {
        FSync.adminChatMessage(player, message);
        event.setCancelled(true);
        return;
    }
    // Finally, set message
    event.setMessage(message);
    // Make format
    String format = "<%1$s> %2$s";
    String tag = fPlayer.getTag();
    if (tag != null && !tag.isEmpty()) {
        format = tag.replace("%", "%%") + " " + format;
    }
    // Set format
    event.setFormat(format);
}
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