@EventHandler(priority = EventPriority.HIGH) // , ignoreCancelled = true public void onBlockBreak(final BlockBreakEvent event) { Block b = event.getBlock(); if (PlotManager.isPlotWorld(b)) { Player p = event.getPlayer(); boolean canbuild = PlotMe.cPerms(event.getPlayer(), "plotme.admin.buildanywhere"); String id = PlotManager.getPlotId(b.getLocation()); if (id.equalsIgnoreCase("")) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { Plot plot = PlotManager.getMap(p).plots.get(id); if (plot == null) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else if (!plot.isAllowed(p.getName())) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { plot.resetExpire(PlotManager.getMap(b).DaysToExpiration); } } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerInteractEntity(final PlayerInteractEntityEvent event) { Location l = event.getRightClicked().getLocation(); if (PlotManager.isPlotWorld(l)) { Player p = event.getPlayer(); boolean canbuild = PlotMe.cPerms(p, "plotme.admin.buildanywhere"); String id = PlotManager.getPlotId(l); if (id.equalsIgnoreCase("")) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { Plot plot = PlotManager.getPlotById(p, id); if (plot == null) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else if (!plot.isAllowed(p.getName())) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { plot.resetExpire(PlotManager.getMap(l).DaysToExpiration); } } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockIgnite(final BlockIgniteEvent event) { Block b = event.getBlock(); if (b != null) { PlotMapInfo pmi = PlotManager.getMap(b); if (pmi != null) { if (pmi.DisableIgnition) { event.setCancelled(true); } else { String id = PlotManager.getPlotId(b.getLocation()); Player p = event.getPlayer(); if (id.equalsIgnoreCase("") || p == null) { event.setCancelled(true); } else { Plot plot = PlotManager.getPlotById(b, id); if (plot == null) { event.setCancelled(true); } else if (!plot.isAllowed(p.getName())) { event.setCancelled(true); } } } } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityExplode(final EntityExplodeEvent event) { Location l = event.getLocation(); if (l != null) { PlotMapInfo pmi = PlotManager.getMap(l); if (pmi != null && pmi.DisableExplosion) event.setCancelled(true); } }
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerInteract(final PlayerInteractEvent event) { Block b = event.getClickedBlock(); if (PlotManager.isPlotWorld(b)) { PlotMapInfo pmi = PlotManager.getMap(b); boolean blocked = false; Player player = event.getPlayer(); boolean canbuild = PlotMe.cPerms(player, "plotme.admin.buildanywhere"); if (event.isBlockInHand() && event.getAction() == Action.RIGHT_CLICK_BLOCK) { BlockFace face = event.getBlockFace(); Block builtblock = b.getWorld() .getBlockAt( b.getX() + face.getModX(), b.getY() + face.getModY(), b.getZ() + face.getModZ()); String id = PlotManager.getPlotId(builtblock.getLocation()); Player p = event.getPlayer(); if (id.equalsIgnoreCase("")) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { Plot plot = PlotManager.getPlotById(p, id); if (plot == null) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { if (!plot.isAllowed(p.getName())) { if (!canbuild) { p.sendMessage(PlotMe.caption("ErrCannotBuild")); event.setCancelled(true); } } else { plot.resetExpire(PlotManager.getMap(b).DaysToExpiration); } } } } else { /*for(int blockid : pmi.ProtectedBlocks) { if(blockid == b.getTypeId()) { if(!PlotMe.cPerms(player, "plotme.unblock." + blockid)) blocked = true; break; } }*/ if (pmi.ProtectedBlocks.contains(b.getTypeId())) { if (!PlotMe.cPerms(player, "plotme.unblock." + b.getTypeId())) blocked = true; } ItemStack is = event.getItem(); if (is != null && event.getAction() == Action.RIGHT_CLICK_BLOCK) { int itemid = is.getType().getId(); byte itemdata = is.getData().getData(); if (pmi.PreventedItems.contains("" + itemid) || pmi.PreventedItems.contains("" + itemid + ":" + itemdata)) { if (!PlotMe.cPerms(player, "plotme.unblock." + itemid)) blocked = true; } } if (blocked) { String id = PlotManager.getPlotId(b.getLocation()); Player p = event.getPlayer(); if (id.equalsIgnoreCase("")) { if (!canbuild) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { p.sendMessage(PlotMe.caption("ErrCannotUse")); } event.setCancelled(true); } } else { Plot plot = PlotManager.getPlotById(p, id); if (plot == null) { if (!canbuild) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { p.sendMessage(PlotMe.caption("ErrCannotUse")); } event.setCancelled(true); } } else if (!plot.isAllowed(p.getName())) { if (!canbuild) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { p.sendMessage(PlotMe.caption("ErrCannotUse")); } event.setCancelled(true); } } } } } } }