1 | package sh.okx.rankup.placeholders; | |
2 | ||
3 | import lombok.RequiredArgsConstructor; | |
4 | import org.bukkit.entity.Player; | |
5 | import sh.okx.rankup.RankupPlugin; | |
6 | import sh.okx.rankup.prestige.Prestige; | |
7 | import sh.okx.rankup.prestige.Prestiges; | |
8 | import sh.okx.rankup.ranks.Rank; | |
9 | import sh.okx.rankup.ranks.RankElement; | |
10 | import sh.okx.rankup.ranks.Rankups; | |
11 | import sh.okx.rankup.requirements.Requirement; | |
12 | ||
13 | import java.util.Objects; | |
14 | import java.util.function.Function; | |
15 | import java.util.regex.Matcher; | |
16 | import java.util.regex.Pattern; | |
17 | ||
18 | @RequiredArgsConstructor | |
19 | public class RankupExpansion implements Expansion { | |
20 | private static final Pattern PATTERN = Pattern.compile("(.*)#(.*)"); | |
21 | ||
22 | private final RankupPlugin plugin; | |
23 | private final Placeholders placeholders; | |
24 | ||
25 | @Override | |
26 | public String placeholder(Player player, String params) { | |
27 |
1
1. placeholder : negated conditional → KILLED |
if (player == null) { |
28 | return ""; | |
29 | } | |
30 | params = params.toLowerCase(); | |
31 | ||
32 | Rankups rankups = plugin.getRankups(); | |
33 | RankElement<Rank> rankElement = rankups.getByPlayer(player); | |
34 |
1
1. placeholder : negated conditional → KILLED |
Rank rank = rankElement == null ? null : rankElement.getRank(); |
35 | ||
36 | Prestiges prestiges = plugin.getPrestiges(); | |
37 | RankElement<Prestige> prestigeElement = null; | |
38 | Prestige prestige = null; | |
39 |
1
1. placeholder : negated conditional → KILLED |
if (prestiges != null) { |
40 | prestigeElement = prestiges.getByPlayer(player); | |
41 |
1
1. placeholder : negated conditional → NO_COVERAGE |
prestige = prestigeElement == null ? null : prestigeElement.getRank(); |
42 | } | |
43 | ||
44 |
1
1. placeholder : negated conditional → KILLED |
if (params.startsWith("requirement_")) { |
45 | String[] parts = params.split("_", 3); | |
46 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholderRequirement(player, rank, |
47 |
2
1. placeholder : changed conditional boundary → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
replacePattern(parts[1]), parts.length > 2 ? parts[2] : ""); |
48 |
1
1. placeholder : negated conditional → KILLED |
} else if (params.startsWith("rank_requirement_")) { |
49 | String[] parts = params.split("_", 5); | |
50 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholderRequirement(player, rankups.getRankByName(parts[2]), |
51 |
2
1. placeholder : changed conditional boundary → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
replacePattern(parts[3]), parts.length > 4 ? parts[4] : ""); |
52 |
1
1. placeholder : negated conditional → KILLED |
} else if (params.startsWith("rank_money_")) { |
53 | String[] parts = params.split("_", 4); | |
54 | double amount = Objects.requireNonNull(rankups.getRankByName(parts[2]), "Rankup " + parts[2] + " does not exist").getRequirement(player, "money").getValueDouble(); | |
55 |
3
1. placeholder : changed conditional boundary → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE 3. placeholder : negated conditional → NO_COVERAGE |
if (parts.length > 3 && parts[3].equalsIgnoreCase("left")) { |
56 |
1
1. placeholder : Replaced double subtraction with addition → NO_COVERAGE |
amount = amount - plugin.getEconomy().getBalance(player); |
57 | } | |
58 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return plugin.getPlaceholders().formatMoney(Math.max(0, amount)); |
59 |
1
1. placeholder : negated conditional → KILLED |
} else if (params.startsWith("status_")) { |
60 | String[] parts = params.split("_", 2); | |
61 | Rank statusRank = rankups.getRankByName(parts[1]); | |
62 | ||
63 |
1
1. placeholder : negated conditional → KILLED |
if (statusRank == null) { |
64 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return null; |
65 | } | |
66 |
1
1. placeholder : negated conditional → KILLED |
if (rank == null) { |
67 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("status.incomplete"); |
68 | } | |
69 |
1
1. placeholder : negated conditional → KILLED |
if (statusRank.equals(rank)) { |
70 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return getPlaceholder("status.current"); |
71 | } | |
72 | ||
73 | // is playerRank before or after statusRank? | |
74 | for (RankElement<Rank> element : rankups.getTree().asList()) { | |
75 |
1
1. placeholder : negated conditional → KILLED |
if (element.getRank().equals(statusRank)) { |
76 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return getPlaceholder("status.complete"); |
77 |
1
1. placeholder : negated conditional → KILLED |
} else if (element.getRank().equals(rank)) { |
78 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return getPlaceholder("status.incomplete"); |
79 | } | |
80 | } | |
81 | ||
82 | // this should not happen | |
83 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return null; |
84 | } | |
85 | ||
86 | switch (params) { | |
87 | case "current_prestige": | |
88 |
1
1. placeholder : removed call to sh/okx/rankup/placeholders/RankupExpansion::requirePrestiging → SURVIVED |
requirePrestiging(prestiges, params); |
89 |
2
1. placeholder : negated conditional → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
if (prestige == null || prestige.getRank() == null) { |
90 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("no-prestige"); |
91 | } else { | |
92 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return prestige.getRank(); |
93 | } | |
94 | case "current_prestige_name": | |
95 |
1
1. placeholder : removed call to sh/okx/rankup/placeholders/RankupExpansion::requirePrestiging → NO_COVERAGE |
requirePrestiging(prestiges, params); |
96 |
2
1. placeholder : negated conditional → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
if (prestige == null || prestige.getRank() == null) { |
97 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("no-prestige"); |
98 | } else { | |
99 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return prestige.getDisplayName(); |
100 | } | |
101 | case "next_prestige": | |
102 |
1
1. placeholder : removed call to sh/okx/rankup/placeholders/RankupExpansion::requirePrestiging → SURVIVED |
requirePrestiging(prestiges, params); |
103 |
2
1. placeholder : negated conditional → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
if (prestigeElement != null && !prestigeElement.hasNext()) { |
104 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("highest-rank"); |
105 | } | |
106 |
2
1. lambda$placeholder$0 : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$0 → NO_COVERAGE 2. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return orElse(prestigeElement, e -> e.getNext().getRank().getRank(), prestiges.getTree().getFirst().getNext().getRank().getRank()); |
107 | case "next_prestige_name": | |
108 |
1
1. placeholder : removed call to sh/okx/rankup/placeholders/RankupExpansion::requirePrestiging → NO_COVERAGE |
requirePrestiging(prestiges, params); |
109 |
2
1. placeholder : negated conditional → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
if (prestigeElement != null && !prestigeElement.hasNext()) { |
110 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("highest-rank"); |
111 | } else { | |
112 |
2
1. lambda$placeholder$1 : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$1 → NO_COVERAGE 2. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return orElse(prestigeElement, e -> e.getNext().getRank().getDisplayName(), prestiges.getTree().getFirst().getNext().getRank().getDisplayName()); |
113 | } | |
114 | case "prestige_money": | |
115 |
1
1. placeholder : removed call to sh/okx/rankup/placeholders/RankupExpansion::requirePrestiging → NO_COVERAGE |
requirePrestiging(prestiges, params); |
116 |
3
1. lambda$placeholder$2 : negated conditional → NO_COVERAGE 2. lambda$placeholder$2 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$2 → NO_COVERAGE 3. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return String.valueOf(simplify(orElse(prestige, r -> r.isIn(player) ? r.getRequirement(player, "money").getValueDouble() : 0, 0))); |
117 | case "prestige_money_formatted": | |
118 |
1
1. placeholder : removed call to sh/okx/rankup/placeholders/RankupExpansion::requirePrestiging → SURVIVED |
requirePrestiging(prestiges, params); |
119 |
3
1. lambda$placeholder$3 : negated conditional → NO_COVERAGE 2. lambda$placeholder$3 : replaced Double return value with 0 for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$3 → NO_COVERAGE 3. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return plugin.getPlaceholders().formatMoney(orElse(prestige, r -> r.isIn(player) ? r.getRequirement(player, "money").getValueDouble() : 0, 0D)); |
120 | case "current_rank": | |
121 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return orElse(rank, Rank::getRank, getPlaceholder("not-in-ladder")); |
122 | case "current_rank_name": | |
123 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return orElse(rank, Rank::getDisplayName, getPlaceholder("not-in-ladder")); |
124 | case "next_rank": | |
125 |
2
1. placeholder : negated conditional → SURVIVED 2. placeholder : negated conditional → KILLED |
if (rankElement != null && !rankElement.hasNext()) { |
126 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("highest-rank"); |
127 | } else { | |
128 |
2
1. lambda$placeholder$4 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$4 → KILLED 2. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return orElsePlaceholder(rankElement, e -> e.getNext().getRank().getRank(), "not-in-ladder"); |
129 | } | |
130 | case "next_rank_name": | |
131 |
2
1. placeholder : negated conditional → NO_COVERAGE 2. placeholder : negated conditional → NO_COVERAGE |
if (rankElement != null && !rankElement.hasNext()) { |
132 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return getPlaceholder("highest-rank"); |
133 | } else { | |
134 |
2
1. lambda$placeholder$5 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$5 → NO_COVERAGE 2. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return orElsePlaceholder(rankElement, e -> e.getNext().getRank().getDisplayName(), "not-in-ladder"); |
135 | } | |
136 | case "money": | |
137 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return String.valueOf(getMoney(player, rank)); |
138 | case "money_formatted": | |
139 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → SURVIVED |
return placeholders.formatMoney(getMoney(player, rank).doubleValue()); |
140 | case "money_left": | |
141 |
3
1. lambda$placeholder$6 : Replaced double subtraction with addition → KILLED 2. lambda$placeholder$6 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$6 → KILLED 3. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → KILLED |
return String.valueOf(Math.max(0, orElse(rank, r -> simplify(r.getRequirement(player, "money").getValueDouble() - plugin.getEconomy().getBalance(player)), 0).doubleValue())); |
142 | case "money_left_formatted": | |
143 |
3
1. lambda$placeholder$7 : Replaced double subtraction with addition → NO_COVERAGE 2. lambda$placeholder$7 : replaced Double return value with 0 for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$7 → NO_COVERAGE 3. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → SURVIVED |
return placeholders.formatMoney(Math.max(0D, orElse(rank, r -> r.getRequirement(player, "money").getValueDouble() - plugin.getEconomy().getBalance(player), 0D))); |
144 | case "percent_left": | |
145 |
5
1. lambda$placeholder$8 : Replaced double division with multiplication → NO_COVERAGE 2. lambda$placeholder$8 : Replaced double subtraction with addition → NO_COVERAGE 3. lambda$placeholder$8 : Replaced double multiplication with division → NO_COVERAGE 4. lambda$placeholder$8 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$8 → NO_COVERAGE 5. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return String.valueOf(Math.max(0D, orElse(rank, r -> (1 - (plugin.getEconomy().getBalance(player) / r.getRequirement(player, "money").getValueDouble())) * 100, 0).doubleValue())); |
146 | case "percent_left_formatted": | |
147 |
5
1. lambda$placeholder$9 : Replaced double division with multiplication → NO_COVERAGE 2. lambda$placeholder$9 : Replaced double subtraction with addition → NO_COVERAGE 3. lambda$placeholder$9 : Replaced double multiplication with division → NO_COVERAGE 4. lambda$placeholder$9 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$9 → NO_COVERAGE 5. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → SURVIVED |
return placeholders.getPercentFormat().format(Math.max(0D, orElse(rank, r -> (1 - (plugin.getEconomy().getBalance(player) / r.getRequirement(player, "money").getValueDouble())) * 100, 0).doubleValue())); |
148 | case "percent_done": | |
149 |
4
1. lambda$placeholder$10 : Replaced double division with multiplication → NO_COVERAGE 2. lambda$placeholder$10 : Replaced double multiplication with division → NO_COVERAGE 3. lambda$placeholder$10 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$10 → NO_COVERAGE 4. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return String.valueOf(Math.min(100D, orElse(rank, r -> (plugin.getEconomy().getBalance(player) / r.getRequirement(player, "money").getValueDouble()) * 100, 0).doubleValue())); |
150 | case "percent_done_formatted": | |
151 |
4
1. lambda$placeholder$11 : Replaced double division with multiplication → NO_COVERAGE 2. lambda$placeholder$11 : Replaced double multiplication with division → NO_COVERAGE 3. lambda$placeholder$11 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$11 → NO_COVERAGE 4. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → SURVIVED |
return placeholders.getPercentFormat().format(Math.min(100D, orElse(rank, r -> (plugin.getEconomy().getBalance(player) / r.getRequirement(player, "money").getValueDouble()) * 100, 0).doubleValue())); |
152 | case "prestige_percent_left_formatted": | |
153 |
5
1. lambda$placeholder$12 : Replaced double division with multiplication → NO_COVERAGE 2. lambda$placeholder$12 : Replaced double subtraction with addition → NO_COVERAGE 3. lambda$placeholder$12 : Replaced double multiplication with division → NO_COVERAGE 4. lambda$placeholder$12 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$12 → NO_COVERAGE 5. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → SURVIVED |
return placeholders.getPercentFormat().format(Math.max(0D, orElse(prestige, r -> (1 - (plugin.getEconomy().getBalance(player) / r.getRequirement(player, "money").getValueDouble())) * 100, 0).doubleValue())); |
154 | case "prestige_percent_done_formatted": | |
155 |
4
1. lambda$placeholder$13 : Replaced double division with multiplication → NO_COVERAGE 2. lambda$placeholder$13 : Replaced double multiplication with division → NO_COVERAGE 3. lambda$placeholder$13 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$placeholder$13 → NO_COVERAGE 4. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → SURVIVED |
return placeholders.getPercentFormat().format(Math.min(100D, orElse(prestige, r -> (plugin.getEconomy().getBalance(player) / r.getRequirement(player, "money").getValueDouble()) * 100, 0).doubleValue())); |
156 | default: | |
157 |
1
1. placeholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::placeholder → NO_COVERAGE |
return null; |
158 | } | |
159 | } | |
160 | ||
161 | private Number getMoney(Player player, Rank rank) { | |
162 |
2
1. getMoney : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::getMoney → KILLED 2. lambda$getMoney$14 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$getMoney$14 → KILLED |
return orElse(rank, r -> simplify(r.getRequirement(player, "money").getValueDouble()), 0); |
163 | } | |
164 | ||
165 | private void requirePrestiging(Prestiges prestiges, String params) { | |
166 | Objects.requireNonNull(prestiges, "Using %rankup_" + params + "% prestige placeholder but prestiging is disabled."); | |
167 | } | |
168 | ||
169 | private String getPlaceholderRequirement(Player player, Rank rank, String requirementName, String params) { | |
170 |
1
1. getPlaceholderRequirement : negated conditional → NO_COVERAGE |
if (rank == null) { |
171 | return ""; | |
172 | } | |
173 | Requirement requirement = rank.getRequirement(player, requirementName); | |
174 | switch (params) { | |
175 | case "": | |
176 |
1
1. getPlaceholderRequirement : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholderRequirement → NO_COVERAGE |
return orElse(requirement, Requirement::getValueString, "0"); |
177 | case "left": | |
178 |
2
1. getPlaceholderRequirement : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholderRequirement → NO_COVERAGE 2. lambda$getPlaceholderRequirement$15 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$getPlaceholderRequirement$15 → NO_COVERAGE |
return placeholders.getSimpleFormat().format(orElse(requirement, r -> r.getRemaining(player), 0)); |
179 | case "done": | |
180 |
3
1. getPlaceholderRequirement : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholderRequirement → NO_COVERAGE 2. lambda$getPlaceholderRequirement$16 : Replaced double subtraction with addition → NO_COVERAGE 3. lambda$getPlaceholderRequirement$16 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$getPlaceholderRequirement$16 → NO_COVERAGE |
return placeholders.getSimpleFormat().format(orElse(requirement, r -> r.getValueDouble() - r.getRemaining(player), 0)); |
181 | case "percent_left": | |
182 |
4
1. getPlaceholderRequirement : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholderRequirement → NO_COVERAGE 2. lambda$getPlaceholderRequirement$17 : Replaced double division with multiplication → NO_COVERAGE 3. lambda$getPlaceholderRequirement$17 : Replaced double multiplication with division → NO_COVERAGE 4. lambda$getPlaceholderRequirement$17 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$getPlaceholderRequirement$17 → NO_COVERAGE |
return placeholders.getPercentFormat().format(orElse(requirement, r -> (r.getRemaining(player) / r.getValueDouble()) * 100, 0)); |
183 | case "percent_done": | |
184 |
5
1. getPlaceholderRequirement : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholderRequirement → NO_COVERAGE 2. lambda$getPlaceholderRequirement$18 : Replaced double division with multiplication → NO_COVERAGE 3. lambda$getPlaceholderRequirement$18 : Replaced double subtraction with addition → NO_COVERAGE 4. lambda$getPlaceholderRequirement$18 : Replaced double multiplication with division → NO_COVERAGE 5. lambda$getPlaceholderRequirement$18 : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::lambda$getPlaceholderRequirement$18 → NO_COVERAGE |
return placeholders.getPercentFormat().format(orElse(requirement, r -> (1 - (r.getRemaining(player) / r.getValueDouble())) * 100, 100)); |
185 | default: | |
186 |
1
1. getPlaceholderRequirement : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholderRequirement → NO_COVERAGE |
return null; |
187 | } | |
188 | } | |
189 | ||
190 | private Number simplify(Number number) { | |
191 |
1
1. simplify : negated conditional → KILLED |
if (number instanceof Float) { |
192 |
3
1. simplify : Replaced float modulus with multiplication → NO_COVERAGE 2. simplify : negated conditional → NO_COVERAGE 3. simplify : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::simplify → NO_COVERAGE |
return (float) number % 1 == 0 ? number.intValue() : number; |
193 |
1
1. simplify : negated conditional → KILLED |
} else if (number instanceof Double) { |
194 |
3
1. simplify : Replaced double modulus with multiplication → KILLED 2. simplify : negated conditional → KILLED 3. simplify : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::simplify → KILLED |
return (double) number % 1 == 0 ? number.longValue() : number; |
195 | } else { | |
196 |
1
1. simplify : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::simplify → NO_COVERAGE |
return number; |
197 | } | |
198 | } | |
199 | ||
200 | private <T> String orElsePlaceholder(T t, Function<T, Object> value, Object fallback) { | |
201 |
1
1. orElsePlaceholder : negated conditional → KILLED |
if (t == null) { |
202 |
1
1. orElsePlaceholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::orElsePlaceholder → SURVIVED |
return getPlaceholder(String.valueOf(fallback)); |
203 | } | |
204 | ||
205 | try { | |
206 |
1
1. orElsePlaceholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::orElsePlaceholder → KILLED |
return String.valueOf(value.apply(t)); |
207 | } catch (NullPointerException ex) { | |
208 |
1
1. orElsePlaceholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::orElsePlaceholder → NO_COVERAGE |
return getPlaceholder(String.valueOf(fallback)); |
209 | } | |
210 | } | |
211 | ||
212 | private <T, R> R orElse(T t, Function<T, R> value, R fallback) { | |
213 |
1
1. orElse : negated conditional → KILLED |
if (t == null) { |
214 |
1
1. orElse : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::orElse → SURVIVED |
return fallback; |
215 | } | |
216 | ||
217 | try { | |
218 |
1
1. orElse : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::orElse → KILLED |
return value.apply(t); |
219 | } catch (NullPointerException ex) { | |
220 |
1
1. orElse : replaced return value with null for sh/okx/rankup/placeholders/RankupExpansion::orElse → NO_COVERAGE |
return fallback; |
221 | } | |
222 | } | |
223 | ||
224 | private String replacePattern(String string) { | |
225 | Matcher matcher = PATTERN.matcher(string); | |
226 |
1
1. replacePattern : negated conditional → NO_COVERAGE |
if (matcher.matches()) { |
227 |
1
1. replacePattern : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::replacePattern → NO_COVERAGE |
return matcher.group(1) + "#" + matcher.group(2).replace("-", "_"); |
228 | } else { | |
229 |
1
1. replacePattern : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::replacePattern → NO_COVERAGE |
return string; |
230 | } | |
231 | } | |
232 | ||
233 | private String getPlaceholder(String name) { | |
234 |
1
1. getPlaceholder : replaced return value with "" for sh/okx/rankup/placeholders/RankupExpansion::getPlaceholder → KILLED |
return plugin.getConfig().getString("placeholders." + name); |
235 | } | |
236 | } | |
Mutations | ||
27 |
1.1 |
|
34 |
1.1 |
|
39 |
1.1 |
|
41 |
1.1 |
|
44 |
1.1 |
|
46 |
1.1 |
|
47 |
1.1 2.2 |
|
48 |
1.1 |
|
50 |
1.1 |
|
51 |
1.1 2.2 |
|
52 |
1.1 |
|
55 |
1.1 2.2 3.3 |
|
56 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
66 |
1.1 |
|
67 |
1.1 |
|
69 |
1.1 |
|
70 |
1.1 |
|
75 |
1.1 |
|
76 |
1.1 |
|
77 |
1.1 |
|
78 |
1.1 |
|
83 |
1.1 |
|
88 |
1.1 |
|
89 |
1.1 2.2 |
|
90 |
1.1 |
|
92 |
1.1 |
|
95 |
1.1 |
|
96 |
1.1 2.2 |
|
97 |
1.1 |
|
99 |
1.1 |
|
102 |
1.1 |
|
103 |
1.1 2.2 |
|
104 |
1.1 |
|
106 |
1.1 2.2 |
|
108 |
1.1 |
|
109 |
1.1 2.2 |
|
110 |
1.1 |
|
112 |
1.1 2.2 |
|
115 |
1.1 |
|
116 |
1.1 2.2 3.3 |
|
118 |
1.1 |
|
119 |
1.1 2.2 3.3 |
|
121 |
1.1 |
|
123 |
1.1 |
|
125 |
1.1 2.2 |
|
126 |
1.1 |
|
128 |
1.1 2.2 |
|
131 |
1.1 2.2 |
|
132 |
1.1 |
|
134 |
1.1 2.2 |
|
137 |
1.1 |
|
139 |
1.1 |
|
141 |
1.1 2.2 3.3 |
|
143 |
1.1 2.2 3.3 |
|
145 |
1.1 2.2 3.3 4.4 5.5 |
|
147 |
1.1 2.2 3.3 4.4 5.5 |
|
149 |
1.1 2.2 3.3 4.4 |
|
151 |
1.1 2.2 3.3 4.4 |
|
153 |
1.1 2.2 3.3 4.4 5.5 |
|
155 |
1.1 2.2 3.3 4.4 |
|
157 |
1.1 |
|
162 |
1.1 2.2 |
|
170 |
1.1 |
|
176 |
1.1 |
|
178 |
1.1 2.2 |
|
180 |
1.1 2.2 3.3 |
|
182 |
1.1 2.2 3.3 4.4 |
|
184 |
1.1 2.2 3.3 4.4 5.5 |
|
186 |
1.1 |
|
191 |
1.1 |
|
192 |
1.1 2.2 3.3 |
|
193 |
1.1 |
|
194 |
1.1 2.2 3.3 |
|
196 |
1.1 |
|
201 |
1.1 |
|
202 |
1.1 |
|
206 |
1.1 |
|
208 |
1.1 |
|
213 |
1.1 |
|
214 |
1.1 |
|
218 |
1.1 |
|
220 |
1.1 |
|
226 |
1.1 |
|
227 |
1.1 |
|
229 |
1.1 |
|
234 |
1.1 |