UpdateNotifier.java

1
package sh.okx.rankup.util;
2
3
import org.bukkit.ChatColor;
4
import org.bukkit.command.CommandSender;
5
import sh.okx.rankup.util.VersionChecker.VersionCheckerCallback;
6
7
public class UpdateNotifier {
8
  private final String prefix;
9
10
  private final VersionChecker checker;
11
12
  public UpdateNotifier(VersionChecker checker) {
13
    this.prefix = ChatColor.GREEN + "" + ChatColor.BOLD + checker.getPlugin().getName() + ChatColor.RESET + " ";
14
    this.checker = checker;
15
  }
16
17
  public void notify(CommandSender sender, boolean join) {
18 2 1. notify : negated conditional → NO_COVERAGE
2. notify : negated conditional → NO_COVERAGE
    if (!checker.hasChecked() && !join) {
19 1 1. notify : removed call to sh/okx/rankup/util/UpdateNotifier::send → NO_COVERAGE
      send(sender, false, ChatColor.YELLOW + "Checking version...");
20
    }
21 1 1. notify : removed call to sh/okx/rankup/util/VersionChecker::checkVersion → NO_COVERAGE
    checker.checkVersion(new VersionCheckerCallback() {
22
      @Override
23
      public void onLatestVersion(String version) {
24 1 1. onLatestVersion : negated conditional → NO_COVERAGE
        if (!join) {
25 1 1. onLatestVersion : removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE
          send(sender, false, ChatColor.GREEN + "You are on the latest version.");
26
        }
27
      }
28
29
      @Override
30
      public void onOutdatedVersion(String currentVersion, String latestVersion) {
31 1 1. onOutdatedVersion : removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE
        send(sender, join, ChatColor.YELLOW + "A new version is available: " + ChatColor.GOLD + latestVersion
32
            + ChatColor.YELLOW + ". You are on: " + ChatColor.GOLD + currentVersion
33
            + ChatColor.GOLD + "\nhttps://www.spigotmc.org/resources/" + VersionChecker.RESOURCE_ID + "/");
34
      }
35
36
      @Override
37
      public void onPreReleaseVersion(String version) {
38 1 1. onPreReleaseVersion : removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE
        send(sender, join, ChatColor.RED + "You are on a pre-release version.");
39
      }
40
41
      @Override
42
      public void onFailure() {
43 1 1. onFailure : negated conditional → NO_COVERAGE
        if (!join) {
44 1 1. onFailure : removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE
          send(sender, false, ChatColor.RED + "Error while checking version.");
45
        }
46
      }
47
    });
48
  }
49
50
  private void send(CommandSender sender, boolean prefix, String message) {
51 1 1. send : negated conditional → NO_COVERAGE
    if (prefix) {
52 1 1. send : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE
      sender.sendMessage(this.prefix + message);
53
    } else {
54 1 1. send : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE
      sender.sendMessage(message);
55
    }
56
  }
57
}

Mutations

18

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

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

19

1.1
Location : notify
Killed by : none
removed call to sh/okx/rankup/util/UpdateNotifier::send → NO_COVERAGE

21

1.1
Location : notify
Killed by : none
removed call to sh/okx/rankup/util/VersionChecker::checkVersion → NO_COVERAGE

24

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

25

1.1
Location : onLatestVersion
Killed by : none
removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE

31

1.1
Location : onOutdatedVersion
Killed by : none
removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE

38

1.1
Location : onPreReleaseVersion
Killed by : none
removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE

43

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

44

1.1
Location : onFailure
Killed by : none
removed call to sh/okx/rankup/util/UpdateNotifier::access$000 → NO_COVERAGE

51

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

52

1.1
Location : send
Killed by : none
removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE

54

1.1
Location : send
Killed by : none
removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.0