1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

To disable max job limit now it needs to be set to -1 and not 0

This commit is contained in:
Zrips 2023-08-29 12:59:05 +03:00
parent d4a75f1fe8
commit 7ba5a2bd86
6 changed files with 22 additions and 16 deletions

View File

@ -154,7 +154,7 @@ public final class Jobs extends JavaPlugin {
private GuiManager guiManager;
private static JobsDAO dao;
private static List<Job> jobs;
private static List<Job> jobs = new ArrayList<Job>();
private static Job noneJob;
private static Map<Job, Integer> usedSlots = new WeakHashMap<>();

View File

@ -582,7 +582,8 @@ public class Placeholder {
return convert(true);
case maxjobs:
return Integer.toString(Jobs.getPlayerManager().getMaxJobs(user));
int max = Jobs.getPlayerManager().getMaxJobs(user);
return Integer.toString(max == -1 ? 99 : max);
default:
break;

View File

@ -63,9 +63,9 @@ import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.NBT.CMINBT;
import net.Zrips.CMILib.Version.Version;
@ -488,10 +488,10 @@ public class PlayerManager {
Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers();
jPlayer.maxJobsEquation = getMaxJobs(jPlayer);
jPlayer.maxJobsEquation = CMINumber.clamp(getMaxJobs(jPlayer), 0, 9999);
// Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId());
cache.remove(jPlayer.getUniqueId());
}
private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) {
@ -533,10 +533,10 @@ public class PlayerManager {
Jobs.getSignUtil().updateAllSign(job);
job.updateTotalPlayers();
// Removing from cached item boost for recalculation
cache.remove(jPlayer.getUniqueId());
cache.remove(jPlayer.getUniqueId());
return true;
}
@ -931,7 +931,8 @@ public class PlayerManager {
* @return true if the player is under the given jobs size
*/
public boolean getJobsLimit(JobsPlayer jPlayer, short currentCount) {
return getMaxJobs(jPlayer) > currentCount;
int max = getMaxJobs(jPlayer);
return max == -1 ? true : max > currentCount;
}
/**
@ -1064,7 +1065,7 @@ public class PlayerManager {
continue;
}
}
jitems.add(getJobsItemByNbt(item));
}
}
@ -1214,11 +1215,11 @@ public class PlayerManager {
int playerMaxJobs = getMaxJobs(jPlayer);
int playerCurrentJobs = jPlayer.progression.size();
if (playerMaxJobs <= 0 || playerCurrentJobs >= playerMaxJobs)
if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs)
return;
for (Job one : Jobs.getJobs()) {
if (jPlayer.progression.size() >= playerMaxJobs)
if (playerMaxJobs != -1 && jPlayer.progression.size() >= playerMaxJobs)
return;
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())

View File

@ -1571,6 +1571,8 @@ public class ConfigManager {
return job;
}
}
return null;
}

View File

@ -45,6 +45,7 @@ import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.FileHandler.ConfigReader;
import net.Zrips.CMILib.Items.CMIItemStack;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
import net.Zrips.CMILib.Messages.CMIMessages;
import net.Zrips.CMILib.Version.Version;
@ -442,9 +443,9 @@ public class GeneralConfigManager {
"For this to work, the player needs to get a new job for the timer to start.", "Counting in hours");
jobExpiryTime = c.get("JobExpirationTime", 0);
c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use 0 for no maximum", "Keep in mind that jobs.max.[amount] will bypass this setting");
c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use -1 to disable limitations", "Keep in mind that jobs.max.[amount] will bypass this setting");
maxJobs = c.get("max-jobs", 3);
c.addComment("disable-payment-if-max-level-reached", "Disabling the payment if the user reached the maximum level of a job.");
disablePaymentIfMaxLevelReached = c.get("disable-payment-if-max-level-reached", false);

View File

@ -43,6 +43,7 @@ import com.gamingmesh.jobs.economy.PaymentData;
import net.Zrips.CMILib.ActionBar.CMIActionBar;
import net.Zrips.CMILib.Colors.CMIChatColor;
import net.Zrips.CMILib.Container.CMINumber;
import net.Zrips.CMILib.Equations.Parser;
import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.Logs.CMIDebug;
@ -442,7 +443,7 @@ public class JobsPlayer {
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
eq.setVariable("totallevel", getTotalLevels());
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this);
maxJobsEquation = CMINumber.clamp(Jobs.getPlayerManager().getMaxJobs(this), 0, 9999);
limits.put(type, (int) eq.getValue());
setSaved(false);
}