mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-07 07:51:34 +01:00
Allow delevel when getting negative exp
This commit is contained in:
parent
153352195c
commit
a7aead4639
1
pom.xml
1
pom.xml
@ -6,7 +6,6 @@
|
|||||||
<groupId>Jobs</groupId>
|
<groupId>Jobs</groupId>
|
||||||
<artifactId>jobs</artifactId>
|
<artifactId>jobs</artifactId>
|
||||||
<version>3.8.2</version>
|
<version>3.8.2</version>
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>Jobs</name>
|
<name>Jobs</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -121,7 +121,9 @@ public class GeneralConfigManager {
|
|||||||
|
|
||||||
public int AutoJobJoinDelay;
|
public int AutoJobJoinDelay;
|
||||||
public boolean AutoJobJoinUse;
|
public boolean AutoJobJoinUse;
|
||||||
|
|
||||||
|
public boolean AllowDelevel;
|
||||||
|
|
||||||
//BossBar
|
//BossBar
|
||||||
public boolean BossBarEnabled;
|
public boolean BossBarEnabled;
|
||||||
public boolean BossBarShowOnEachAction;
|
public boolean BossBarShowOnEachAction;
|
||||||
@ -460,6 +462,10 @@ public class GeneralConfigManager {
|
|||||||
"Op players are ignored");
|
"Op players are ignored");
|
||||||
AutoJobJoinDelay = c.get("Optimizations.AutoJobJoin.Delay", 15);
|
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",
|
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",
|
"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",
|
"Theroticali this should work without issues, but if you havving some, just disable",
|
||||||
|
@ -43,6 +43,15 @@ public class JobProgression {
|
|||||||
return experience >= maxExperience;
|
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
|
||||||
* @return the job
|
* @return the job
|
||||||
@ -142,11 +151,24 @@ public class JobProgression {
|
|||||||
this.maxExperience = (int) job.getMaxExp(param);
|
this.maxExperience = (int) job.getMaxExp(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxExperience(int level) {
|
||||||
|
HashMap<String, Double> param = new HashMap<String, Double>();
|
||||||
|
param.put("joblevel", (double) level);
|
||||||
|
param.put("numjobs", (double) jPlayer.getJobProgression().size());
|
||||||
|
return (int) job.getMaxExp(param);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a level up
|
* Performs a level up
|
||||||
* @returns if level up was performed
|
* @returns if level up was performed
|
||||||
*/
|
*/
|
||||||
private boolean checkLevelUp() {
|
private boolean checkLevelUp() {
|
||||||
|
|
||||||
|
if (level == 1 && experience < 0)
|
||||||
|
experience = 0;
|
||||||
|
if (experience < 0)
|
||||||
|
return checkLevelDown();
|
||||||
|
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
while (canLevelUp()) {
|
while (canLevelUp()) {
|
||||||
|
|
||||||
@ -168,6 +190,26 @@ public class JobProgression {
|
|||||||
// At max level
|
// At max level
|
||||||
if (experience > maxExperience)
|
if (experience > maxExperience)
|
||||||
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user