1 | package sh.okx.rankup.placeholders; | |
2 | ||
3 | import java.text.DecimalFormat; | |
4 | import java.util.List; | |
5 | import lombok.Getter; | |
6 | import org.bukkit.Bukkit; | |
7 | import sh.okx.rankup.RankupPlugin; | |
8 | ||
9 | public class Placeholders { | |
10 | private final RankupPlugin plugin; | |
11 |
1
1. getMoneyFormat : replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getMoneyFormat → KILLED |
@Getter |
12 | private final DecimalFormat moneyFormat; | |
13 |
1
1. getPercentFormat : replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getPercentFormat → KILLED |
@Getter |
14 | private final DecimalFormat percentFormat; | |
15 |
1
1. getSimpleFormat : replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getSimpleFormat → KILLED |
@Getter |
16 | private final DecimalFormat simpleFormat; | |
17 | private final List<String> shortened; | |
18 |
1
1. getExpansion : replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getExpansion → KILLED |
@Getter |
19 | private RankupExpansion expansion; | |
20 | ||
21 | private RankupPlaceholderExpansion papiExpansion; | |
22 | ||
23 | public Placeholders(RankupPlugin plugin) { | |
24 | this.plugin = plugin; | |
25 | this.shortened = plugin.getConfig().getStringList("shorten"); | |
26 | this.moneyFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.money-format")); | |
27 | this.percentFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.percent-format")); | |
28 | this.simpleFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.simple-format")); | |
29 | } | |
30 | ||
31 | public String formatMoney(double money) { | |
32 | String suffix = ""; | |
33 | ||
34 |
3
1. formatMoney : negated conditional → SURVIVED 2. formatMoney : Changed increment from -1 to 1 → TIMED_OUT 3. formatMoney : changed conditional boundary → KILLED |
for (int i = shortened.size(); i > 0; i--) { |
35 |
1
1. formatMoney : Replaced integer multiplication with division → SURVIVED |
double value = Math.pow(10, 3 * i); |
36 |
2
1. formatMoney : changed conditional boundary → SURVIVED 2. formatMoney : negated conditional → SURVIVED |
if (money >= value) { |
37 |
1
1. formatMoney : Replaced double division with multiplication → NO_COVERAGE |
money /= value; |
38 |
1
1. formatMoney : Replaced integer subtraction with addition → NO_COVERAGE |
suffix = shortened.get(i - 1); |
39 | break; | |
40 | } | |
41 | } | |
42 | ||
43 |
1
1. formatMoney : replaced return value with "" for sh/okx/rankup/placeholders/Placeholders::formatMoney → SURVIVED |
return moneyFormat.format(money) + suffix; |
44 | } | |
45 | ||
46 | ||
47 | public void register() { | |
48 | expansion = new RankupExpansion(plugin, this); | |
49 |
1
1. register : negated conditional → KILLED |
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { |
50 | papiExpansion = new RankupPlaceholderExpansion(plugin, expansion); | |
51 | papiExpansion.register(); | |
52 | } | |
53 | } | |
54 | ||
55 | public void unregister() { | |
56 |
1
1. unregister : negated conditional → KILLED |
if (papiExpansion != null) { |
57 | papiExpansion.unregister(); | |
58 | } | |
59 | } | |
60 | } | |
Mutations | ||
11 |
1.1 |
|
13 |
1.1 |
|
15 |
1.1 |
|
18 |
1.1 |
|
34 |
1.1 2.2 3.3 |
|
35 |
1.1 |
|
36 |
1.1 2.2 |
|
37 |
1.1 |
|
38 |
1.1 |
|
43 |
1.1 |
|
49 |
1.1 |
|
56 |
1.1 |