1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Better way to show archived jobs and option to rejoin with one click

Archive command shows exact level and exp after rejoin
Rejoining jobs exp is not being reset to 0 now
This commit is contained in:
Zrips 2017-09-01 10:54:05 +03:00
parent 741bd0ed97
commit 8a7d1fb765
6 changed files with 32 additions and 13 deletions

View File

@ -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;
}
}

View File

@ -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"));

View File

@ -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]");

View File

@ -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;
}

View File

@ -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

View File

@ -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