1
0
mirror of https://e.coding.net/circlecloud/Residence.git synced 2025-11-24 21:46:16 +00:00

修复补丁导致的刷物品BUG...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092
2015-11-13 20:16:56 +08:00
parent 251bc9e1bf
commit a9850013f3
2 changed files with 17 additions and 13 deletions

View File

@@ -28,12 +28,6 @@ public class ResidenceBugFix implements Listener {
plugin.getLogger().info("防刷生物补丁已加载...");
}
public boolean hasPerm(final ClaimedResidence res, final Player p) {
final FlagPermissions perms = res.getPermissions();
final String world = p.getWorld().getName();
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
}
public Block getPlaceBlock(final PlayerInteractEvent e) {
final Player p = e.getPlayer();
final ItemStack it = p.getItemInHand();
@@ -53,6 +47,12 @@ public class ResidenceBugFix implements Listener {
return b.getRelative(BlockFace.DOWN);
}
public boolean hasPerm(final ClaimedResidence res, final Player p) {
final FlagPermissions perms = res.getPermissions();
final String world = p.getWorld().getName();
return perms.playerHas(p.getName(), world, "place", perms.playerHas(p.getName(), world, "build", false));
}
@EventHandler
public void onBlockPlace(final PlayerInteractEvent e) {
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.PHYSICAL) {
@@ -102,7 +102,7 @@ public class ResidenceBugFix implements Listener {
if (res == null) {
return;
}
if (b1.getType() != Material.AIR && b2.getType() == Material.AIR) {
if (b1.getType() != Material.AIR && b1.getType() != Material.TORCH && b2.getType() == Material.AIR && checkAround(b2)) {
if (!hasPerm(res, p)) {
e.setCancelled(true);
p.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NoPermission") + ChatColor.DARK_RED + " 当前区域不允许此操作!");
@@ -122,9 +122,13 @@ public class ResidenceBugFix implements Listener {
@EventHandler
public void onSugarCanePhysics(final BlockPhysicsEvent e) {
// final Material mat = e.getChangedType();
// if (mat == Material.SUGAR_CANE_BLOCK) {
// e.getBlock().getDrops().clear();
// }
}
private boolean checkAround(final Block b) {
final Block be = b.getRelative(BlockFace.EAST);
final Block bw = b.getRelative(BlockFace.WEST);
final Block bn = b.getRelative(BlockFace.NORTH);
final Block bs = b.getRelative(BlockFace.SOUTH);
return (be.getType() != Material.AIR || bw.getType() != Material.AIR || bn.getType() != Material.AIR || bs.getType() != Material.AIR);
}
}