1 | package sh.okx.rankup.requirements.requirement; | |
2 | ||
3 | import org.bukkit.Bukkit; | |
4 | import org.bukkit.advancement.Advancement; | |
5 | import org.bukkit.advancement.AdvancementProgress; | |
6 | import org.bukkit.entity.Player; | |
7 | import sh.okx.rankup.RankupPlugin; | |
8 | import sh.okx.rankup.requirements.Requirement; | |
9 | ||
10 | import java.util.Iterator; | |
11 | import java.util.regex.Pattern; | |
12 | ||
13 | /** | |
14 | * Advancement requirement | |
15 | * @author Link, with modifications from Okx | |
16 | */ | |
17 | public class AdvancementRequirement extends Requirement { | |
18 | public AdvancementRequirement(RankupPlugin plugin) { | |
19 | super(plugin, "advancement"); | |
20 | } | |
21 | ||
22 | protected AdvancementRequirement(Requirement clone) { | |
23 | super(clone); | |
24 | } | |
25 | ||
26 | @Override | |
27 | public boolean check(Player player) { | |
28 | for (String string : getValuesString()) { | |
29 | Iterator<Advancement> advancementIterator = Bukkit.advancementIterator(); | |
30 | while (advancementIterator.hasNext()) { | |
31 | Advancement adv = advancementIterator.next(); | |
32 | String key = adv.getKey().getKey(); | |
33 | Pattern pattern = Pattern.compile(string.replace("*", ".*").replace("-", "")); | |
34 |
1
1. check : negated conditional → NO_COVERAGE |
if (pattern.matcher(key).find()) { |
35 |
1
1. check : negated conditional → NO_COVERAGE |
boolean positive = !string.startsWith("-"); |
36 | ||
37 | AdvancementProgress progress = player.getAdvancementProgress(adv); | |
38 |
1
1. check : negated conditional → NO_COVERAGE |
if (progress.isDone() == positive) { |
39 |
1
1. check : replaced boolean return with false for sh/okx/rankup/requirements/requirement/AdvancementRequirement::check → NO_COVERAGE |
return true; |
40 | } | |
41 | } | |
42 | ||
43 | ||
44 | } | |
45 | } | |
46 |
1
1. check : replaced boolean return with true for sh/okx/rankup/requirements/requirement/AdvancementRequirement::check → NO_COVERAGE |
return false; |
47 | } | |
48 | ||
49 | @Override | |
50 | public Requirement clone() { | |
51 |
1
1. clone : replaced return value with null for sh/okx/rankup/requirements/requirement/AdvancementRequirement::clone → NO_COVERAGE |
return new AdvancementRequirement(this); |
52 | } | |
53 | ||
54 | @Override | |
55 | public double getValueDouble() { | |
56 |
1
1. getValueDouble : replaced double return with 0.0d for sh/okx/rankup/requirements/requirement/AdvancementRequirement::getValueDouble → NO_COVERAGE |
return 1; |
57 | } | |
58 | } | |
Mutations | ||
34 |
1.1 |
|
35 |
1.1 |
|
38 |
1.1 |
|
39 |
1.1 |
|
46 |
1.1 |
|
51 |
1.1 |
|
56 |
1.1 |