mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-21 15:41:19 +01:00
Fixing issue with quest chance value being opposite
This commit is contained in:
parent
497673f2dc
commit
7715864301
@ -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 {
|
||||||
|
|
||||||
@ -231,14 +239,14 @@ public class Job {
|
|||||||
|
|
||||||
public JobInfo getJobInfo(ActionInfo action, int level) {
|
public JobInfo getJobInfo(ActionInfo action, int level) {
|
||||||
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
|
BiPredicate<JobInfo, ActionInfo> condition = (jobInfo, actionInfo) -> {
|
||||||
if (actionInfo instanceof PotionItemActionInfo) {
|
if (actionInfo instanceof PotionItemActionInfo) {
|
||||||
return jobInfo.getName().equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithSub()) ||
|
return jobInfo.getName().equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithSub()) ||
|
||||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithSub());
|
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(((PotionItemActionInfo) action).getNameWithSub());
|
||||||
}
|
}
|
||||||
|
|
||||||
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
|
return jobInfo.getName().equalsIgnoreCase(action.getNameWithSub()) ||
|
||||||
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
|
(jobInfo.getName() + ":" + jobInfo.getMeta()).equalsIgnoreCase(action.getNameWithSub()) ||
|
||||||
jobInfo.getName().equalsIgnoreCase(action.getName());
|
jobInfo.getName().equalsIgnoreCase(action.getName());
|
||||||
};
|
};
|
||||||
|
|
||||||
String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName());
|
String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName());
|
||||||
@ -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,16 +519,13 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (i > 20)
|
if (i > 20)
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user