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

Fixing issue with quest chance value being opposite

This commit is contained in:
Zrips 2020-09-28 16:20:28 +03:00
parent 497673f2dc
commit 7715864301

View File

@ -18,11 +18,16 @@
package com.gamingmesh.jobs.container; package com.gamingmesh.jobs.container;
import com.gamingmesh.jobs.Jobs; import java.util.ArrayList;
import com.gamingmesh.jobs.CMILib.CMIChatColor; import java.util.Calendar;
import com.gamingmesh.jobs.CMILib.CMIMaterial; import java.util.Collections;
import com.gamingmesh.jobs.actions.PotionItemActionInfo; import java.util.Date;
import com.gamingmesh.jobs.resources.jfep.Parser; import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.function.BiPredicate;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -30,8 +35,11 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.*; import com.gamingmesh.jobs.Jobs;
import java.util.function.BiPredicate; import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
import com.gamingmesh.jobs.actions.PotionItemActionInfo;
import com.gamingmesh.jobs.resources.jfep.Parser;
public class Job { public class Job {
@ -502,6 +510,8 @@ 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<>(this.quests);
Collections.shuffle(ls); Collections.shuffle(ls);
@ -509,14 +519,11 @@ public class Job {
int i = 0; int i = 0;
while (true) { while (true) {
i++; i++;
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) if (one.getChance() <= target && (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase()))) {
if (excludeQuests == null || !excludeQuests.contains(one.getConfigName().toLowerCase())) {
if (!one.isInLevelRange(level)) if (!one.isInLevelRange(level))
continue; continue;
return one; return one;
} }
} }