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();
}
}
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());
}
}
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());
}
}
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);
}
}
}
}
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;
}
Aggregations