MCPcopy Create free account
hub / github.com/boxbeam/RedLib / onClick

Method onClick

src/redempt/redlib/region/SelectionTool.java:56–77  ·  view source on GitHub ↗
(PlayerInteractEvent e)

Source from the content-addressed store, hash-verified

54 }
55
56 @EventHandler
57 public void onClick(PlayerInteractEvent e) {
58 if (e.getAction() != Action.RIGHT_CLICK_BLOCK || e.getItem() == null) {
59 return;
60 }
61 if (!ItemUtils.compare(e.getItem(), item)) {
62 return;
63 }
64 Location[] locations = selections.getOrDefault(e.getPlayer().getUniqueId(), new Location[2]);
65 if (locations[0] != null && locations[1] != null) {
66 locations[0] = null;
67 locations[1] = null;
68 }
69 if (locations[0] == null) {
70 locations[0] = e.getClickedBlock().getLocation();
71 e.getPlayer().sendMessage(RedLib.msg("firstLocationSet"));
72 } else if (locations[1] == null) {
73 locations[1] = e.getClickedBlock().getLocation();
74 e.getPlayer().sendMessage(RedLib.msg("secondLocationSet"));
75 }
76 selections.put(e.getPlayer().getUniqueId(), locations);
77 }
78
79 /**
80 * Gets the item used by this SelectionTool

Callers

nothing calls this directly

Calls 6

compareMethod · 0.95
msgMethod · 0.95
sendMessageMethod · 0.80
getItemMethod · 0.45
getPlayerMethod · 0.45
getLocationMethod · 0.45

Tested by

no test coverage detected