diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index 577330a7..b7e658a6 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -245,14 +245,14 @@ public class PlayerManager { return jPlayer; } - + /** * Get the player job info for specific player * @param player - the player who's job you're getting * @return the player job info of the player */ public JobsPlayer getJobsPlayerOffline(Entry info) { - + if (info == null) return null; @@ -282,7 +282,7 @@ public class PlayerManager { return jPlayer; } - + /** * Causes player to join their job * @param jPlayer @@ -317,21 +317,22 @@ public class PlayerManager { * @param jPlayer * @param job */ - public void leaveJob(JobsPlayer jPlayer, Job job) { + public boolean leaveJob(JobsPlayer jPlayer, Job job) { // synchronized (jPlayer.saveLock) { if (!jPlayer.isInJob(job)) - return; - Jobs.getJobsDAO().recordToArchive(jPlayer, job); - // let the user leave the job - if (!jPlayer.leaveJob(job)) - return; + return false; // JobsJoin event JobsLeaveEvent jobsleaveevent = new JobsLeaveEvent(jPlayer, job); Bukkit.getServer().getPluginManager().callEvent(jobsleaveevent); // If event is canceled, dont do anything if (jobsleaveevent.isCancelled()) - return; + return false; + + Jobs.getJobsDAO().recordToArchive(jPlayer, job); + // let the user leave the job + if (!jPlayer.leaveJob(job)) + return false; Jobs.getJobsDAO().quitJob(jPlayer, job); PerformCommands.PerformCommandsOnLeave(jPlayer, job); @@ -340,6 +341,7 @@ public class PlayerManager { Jobs.getSignUtil().SignUpdate(job.getName()); Jobs.getSignUtil().SignUpdate("gtoplist"); job.updateTotalPlayers(); + return true; // } } @@ -638,7 +640,7 @@ public class PlayerManager { return data; ItemStack iih = Jobs.getNms().getItemInMainHand(player); - + if (iih == null || prog == null) return data; diff --git a/com/gamingmesh/jobs/commands/list/leave.java b/com/gamingmesh/jobs/commands/list/leave.java index 9efbcc85..1f68faec 100644 --- a/com/gamingmesh/jobs/commands/list/leave.java +++ b/com/gamingmesh/jobs/commands/list/leave.java @@ -11,7 +11,6 @@ import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; - public class leave implements Cmd { @Override @@ -35,10 +34,11 @@ public class leave implements Cmd { return true; } - Jobs.getPlayerManager().leaveJob(jPlayer, job); - String message = Jobs.getLanguage().getMessage("command.leave.success"); - message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); - sender.sendMessage(message); + if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE)); + } else + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); return true; + } } diff --git a/com/gamingmesh/jobs/container/Job.java b/com/gamingmesh/jobs/container/Job.java index a739c849..1fe41e4e 100644 --- a/com/gamingmesh/jobs/container/Job.java +++ b/com/gamingmesh/jobs/container/Job.java @@ -121,7 +121,11 @@ public class Job { public void setPointBoost(double Point) { this.PointBoost = Point; } - + + public boolean same(Job job) { + return this.getName().equalsIgnoreCase(job.getName()); + } + public double getPointBoost() { return this.PointBoost; } diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index 2286a935..ca864aa2 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -293,7 +293,7 @@ public class JobsPlayer { */ public JobProgression getJobProgression(Job job) { for (JobProgression prog : progression) { - if (prog.getJob().equals(job)) + if (prog.getJob().same(job)) return prog; } return null; @@ -456,7 +456,7 @@ public class JobsPlayer { // synchronized (saveLock) { if (!isInJob(newjob)) { for (JobProgression prog : progression) { - if (!prog.getJob().equals(oldjob)) + if (!prog.getJob().same(oldjob)) continue; prog.setJob(newjob); @@ -490,7 +490,7 @@ public class JobsPlayer { */ public boolean isInJob(Job job) { for (JobProgression prog : progression) { - if (prog.getJob().equals(job)) + if (prog.getJob().same(job)) return true; } return false; diff --git a/com/gamingmesh/jobs/stuff/ActionBar.java b/com/gamingmesh/jobs/stuff/ActionBar.java index 283ae7ec..24de8e2f 100644 --- a/com/gamingmesh/jobs/stuff/ActionBar.java +++ b/com/gamingmesh/jobs/stuff/ActionBar.java @@ -122,6 +122,9 @@ public class ActionBar { if (msg == null || nmsChatSerializer == null) return; + if (receivingPacket == null) + return; + if (cleanVersion < 1800 || !(receivingPacket instanceof Player)) { receivingPacket.sendMessage(ChatColor.translateAlternateColorCodes('&', msg)); return;