Search in sources :

Example 1 with JobsPlayer

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

the class JobsCommands method removexp.

@JobCommand
public boolean removexp(CommandSender sender, String[] args) {
    if (args.length < 3) {
        sendUsage(sender, "removexp");
        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;
    }
    double xpLost;
    try {
        xpLost = Double.parseDouble(args[2]);
    } catch (Exception e) {
        sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
        return true;
    }
    if (xpLost <= 0) {
        sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
        return true;
    }
    // check if player already has the job
    if (jPlayer.isInJob(job)) {
        Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
        Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
        if (player != null) {
            String message = Language.getMessage("command.removexp.output.target");
            message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
            message = message.replace("%xplost%", Double.valueOf(xpLost).toString());
            player.sendMessage(message);
        }
        sender.sendMessage(Language.getMessage("command.admin.success"));
    }
    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)

Example 2 with JobsPlayer

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

the class JobsCommands method fire.

@JobCommand
public boolean fire(CommandSender sender, String[] args) {
    if (args.length < 2) {
        sendUsage(sender, "fire");
        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;
    }
    if (!jPlayer.isInJob(job)) {
        String message = ChatColor.RED + Language.getMessage("command.fire.error.nojob");
        message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
        sender.sendMessage(message);
        return true;
    }
    try {
        Jobs.getPlayerManager().leaveJob(jPlayer, job);
        Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
        if (player != null) {
            String message = Language.getMessage("command.fire.output.target");
            message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
            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)

Example 3 with JobsPlayer

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

the class JobsCommands method leaveall.

@JobCommand
public boolean leaveall(CommandSender sender, String[] args) {
    if (!(sender instanceof Player))
        return false;
    Player pSender = (Player) sender;
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
    List<JobProgression> jobs = jPlayer.getJobProgression();
    if (jobs.size() == 0) {
        sender.sendMessage(Language.getMessage("command.leaveall.error.nojobs"));
        return true;
    }
    Jobs.getPlayerManager().leaveAllJobs(jPlayer);
    sender.sendMessage(Language.getMessage("command.leaveall.success"));
    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) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer)

Example 4 with JobsPlayer

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

the class JobsCommands method employ.

@JobCommand
public boolean employ(CommandSender sender, String[] args) {
    if (args.length < 2) {
        sendUsage(sender, "employ");
        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;
    }
    if (jPlayer.isInJob(job)) {
        // already in job message
        String message = ChatColor.RED + Language.getMessage("command.employ.error.alreadyin");
        message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
        sender.sendMessage(message);
        return true;
    }
    try {
        // check if player already has the job
        Jobs.getPlayerManager().joinJob(jPlayer, job);
        Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
        if (player != null) {
            String message = Language.getMessage("command.employ.output.target");
            message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
            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)

Example 5 with JobsPlayer

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

the class PlayerManager method reload.

/**
 * Perform reload
 */
public void reload() {
    synchronized (players) {
        for (JobsPlayer jPlayer : players.values()) {
            for (JobProgression progression : jPlayer.getJobProgression()) {
                String jobName = progression.getJob().getName();
                Job job = Jobs.getJob(jobName);
                if (job != null) {
                    progression.setJob(job);
                }
            }
            if (jPlayer.isOnline()) {
                jPlayer.reloadHonorific();
                Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
            }
        }
    }
}
Also used : JobProgression(com.gamingmesh.jobs.container.JobProgression) Job(com.gamingmesh.jobs.container.Job) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer)

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