GuiListener.java

1
package sh.okx.rankup.gui;
2
3
import lombok.RequiredArgsConstructor;
4
import org.bukkit.Bukkit;
5
import org.bukkit.entity.Player;
6
import org.bukkit.event.EventHandler;
7
import org.bukkit.event.Listener;
8
import org.bukkit.event.inventory.InventoryClickEvent;
9
import org.bukkit.inventory.Inventory;
10
import sh.okx.rankup.RankupPlugin;
11
12
@RequiredArgsConstructor
13
public class GuiListener implements Listener {
14
  private final RankupPlugin plugin;
15
16
  @EventHandler
17
  public void on(InventoryClickEvent e) {
18
    Inventory inventory = e.getInventory();
19 1 1. on : negated conditional → NO_COVERAGE
    if (inventory == null
20 1 1. on : negated conditional → NO_COVERAGE
        || !(inventory.getHolder() instanceof Gui)
21 1 1. on : negated conditional → NO_COVERAGE
        || !inventory.equals(e.getClickedInventory())) {
22
      return;
23
    }
24 1 1. on : removed call to org/bukkit/event/inventory/InventoryClickEvent::setCancelled → NO_COVERAGE
    e.setCancelled(true);
25
26
    Player player = (Player) e.getWhoClicked();
27
    Gui gui = (Gui) inventory.getHolder();
28
29 1 1. on : negated conditional → NO_COVERAGE
    if (gui.getRankup().isSimilar(e.getCurrentItem())) {
30
      Bukkit.getScheduler().runTask(plugin, player::closeInventory);
31 1 1. on : negated conditional → NO_COVERAGE
      if (gui.isPrestige()) {
32 1 1. on : removed call to sh/okx/rankup/RankupHelper::prestige → NO_COVERAGE
        plugin.getHelper().prestige(player);
33
      } else {
34 1 1. on : removed call to sh/okx/rankup/RankupHelper::rankup → NO_COVERAGE
        plugin.getHelper().rankup(player);
35
      }
36 1 1. on : negated conditional → NO_COVERAGE
    } else if (gui.getCancel().isSimilar(e.getCurrentItem())) {
37
      Bukkit.getScheduler().runTask(plugin, () -> {
38 1 1. lambda$on$0 : removed call to org/bukkit/entity/Player::closeInventory → NO_COVERAGE
        player.closeInventory();
39 1 1. lambda$on$0 : negated conditional → NO_COVERAGE
        if (gui.isReturnToRanksGui()) {
40
          Bukkit.dispatchCommand(player, "ranks");
41
        }
42
      });
43
    }
44
  }
45
}

Mutations

19

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

20

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

21

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

24

1.1
Location : on
Killed by : none
removed call to org/bukkit/event/inventory/InventoryClickEvent::setCancelled → NO_COVERAGE

29

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

31

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

32

1.1
Location : on
Killed by : none
removed call to sh/okx/rankup/RankupHelper::prestige → NO_COVERAGE

34

1.1
Location : on
Killed by : none
removed call to sh/okx/rankup/RankupHelper::rankup → NO_COVERAGE

36

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

38

1.1
Location : lambda$on$0
Killed by : none
removed call to org/bukkit/entity/Player::closeInventory → NO_COVERAGE

39

1.1
Location : lambda$on$0
Killed by : none
negated conditional → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.0