Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.    
  2.     @EventHandler
  3.     public void onPlayeriPvPEvent(final PlayerBucketEmptyEvent e) {
  4.         final Player p = e.getPlayer();
  5.         final Location loc = e.getBlockClicked().getLocation();
  6.         if (this.gameManager.isPvpEnabled()) {
  7.             return;
  8.         }
  9.         if (e.getBucket() == Material.WATER_BUCKET) {
  10.             return;
  11.         }
  12.         Entity[] entities;
  13.         for (int length = (entities = loc.getChunk().getEntities()).length, i = 0; i < length; ++i) {
  14.             final Entity entity = entities[i];
  15.             if (entity instanceof Player) {
  16.                 final Player target = (Player)entity;
  17.                 if (target.getLocation().distance(loc) <= 4.9 && !target.getName().equalsIgnoreCase(p.getName())) {
  18.                     e.setCancelled(true);
  19.                     p.sendMessage(String.valueOf(String.valueOf(this.gameManager.getErrorPrefix())) + Color.translate("&cYou can't do this before PVP"));
  20.                     return;
  21.                 }
  22.             }
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement