Placeholders.java

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
Location : getMoneyFormat
Killed by : sh.okx.rankup.legacy.LegacyPlaceholderTest.[engine:junit-jupiter]/[class:sh.okx.rankup.legacy.LegacyPlaceholderTest]/[method:testLegacy()]
replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getMoneyFormat → KILLED

13

1.1
Location : getPercentFormat
Killed by : sh.okx.rankup.legacy.LegacyPlaceholderTest.[engine:junit-jupiter]/[class:sh.okx.rankup.legacy.LegacyPlaceholderTest]/[method:testLegacy()]
replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getPercentFormat → KILLED

15

1.1
Location : getSimpleFormat
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementPresent()]
replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getSimpleFormat → KILLED

18

1.1
Location : getExpansion
Killed by : sh.okx.rankup.RankupPlaceholderTest.[engine:junit-jupiter]/[class:sh.okx.rankup.RankupPlaceholderTest]/[method:testStatusCurrent()]
replaced return value with null for sh/okx/rankup/placeholders/Placeholders::getExpansion → KILLED

34

1.1
Location : formatMoney
Killed by : sh.okx.rankup.commands.CommandInfoTest.[engine:junit-jupiter]/[class:sh.okx.rankup.commands.CommandInfoTest]/[method:testPlaceholders()]
changed conditional boundary → KILLED

2.2
Location : formatMoney
Killed by : none
Changed increment from -1 to 1 → TIMED_OUT

3.3
Location : formatMoney
Killed by : none
negated conditional → SURVIVED

35

1.1
Location : formatMoney
Killed by : none
Replaced integer multiplication with division → SURVIVED

36

1.1
Location : formatMoney
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : formatMoney
Killed by : none
negated conditional → SURVIVED

37

1.1
Location : formatMoney
Killed by : none
Replaced double division with multiplication → NO_COVERAGE

38

1.1
Location : formatMoney
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

43

1.1
Location : formatMoney
Killed by : none
replaced return value with "" for sh/okx/rankup/placeholders/Placeholders::formatMoney → SURVIVED

49

1.1
Location : register
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
negated conditional → KILLED

56

1.1
Location : unregister
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.0