1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00

Add permission based max quests

Closes #964
Closes #809
This commit is contained in:
montlikadani 2020-11-16 21:57:09 +01:00
parent 416ad5f8e7
commit e24dba84a6
5 changed files with 29 additions and 8 deletions

View File

@ -156,7 +156,7 @@ public class PermissionManager {
else if (amount == 0D || allowMinus || temp > amount) else if (amount == 0D || allowMinus || temp > amount)
amount = temp; amount = temp;
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
ignored.printStackTrace(); // Should be ignored
} }
} }

View File

@ -1169,8 +1169,7 @@ public class ConfigManager {
desc = sqsection.getStringList("RewardDesc"), desc = sqsection.getStringList("RewardDesc"),
areas = sqsection.getStringList("RestrictedAreas"); areas = sqsection.getStringList("RestrictedAreas");
if (sqsection.isInt("fromLevel")) quest.setMinLvl(sqsection.getInt("fromLevel"));
quest.setMinLvl(sqsection.getInt("fromLevel"));
if (sqsection.isInt("toLevel")) if (sqsection.isInt("toLevel"))
quest.setMaxLvl(sqsection.getInt("toLevel")); quest.setMaxLvl(sqsection.getInt("toLevel"));

View File

@ -304,6 +304,22 @@ public class JobsPlayer {
return Boost; return Boost;
} }
public int getPlayerMaxQuest(String jobName) {
int m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest." + jobName, false, true, false).intValue();
int max = m1;
m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest.all", false, true, false).intValue();
if (m1 != 0 && (m1 > max || m1 < max)) {
max = m1;
}
m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest", false, true, false).intValue();
if (m1 != 0 && (m1 > max || m1 < max)) {
max = m1;
}
return max;
}
/** /**
* Reloads max experience for this job. * Reloads max experience for this job.

View File

@ -16,8 +16,7 @@ public class Quest {
private Job job; private Job job;
private Long validUntil = 0L; private Long validUntil = 0L;
private int chance = 100; private int chance = 100, minLvl = 0;
private Integer minLvl = null;
private Integer maxLvl = null; private Integer maxLvl = null;
private final List<String> rewardCmds = new ArrayList<>(), rewards = new ArrayList<>(), area = new ArrayList<>(); private final List<String> rewardCmds = new ArrayList<>(), rewards = new ArrayList<>(), area = new ArrayList<>();
@ -126,7 +125,7 @@ public class Quest {
this.configName = configName; this.configName = configName;
} }
public Integer getMinLvl() { public int getMinLvl() {
return minLvl; return minLvl;
} }
@ -146,10 +145,10 @@ public class Quest {
if (level == null) if (level == null)
return true; return true;
if (getMinLvl() != null && level < getMinLvl()) if (level < minLvl)
return false; return false;
if (getMaxLvl() != null && level > getMaxLvl()) if (maxLvl != null && level > maxLvl)
return false; return false;
return true; return true;

View File

@ -104,6 +104,13 @@ public class QuestProgression {
} }
} }
if (quest.getJob() != null) {
int maxQuest = jPlayer.getPlayerMaxQuest(quest.getJob().getName());
if (maxQuest > 0 && jPlayer.getDoneQuests() >= maxQuest) {
return;
}
}
if (!isCompleted()) { if (!isCompleted()) {
HashMap<String, QuestObjective> byAction = quest.getObjectives().get(action.getType()); HashMap<String, QuestObjective> byAction = quest.getObjectives().get(action.getType());