mirror of
https://e.coding.net/circlecloud/SimpleProtect.git
synced 2024-11-22 01:49:03 +00:00
去除无效代码...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
d9f7ba3ff2
commit
0f3f81f575
@ -3,7 +3,9 @@ package cn.citycraft.SimpleProtect.listen;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
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.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -17,36 +19,36 @@ public class Nightvision implements Listener {
|
|||||||
|
|
||||||
SimpleProtect plugin;
|
SimpleProtect plugin;
|
||||||
|
|
||||||
public Nightvision(SimpleProtect main) {
|
public Nightvision(final SimpleProtect main) {
|
||||||
plugin = main;
|
plugin = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void OnBlockBreak(BlockBreakEvent e) {
|
public void OnBlockBreak(final BlockBreakEvent e) {
|
||||||
Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
if (p.hasPermission("sp.ignore.nightvision") || p.isOp()) {
|
if (p.hasPermission("sp.ignore.nightvision") || p.isOp()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int light = p.getLocation().getBlock().getLightLevel();
|
final int light = p.getLocation().getBlock().getLightLevel();
|
||||||
if (light > 0) {
|
if (light > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block b = e.getBlock();
|
final Block b = e.getBlock();
|
||||||
Material blockid = b.getType();
|
final Material blockid = b.getType();
|
||||||
Location loc = b.getLocation();
|
final Location loc = b.getLocation();
|
||||||
World World = loc.getWorld();
|
final World World = loc.getWorld();
|
||||||
int x = loc.getBlockX();
|
final int x = loc.getBlockX();
|
||||||
int y = loc.getBlockY();
|
final int y = loc.getBlockY();
|
||||||
int z = loc.getBlockZ();
|
final int z = loc.getBlockZ();
|
||||||
Location loc_top = new Location(World, x, y + 1, z);
|
final Location loc_top = new Location(World, x, y + 1, z);
|
||||||
if (loc_top.getBlock().getType() == Material.AIR) {
|
if (loc_top.getBlock().getType() == Material.AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collection<PotionEffect> effect = p.getActivePotionEffects();
|
final Collection<PotionEffect> effect = p.getActivePotionEffects();
|
||||||
Iterator<PotionEffect> iterator = effect.iterator();
|
final Iterator<PotionEffect> iterator = effect.iterator();
|
||||||
Boolean flag = Boolean.valueOf(false);
|
Boolean flag = Boolean.valueOf(false);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
PotionEffect element = (PotionEffect) iterator.next();
|
final PotionEffect element = iterator.next();
|
||||||
if (element.toString().toUpperCase().contains("NIGHT_VISION")) {
|
if (element.toString().toUpperCase().contains("NIGHT_VISION")) {
|
||||||
flag = Boolean.valueOf(true);
|
flag = Boolean.valueOf(true);
|
||||||
break;
|
break;
|
||||||
@ -56,13 +58,8 @@ public class Nightvision implements Listener {
|
|||||||
if (blockid == Material.AIR) {
|
if (blockid == Material.AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (blockid == Material.STONE || blockid == Material.GOLD_ORE
|
if (blockid == Material.STONE || blockid == Material.GOLD_ORE || blockid == Material.IRON_ORE || blockid == Material.COAL_ORE || blockid == Material.DIAMOND_ORE
|
||||||
|| blockid == Material.IRON_ORE
|
|| blockid == Material.REDSTONE_ORE || blockid == Material.LAPIS_ORE || blockid == Material.EMERALD_ORE) {
|
||||||
|| blockid == Material.COAL_ORE
|
|
||||||
|| blockid == Material.DIAMOND_ORE
|
|
||||||
|| blockid == Material.REDSTONE_ORE
|
|
||||||
|| blockid == Material.LAPIS_ORE
|
|
||||||
|| blockid == Material.EMERALD_ORE) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
p.sendMessage(plugin.getfullmsg("Nightvision.Tip"));
|
p.sendMessage(plugin.getfullmsg("Nightvision.Tip"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user