Search in sources :

Example 1 with JobProgression

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

the class PlayerManager method leaveAllJobs.

/**
     * Causes player to leave all their jobs
     * @param jPlayer
     */
public void leaveAllJobs(JobsPlayer jPlayer) {
    synchronized (jPlayer.saveLock) {
        for (JobProgression job : jPlayer.getJobProgression()) {
            Jobs.getJobsDAO().quitJob(jPlayer, job.getJob());
            Jobs.leaveSlot(job.getJob());
        }
        jPlayer.leaveAllJobs();
    }
}
Also used : JobProgression(com.gamingmesh.jobs.container.JobProgression)

Example 2 with JobProgression

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

the class PlayerManager method removeExperience.

/**
     * Removes experience to the player
     * @param jPlayer
     * @param job - the job
     * @param experience - experience gained
     */
public void removeExperience(JobsPlayer jPlayer, Job job, double experience) {
    synchronized (jPlayer.saveLock) {
        JobProgression prog = jPlayer.getJobProgression(job);
        if (prog == null)
            return;
        prog.addExperience(-experience);
        jPlayer.save(Jobs.getJobsDAO());
    }
}
Also used : JobProgression(com.gamingmesh.jobs.container.JobProgression)

Example 3 with JobProgression

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

the class PlayerManager method addExperience.

/**
     * Adds experience to the player
     * @param jPlayer
     * @param job - the job
     * @param experience - experience gained
     */
public void addExperience(JobsPlayer jPlayer, Job job, double experience) {
    synchronized (jPlayer.saveLock) {
        JobProgression prog = jPlayer.getJobProgression(job);
        if (prog == null)
            return;
        int oldLevel = prog.getLevel();
        if (prog.addExperience(experience))
            performLevelUp(jPlayer, job, oldLevel);
        jPlayer.save(Jobs.getJobsDAO());
    }
}
Also used : JobProgression(com.gamingmesh.jobs.container.JobProgression)

Example 4 with JobProgression

use of com.gamingmesh.jobs.container.JobProgression 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)

Example 5 with JobProgression

use of com.gamingmesh.jobs.container.JobProgression 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)

Aggregations

JobProgression (com.gamingmesh.jobs.container.JobProgression)12 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)7 Player (org.bukkit.entity.Player)6 OfflinePlayer (org.bukkit.OfflinePlayer)4 Job (com.gamingmesh.jobs.container.Job)3 JobInfo (com.gamingmesh.jobs.container.JobInfo)1 JobPermission (com.gamingmesh.jobs.container.JobPermission)1 Title (com.gamingmesh.jobs.container.Title)1 ChatColor (com.gamingmesh.jobs.util.ChatColor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Permission (org.bukkit.permissions.Permission)1 PermissionAttachment (org.bukkit.permissions.PermissionAttachment)1 PermissionAttachmentInfo (org.bukkit.permissions.PermissionAttachmentInfo)1