Requirement.java

1
package sh.okx.rankup.requirements;
2
3
import lombok.Getter;
4
import org.bukkit.entity.Player;
5
import sh.okx.rankup.RankupPlugin;
6
7
public abstract class Requirement implements Cloneable {
8
  protected final RankupPlugin plugin;
9 1 1. getName : replaced return value with "" for sh/okx/rankup/requirements/Requirement::getName → KILLED
  @Getter
10
  protected final String name;
11
  private String value;
12 1 1. getSub : replaced return value with "" for sh/okx/rankup/requirements/Requirement::getSub → KILLED
  @Getter
13
  private String sub;
14
  private boolean subRequirement;
15
16
  public Requirement(RankupPlugin plugin, String name) {
17
    this(plugin, name, false);
18
  }
19
20
  public Requirement(RankupPlugin plugin, String name, boolean subRequirement) {
21
    this.plugin = plugin;
22
    this.name = name;
23
    this.subRequirement = subRequirement;
24
  }
25
26
  protected Requirement(Requirement clone) {
27
    this.plugin = clone.plugin;
28
    this.name = clone.name;
29
    this.value = clone.value;
30
    this.sub = clone.sub;
31
    this.subRequirement = clone.subRequirement;
32
  }
33
34
  public void setValue(String value) {
35 1 1. setValue : negated conditional → KILLED
    if (hasSubRequirement()) {
36
      String[] parts = value.split(" ", 2);
37 2 1. setValue : changed conditional boundary → KILLED
2. setValue : negated conditional → KILLED
      if (parts.length < 2) {
38
        throw new IllegalArgumentException("Amount and sub-requirement not present for requirement '" + getName() + "'. You must use the format '" + getName() + " <sub-requirement> <amount>'");
39
      }
40
41
      this.sub = parts[0];
42
      this.value = parts[1];
43
    } else {
44
      this.value = value;
45
    }
46
  }
47
48
  public String getValueString() {
49 1 1. getValueString : replaced return value with "" for sh/okx/rankup/requirements/Requirement::getValueString → NO_COVERAGE
    return value;
50
  }
51
52
  public String[] getValuesString() {
53 1 1. getValuesString : replaced return value with null for sh/okx/rankup/requirements/Requirement::getValuesString → NO_COVERAGE
    return value.split(" ");
54
  }
55
56
  public double getValueDouble() {
57 1 1. getValueDouble : replaced double return with 0.0d for sh/okx/rankup/requirements/Requirement::getValueDouble → KILLED
    return Double.parseDouble(value);
58
  }
59
60
  public int getValueInt() {
61 1 1. getValueInt : replaced int return with 0 for sh/okx/rankup/requirements/Requirement::getValueInt → NO_COVERAGE
    return Integer.parseInt(value);
62
  }
63
64
  public boolean getValueBoolean() {
65 2 1. getValueBoolean : replaced boolean return with false for sh/okx/rankup/requirements/Requirement::getValueBoolean → NO_COVERAGE
2. getValueBoolean : replaced boolean return with true for sh/okx/rankup/requirements/Requirement::getValueBoolean → NO_COVERAGE
    return Boolean.parseBoolean(value);
66
  }
67
68
  public String getFullName() {
69 1 1. getFullName : negated conditional → KILLED
    if (hasSubRequirement()) {
70 1 1. getFullName : replaced return value with "" for sh/okx/rankup/requirements/Requirement::getFullName → KILLED
      return name + "#" + sub;
71
    } else {
72 1 1. getFullName : replaced return value with "" for sh/okx/rankup/requirements/Requirement::getFullName → KILLED
      return name;
73
    }
74
  }
75
76
  /**
77
   * Check if a player meets this requirement
78
   *
79
   * @param player the player to check
80
   * @return true if they meet the requirement, false otherwise
81
   */
82
  public abstract boolean check(Player player);
83
84
  /**
85
   * Get the remaining amount needed for <code>Requirement#check(Player)</code> to yield true.
86
   * This is not required and is only used in placeholders.
87
   *
88
   * @param player the player to find the remaining amount of
89
   * @return the remaining amount needed. Should be non-negative.
90
   */
91
  public double getRemaining(Player player) {
92 2 1. getRemaining : negated conditional → NO_COVERAGE
2. getRemaining : replaced double return with 0.0d for sh/okx/rankup/requirements/Requirement::getRemaining → NO_COVERAGE
    return check(player) ? 0 : 1;
93
  }
94
95
  public final boolean hasSubRequirement() {
96 2 1. hasSubRequirement : replaced boolean return with false for sh/okx/rankup/requirements/Requirement::hasSubRequirement → KILLED
2. hasSubRequirement : replaced boolean return with true for sh/okx/rankup/requirements/Requirement::hasSubRequirement → KILLED
    return subRequirement;
97
  }
98
99
  public abstract Requirement clone();
100
101
  public double getTotal(Player player) {
102 1 1. getTotal : replaced double return with 0.0d for sh/okx/rankup/requirements/Requirement::getTotal → NO_COVERAGE
    return 1;
103
  }
104
}

