Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onPlayeriPvPEvent(final PlayerBucketEmptyEvent e) {
- final Player p = e.getPlayer();
- final Location loc = e.getBlockClicked().getLocation();
- if (this.gameManager.isPvpEnabled()) {
- return;
- }
- if (e.getBucket() == Material.WATER_BUCKET) {
- return;
- }
- Entity[] entities;
- for (int length = (entities = loc.getChunk().getEntities()).length, i = 0; i < length; ++i) {
- final Entity entity = entities[i];
- if (entity instanceof Player) {
- final Player target = (Player)entity;
- if (target.getLocation().distance(loc) <= 4.9 && !target.getName().equalsIgnoreCase(p.getName())) {
- e.setCancelled(true);
- p.sendMessage(String.valueOf(String.valueOf(this.gameManager.getErrorPrefix())) + Color.translate("&cYou can't do this before PVP"));
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement