Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public class RpgBlockListener extends PluginListener {
  2. public boolean onBlockDestroy(Player p, Block b)
  3. {
  4. if(!p.isAdmin())
  5. {
  6. if(b.getStatus() == 3 || b.getStatus() == 1 || b.getStatus() == 0)
  7. {
  8. synchronized(RpgMod.neutralCities)
  9. {
  10.  
  11. for(Location l : RpgMod.neutralCities.values())
  12. {
  13. p.sendMessage(""+RpgBlockListener.getDistanceLocBlock(l,b));
  14. if(RpgBlockListener.getDistanceLocBlock(l, b) < 100)
  15. {
  16. p.sendMessage("This block should not have been destroyed.");
  17. return true;
  18. }
  19. }
  20. }
  21. }
  22. }
  23. p.sendMessage("This block should have been destroyed");
  24. return false;
  25. }
  26.  
  27. public static double getDistanceLocBlock(Location a, Block b) {
  28. double xPart = Math.pow(a.x - b.getX(), 2);
  29. double yPart = Math.pow(a.y - b.getY(), 2);
  30. double zPart = Math.pow(a.z - b.getZ(), 2);
  31. return Math.sqrt(xPart + yPart + zPart); }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement