Prestige.java

1
package sh.okx.rankup.prestige;
2
3
import java.util.List;
4
import lombok.EqualsAndHashCode;
5
import lombok.Getter;
6
import lombok.ToString;
7
import me.clip.placeholderapi.PlaceholderAPI;
8
import org.bukkit.Bukkit;
9
import org.bukkit.configuration.ConfigurationSection;
10
import org.bukkit.entity.Player;
11
import sh.okx.rankup.RankupPlugin;
12
import sh.okx.rankup.messages.pebble.PebbleMessageBuilder;
13
import sh.okx.rankup.ranks.Rank;
14
import sh.okx.rankup.ranks.requirements.ListRankRequirements;
15
import sh.okx.rankup.ranks.requirements.RankRequirements;
16
import sh.okx.rankup.requirements.Requirement;
17
18 26 1. canEqual : replaced boolean return with false for sh/okx/rankup/prestige/Prestige::canEqual → NO_COVERAGE
2. canEqual : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::canEqual → NO_COVERAGE
3. equals : negated conditional → NO_COVERAGE
4. equals : negated conditional → NO_COVERAGE
5. equals : negated conditional → NO_COVERAGE
6. equals : negated conditional → NO_COVERAGE
7. equals : negated conditional → NO_COVERAGE
8. equals : negated conditional → NO_COVERAGE
9. equals : negated conditional → NO_COVERAGE
10. equals : negated conditional → NO_COVERAGE
11. equals : negated conditional → NO_COVERAGE
12. equals : negated conditional → NO_COVERAGE
13. equals : replaced boolean return with false for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
14. equals : replaced boolean return with false for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
15. equals : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
16. equals : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
17. equals : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
18. equals : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
19. equals : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE
20. hashCode : Replaced integer multiplication with division → NO_COVERAGE
21. hashCode : Replaced integer addition with subtraction → NO_COVERAGE
22. hashCode : Replaced integer multiplication with division → NO_COVERAGE
23. hashCode : Replaced integer addition with subtraction → NO_COVERAGE
24. hashCode : negated conditional → NO_COVERAGE
25. hashCode : negated conditional → NO_COVERAGE
26. hashCode : replaced int return with 0 for sh/okx/rankup/prestige/Prestige::hashCode → NO_COVERAGE
@EqualsAndHashCode(callSuper = true)
19 1 1. toString : replaced return value with "" for sh/okx/rankup/prestige/Prestige::toString → NO_COVERAGE
@ToString(callSuper = true)
20
public class Prestige extends Rank {
21 1 1. getFrom : replaced return value with "" for sh/okx/rankup/prestige/Prestige::getFrom → NO_COVERAGE
  @Getter
22
  private final String from;
23 1 1. getTo : replaced return value with "" for sh/okx/rankup/prestige/Prestige::getTo → NO_COVERAGE
  @Getter
24
  private final String to;
25
26
  protected Prestige(ConfigurationSection section, RankupPlugin plugin, String next, String rank, RankRequirements requirements, List<String> commands, String from, String to) {
27
    super(section, plugin, next, rank, rank, requirements, commands);
28
    this.from = from;
29
    this.to = to;
30
  }
31
32
  public static Prestige deserialize(RankupPlugin plugin, ConfigurationSection section) {
33
    List<String> requirementsList = section.getStringList("requirements");
34
    List<Requirement> requirements = plugin.getRequirements().getRequirements(requirementsList);
35
36 1 1. deserialize : replaced return value with null for sh/okx/rankup/prestige/Prestige::deserialize → KILLED
    return new Prestige(section, plugin,
37
        section.getString("next"),
38
        section.getString("rank"),
39
        new ListRankRequirements(requirements),
40
        section.getStringList("commands"),
41
        section.getString("from"),
42
        section.getString("to"));
43
  }
44
45
  @Override
46
  public void runCommands(Player player, Rank next) {
47
    for (String command : commands) {
48
      String string = new PebbleMessageBuilder(this.plugin, command)
49
          .replacePlayer(player)
50
          .replaceOldRank(this)
51
          .replaceRank(next)
52
          .toString();
53 1 1. runCommands : negated conditional → NO_COVERAGE
      if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
54
        string = PlaceholderAPI.setPlaceholders(player, string);
55
      }
56
      Bukkit.dispatchCommand(Bukkit.getConsoleSender(), string);
57
    }
58
  }
59
60
  @Override
61
  public boolean isIn(Player player) {
62
    // first prestige does not have a rank
63
    boolean inFrom = plugin.getPermissions().inGroup(player.getUniqueId(), from);
64 2 1. isIn : negated conditional → SURVIVED
2. isIn : negated conditional → KILLED
    if (rank == null && inFrom) {
65
      // not in any other prestiges
66
      for (Prestige prestige : plugin.getPrestiges().getTree()) {
67 2 1. isIn : negated conditional → NO_COVERAGE
2. isIn : negated conditional → NO_COVERAGE
        if (prestige != this && prestige.isIn(player)) {
68 1 1. isIn : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isIn → NO_COVERAGE
          return false;
69
        }
70
      }
71 1 1. isIn : replaced boolean return with false for sh/okx/rankup/prestige/Prestige::isIn → NO_COVERAGE
      return true;
72
    }
73
74 1 1. isIn : negated conditional → KILLED
    if (rank == null) {
75 1 1. isIn : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isIn → KILLED
      return false;
76
    }
77
78
    // subsequent prestiges
79
    boolean inRank = plugin.getPermissions().inGroup(player.getUniqueId(), rank);
80 1 1. isIn : negated conditional → KILLED
    if (inRank) {
81 1 1. isIn : replaced boolean return with false for sh/okx/rankup/prestige/Prestige::isIn → NO_COVERAGE
      return true;
82
    }
83
84 1 1. isIn : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isIn → KILLED
    return false;
85
  }