Mutations

9

1.1
Location : getName
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
replaced return value with "" for sh/okx/rankup/requirements/Requirement::getName → KILLED

12

1.1
Location : getSub
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
replaced return value with "" for sh/okx/rankup/requirements/Requirement::getSub → KILLED

35

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

37

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

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

49

1.1
Location : getValueString
Killed by : none
replaced return value with "" for sh/okx/rankup/requirements/Requirement::getValueString → NO_COVERAGE

53

1.1
Location : getValuesString
Killed by : none
replaced return value with null for sh/okx/rankup/requirements/Requirement::getValuesString → NO_COVERAGE

57

1.1
Location : getValueDouble
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
replaced double return with 0.0d for sh/okx/rankup/requirements/Requirement::getValueDouble → KILLED

61

1.1
Location : getValueInt
Killed by : none
replaced int return with 0 for sh/okx/rankup/requirements/Requirement::getValueInt → NO_COVERAGE

65

1.1
Location : getValueBoolean
Killed by : none
replaced boolean return with false for sh/okx/rankup/requirements/Requirement::getValueBoolean → NO_COVERAGE

2.2
Location : getValueBoolean
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/Requirement::getValueBoolean → NO_COVERAGE

69

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

70

1.1
Location : getFullName
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
replaced return value with "" for sh/okx/rankup/requirements/Requirement::getFullName → KILLED

72

1.1
Location : getFullName
Killed by : sh.okx.rankup.pebble.PebbleTest.[engine:junit-jupiter]/[class:sh.okx.rankup.pebble.PebbleTest]/[method:testRequirementPresent()]
replaced return value with "" for sh/okx/rankup/requirements/Requirement::getFullName → KILLED

92

1.1
Location : getRemaining
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getRemaining
Killed by : none
replaced double return with 0.0d for sh/okx/rankup/requirements/Requirement::getRemaining → NO_COVERAGE

96

1.1
Location : hasSubRequirement
Killed by : sh.okx.rankup.requirements.MobKillsRequirementsTest.[engine:junit-jupiter]/[class:sh.okx.rankup.requirements.MobKillsRequirementsTest]/[method:testMobKillsRequirements()]
replaced boolean return with false for sh/okx/rankup/requirements/Requirement::hasSubRequirement → KILLED

2.2
Location : hasSubRequirement
Killed by : sh.okx.rankup.RankupPlaceholderTest.[engine:junit-jupiter]/[class:sh.okx.rankup.RankupPlaceholderTest]/[method:testStatusCurrent()]
replaced boolean return with true for sh/okx/rankup/requirements/Requirement::hasSubRequirement → KILLED

102

1.1
Location : getTotal
Killed by : none
replaced double return with 0.0d for sh/okx/rankup/requirements/Requirement::getTotal → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.0