mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Excluding job count with ignore-jobs-max
This commit is contained in:
parent
ddc9000f8f
commit
a23b0af09b
@ -5,7 +5,6 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -97,7 +96,7 @@ public class GuiManager {
|
|||||||
Job job = jobsList.get(i);
|
Job job = jobsList.get(i);
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
for (JobProgression onePJob : jPlayer.progression) {
|
for (JobProgression onePJob : jPlayer.getJobProgression()) {
|
||||||
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName())) {
|
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName())) {
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
|
lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
|
||||||
break;
|
break;
|
||||||
@ -272,7 +271,7 @@ public class GuiManager {
|
|||||||
ItemStack guiItem = job.getGuiItem().clone();
|
ItemStack guiItem = job.getGuiItem().clone();
|
||||||
|
|
||||||
int level = prog != null ? prog.getLevel() : 1;
|
int level = prog != null ? prog.getLevel() : 1;
|
||||||
int numjobs = jPlayer.progression.size();
|
int numjobs = jPlayer.getJobProgression().size();
|
||||||
int nextButton = Jobs.getGCManager().getJobsGUINextButton();
|
int nextButton = Jobs.getGCManager().getJobsGUINextButton();
|
||||||
int backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
int backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
||||||
|
|
||||||
@ -488,7 +487,7 @@ public class GuiManager {
|
|||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job);
|
||||||
|
|
||||||
int numjobs = jPlayer.progression.size();
|
int numjobs = jPlayer.getJobProgression().size();
|
||||||
int level = jPlayer.getJobProgression(job) != null ? jPlayer.getJobProgression(job).getLevel() : 1;
|
int level = jPlayer.getJobProgression(job) != null ? jPlayer.getJobProgression(job).getLevel() : 1;
|
||||||
|
|
||||||
ItemStack guiItem = job.getGuiItem().clone();
|
ItemStack guiItem = job.getGuiItem().clone();
|
||||||
@ -510,15 +509,15 @@ public class GuiManager {
|
|||||||
|
|
||||||
double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation);
|
double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation);
|
||||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
String incomeColor = income >= 0 ? "" : CMIChatColor.DARK_RED.toString();
|
||||||
|
|
||||||
double xp = jInfo.getExperience(level, numjobs, jPlayer.maxJobsEquation);
|
double xp = jInfo.getExperience(level, numjobs, jPlayer.maxJobsEquation);
|
||||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
String xpColor = xp >= 0 ? "" : CMIChatColor.GRAY.toString();
|
||||||
|
|
||||||
double points = jInfo.getPoints(level, numjobs, jPlayer.maxJobsEquation);
|
double points = jInfo.getPoints(level, numjobs, jPlayer.maxJobsEquation);
|
||||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||||
String pointsColor = points >= 0 ? "" : ChatColor.RED.toString();
|
String pointsColor = points >= 0 ? "" : CMIChatColor.RED.toString();
|
||||||
|
|
||||||
if (income == 0D && points == 0D && xp == 0D)
|
if (income == 0D && points == 0D && xp == 0D)
|
||||||
continue;
|
continue;
|
||||||
|
@ -382,7 +382,7 @@ public class Placeholder {
|
|||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(value);
|
int id = Integer.parseInt(value);
|
||||||
if (id > 0)
|
if (id > 0)
|
||||||
return user.progression.get(id - 1);
|
return user.getJobProgression().get(id - 1);
|
||||||
} catch (IndexOutOfBoundsException | NumberFormatException e) {
|
} catch (IndexOutOfBoundsException | NumberFormatException e) {
|
||||||
Job job = Jobs.getJob(value);
|
Job job = Jobs.getJob(value);
|
||||||
if (job != null)
|
if (job != null)
|
||||||
@ -465,18 +465,18 @@ public class Placeholder {
|
|||||||
case user_displayhonorific:
|
case user_displayhonorific:
|
||||||
return user.getDisplayHonorific();
|
return user.getDisplayHonorific();
|
||||||
case user_joinedjobcount:
|
case user_joinedjobcount:
|
||||||
return Integer.toString(user.progression.size());
|
return Integer.toString(user.getJobProgression().size());
|
||||||
case user_archived_jobs:
|
case user_archived_jobs:
|
||||||
return Integer.toString(user.getArchivedJobs().getArchivedJobs().size());
|
return Integer.toString(user.getArchivedJobs().getArchivedJobs().size());
|
||||||
case user_jobs:
|
case user_jobs:
|
||||||
StringBuilder jobNames = new StringBuilder();
|
StringBuilder jobNames = new StringBuilder();
|
||||||
for (JobProgression prog : user.progression) {
|
for (JobProgression prog : user.getJobProgression()) {
|
||||||
if (!jobNames.toString().isEmpty()) {
|
if (!jobNames.toString().isEmpty()) {
|
||||||
jobNames.append(LC.info_ListSpliter.getLocale());
|
jobNames.append(LC.info_ListSpliter.getLocale());
|
||||||
}
|
}
|
||||||
jobNames.append(prog.getJob().getDisplayName());
|
jobNames.append(prog.getJob().getDisplayName());
|
||||||
}
|
}
|
||||||
if (user.progression.isEmpty()) {
|
if (user.getJobProgression().isEmpty()) {
|
||||||
if (Jobs.getNoneJob() != null)
|
if (Jobs.getNoneJob() != null)
|
||||||
jobNames.append(Jobs.getNoneJob().getDisplayName());
|
jobNames.append(Jobs.getNoneJob().getDisplayName());
|
||||||
}
|
}
|
||||||
@ -579,7 +579,7 @@ public class Placeholder {
|
|||||||
if (!Jobs.getCommandManager().hasJobPermission(player, job) ||
|
if (!Jobs.getCommandManager().hasJobPermission(player, job) ||
|
||||||
user.isInJob(job) ||
|
user.isInJob(job) ||
|
||||||
job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots() ||
|
job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots() ||
|
||||||
!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(user, (short) user.progression.size()))
|
!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(user, (short) user.getJobProgression().size()))
|
||||||
return convert(false);
|
return convert(false);
|
||||||
|
|
||||||
return convert(true);
|
return convert(true);
|
||||||
|
@ -325,7 +325,7 @@ public class PlayerManager {
|
|||||||
if (!resetID && jPlayer.getUserId() == -1)
|
if (!resetID && jPlayer.getUserId() == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (JobProgression oneJ : jPlayer.progression)
|
for (JobProgression oneJ : jPlayer.getJobProgression())
|
||||||
dao.insertJob(jPlayer, oneJ);
|
dao.insertJob(jPlayer, oneJ);
|
||||||
|
|
||||||
dao.saveLog(jPlayer);
|
dao.saveLog(jPlayer);
|
||||||
@ -547,7 +547,7 @@ public class PlayerManager {
|
|||||||
* @param jPlayer {@link JobsPlayer}
|
* @param jPlayer {@link JobsPlayer}
|
||||||
*/
|
*/
|
||||||
public void leaveAllJobs(JobsPlayer jPlayer) {
|
public void leaveAllJobs(JobsPlayer jPlayer) {
|
||||||
for (JobProgression job : new ArrayList<>(jPlayer.progression))
|
for (JobProgression job : new ArrayList<>(jPlayer.getJobProgression()))
|
||||||
leaveJob(jPlayer, job.getJob());
|
leaveJob(jPlayer, job.getJob());
|
||||||
|
|
||||||
jPlayer.leaveAllJobs();
|
jPlayer.leaveAllJobs();
|
||||||
@ -976,7 +976,7 @@ public class PlayerManager {
|
|||||||
*/
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
for (JobsPlayer jPlayer : playersUUID.values()) {
|
for (JobsPlayer jPlayer : playersUUID.values()) {
|
||||||
for (JobProgression progression : jPlayer.progression) {
|
for (JobProgression progression : jPlayer.getJobProgression()) {
|
||||||
Job job = Jobs.getJob(progression.getJob().getName());
|
Job job = Jobs.getJob(progression.getJob().getName());
|
||||||
if (job != null)
|
if (job != null)
|
||||||
progression.setJob(job);
|
progression.setJob(job);
|
||||||
@ -1193,13 +1193,13 @@ public class PlayerManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int playerMaxJobs = getMaxJobs(jPlayer);
|
int playerMaxJobs = getMaxJobs(jPlayer);
|
||||||
int playerCurrentJobs = jPlayer.progression.size();
|
int playerCurrentJobs = jPlayer.getJobProgression().size();
|
||||||
|
|
||||||
if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs)
|
if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Job one : Jobs.getJobs()) {
|
for (Job one : Jobs.getJobs()) {
|
||||||
if (playerMaxJobs != -1 && jPlayer.progression.size() >= playerMaxJobs)
|
if (playerMaxJobs != -1 && jPlayer.getJobProgression().size() >= playerMaxJobs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
|
if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots())
|
||||||
|
@ -364,7 +364,7 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int level = prog != null ? prog.getLevel() : 1;
|
int level = prog != null ? prog.getLevel() : 1;
|
||||||
int numjobs = player.progression.size();
|
int numjobs = player.getJobCount();
|
||||||
|
|
||||||
for (JobInfo info : job.getJobInfo(type)) {
|
for (JobInfo info : job.getJobInfo(type)) {
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class fireall implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jPlayer.progression.isEmpty()) {
|
if (jPlayer.getJobProgression().isEmpty()) {
|
||||||
Language.sendMessage(sender, "command.fireall.error.nojobs");
|
Language.sendMessage(sender, "command.fireall.error.nojobs");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class join implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) {
|
if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.getJobCount(false))) {
|
||||||
Language.sendMessage(sender, "command.join.error.maxjobs");
|
Language.sendMessage(sender, "command.join.error.maxjobs");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class quests implements Cmd {
|
|||||||
|
|
||||||
Language.sendMessage(sender, "command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests());
|
Language.sendMessage(sender, "command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests());
|
||||||
|
|
||||||
for (JobProgression jobProg : jPlayer.progression) {
|
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
||||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||||
|
|
||||||
for (QuestProgression q : list) {
|
for (QuestProgression q : list) {
|
||||||
@ -171,7 +171,7 @@ public class quests implements Cmd {
|
|||||||
gui.addLock(InvType.Gui);
|
gui.addLock(InvType.Gui);
|
||||||
gui.addLock(InvType.Main);
|
gui.addLock(InvType.Main);
|
||||||
|
|
||||||
for (JobProgression jobProg : jPlayer.progression) {
|
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
||||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||||
|
|
||||||
for (QuestProgression q : list) {
|
for (QuestProgression q : list) {
|
||||||
|
@ -35,7 +35,7 @@ public class stats implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jPlayer.progression.isEmpty()) {
|
if (jPlayer.getJobProgression().isEmpty()) {
|
||||||
Language.sendMessage(sender, "command.stats.error.nojob");
|
Language.sendMessage(sender, "command.stats.error.nojob");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class BossBarManager {
|
|||||||
if (Version.getCurrent().isLower(Version.v1_9_R1) || player == null)
|
if (Version.getCurrent().isLower(Version.v1_9_R1) || player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (JobProgression oneJob : player.progression) {
|
for (JobProgression oneJob : player.getJobProgression()) {
|
||||||
if (oneJob.getLastExperience() != 0) {
|
if (oneJob.getLastExperience() != 0) {
|
||||||
ShowJobProgression(player, oneJob, oneJob.getLastExperience());
|
ShowJobProgression(player, oneJob, oneJob.getLastExperience());
|
||||||
}
|
}
|
||||||
|
@ -168,14 +168,14 @@ public class JobProgression {
|
|||||||
public void reloadMaxExperience() {
|
public void reloadMaxExperience() {
|
||||||
Map<String, Double> param = new HashMap<>();
|
Map<String, Double> param = new HashMap<>();
|
||||||
param.put("joblevel", (double) level);
|
param.put("joblevel", (double) level);
|
||||||
param.put("numjobs", (double) jPlayer.progression.size());
|
param.put("numjobs", (double) jPlayer.getJobProgression().size());
|
||||||
maxExperience = (int) job.getMaxExp(param);
|
maxExperience = (int) job.getMaxExp(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxExperience(int level) {
|
public int getMaxExperience(int level) {
|
||||||
Map<String, Double> param = new HashMap<>();
|
Map<String, Double> param = new HashMap<>();
|
||||||
param.put("joblevel", (double) level);
|
param.put("joblevel", (double) level);
|
||||||
param.put("numjobs", (double) jPlayer.progression.size());
|
param.put("numjobs", (double) jPlayer.getJobProgression().size());
|
||||||
return (int) job.getMaxExp(param);
|
return (int) job.getMaxExp(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ import net.Zrips.CMILib.Colors.CMIChatColor;
|
|||||||
import net.Zrips.CMILib.Container.CMINumber;
|
import net.Zrips.CMILib.Container.CMINumber;
|
||||||
import net.Zrips.CMILib.Equations.Parser;
|
import net.Zrips.CMILib.Equations.Parser;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
|
||||||
import net.Zrips.CMILib.Time.CMITimeManager;
|
import net.Zrips.CMILib.Time.CMITimeManager;
|
||||||
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
|
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
|
||||||
import net.Zrips.CMILib.Version.Schedulers.CMITask;
|
import net.Zrips.CMILib.Version.Schedulers.CMITask;
|
||||||
@ -476,6 +475,24 @@ public class JobsPlayer {
|
|||||||
return Collections.unmodifiableList(progression);
|
return Collections.unmodifiableList(progression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getJobCount() {
|
||||||
|
return getJobCount(true);
|
||||||
|
}
|
||||||
|
public int getJobCount(boolean includeIgnoredMaxJobs) {
|
||||||
|
|
||||||
|
if (includeIgnoredMaxJobs)
|
||||||
|
return progression.size();
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (JobProgression one : progression) {
|
||||||
|
if (one.getJob().isIgnoreMaxJobs())
|
||||||
|
continue;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the job progression from the certain job
|
* Get the job progression from the certain job
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user