1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-21 15:41:19 +01:00

Lets try to update total players with full job name

- Fixes #876
This commit is contained in:
montlikadani 2020-08-11 15:23:51 +02:00
parent 9fdbc0588d
commit 9a6d657c61
5 changed files with 24 additions and 28 deletions

View File

@ -599,7 +599,7 @@ public class ConfigManager {
int amount = 10; int amount = 10;
try { try {
amount = Integer.valueOf(myKey); amount = Integer.valueOf(myKey);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!"); Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!");
return null; return null;

View File

@ -1,5 +1,6 @@
package com.gamingmesh.jobs.container; package com.gamingmesh.jobs.container;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.resources.jfep.Parser;
@ -14,10 +15,12 @@ public class CurrencyLimit {
public CurrencyLimit(boolean enabled, List<CurrencyType> stopWith, int timeLimit, int announcementDelay, Parser maxEquation) { public CurrencyLimit(boolean enabled, List<CurrencyType> stopWith, int timeLimit, int announcementDelay, Parser maxEquation) {
this.enabled = enabled; this.enabled = enabled;
this.stopWith = stopWith; this.stopWith = stopWith == null ? new ArrayList<>() : stopWith;
this.timeLimit = timeLimit; this.timeLimit = timeLimit;
this.announcementDelay = announcementDelay; this.announcementDelay = announcementDelay;
this.maxEquation = maxEquation;
if (maxEquation != null)
this.maxEquation = maxEquation;
} }
public CurrencyLimit() { public CurrencyLimit() {
@ -36,7 +39,7 @@ public class CurrencyLimit {
} }
public void setStopWith(List<CurrencyType> stopWith) { public void setStopWith(List<CurrencyType> stopWith) {
this.stopWith = stopWith; this.stopWith = stopWith == null ? new ArrayList<>() : stopWith;
} }
public int getTimeLimit() { public int getTimeLimit() {
@ -60,7 +63,8 @@ public class CurrencyLimit {
} }
public void setMaxEquation(Parser maxEquation) { public void setMaxEquation(Parser maxEquation) {
this.maxEquation = maxEquation; if (maxEquation != null)
this.maxEquation = maxEquation;
} }
} }

View File

@ -33,6 +33,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.*; import java.util.*;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import javax.swing.Box.Filler;
public class Job { public class Job {
private EnumMap<ActionType, List<JobInfo>> jobInfo = new EnumMap<>(ActionType.class); private EnumMap<ActionType, List<JobInfo>> jobInfo = new EnumMap<>(ActionType.class);
@ -150,6 +152,10 @@ public class Job {
public void updateTotalPlayers() { public void updateTotalPlayers() {
totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(jobName); totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(jobName);
if (totalPlayers <= 0) {
totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(fullName);
}
updateBonus(); updateBonus();
} }

View File

@ -49,7 +49,7 @@ public class JobsPlayer {
public ArrayList<JobProgression> progression = new ArrayList<>(); public ArrayList<JobProgression> progression = new ArrayList<>();
private ArchivedJobs archivedJobs = new ArchivedJobs(); private ArchivedJobs archivedJobs = new ArchivedJobs();
private PaymentData paymentLimits = null; private PaymentData paymentLimits;
private HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>(); private HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>();
@ -74,7 +74,7 @@ public class JobsPlayer {
private Long seen = System.currentTimeMillis(); private Long seen = System.currentTimeMillis();
private HashMap<String, Boolean> permissionsCache = null; private HashMap<String, Boolean> permissionsCache;
private Long lastPermissionUpdate = -1L; private Long lastPermissionUpdate = -1L;
private HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>(); private HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>();
@ -83,7 +83,7 @@ public class JobsPlayer {
private final HashMap<UUID, HashMap<Job, Long>> leftTimes = new HashMap<>(); private final HashMap<UUID, HashMap<Job, Long>> leftTimes = new HashMap<>();
private PlayerPoints pointsData = null; private PlayerPoints pointsData;
public JobsPlayer(String userName) { public JobsPlayer(String userName) {
this.userName = userName == null ? "Unknown" : userName; this.userName = userName == null ? "Unknown" : userName;
@ -234,10 +234,7 @@ public class JobsPlayer {
* @return the player * @return the player
*/ */
public Player getPlayer() { public Player getPlayer() {
if (playerUUID != null) return playerUUID != null ? Bukkit.getPlayer(playerUUID) : null;
return Bukkit.getPlayer(playerUUID);
return null;
} }
/** /**
@ -890,16 +887,12 @@ public class JobsPlayer {
return ls; return ls;
HashMap<String, QuestProgression> qpl = qProgression.get(job.getName()); HashMap<String, QuestProgression> qpl = qProgression.get(job.getName());
if (qpl == null) if (qpl == null)
return ls; return ls;
for (Entry<String, QuestProgression> one : qpl.entrySet()) { for (Entry<String, QuestProgression> one : qpl.entrySet()) {
QuestProgression prog = one.getValue(); QuestProgression prog = one.getValue();
if (prog.isEnded()) if (prog.isEnded() || prog.getQuest() == null)
continue;
if (prog.getQuest() == null)
continue; continue;
for (Entry<ActionType, HashMap<String, QuestObjective>> oneAction : prog.getQuest().getObjectives().entrySet()) { for (Entry<ActionType, HashMap<String, QuestObjective>> oneAction : prog.getQuest().getObjectives().entrySet()) {
@ -948,7 +941,6 @@ public class JobsPlayer {
HashMap<String, QuestProgression> orprog = qProgression.get(quest.getJob().getName()); HashMap<String, QuestProgression> orprog = qProgression.get(quest.getJob().getName());
Quest q = quest.getJob().getNextQuest(getQuestNameList(quest.getJob(), null), getJobProgression(quest.getJob()).getLevel()); Quest q = quest.getJob().getNextQuest(getQuestNameList(quest.getJob(), null), getJobProgression(quest.getJob()).getLevel());
if (q == null) { if (q == null) {
for (JobProgression one : this.getJobProgression()) { for (JobProgression one : this.getJobProgression()) {
if (one.getJob().isSame(quest.getJob())) if (one.getJob().isSame(quest.getJob()))
@ -1211,8 +1203,7 @@ public class JobsPlayer {
if (maxV == null || maxV == 0) if (maxV == null || maxV == 0)
maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault(); maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault();
int max = maxV.intValue(); return maxV.intValue();
return max;
} }
public int getMaxFurnacesAllowed() { public int getMaxFurnacesAllowed() {
@ -1221,9 +1212,7 @@ public class JobsPlayer {
if (maxV == null || maxV == 0) if (maxV == null || maxV == 0)
maxV = (double) Jobs.getGCManager().getFurnacesMaxDefault(); maxV = (double) Jobs.getGCManager().getFurnacesMaxDefault();
int max = maxV.intValue(); return maxV.intValue();
return max;
} }
public int getSkippedQuests() { public int getSkippedQuests() {
@ -1244,10 +1233,7 @@ public class JobsPlayer {
return false; return false;
HashMap<Job, Long> map = leftTimes.get(uuid); HashMap<Job, Long> map = leftTimes.get(uuid);
if (!map.containsKey(job)) return map.containsKey(job) && map.get(job).longValue() < System.currentTimeMillis();
return false;
return map.get(job).longValue() < System.currentTimeMillis();
} }
public void setLeftTime(Job job) { public void setLeftTime(Job job) {

View File

@ -1192,7 +1192,7 @@ public abstract class JobsDAO {
ResultSet res = null; ResultSet res = null;
try { try {
Job job = Jobs.getJob(JobName); Job job = Jobs.getJob(JobName);
if (job != null) { if (job != null && job.getId() != 0) {
prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;"); prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;");
prest.setInt(1, job.getId()); prest.setInt(1, job.getId());
res = prest.executeQuery(); res = prest.executeQuery();