diff --git a/src/main/java/cn/citycraft/SimpleProtect/listen/Nightvision.java b/src/main/java/cn/citycraft/SimpleProtect/listen/Nightvision.java index 11d782e..8242248 100644 --- a/src/main/java/cn/citycraft/SimpleProtect/listen/Nightvision.java +++ b/src/main/java/cn/citycraft/SimpleProtect/listen/Nightvision.java @@ -3,7 +3,9 @@ package cn.citycraft.SimpleProtect.listen; import java.util.Collection; import java.util.Iterator; -import org.bukkit.*; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -17,36 +19,36 @@ public class Nightvision implements Listener { SimpleProtect plugin; - public Nightvision(SimpleProtect main) { + public Nightvision(final SimpleProtect main) { plugin = main; } @EventHandler - public void OnBlockBreak(BlockBreakEvent e) { - Player p = e.getPlayer(); + public void OnBlockBreak(final BlockBreakEvent e) { + final Player p = e.getPlayer(); if (p.hasPermission("sp.ignore.nightvision") || p.isOp()) { return; } - int light = p.getLocation().getBlock().getLightLevel(); + final int light = p.getLocation().getBlock().getLightLevel(); if (light > 0) { return; } - Block b = e.getBlock(); - Material blockid = b.getType(); - Location loc = b.getLocation(); - World World = loc.getWorld(); - int x = loc.getBlockX(); - int y = loc.getBlockY(); - int z = loc.getBlockZ(); - Location loc_top = new Location(World, x, y + 1, z); + final Block b = e.getBlock(); + final Material blockid = b.getType(); + final Location loc = b.getLocation(); + final World World = loc.getWorld(); + final int x = loc.getBlockX(); + final int y = loc.getBlockY(); + final int z = loc.getBlockZ(); + final Location loc_top = new Location(World, x, y + 1, z); if (loc_top.getBlock().getType() == Material.AIR) { return; } - Collection effect = p.getActivePotionEffects(); - Iterator iterator = effect.iterator(); + final Collection effect = p.getActivePotionEffects(); + final Iterator iterator = effect.iterator(); Boolean flag = Boolean.valueOf(false); while (iterator.hasNext()) { - PotionEffect element = (PotionEffect) iterator.next(); + final PotionEffect element = iterator.next(); if (element.toString().toUpperCase().contains("NIGHT_VISION")) { flag = Boolean.valueOf(true); break; @@ -56,13 +58,8 @@ public class Nightvision implements Listener { if (blockid == Material.AIR) { return; } - if (blockid == Material.STONE || blockid == Material.GOLD_ORE - || blockid == Material.IRON_ORE - || blockid == Material.COAL_ORE - || blockid == Material.DIAMOND_ORE - || blockid == Material.REDSTONE_ORE - || blockid == Material.LAPIS_ORE - || blockid == Material.EMERALD_ORE) { + if (blockid == Material.STONE || blockid == Material.GOLD_ORE || blockid == Material.IRON_ORE || blockid == Material.COAL_ORE || blockid == Material.DIAMOND_ORE + || blockid == Material.REDSTONE_ORE || blockid == Material.LAPIS_ORE || blockid == Material.EMERALD_ORE) { e.setCancelled(true); p.sendMessage(plugin.getfullmsg("Nightvision.Tip")); }