RanksGuiListener.java

1
package sh.okx.rankup.ranksgui;
2
3
import java.util.HashMap;
4
import java.util.Map;
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.event.inventory.InventoryCloseEvent;
10
11
public class RanksGuiListener implements Listener {
12
13
  private final Map<Player, RanksGui> guiMap = new HashMap<>();
14
15
  @EventHandler
16
  public void on(InventoryCloseEvent event) {
17 1 1. on : negated conditional → NO_COVERAGE
    if (!(event.getPlayer() instanceof Player)) {
18
      return;
19
    }
20
    Player player = (Player) event.getPlayer();
21 1 1. on : negated conditional → NO_COVERAGE
    if (guiMap.containsKey(player)) {
22
      RanksGui ranksGui = guiMap.get(player);
23 1 1. on : negated conditional → NO_COVERAGE
      if (ranksGui.getInventory() != null
24 1 1. on : negated conditional → NO_COVERAGE
          && ranksGui.getInventory() == event.getInventory()) {
25
        guiMap.remove(player);
26
      }
27
    }
28
  }
29
30
  @EventHandler
31
  public void on(InventoryClickEvent event) {
32 1 1. on : negated conditional → NO_COVERAGE
    if (!(event.getWhoClicked() instanceof Player)) {
33
      return;
34
    }
35
    Player player = (Player) event.getWhoClicked();
36
    RanksGui ranksGui = guiMap.get(player);
37 2 1. on : negated conditional → NO_COVERAGE
2. on : negated conditional → NO_COVERAGE
    if (ranksGui != null && event.getInventory() == ranksGui.getInventory()) {
38 1 1. on : removed call to org/bukkit/event/inventory/InventoryClickEvent::setCancelled → NO_COVERAGE
      event.setCancelled(true);
39 1 1. on : removed call to sh/okx/rankup/ranksgui/RanksGui::click → NO_COVERAGE
      ranksGui.click(event);
40
    }
41
  }
42
43
  public void open(RanksGui gui) {
44
    guiMap.put(gui.getPlayer(), gui);
45 1 1. open : removed call to sh/okx/rankup/ranksgui/RanksGui::open → KILLED
    gui.open();
46
  }
47
}
48
    

Mutations

17

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

21

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

23

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

24

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

32

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

37

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

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

38

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

39

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

45

1.1
Location : open
Killed by : sh.okx.rankup.ranksgui.RanksGuiTest.[engine:junit-jupiter]/[class:sh.okx.rankup.ranksgui.RanksGuiTest]/[method:testRowsWithGroup()]
removed call to sh/okx/rankup/ranksgui/RanksGui::open → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.0