Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EnchantsFunctions {
- private Main pl;
- private int EmptySlots;
- static List<Block> blocks2 = new ArrayList<Block>();
- @SuppressWarnings("static-access")
- public EnchantsFunctions(Main pl) {
- this.pl = pl;
- }
- public static int getEmptySlots(Player p) {
- Inventory inventory = p.getInventory();
- ItemStack[] cont = inventory.getContents();
- int i = 0;
- for (ItemStack item : cont)
- if (item != null && item.getType() != Material.AIR) {
- i++;
- }
- return 36 - i;
- }
- public static List<Block> getNearbyBlocks(Location location, int radius) {
- List<Block> blocks = new ArrayList<Block>();
- for (int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
- for (int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
- for (int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
- blocks.add(location.getWorld().getBlockAt(x, y, z));
- location.getWorld().getBlockAt(x, y, z).setType(Material.AIR);
- blocks2 = blocks;
- }
- }
- }
- return blocks;
- }
- public void AddBlocks(Player player) {
- for (int i = 0; i <= getEmptySlots(player); i++) {
- player.getInventory().addItem(new ItemStack(Material.getMaterial(blocks2.get(i).getType().getId())));
- }
- }
- public void Epxlosive(int level, Player player) {
- Location position = player.getLocation();
- int radius = level;
- getNearbyBlocks(position, radius);
- for(int i = 0; i <= blocks2.size(); i++) {
- AddBlocks(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement