Advertisement
chumanista

Untitled

Jun 29th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package com.chumanista.youtube;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.entity.ExperienceOrb;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.block.BlockPlaceEvent;
  8. import org.bukkit.inventory.ItemStack;
  9.  
  10. public class PremiumCaseListener implements Listener {
  11.    
  12.     @EventHandler
  13.     public void onPlace(BlockPlaceEvent e) {
  14.        
  15.         if (e.getBlock().getType().equals(ItemStacks.getPremiumCaseMaterial())
  16.             && e.getPlayer().getItemInHand().equals(ItemStacks.getPremiumCase())) {
  17.            
  18.             if (!e.getPlayer().getInventory().contains(ItemStacks.getPremiumCaseKey())) {
  19.                 e.getPlayer().sendMessage(ChatColor.RED + "Nie masz klucza!");
  20.                 e.setCancelled(true);
  21.                 return;
  22.             }
  23.            
  24.             for (ItemToDrop i : PremiumCase.dropy) {
  25.                 if (Utils.getChance(i.getChance())) {
  26.                     if (i.getPremiumCase().equals(ItemStacks.getPremiumCase())) {
  27.                        
  28.                         ItemStack toDrop = i.getDrop();
  29.                         int amount = Utils.getRandInt(i.getMinAmount(), i.getMaxAmount());
  30.                        
  31.                         toDrop.setAmount(amount);
  32.                         e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), toDrop);
  33.                         e.getBlock().getWorld().spawn(e.getBlock().getLocation(), ExperienceOrb.class);
  34.                         e.getBlock().breakNaturally();
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.     }
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement