Search in sources :

Example 31 with JobsPlayer

use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.

the class JobsCommands method playerinfo.

@JobCommand
public boolean playerinfo(CommandSender sender, String[] args) {
    if (args.length < 2) {
        sendUsage(sender, "playerinfo");
        sendValidActions(sender);
        return true;
    }
    OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
    String jobName = args[1];
    Job job = Jobs.getJob(jobName);
    if (job == null) {
        sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
        return true;
    }
    String type = "";
    if (args.length >= 3) {
        type = args[2];
    }
    sender.sendMessage(jobInfoMessage(jPlayer, job, type).split("\n"));
    return true;
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer) Job(com.gamingmesh.jobs.container.Job) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer)

Example 32 with JobsPlayer

use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.

the class JobsCommands method stats.

@JobCommand
public boolean stats(CommandSender sender, String[] args) {
    JobsPlayer jPlayer = null;
    if (args.length >= 1) {
        if (!sender.hasPermission("jobs.command.admin.stats")) {
            sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission"));
            return true;
        }
        OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
        jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
    } else if (sender instanceof Player) {
        jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
    }
    if (jPlayer == null) {
        sendUsage(sender, "stats");
        return true;
    }
    if (jPlayer.getJobProgression().size() == 0) {
        sender.sendMessage(Language.getMessage("command.stats.error.nojob"));
        return true;
    }
    for (JobProgression jobProg : jPlayer.getJobProgression()) {
        sender.sendMessage(jobStatsMessage(jobProg).split("\n"));
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) JobProgression(com.gamingmesh.jobs.container.JobProgression) OfflinePlayer(org.bukkit.OfflinePlayer) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer)

Example 33 with JobsPlayer

use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.

the class JobsCommands method promote.

@JobCommand
public boolean promote(CommandSender sender, String[] args) {
    if (args.length < 3) {
        sendUsage(sender, "promote");
        return true;
    }
    OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
    Job job = Jobs.getJob(args[1]);
    if (job == null) {
        sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
        return true;
    }
    try {
        // check if player already has the job
        if (jPlayer.isInJob(job)) {
            Integer levelsGained = Integer.parseInt(args[2]);
            Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained);
            Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
            if (player != null) {
                String message = Language.getMessage("command.promote.output.target");
                message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
                message = message.replace("%levelsgained%", Integer.valueOf(levelsGained).toString());
                player.sendMessage(message);
            }
            sender.sendMessage(Language.getMessage("command.admin.success"));
        }
    } catch (Exception e) {
        sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) OfflinePlayer(org.bukkit.OfflinePlayer) Job(com.gamingmesh.jobs.container.Job) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)33 Player (org.bukkit.entity.Player)26 OfflinePlayer (org.bukkit.OfflinePlayer)15 Job (com.gamingmesh.jobs.container.Job)14 EventHandler (org.bukkit.event.EventHandler)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 JobProgression (com.gamingmesh.jobs.container.JobProgression)7 ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)6 Block (org.bukkit.block.Block)4 ItemStack (org.bukkit.inventory.ItemStack)4 CraftingInventory (org.bukkit.inventory.CraftingInventory)3 BlockActionInfo (com.gamingmesh.jobs.actions.BlockActionInfo)2 AnvilInventory (org.bukkit.inventory.AnvilInventory)2 EnchantingInventory (org.bukkit.inventory.EnchantingInventory)2 Inventory (org.bukkit.inventory.Inventory)2 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)2 MetadataValue (org.bukkit.metadata.MetadataValue)2 EntityActionInfo (com.gamingmesh.jobs.actions.EntityActionInfo)1 JobPermission (com.gamingmesh.jobs.container.JobPermission)1 Title (com.gamingmesh.jobs.container.Title)1