Advertisement
williambriggs

Code

Aug 11th, 2022
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package me.will.randomthings.listeners;
  2.  
  3. import me.will.randomthings.RandomThings;
  4. import net.Indyuce.mmoitems.MMOItems;
  5. import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.block.BlockBreakEvent;
  9. import org.bukkit.inventory.ItemStack;
  10.  
  11. public class BlockBreak implements Listener {
  12.  
  13. @EventHandler
  14. public void playerBreak(BlockBreakEvent event) {
  15.  
  16. if (RandomThings.getPlugin().getTomlConfig().getList("List").contains(event.getBlock().getBiome() + "-" + event.getBlock().getType())) {
  17.  
  18. String id = event.getBlock().getBiome() + "-" + event.getBlock().getType();
  19. Object[] data = RandomThings.getPlugin().getTomlConfig().getList(id).toArray();
  20.  
  21.  
  22. if (!(Math.random() < (Float.parseFloat((String) data[1])))) { event.setDropItems(true); } else {
  23. MMOItem mmoitem = MMOItems.plugin.getMMOItem(MMOItems.plugin.getTypes().get("CONSUMABLE"), (String) data[0]);
  24. if (mmoitem == null) { return; }
  25. ItemStack item = mmoitem.newBuilder().build();
  26. if (item == null) { return; }
  27. event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
  28. event.setDropItems(false);
  29. }
  30.  
  31. }
  32.  
  33.  
  34. }
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement