Skip to content
This repository has been archived by the owner on Apr 29, 2018. It is now read-only.

Commit

Permalink
Fixed issue #8 where PlayerInteractEvent was returning null
Browse files Browse the repository at this point in the history
  • Loading branch information
MtthwBrwng committed Jul 13, 2016
1 parent c87bd60 commit efce19a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.mattslab.flashlightplus</groupId>
<artifactId>FlashlightPlus</artifactId>
<version>1.10.2-1.0.16</version>
<version>1.10.2-1.0.17</version>

<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
} else if (args[0].equalsIgnoreCase("spawn") && player.hasPermission("flashlight.spawn")) {
ItemStack flashlight = new ItemBuilder(Material.TORCH)
.withName(ChatColor.DARK_AQUA + "[" + ChatColor.WHITE + "Flashlight" + ChatColor.DARK_AQUA + "]")
.withLores(ChatColor.RED + "Usage:", ChatColor.GREEN + "Left click for a night vision effect")
.withLores(ChatColor.RED + "Usage:", ChatColor.GREEN + "Right click for a night vision effect")
.withAmount(1)
.toItemStack();
if (args.length == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ public void onLeave(PlayerQuitEvent e) {
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
PlayerInventory playerInv = event.getPlayer().getInventory();
ItemStack torchMain = playerInv.getItemInMainHand();
if ((event.getAction() == Action.LEFT_CLICK_AIR)) {
if (torchMain.getItemMeta().getDisplayName().equals(ChatColor.DARK_AQUA + "[" + ChatColor.WHITE + "Flashlight" + ChatColor.DARK_AQUA + "]")) {
togglePlayer(player);
}
ItemStack torch = playerInv.getItemInMainHand();
if ((event.getAction() == Action.RIGHT_CLICK_AIR) &&
(torch.hasItemMeta()) &&
(torch.getItemMeta().getDisplayName() != null) &&
(torch.getItemMeta().getDisplayName().equals(ChatColor.DARK_AQUA + "[" + ChatColor.WHITE + "Flashlight" + ChatColor.DARK_AQUA + "]"))) {
togglePlayer(player);
}
}


@EventHandler
public void onPlayerPlace(PlayerInteractEvent event) {
PlayerInventory playerInv = event.getPlayer().getInventory();
ItemStack torchMain = playerInv.getItemInMainHand();
ItemStack torch = playerInv.getItemInMainHand();
if ((event.getAction() == Action.RIGHT_CLICK_BLOCK) &&
(torchMain.hasItemMeta()) &&
(torchMain.getItemMeta().getDisplayName() != null) &&
(torchMain.getItemMeta().getDisplayName().equals(ChatColor.DARK_AQUA + "[" + ChatColor.WHITE + "Flashlight" + ChatColor.DARK_AQUA + "]"))) {
(torch.hasItemMeta()) &&
(torch.getItemMeta().getDisplayName() != null) &&
(torch.getItemMeta().getDisplayName().equals(ChatColor.DARK_AQUA + "[" + ChatColor.WHITE + "Flashlight" + ChatColor.DARK_AQUA + "]"))) {
event.setCancelled(true);
}

Expand Down

0 comments on commit efce19a

Please # to comment.