mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Calculate the max jobs variable for equations
This commit is contained in:
parent
ec0670007c
commit
416ad5f8e7
@ -215,15 +215,15 @@ public class GuiManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
double income = jInfo.getIncome(level, numjobs);
|
||||
double income = jInfo.getIncome(level, numjobs, JPlayer.maxJobsEquation);
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = jInfo.getExperience(level, numjobs);
|
||||
double xp = jInfo.getExperience(level, numjobs, JPlayer.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
|
||||
double points = jInfo.getPoints(level, numjobs);
|
||||
double points = jInfo.getPoints(level, numjobs, JPlayer.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
|
||||
|
||||
@ -372,15 +372,15 @@ public class GuiManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
double income = jInfo.getIncome(level, numjobs);
|
||||
double income = jInfo.getIncome(level, numjobs, JPlayer.maxJobsEquation);
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = jInfo.getExperience(level, numjobs);
|
||||
double xp = jInfo.getExperience(level, numjobs, JPlayer.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
|
||||
double points = jInfo.getPoints(level, numjobs);
|
||||
double points = jInfo.getPoints(level, numjobs, JPlayer.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
|
||||
|
||||
|
@ -892,8 +892,8 @@ public class Jobs extends JavaPlugin {
|
||||
if (jobinfo == null)
|
||||
return;
|
||||
|
||||
Double income = jobinfo.getIncome(1, numjobs);
|
||||
Double pointAmount = jobinfo.getPoints(1, numjobs);
|
||||
Double income = jobinfo.getIncome(1, numjobs, jPlayer.maxJobsEquation);
|
||||
Double pointAmount = jobinfo.getPoints(1, numjobs, jPlayer.maxJobsEquation);
|
||||
|
||||
if (income == 0D && pointAmount == 0D)
|
||||
return;
|
||||
@ -997,9 +997,9 @@ public class Jobs extends JavaPlugin {
|
||||
continue;
|
||||
}
|
||||
|
||||
Double income = jobinfo.getIncome(level, numjobs);
|
||||
Double pointAmount = jobinfo.getPoints(level, numjobs);
|
||||
Double expAmount = jobinfo.getExperience(level, numjobs);
|
||||
Double income = jobinfo.getIncome(level, numjobs, jPlayer.maxJobsEquation);
|
||||
Double pointAmount = jobinfo.getPoints(level, numjobs, jPlayer.maxJobsEquation);
|
||||
Double expAmount = jobinfo.getExperience(level, numjobs, jPlayer.maxJobsEquation);
|
||||
|
||||
if (income == 0D && pointAmount == 0D && expAmount == 0D)
|
||||
continue;
|
||||
|
@ -573,9 +573,7 @@ public class Placeholder {
|
||||
return convert(true);
|
||||
|
||||
case maxjobs:
|
||||
int max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max", false).intValue();
|
||||
max = max == 0 ? Jobs.getGCManager().getMaxJobs() : max;
|
||||
return Integer.toString(max);
|
||||
return Integer.toString(Jobs.getPlayerManager().getMaxJobs(user));
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -622,9 +620,7 @@ public class Placeholder {
|
||||
// Global placeholders
|
||||
switch (placeHolder) {
|
||||
case maxjobs:
|
||||
int max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max", false).intValue();
|
||||
max = max == 0 ? Jobs.getGCManager().getMaxJobs() : max;
|
||||
return Integer.toString(max);
|
||||
return Integer.toString(Jobs.getPlayerManager().getMaxJobs(user));
|
||||
case total_workers:
|
||||
return Integer.toString(Jobs.getJobsDAO().getTotalPlayers());
|
||||
default:
|
||||
|
@ -393,6 +393,7 @@ public class PlayerManager {
|
||||
Jobs.getSignUtil().updateAllSign(job);
|
||||
|
||||
job.updateTotalPlayers();
|
||||
jPlayer.maxJobsEquation = getMaxJobs(jPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -779,14 +780,27 @@ public class PlayerManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get max jobs
|
||||
* @param player
|
||||
* @return True if he have permission
|
||||
* Checks whenever the given jobs player is under the max allowed jobs.
|
||||
* @param player {@link JobsPlayer}
|
||||
* @param currentCount the current jobs size
|
||||
* @return true if the player is under the given jobs size
|
||||
*/
|
||||
public boolean getJobsLimit(JobsPlayer jPlayer, short currentCount) {
|
||||
return getMaxJobs(jPlayer) > currentCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum jobs from player.
|
||||
* @param jPlayer {@link JobsPlayer}
|
||||
* @return the maximum allowed jobs
|
||||
*/
|
||||
public int getMaxJobs(JobsPlayer jPlayer) {
|
||||
if (jPlayer == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int max = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.max", false).intValue();
|
||||
max = max == 0 ? Jobs.getGCManager().getMaxJobs() : max;
|
||||
return max > currentCount;
|
||||
return max == 0 ? Jobs.getGCManager().getMaxJobs() : max;
|
||||
}
|
||||
|
||||
public BoostMultiplier getBoost(JobsPlayer player, Job job) {
|
||||
|
@ -348,16 +348,16 @@ public class JobsCommands implements CommandExecutor {
|
||||
|
||||
String materialName = info.getRealisticName();
|
||||
|
||||
double income = info.getIncome(level, numjobs);
|
||||
double income = info.getIncome(level, numjobs, player.maxJobsEquation);
|
||||
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = info.getExperience(level, numjobs);
|
||||
double xp = info.getExperience(level, numjobs, player.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
|
||||
double points = info.getPoints(level, numjobs);
|
||||
double points = info.getPoints(level, numjobs, player.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
|
||||
|
||||
|
@ -120,6 +120,7 @@ public class ConfigManager {
|
||||
cfg.addComment(pt + ".leveling-progression-equation", "Equation used for calculating how much experience is needed to go to the next level.",
|
||||
"Available parameters:",
|
||||
" numjobs - the number of jobs the player has",
|
||||
" maxjobs - the number of jobs the player have max",
|
||||
" joblevel - the level the player has attained in the job.",
|
||||
" NOTE: Please take care of the brackets when modifying this equation.");
|
||||
cfg.get(pt + ".leveling-progression-equation", "10*(joblevel)+(joblevel*joblevel*4)");
|
||||
@ -127,6 +128,7 @@ public class ConfigManager {
|
||||
cfg.addComment(pt + ".income-progression-equation", "Equation used for calculating how much income is given per action for the job level.",
|
||||
"Available parameters:",
|
||||
" numjobs - the number of jobs the player has",
|
||||
" maxjobs - the number of jobs the player have max",
|
||||
" baseincome - the income for the action at level 1 (as set in the configuration).",
|
||||
" joblevel - the level the player has attained in the job.",
|
||||
"NOTE: Please take care of the brackets when modifying this equation.");
|
||||
@ -135,6 +137,7 @@ public class ConfigManager {
|
||||
cfg.addComment(pt + ".points-progression-equation", "Equation used for calculating how much points is given per action for the job level.",
|
||||
"Available parameters:",
|
||||
" numjobs - the number of jobs the player has",
|
||||
" maxjobs - the number of jobs the player have max",
|
||||
" basepoints - the points for the action at level 1 (as set in the configuration).",
|
||||
" joblevel - the level the player has attained in the job.",
|
||||
"NOTE: Please take care of the brackets when modifying this equation.");
|
||||
@ -143,6 +146,7 @@ public class ConfigManager {
|
||||
cfg.addComment(pt + ".experience-progression-equation", "Equation used for calculating how much experience is given per action for the job level.",
|
||||
"Available parameters:",
|
||||
" numjobs - the number of jobs the player has",
|
||||
" maxjobs - the number of jobs the player have max",
|
||||
" baseexperience - the experience for the action at level 1 (as set in the configuration).",
|
||||
" joblevel - the level the player has attained in the job.",
|
||||
"NOTE: Please take care of the brackets when modifying this equation.");
|
||||
@ -785,7 +789,6 @@ public class ConfigManager {
|
||||
maxExpEquation.setVariable("numjobs", 1);
|
||||
maxExpEquation.setVariable("maxjobs", 2);
|
||||
maxExpEquation.setVariable("joblevel", 1);
|
||||
maxExpEquation.getValue();
|
||||
} catch (Throwable e) {
|
||||
log.warning("Job " + jobKey + " has an invalid leveling-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
@ -801,7 +804,6 @@ public class ConfigManager {
|
||||
incomeEquation.setVariable("maxjobs", 2);
|
||||
incomeEquation.setVariable("joblevel", 1);
|
||||
incomeEquation.setVariable("baseincome", 1);
|
||||
incomeEquation.getValue();
|
||||
} catch (Throwable e) {
|
||||
log.warning("Job " + jobKey + " has an invalid income-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
@ -817,7 +819,6 @@ public class ConfigManager {
|
||||
expEquation.setVariable("maxjobs", 2);
|
||||
expEquation.setVariable("joblevel", 1);
|
||||
expEquation.setVariable("baseexperience", 1);
|
||||
expEquation.getValue();
|
||||
} catch (Throwable e) {
|
||||
log.warning("Job " + jobKey + " has an invalid experience-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
@ -833,7 +834,6 @@ public class ConfigManager {
|
||||
pointsEquation.setVariable("maxjobs", 2);
|
||||
pointsEquation.setVariable("joblevel", 1);
|
||||
pointsEquation.setVariable("basepoints", 1);
|
||||
pointsEquation.getValue();
|
||||
} catch (Throwable e) {
|
||||
log.warning("Job " + jobKey + " has an invalid points-progression-equation property. Skipping job!");
|
||||
continue;
|
||||
|
@ -110,35 +110,38 @@ public class JobInfo {
|
||||
return basePoints;
|
||||
}
|
||||
|
||||
public double getIncome(double level, double numjobs) {
|
||||
public double getIncome(double level, int numjobs, int maxJobs) {
|
||||
if (softIncomeLevelLimit != null && level > softIncomeLevelLimit)
|
||||
level = softIncomeLevelLimit;
|
||||
if (baseIncome == 0 || !Jobs.getGCManager().PaymentMethodsMoney)
|
||||
return 0;
|
||||
moneyEquation.setVariable("joblevel", level);
|
||||
moneyEquation.setVariable("numjobs", numjobs);
|
||||
moneyEquation.setVariable("maxjobs", maxJobs);
|
||||
moneyEquation.setVariable("baseincome", baseIncome);
|
||||
return moneyEquation.getValue();
|
||||
}
|
||||
|
||||
public double getExperience(double level, double numjobs) {
|
||||
public double getExperience(double level, int numjobs, int maxJobs) {
|
||||
if (softExpLevelLimit != null && level > softExpLevelLimit)
|
||||
level = softExpLevelLimit;
|
||||
if (baseXp == 0 || !Jobs.getGCManager().PaymentMethodsExp)
|
||||
return 0;
|
||||
xpEquation.setVariable("joblevel", level);
|
||||
xpEquation.setVariable("numjobs", numjobs);
|
||||
xpEquation.setVariable("maxjobs", maxJobs);
|
||||
xpEquation.setVariable("baseexperience", baseXp);
|
||||
return xpEquation.getValue();
|
||||
}
|
||||
|
||||
public double getPoints(double level, double numjobs) {
|
||||
public double getPoints(double level, int numjobs, int maxJobs) {
|
||||
if (softPointsLevelLimit != null && level > softPointsLevelLimit)
|
||||
level = softPointsLevelLimit;
|
||||
if (basePoints == 0 || !Jobs.getGCManager().PaymentMethodsPoints)
|
||||
return 0;
|
||||
pointsEquation.setVariable("joblevel", level);
|
||||
pointsEquation.setVariable("numjobs", numjobs);
|
||||
pointsEquation.setVariable("maxjobs", maxJobs);
|
||||
pointsEquation.setVariable("basepoints", basePoints);
|
||||
return pointsEquation.getValue();
|
||||
}
|
||||
|
@ -43,13 +43,17 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
public class JobsPlayer {
|
||||
// the player the object belongs to
|
||||
private String userName = "Unknown";
|
||||
// progression of the player in each job
|
||||
public UUID playerUUID;
|
||||
public final ArrayList<JobProgression> progression = new ArrayList<>();
|
||||
private ArchivedJobs archivedJobs = new ArchivedJobs();
|
||||
|
||||
private String userName = "Unknown";
|
||||
|
||||
public UUID playerUUID;
|
||||
|
||||
// progression of the player in each job
|
||||
public final ArrayList<JobProgression> progression = new ArrayList<>();
|
||||
|
||||
public int maxJobsEquation = 0;
|
||||
|
||||
private ArchivedJobs archivedJobs = new ArchivedJobs();
|
||||
private PaymentData paymentLimits;
|
||||
|
||||
private final HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>();
|
||||
@ -70,7 +74,6 @@ public class JobsPlayer {
|
||||
// save lock
|
||||
// public final Object saveLock = new Object();
|
||||
|
||||
// log
|
||||
private HashMap<String, Log> logList = new HashMap<>();
|
||||
|
||||
private Long seen = System.currentTimeMillis();
|
||||
@ -839,8 +842,8 @@ public class JobsPlayer {
|
||||
JobInfo jobinfo = Jobs.getNoneJob().getJobInfo(info, 1);
|
||||
if (jobinfo == null)
|
||||
return false;
|
||||
Double income = jobinfo.getIncome(1, numjobs);
|
||||
Double points = jobinfo.getPoints(1, numjobs);
|
||||
Double income = jobinfo.getIncome(1, numjobs, maxJobsEquation);
|
||||
Double points = jobinfo.getPoints(1, numjobs, maxJobsEquation);
|
||||
if (income == 0D && points == 0D)
|
||||
return false;
|
||||
}
|
||||
@ -850,9 +853,9 @@ public class JobsPlayer {
|
||||
JobInfo jobinfo = prog.getJob().getJobInfo(info, level);
|
||||
if (jobinfo == null)
|
||||
continue;
|
||||
Double income = jobinfo.getIncome(level, numjobs);
|
||||
Double pointAmount = jobinfo.getPoints(level, numjobs);
|
||||
Double expAmount = jobinfo.getExperience(level, numjobs);
|
||||
Double income = jobinfo.getIncome(level, numjobs, maxJobsEquation);
|
||||
Double pointAmount = jobinfo.getPoints(level, numjobs, maxJobsEquation);
|
||||
Double expAmount = jobinfo.getExperience(level, numjobs, maxJobsEquation);
|
||||
if (income != 0D || pointAmount != 0D || expAmount != 0D)
|
||||
return true;
|
||||
}
|
||||
|
@ -53,12 +53,14 @@ Jobs:
|
||||
# Equation used for calculating how much experience is needed to go to the next level.
|
||||
# Available parameters:
|
||||
# numjobs - the number of jobs the player has
|
||||
# maxjobs - the number of jobs the player have max
|
||||
# joblevel - the level the player has attained in the job.
|
||||
# NOTE: Please take care of the brackets when modifying this equation.
|
||||
leveling-progression-equation: 10*(joblevel)+(joblevel*joblevel*4)
|
||||
# Equation used for calculating how much income is given per action for the job level.
|
||||
# Available parameters:
|
||||
# numjobs - the number of jobs the player has
|
||||
# maxjobs - the number of jobs the player have max
|
||||
# baseincome - the income for the action at level 1 (as set in the configuration).
|
||||
# joblevel - the level the player has attained in the job.
|
||||
# NOTE: Please take care of the brackets when modifying this equation.
|
||||
@ -66,6 +68,7 @@ Jobs:
|
||||
# Equation used for calculating how much points is given per action for the job level.
|
||||
# Available parameters:
|
||||
# numjobs - the number of jobs the player has
|
||||
# maxjobs - the number of jobs the player have max
|
||||
# basepoints - the points for the action at level 1 (as set in the configuration).
|
||||
# joblevel - the level the player has attained in the job.
|
||||
# NOTE: Please take care of the brackets when modifying this equation.
|
||||
@ -73,6 +76,7 @@ Jobs:
|
||||
# Equation used for calculating how much experience is given per action for the job level.
|
||||
# Available parameters:
|
||||
# numjobs - the number of jobs the player has
|
||||
# maxjobs - the number of jobs the player have max
|
||||
# baseexperience - the experience for the action at level 1 (as set in the configuration).
|
||||
# joblevel - the level the player has attained in the job.
|
||||
# NOTE: Please take care of the brackets when modifying this equation.
|
||||
@ -350,7 +354,7 @@ Jobs:
|
||||
income: 5.0
|
||||
experience: 10.0
|
||||
# Shear sheeps by its color
|
||||
# You can use "color-all" to specify all known colors.
|
||||
# You can use "color-all" identifier to specify all known colors.
|
||||
Shear:
|
||||
Black:
|
||||
income: 2.0
|
||||
|
Loading…
Reference in New Issue
Block a user