1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 15:03:36 +01:00

Trying to fix quests

Fixes #936
This commit is contained in:
montlikadani 2020-10-04 10:34:50 +02:00
parent 6be60c1309
commit 2c369c57db
2 changed files with 12 additions and 13 deletions

View File

@ -84,11 +84,10 @@ public class Job {
private Parser moneyEquation, xpEquation, pointsEquation; private Parser moneyEquation, xpEquation, pointsEquation;
private List<String> fDescription = new ArrayList<>(); private final List<String> fDescription = new ArrayList<>();
private List<String> worldBlacklist = new ArrayList<>(); private List<String> worldBlacklist = new ArrayList<>();
private List<Quest> quests = new ArrayList<>(); private final List<Quest> quests = new ArrayList<>();
private int maxDailyQuests = 1; private int maxDailyQuests = 1;
private int id = 0; private int id = 0;
@ -510,23 +509,23 @@ public class Job {
// return getNextQuest(null, null); // return getNextQuest(null, null);
// } // }
Random rand = new Random(System.nanoTime());
public Quest getNextQuest(List<String> excludeQuests, Integer level) { public Quest getNextQuest(List<String> excludeQuests, Integer level) {
List<Quest> ls = new ArrayList<>(this.quests); List<Quest> ls = new ArrayList<>(quests);
Collections.shuffle(ls); Collections.shuffle(ls);
int i = 0; int i = 0;
while (true) { while (true) {
i++; i++;
final Random rand = new Random(System.nanoTime());
int target = rand.nextInt(100); int target = rand.nextInt(100);
for (Quest one : ls) { for (Quest one : ls) {
if (one.getChance() <= target && (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase()))) { if (one.getChance() >= target && (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase()))
if (!one.isInLevelRange(level)) && one.isInLevelRange(level)) {
continue;
return one; return one;
} }
} }
if (i > 20) if (i > 20)
return null; return null;
} }

View File

@ -57,10 +57,10 @@ public class Util {
if (w != null) if (w != null)
return w; return w;
name = name.replace("_", "").replace(".", "").replace("-", ""); name = name.replaceAll("[_|.|-]", "");
for (World one : Bukkit.getWorlds()) { for (World one : Bukkit.getWorlds()) {
String n = one.getName().replace("_", "").replace(".", "").replace("-", ""); String n = one.getName().replaceAll("[_|.|-]", "");
if (n.equalsIgnoreCase(name)) if (n.equalsIgnoreCase(name))
return one; return one;
} }
@ -69,7 +69,7 @@ public class Util {
} }
public static String firstToUpperCase(String name) { public static String firstToUpperCase(String name) {
return name.toLowerCase().replace("_", " ").substring(0, 1).toUpperCase() + name.toLowerCase().replace("_", " ").substring(1); return name.toLowerCase().replace('_', ' ').substring(0, 1).toUpperCase() + name.toLowerCase().replace('_', ' ').substring(1);
} }
public static HashMap<UUID, String> getJobsEditorMap() { public static HashMap<UUID, String> getJobsEditorMap() {
@ -125,7 +125,7 @@ public class Util {
break; break;
} }
} else { } else {
if (lookingFor.equals(material)) { if (lookingFor == material) {
return block; return block;
} }
} }