diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index d40ae7b0..2ad0ca8e 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -87,7 +87,7 @@ public class JobsCommands implements CommandExecutor { return true; } - if (!hasCommandPermission(sender, cmd)) { + if (!hasCommandPermission(sender, cmd)) { if (sender instanceof Player) { RawMessage rm = new RawMessage(); rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + label + ".command." + cmd); @@ -98,7 +98,7 @@ public class JobsCommands implements CommandExecutor { Jobs.sendMessage(sender, Jobs.getLanguage().getMessage("general.error.permission")); return true; } - + String[] myArgs = reduceArgs(args); if (myArgs.length > 0) { if (myArgs[myArgs.length - 1].equals("?")) { @@ -110,7 +110,7 @@ public class JobsCommands implements CommandExecutor { // if (cmdClass == null) { // return help(sender, 1); // } - + boolean back = cmdClass.perform(plugin, sender, myArgs); if (back) return true; @@ -581,7 +581,7 @@ public class JobsCommands implements CommandExecutor { String message = Jobs.getLanguage().getMessage("command.stats.output", "%joblevel%", jobProg.getLevel(), "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE, - "%jobxp%",Math.round(jobProg.getExperience() * 100.0) / 100.0, + "%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0, "%jobmaxxp%", jobProg.getMaxExperience()); return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message; } @@ -614,12 +614,13 @@ public class JobsCommands implements CommandExecutor { * @return the message */ public String jobStatsMessageArchive(JobsPlayer jPlayer, JobProgression jobProg) { - String message = Jobs.getLanguage().getMessage("command.archive.feedback", - "%joblevel%", jobProg.getLevel(), - "%leftjoblevel%", jPlayer.getLevelAfterRejoin(jobProg), + int level = jPlayer.getLevelAfterRejoin(jobProg); + int exp = jPlayer.getExpAfterRejoin(jobProg, jPlayer.getLevelAfterRejoin(jobProg)); + String message = Jobs.getLanguage().getMessage("command.stats.output", + "%joblevel%", level, "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName() + ChatColor.WHITE, - "%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0, - "%jobmaxxp%", jobProg.getMaxExperience()); - return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message; + "%jobxp%", Math.round(exp * 100.0) / 100.0, + "%jobmaxxp%", jobProg.getMaxExperience(level)); + return " " + jobProgressMessage(jobProg.getMaxExperience(level), exp) + " " + message; } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/archive.java b/src/main/java/com/gamingmesh/jobs/commands/list/archive.java index d354a27b..b82dce62 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/archive.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/archive.java @@ -49,8 +49,8 @@ public class archive implements Cmd { if (jobInfo.canRejoin()) rm.add(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo), "Click to rejoin this job", "jobs join " + jobInfo.getJob().getName()); else - rm.add(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo), "You cant join, need to wait " + (TimeManage.to24hourShort(jobInfo.getLeftOn() + jobInfo - .getJob().getRejoinCd() - System.currentTimeMillis()))); + rm.add(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo), Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo + .getRejoinTimeMessage())); rm.show(sender); } sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 9a418cf2..13d586ff 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -250,7 +250,6 @@ public class LanguageManager { c.get("command.archive.help.args", "[playername]"); Jobs.getGCManager().commandArgs.put("archive", Arrays.asList("[playername]")); c.get("command.archive.error.nojob", "There is no jobs saved."); - c.get("command.archive.feedback", " lvl%joblevel%(%leftjoblevel%) %jobname% : %jobxp%/%jobmaxxp% xp"); c.get("command.give.help.info", "Gives item by jobs name and item category name. Player name is optional"); c.get("command.give.help.args", "[playername] [jobname] [itemname]"); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java index b6148af3..74cbc77a 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java @@ -241,6 +241,8 @@ public class JobProgression { return true; if (this.leftOn + this.getJob().getRejoinCd() < System.currentTimeMillis()) return true; + if (this.jPlayer != null && jPlayer.getPlayer() != null && jPlayer.getPlayer().hasPermission("jobs.rejoinbypass")) + return true; return false; } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 8287d756..8cf00a67 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -388,6 +388,7 @@ public class JobsPlayer { JobProgression archived = this.getArchivedJobProgression(job); if (archived != null) { level = getLevelAfterRejoin(archived); + exp = getExpAfterRejoin(archived, level); Jobs.getJobsDAO().deleteArchive(this, job); } @@ -425,6 +426,20 @@ public class JobsPlayer { return level; } + public int getExpAfterRejoin(JobProgression jp, int level) { + if (jp == null) + return 1; + Integer max = jp.getMaxExperience(level); + Double exp = jp.getExperience(); + if (exp > max) + exp = max.doubleValue(); + + if (exp > 0) { + exp = (exp - (exp * (Jobs.getGCManager().levelLossPercentage / 100.0))); + } + return exp.intValue(); + } + /** * Player leaves a job * @param job - the job left diff --git a/src/main/java/jobConfig.yml b/src/main/java/jobConfig.yml index 92a599ec..a531d93d 100644 --- a/src/main/java/jobConfig.yml +++ b/src/main/java/jobConfig.yml @@ -65,6 +65,8 @@ Jobs: # joblevel - the level the player has attained in the job. # NOTE: Please take care of the brackets when modifying this equation. experience-progression-equation: baseexperience-(baseexperience*((numjobs-1) *0.01)) + # Defines how often in seconds player can rejoin this job. Can be bypassed with jobs.rejoinbypass + rejoinCooldown: 10 # GUI icon information when using GUI function Gui: # id of block