diff --git a/src/com/wasteofplastic/askyblock/listeners/ChatListener.java b/src/com/wasteofplastic/askyblock/listeners/ChatListener.java index 88a09bb1d..7e7b4e707 100644 --- a/src/com/wasteofplastic/askyblock/listeners/ChatListener.java +++ b/src/com/wasteofplastic/askyblock/listeners/ChatListener.java @@ -77,7 +77,7 @@ public ChatListener(ASkyBlock plugin) { - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onChat(final AsyncPlayerChatEvent event) { if (DEBUG) plugin.getLogger().info("DEBUG: " + event.getEventName()); diff --git a/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java b/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java index e226f79f9..59621007d 100644 --- a/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java +++ b/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java @@ -1756,38 +1756,46 @@ public void onPlayerInteract(final PlayerInteractEvent e) { plugin.getLogger().info("DEBUG: Material " + e.getMaterial()); } // Look along player's sight line to see if any blocks are fire - BlockIterator iter = new BlockIterator(e.getPlayer(), 10); - Block lastBlock = iter.next(); - while (iter.hasNext()) { - lastBlock = iter.next(); - if (DEBUG) - plugin.getLogger().info("DEBUG: lastBlock = " + lastBlock.toString()); - if (lastBlock.equals(e.getClickedBlock())) { - if (DEBUG) - plugin.getLogger().info("DEBUG: found clicked block"); - continue; - } - if (lastBlock.getType().equals(Material.FIRE)) { + try { + BlockIterator iter = new BlockIterator(e.getPlayer(), 10); + Block lastBlock = iter.next(); + while (iter.hasNext()) { + lastBlock = iter.next(); if (DEBUG) - plugin.getLogger().info("DEBUG: fire found"); - if (island != null && island.isSpawn()) { - if (!island.getIgsFlag(SettingsFlag.FIRE_EXTINGUISH)) { - e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); - e.setCancelled(true); - return; - } - } else { - if (Settings.allowFireExtinguish) { - if (DEBUG) - plugin.getLogger().info("DEBUG: extinguishing is allowed"); - continue; + plugin.getLogger().info("DEBUG: lastBlock = " + lastBlock.toString()); + if (lastBlock.equals(e.getClickedBlock())) { + if (DEBUG) + plugin.getLogger().info("DEBUG: found clicked block"); + continue; + } + if (lastBlock.getType().equals(Material.FIRE)) { + if (DEBUG) + plugin.getLogger().info("DEBUG: fire found"); + if (island != null && island.isSpawn()) { + if (!island.getIgsFlag(SettingsFlag.FIRE_EXTINGUISH)) { + e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); + e.setCancelled(true); + return; + } } else { - e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); - e.setCancelled(true); - return; + if (Settings.allowFireExtinguish) { + if (DEBUG) + plugin.getLogger().info("DEBUG: extinguishing is allowed"); + continue; + } else { + e.getPlayer().sendMessage(ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected); + e.setCancelled(true); + return; + } } } } + } catch (Exception ex) { + // To catch at block iterator exceptions that can happen in the void or at the very top of blocks + if (DEBUG) { + plugin.getLogger().info("DEBUG: block iterator error"); + ex.printStackTrace(); + } } // Handle Shulker Boxes if (e.getClickedBlock().getType().toString().contains("BOX")) {