diff --git a/pom.xml b/pom.xml
index 0615ad82..6e78c298 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,6 @@
Jobs
jobs
3.8.2
- jar
Jobs
http://maven.apache.org
diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java
index 6b9fc31f..b6e165a4 100644
--- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java
+++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java
@@ -121,7 +121,9 @@ public class GeneralConfigManager {
public int AutoJobJoinDelay;
public boolean AutoJobJoinUse;
-
+
+ public boolean AllowDelevel;
+
//BossBar
public boolean BossBarEnabled;
public boolean BossBarShowOnEachAction;
@@ -460,6 +462,10 @@ public class GeneralConfigManager {
"Op players are ignored");
AutoJobJoinDelay = c.get("Optimizations.AutoJobJoin.Delay", 15);
+ c.getW().addComment("Optimizations.AllowDelevel", "When set to true players who gets negavite experience can delevel job up to level 1",
+ "ATTENTION! Set it to true only if you certain that commands performed on levelup will not cause issues if player start level and delevel in a row.");
+ AllowDelevel = c.get("Optimizations.AllowDelevel", false);
+
c.getW().addComment("Optimizations.UseLocalOfflinePlayersData", "With this set to true, offline player data will be taken from local player data files",
"This will eliminate small lag spikes when request is being send to mojangs servers for offline players data",
"Theroticali this should work without issues, but if you havving some, just disable",
diff --git a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java
index c6b5da92..52a1e3f7 100644
--- a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java
+++ b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java
@@ -43,6 +43,15 @@ public class JobProgression {
return experience >= maxExperience;
}
+ /**
+ * Can the job level down?
+ * @return true if the job can level up
+ * @return false if the job cannot
+ */
+ public boolean canLevelDown() {
+ return experience < 0;
+ }
+
/**
* Return the job
* @return the job
@@ -142,11 +151,24 @@ public class JobProgression {
this.maxExperience = (int) job.getMaxExp(param);
}
+ public int getMaxExperience(int level) {
+ HashMap param = new HashMap();
+ param.put("joblevel", (double) level);
+ param.put("numjobs", (double) jPlayer.getJobProgression().size());
+ return (int) job.getMaxExp(param);
+ }
+
/**
* Performs a level up
* @returns if level up was performed
*/
private boolean checkLevelUp() {
+
+ if (level == 1 && experience < 0)
+ experience = 0;
+ if (experience < 0)
+ return checkLevelDown();
+
boolean ret = false;
while (canLevelUp()) {
@@ -168,6 +190,26 @@ public class JobProgression {
// At max level
if (experience > maxExperience)
experience = maxExperience;
+
+ return ret;
+ }
+
+ /**
+ * Performs a level up
+ * @returns if level up was performed
+ */
+ private boolean checkLevelDown() {
+ boolean ret = false;
+ while (canLevelDown()) {
+ // Don't level down at 1
+ if (level <= 1)
+ break;
+ level--;
+ int exp = getMaxExperience(level);
+ experience = experience + exp;
+ ret = true;
+ reloadMaxExperience();
+ }
return ret;
}