Advertisement
amitay12123

Untitled

Apr 20th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1.  
  2. public class EnchantsFunctions {
  3.  
  4. private Main pl;
  5. private int EmptySlots;
  6. static List<Block> blocks2 = new ArrayList<Block>();
  7.  
  8. @SuppressWarnings("static-access")
  9. public EnchantsFunctions(Main pl) {
  10. this.pl = pl;
  11. }
  12.  
  13. public static int getEmptySlots(Player p) {
  14. Inventory inventory = p.getInventory();
  15. ItemStack[] cont = inventory.getContents();
  16. int i = 0;
  17. for (ItemStack item : cont)
  18. if (item != null && item.getType() != Material.AIR) {
  19. i++;
  20. }
  21. return 36 - i;
  22. }
  23.  
  24. public static List<Block> getNearbyBlocks(Location location, int radius) {
  25. List<Block> blocks = new ArrayList<Block>();
  26. for (int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
  27. for (int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
  28. for (int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
  29. blocks.add(location.getWorld().getBlockAt(x, y, z));
  30. location.getWorld().getBlockAt(x, y, z).setType(Material.AIR);
  31. blocks2 = blocks;
  32.  
  33. }
  34. }
  35. }
  36.  
  37. return blocks;
  38.  
  39. }
  40.  
  41. public void AddBlocks(Player player) {
  42. for (int i = 0; i <= getEmptySlots(player); i++) {
  43. player.getInventory().addItem(new ItemStack(Material.getMaterial(blocks2.get(i).getType().getId())));
  44. }
  45. }
  46.  
  47. public void Epxlosive(int level, Player player) {
  48. Location position = player.getLocation();
  49. int radius = level;
  50. getNearbyBlocks(position, radius);
  51. for(int i = 0; i <= blocks2.size(); i++) {
  52. AddBlocks(player);
  53. }
  54.  
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement