Search in sources :

Example 21 with FPlayer

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

the class Command_tag method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (args.length == 1) {
        if ("list".equalsIgnoreCase(args[0])) {
            msg("Tags for all online players:");
            for (final Player player : server.getOnlinePlayers()) {
                final FPlayer playerdata = plugin.pl.getPlayer(player);
                if (playerdata.getTag() != null) {
                    msg(player.getName() + ": " + playerdata.getTag());
                }
            }
            return true;
        } else if ("clearall".equalsIgnoreCase(args[0])) {
            if (!plugin.al.isAdmin(sender)) {
                noPerms();
                return true;
            }
            FUtil.adminAction(sender.getName(), "Removing all tags", false);
            int count = 0;
            for (final Player player : server.getOnlinePlayers()) {
                final FPlayer playerdata = plugin.pl.getPlayer(player);
                if (playerdata.getTag() != null) {
                    count++;
                    playerdata.setTag(null);
                }
            }
            msg(count + " tag(s) removed.");
            return true;
        } else if ("off".equalsIgnoreCase(args[0])) {
            if (senderIsConsole) {
                msg("\"/tag off\" can't be used from the console. Use \"/tag clear <player>\" or \"/tag clearall\" instead.");
            } else {
                plugin.pl.getPlayer(playerSender).setTag(null);
                msg("Your tag has been removed.");
            }
            return true;
        } else {
            return false;
        }
    } else if (args.length >= 2) {
        if ("clear".equalsIgnoreCase(args[0])) {
            if (!plugin.al.isAdmin(sender)) {
                noPerms();
                return true;
            }
            final Player player = getPlayer(args[1]);
            if (player == null) {
                msg(FreedomCommand.PLAYER_NOT_FOUND);
                return true;
            }
            plugin.pl.getPlayer(player).setTag(null);
            msg("Removed " + player.getName() + "'s tag.");
            return true;
        } else if ("set".equalsIgnoreCase(args[0])) {
            final String inputTag = StringUtils.join(args, " ", 1, args.length);
            final String outputTag = FUtil.colorize(StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag), new String[] { "" + ChatColor.COLOR_CHAR, "&k" }, new String[] { "", "" })) + ChatColor.RESET;
            if (!plugin.al.isAdmin(sender)) {
                final String rawTag = ChatColor.stripColor(outputTag).toLowerCase();
                if (rawTag.length() > 20) {
                    msg("That tag is too long (Max is 20 characters).");
                    return true;
                }
                for (String word : FORBIDDEN_WORDS) {
                    if (rawTag.contains(word)) {
                        msg("That tag contains a forbidden word.");
                        return true;
                    }
                }
            }
            plugin.pl.getPlayer(playerSender).setTag(outputTag);
            msg("Tag set to '" + outputTag + "'.");
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player)

Example 22 with FPlayer

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

the class Command_tagnyan method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (args.length < 1) {
        return false;
    }
    final StringBuilder tag = new StringBuilder();
    for (char c : ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " "))).toCharArray()) {
        tag.append(FUtil.randomChatColor()).append(c);
    }
    String tagStr = tag.toString();
    for (String word : Command_tag.FORBIDDEN_WORDS) {
        if (tagStr.contains(word)) {
            msg("That tag contains a forbidden word.");
            return true;
        }
    }
    final FPlayer data = plugin.pl.getPlayer(playerSender);
    data.setTag(tagStr);
    msg("Set tag to " + tag);
    return true;
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer)

Example 23 with FPlayer

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

the class Command_tossmob method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (!ConfigEntry.TOSSMOB_ENABLED.getBoolean()) {
        msg("Tossmob is currently disabled.");
        return true;
    }
    FPlayer playerData = plugin.pl.getPlayer(playerSender);
    EntityType type = null;
    if (args.length >= 1) {
        if ("off".equals(args[0])) {
            playerData.disableMobThrower();
            msg("MobThrower is disabled.", ChatColor.GREEN);
            return true;
        }
        if (args[0].equalsIgnoreCase("list")) {
            StringBuilder sb = new StringBuilder();
            for (EntityType loop : EntityType.values()) {
                if (loop.isAlive()) {
                    sb.append(" ").append(DepreciationAggregator.getName_EntityType(loop));
                }
            }
            msg("Supported mobs: " + sb.toString().trim(), ChatColor.GREEN);
            return true;
        }
        for (EntityType loopType : EntityType.values()) {
            if (DepreciationAggregator.getName_EntityType(loopType).toLowerCase().equalsIgnoreCase(args[0])) {
                type = loopType;
                break;
            }
        }
        if (type == null) {
            msg(args[0] + " is not a supported mob type. Using a pig instead.", ChatColor.RED);
            msg("By the way, you can type /tossmob list to see all possible mobs.", ChatColor.RED);
            type = EntityType.PIG;
        }
    }
    double speed = 1.0;
    if (args.length >= 2) {
        try {
            speed = Double.parseDouble(args[1]);
        } catch (NumberFormatException nfex) {
        }
    }
    if (speed < 1.0) {
        speed = 1.0;
    } else if (speed > 5.0) {
        speed = 5.0;
    }
    playerData.enableMobThrower(type, speed);
    msg("MobThrower is enabled. Creature: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
    msg("Left click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
    msg("Type '/tossmob off' to disable.  -By Madgeek1450", ChatColor.GREEN);
    playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.BONE, 1));
    return true;
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) EntityType(org.bukkit.entity.EntityType) ItemStack(org.bukkit.inventory.ItemStack)

Example 24 with FPlayer

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

the class RankManager method onPlayerJoin.

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    //plugin.pl.getData(player);
    final FPlayer fPlayer = plugin.pl.getPlayer(player);
    // Unban admins
    boolean isAdmin = plugin.al.isAdmin(player);
    if (isAdmin) {
        // Verify strict IP match
        if (!plugin.al.isIdentityMatched(player)) {
            FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED);
            fPlayer.setSuperadminIdVerified(false);
        } else {
            fPlayer.setSuperadminIdVerified(true);
            plugin.al.updateLastLogin(player);
        }
    }
    // Handle impostors
    if (plugin.al.isAdminImpostor(player)) {
        FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage());
        FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
        player.getInventory().clear();
        player.setOp(false);
        player.setGameMode(GameMode.SURVIVAL);
        plugin.pl.getPlayer(player).getFreezeData().setFrozen(true);
        player.sendMessage(ChatColor.RED + "You are marked as an impostor, please verify yourself!");
        return;
    }
    // Set display
    if (isAdmin || FUtil.DEVELOPERS.contains(player.getName())) {
        final Displayable display = getDisplay(player);
        String loginMsg = display.getColoredLoginMessage();
        if (isAdmin) {
            Admin admin = plugin.al.getAdmin(player);
            if (admin.hasLoginMessage()) {
                loginMsg = ChatUtils.colorize(admin.getLoginMessage());
            }
        }
        FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + loginMsg);
        plugin.pl.getPlayer(player).setTag(display.getColoredTag());
        String displayName = display.getColor() + player.getName();
        try {
            player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
        } catch (IllegalArgumentException ex) {
        }
    }
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) Admin(me.totalfreedom.totalfreedommod.admin.Admin) EventHandler(org.bukkit.event.EventHandler)

Example 25 with FPlayer

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

the class Command_orbit method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    if (args.length == 0) {
        return false;
    }
    Player player = getPlayer(args[0]);
    if (player == null) {
        msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
        return true;
    }
    FPlayer playerdata = plugin.pl.getPlayer(player);
    double strength = 10.0;
    if (args.length >= 2) {
        if (args[1].equals("stop")) {
            msg("Stopped orbiting " + player.getName());
            playerdata.stopOrbiting();
            return true;
        }
        try {
            strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
        } catch (NumberFormatException ex) {
            msg(ex.getMessage(), ChatColor.RED);
            return true;
        }
    }
    player.setGameMode(GameMode.SURVIVAL);
    playerdata.startOrbiting(strength);
    player.setVelocity(new Vector(0, strength, 0));
    FUtil.adminAction(sender.getName(), "Orbiting " + player.getName(), false);
    return true;
}
Also used : FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) FPlayer(me.totalfreedom.totalfreedommod.player.FPlayer) Player(org.bukkit.entity.Player) Vector(org.bukkit.util.Vector)

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