From 4844547d1969aeb6e2f1a24f1240b3da090e0de4 Mon Sep 17 00:00:00 2001 From: Zrips Date: Thu, 9 Nov 2017 15:24:29 +0200 Subject: [PATCH] Allow soft limits to stop income increase after certain level, but allow further leveling. --- .../gamingmesh/jobs/config/ConfigManager.java | 13 +++++++++++- .../jobs/container/BossBarInfo.java | 2 +- .../gamingmesh/jobs/container/JobInfo.java | 20 +++++++++++++++++-- .../com/gamingmesh/jobs/dao/JobsMySQL.java | 2 +- src/main/resources/jobConfig.yml | 6 ++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 8da6ac62..1d9857b4 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -51,6 +51,7 @@ import com.gamingmesh.jobs.container.JobLimitedItems; import com.gamingmesh.jobs.container.JobPermission; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; public class ConfigManager { private Jobs plugin; @@ -484,6 +485,16 @@ public class ConfigManager { job.setXpEquation(expEquation); job.setPointsEquation(pointsEquation); + Integer softIncomeLimit = null; + Integer softExpLimit = null; + Integer softPointsLimit = null; + if (jobSection.isInt("softIncomeLimit")) + softIncomeLimit = jobSection.getInt("softIncomeLimit"); + if (jobSection.isInt("softExpLimit")) + softExpLimit = jobSection.getInt("softExpLimit"); + if (jobSection.isInt("softPointsLimit")) + softPointsLimit = jobSection.getInt("softPointsLimit"); + for (ActionType actionType : ActionType.values()) { ConfigurationSection typeSection = jobSection.getConfigurationSection(actionType.getName()); ArrayList jobInfo = new ArrayList(); @@ -686,7 +697,7 @@ public class ConfigManager { } jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, pointsEquation, points, fromlevel, - untilLevel, section.getCurrentPath())); + untilLevel, section.getCurrentPath(), softIncomeLimit, softExpLimit, softPointsLimit)); } } job.setJobInfo(actionType, jobInfo); diff --git a/src/main/java/com/gamingmesh/jobs/container/BossBarInfo.java b/src/main/java/com/gamingmesh/jobs/container/BossBarInfo.java index cccffa10..3c211542 100644 --- a/src/main/java/com/gamingmesh/jobs/container/BossBarInfo.java +++ b/src/main/java/com/gamingmesh/jobs/container/BossBarInfo.java @@ -10,7 +10,7 @@ public class BossBarInfo { int id = -1; public BossBarInfo(String PlayerName, String jobName, BossBar bar) { - this.PlayerName =PlayerName; + this.PlayerName = PlayerName; this.jobName = jobName; this.bar = bar; } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobInfo.java b/src/main/java/com/gamingmesh/jobs/container/JobInfo.java index fd687963..f2577948 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobInfo.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobInfo.java @@ -30,11 +30,19 @@ public class JobInfo { private Parser moneyEquation, xpEquation, pointsEquation; private int fromLevel = 0; private int untilLevel = Integer.MAX_VALUE; - + private String configPath = ""; + private Integer softIncomeLevelLimit; + private Integer softExpLevelLimit; + private Integer softPointsLevelLimit; public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation, Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath) { + this(actionType, id, meta, name, baseIncome, moneyEquation, baseXp, xpEquation, pointsEquation, basePoints, fromLevel, untilLevel, configPath, null, null, null); + } + + public JobInfo(ActionType actionType, int id, String meta, String name, double baseIncome, Parser moneyEquation, double baseXp, Parser xpEquation, + Parser pointsEquation, double basePoints, int fromLevel, int untilLevel, String configPath, Integer softIncomeLevelLimit, Integer softExpLevelLimit, Integer softPointsLevelLimit) { this.actionType = actionType; this.id = id; this.meta = meta; @@ -48,7 +56,9 @@ public class JobInfo { this.fromLevel = fromLevel; this.untilLevel = untilLevel; this.configPath = configPath; - + this.softIncomeLevelLimit = softIncomeLevelLimit; + this.softExpLevelLimit = softExpLevelLimit; + this.softPointsLevelLimit = softPointsLevelLimit; } public int getFromLevel() { @@ -92,6 +102,8 @@ public class JobInfo { } public double getIncome(double level, double numjobs) { + if (softIncomeLevelLimit != null && level > softIncomeLevelLimit) + level = softIncomeLevelLimit; if (baseIncome == 0 || !Jobs.getGCManager().PaymentMethodsMoney) return 0; moneyEquation.setVariable("joblevel", level); @@ -101,6 +113,8 @@ public class JobInfo { } public double getExperience(double level, double numjobs) { + if (softExpLevelLimit != null && level > softExpLevelLimit) + level = softExpLevelLimit; if (baseXp == 0 || !Jobs.getGCManager().PaymentMethodsExp) return 0; xpEquation.setVariable("joblevel", level); @@ -110,6 +124,8 @@ public class JobInfo { } public double getPoints(double level, double numjobs) { + if (softPointsLevelLimit != null && level > softPointsLevelLimit) + level = softPointsLevelLimit; if (basePoints == 0 || !Jobs.getGCManager().PaymentMethodsPoints) return 0; pointsEquation.setVariable("joblevel", level); diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java b/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java index b028690c..0607ef38 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java @@ -151,7 +151,7 @@ public class JobsMySQL extends JobsDAO { statement.close(); return true; } catch (SQLException e) { - Jobs.consoleMsg("Not a table |" + "SELECT * FROM " + table + "|"); +// Jobs.consoleMsg("Not a table |" + "SELECT * FROM " + table + "|"); close(statement); return false; } diff --git a/src/main/resources/jobConfig.yml b/src/main/resources/jobConfig.yml index 7a35de23..cf9cf3b9 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -38,6 +38,12 @@ Jobs: # [OPTIONAL] - the maximum number of users on the server that can have this job at # any one time (includes offline players). slots: 1 + # Soft limits will allow to stop income/exp/point payment increase at some particular level but allow further general leveling. + # In example if player is level 70, he will get paid as he would be at level 50, exp gain will be as he would be at lvl 40 and point gain will be as at level 60 + # This only aplies after players level is higher than provided particular limit. + softIncomeLimit: 50 + softExpLimit: 40 + softPointsLimit: 60 # 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