TownyUtils.java

1
package sh.okx.rankup.requirements.requirement.towny;
2
3
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
4
import com.palmergames.bukkit.towny.object.Nation;
5
import com.palmergames.bukkit.towny.object.Resident;
6
import com.palmergames.bukkit.towny.object.Town;
7
import com.palmergames.bukkit.towny.object.TownyUniverse;
8
import org.bukkit.entity.Player;
9
10
public class TownyUtils {
11
    private static TownyUtils instance;
12
13
    public static TownyUtils getInstance() {
14 1 1. getInstance : negated conditional → NO_COVERAGE
        if (instance == null) {
15
            instance = new TownyUtils();
16
        }
17 1 1. getInstance : replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getInstance → NO_COVERAGE
        return instance;
18
    }
19
20
    public boolean isResident(Player player) {
21
        try {
22
            Town town = TownyUniverse.getDataSource().getResident(player.getName()).getTown();
23
24 2 1. isResident : negated conditional → NO_COVERAGE
2. isResident : replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isResident → NO_COVERAGE
            return town != null;
25
        } catch (NotRegisteredException e) {
26 1 1. isResident : replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isResident → NO_COVERAGE
            return false;
27
        }
28
    }
29
30
    public Resident getResident(Player player) {
31
        try {
32 1 1. getResident : replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getResident → NO_COVERAGE
            return TownyUniverse.getDataSource().getResident(player.getName());
33
        } catch (NotRegisteredException e) {
34
            return null;
35
        }
36
    }
37
38
    public Town getTown(Player player) {
39
        try {
40 1 1. getTown : replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getTown → NO_COVERAGE
            return TownyUniverse.getDataSource().getResident(player.getName()).getTown();
41
        } catch (NotRegisteredException e) {
42
            return null;
43
        }
44
    }
45
46
    public Nation getNation(Player player) {
47
        Town town = getTown(player);
48
49
        try {
50 2 1. getNation : negated conditional → NO_COVERAGE
2. getNation : replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getNation → NO_COVERAGE
            return getTown(player) == null ? null : town.getNation();
51
        } catch (NotRegisteredException e) {
52
            return null;
53
        }
54
    }
55
56
    public boolean isMayor(Player player) {
57
        try {
58 2 1. isMayor : replaced boolean return with false for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isMayor → NO_COVERAGE
2. isMayor : replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isMayor → NO_COVERAGE
            return TownyUniverse.getDataSource().getResident(player.getName()).isMayor();
59
        } catch (NotRegisteredException e) {
60 1 1. isMayor : replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isMayor → NO_COVERAGE
            return false;
61
        }
62
    }
63
64
    public boolean isKing(Player player) {
65
        try {
66 2 1. isKing : replaced boolean return with false for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isKing → NO_COVERAGE
2. isKing : replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isKing → NO_COVERAGE
            return TownyUniverse.getDataSource().getResident(player.getName()).isKing();
67
        } catch (NotRegisteredException e) {
68 1 1. isKing : replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isKing → NO_COVERAGE
            return false;
69
        }
70
    }
71
}

Mutations

14

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

17

1.1
Location : getInstance
Killed by : none
replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getInstance → NO_COVERAGE

24

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

2.2
Location : isResident
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isResident → NO_COVERAGE

26

1.1
Location : isResident
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isResident → NO_COVERAGE

32

1.1
Location : getResident
Killed by : none
replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getResident → NO_COVERAGE

40

1.1
Location : getTown
Killed by : none
replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getTown → NO_COVERAGE

50

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

2.2
Location : getNation
Killed by : none
replaced return value with null for sh/okx/rankup/requirements/requirement/towny/TownyUtils::getNation → NO_COVERAGE

58

1.1
Location : isMayor
Killed by : none
replaced boolean return with false for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isMayor → NO_COVERAGE

2.2
Location : isMayor
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isMayor → NO_COVERAGE

60

1.1
Location : isMayor
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isMayor → NO_COVERAGE

66

1.1
Location : isKing
Killed by : none
replaced boolean return with false for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isKing → NO_COVERAGE

2.2
Location : isKing
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isKing → NO_COVERAGE

68

1.1
Location : isKing
Killed by : none
replaced boolean return with true for sh/okx/rankup/requirements/requirement/towny/TownyUtils::isKing → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.0