86
87
  public boolean isEligible(Player player) {
88 2 1. isEligible : replaced boolean return with false for sh/okx/rankup/prestige/Prestige::isEligible → NO_COVERAGE
2. isEligible : replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isEligible → NO_COVERAGE
    return plugin.getPermissions().inGroup(player.getUniqueId(), from);
89
  }
90
}

Mutations

18

1.1
Location : canEqual
Killed by : none
replaced boolean return with false for sh/okx/rankup/prestige/Prestige::canEqual → NO_COVERAGE

2.2
Location : canEqual
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::canEqual → NO_COVERAGE

3.3
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

4.4
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

5.5
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

7.7
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

8.8
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

9.9
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

10.10
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

11.11
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

12.12
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

13.13
Location : equals
Killed by : none
replaced boolean return with false for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

14.14
Location : equals
Killed by : none
replaced boolean return with false for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

15.15
Location : equals
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

16.16
Location : equals
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

17.17
Location : equals
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

18.18
Location : equals
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

19.19
Location : equals
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::equals → NO_COVERAGE

20.20
Location : hashCode
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

21.21
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

22.22
Location : hashCode
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

23.23
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

24.24
Location : hashCode
Killed by : none
negated conditional → NO_COVERAGE

25.25
Location : hashCode
Killed by : none
negated conditional → NO_COVERAGE

26.26
Location : hashCode
Killed by : none
replaced int return with 0 for sh/okx/rankup/prestige/Prestige::hashCode → NO_COVERAGE

19

1.1
Location : toString
Killed by : none
replaced return value with "" for sh/okx/rankup/prestige/Prestige::toString → NO_COVERAGE

21

1.1
Location : getFrom
Killed by : none
replaced return value with "" for sh/okx/rankup/prestige/Prestige::getFrom → NO_COVERAGE

23

1.1
Location : getTo
Killed by : none
replaced return value with "" for sh/okx/rankup/prestige/Prestige::getTo → NO_COVERAGE

36

1.1
Location : deserialize
Killed by : sh.okx.rankup.prestige.BrokenPrestigeTest.[engine:junit-jupiter]/[class:sh.okx.rankup.prestige.BrokenPrestigeTest]/[method:testPrestige()]
replaced return value with null for sh/okx/rankup/prestige/Prestige::deserialize → KILLED

53

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

64

1.1
Location : isIn
Killed by : none
negated conditional → SURVIVED

2.2
Location : isIn
Killed by : sh.okx.rankup.prestige.BrokenPrestigeTest.[engine:junit-jupiter]/[class:sh.okx.rankup.prestige.BrokenPrestigeTest]/[method:testPrestige()]
negated conditional → KILLED

67

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

2.2
Location : isIn
Killed by : none
negated conditional → NO_COVERAGE

68

1.1
Location : isIn
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isIn → NO_COVERAGE

71

1.1
Location : isIn
Killed by : none
replaced boolean return with false for sh/okx/rankup/prestige/Prestige::isIn → NO_COVERAGE

74

1.1
Location : isIn
Killed by : sh.okx.rankup.prestige.BrokenPrestigeTest.[engine:junit-jupiter]/[class:sh.okx.rankup.prestige.BrokenPrestigeTest]/[method:testPrestige()]
negated conditional → KILLED

75

1.1
Location : isIn
Killed by : sh.okx.rankup.prestige.BrokenPrestigeTest.[engine:junit-jupiter]/[class:sh.okx.rankup.prestige.BrokenPrestigeTest]/[method:testPrestige()]
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isIn → KILLED

80

1.1
Location : isIn
Killed by : sh.okx.rankup.prestige.BrokenPrestigeTest.[engine:junit-jupiter]/[class:sh.okx.rankup.prestige.BrokenPrestigeTest]/[method:testPrestige()]
negated conditional → KILLED

81

1.1
Location : isIn
Killed by : none
replaced boolean return with false for sh/okx/rankup/prestige/Prestige::isIn → NO_COVERAGE

84

1.1
Location : isIn
Killed by : sh.okx.rankup.prestige.BrokenPrestigeTest.[engine:junit-jupiter]/[class:sh.okx.rankup.prestige.BrokenPrestigeTest]/[method:testPrestige()]
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isIn → KILLED

88

1.1
Location : isEligible
Killed by : none
replaced boolean return with false for sh/okx/rankup/prestige/Prestige::isEligible → NO_COVERAGE

2.2
Location : isEligible
Killed by : none
replaced boolean return with true for sh/okx/rankup/prestige/Prestige::isEligible → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.0