Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.smq.sdrop;
- import java.util.Random;
- import org.apache.commons.lang.Validate;
- import org.bukkit.ChatColor;
- import org.bukkit.GameMode;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockBreakEvent;
- import org.bukkit.inventory.ItemStack;
- public class Drop implements Listener{
- public static Main plugin;
- public Drop(Main instance){}
- Random rand = new Random();
- public double getRandomDouble(double min, double max) throws IllegalArgumentException{
- Validate.isTrue(max > min, "Max. jest mniejsze niz Min.");
- return (rand.nextDouble() * (max - min) + min);
- }
- public boolean getChance(double chance){
- return (chance >= 100 || (chance >= getRandomDouble(0, 100)));
- }
- @EventHandler
- public void onBreak(BlockBreakEvent evt){
- Player p = evt.getPlayer();
- Block b = evt.getBlock();
- int goldAmount1 = rand.nextInt(4) + 1;
- int diamondAmount1 = rand.nextInt(4) + 1;
- int emeraldAmount1 = rand.nextInt(4) + 1;
- int redstoneAmount1 = rand.nextInt(8) + 3;
- int coalAmount1 = rand.nextInt(4) + 1;
- int ironAmount1 = rand.nextInt(4) + 1;
- int goldAmount2 = rand.nextInt(3) + 1;
- int diamondAmount2 = rand.nextInt(3) + 1;
- int emeraldAmount2 = rand.nextInt(3) + 1;
- int redstoneAmount2 = rand.nextInt(6) + 2;
- int coalAmount2 = rand.nextInt(3) + 1;
- int ironAmount2 = rand.nextInt(3) + 1;
- int goldAmount3 = rand.nextInt(2) + 1;
- int diamondAmount3 = rand.nextInt(2) + 1;
- int emeraldAmount3 = rand.nextInt(2) + 1;
- int redstoneAmount3 = rand.nextInt(4) + 1;
- int coalAmount3 = rand.nextInt(2) + 1;
- int ironAmount3 = rand.nextInt(2) + 1;
- if(b.getType() == Material.STONE){
- if(b.getLocation().getBlockY() <= 64){
- if(p.getGameMode() == GameMode.SURVIVAL){
- if(getChance(1.5)){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getGameMode() == GameMode.SURVIVAL){
- if(getChance(0.65)){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND));
- p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getGameMode() == GameMode.SURVIVAL){
- if(getChance(0.8)){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE));
- p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getGameMode() == GameMode.SURVIVAL){
- if(getChance(0.55)){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE));
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getGameMode() == GameMode.SURVIVAL){
- if(getChance(2)){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL));
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getGameMode() == GameMode.SURVIVAL){
- if(getChance(0.2)){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD));
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
- if(getChance(0.55)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE, goldAmount1));
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
- if(getChance(0.65)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, diamondAmount1));
- p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
- if(getChance(0.2)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD, emeraldAmount1));
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 21){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
- if(getChance(0.8)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE, redstoneAmount1));
- p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
- if(getChance(2)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL, coalAmount1));
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
- if(getChance(1.5)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE, ironAmount1));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
- if(getChance(0.55)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE, goldAmount2));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
- if(getChance(1.5)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE, ironAmount2));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
- if(getChance(0.2)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD, emeraldAmount2));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
- if(getChance(0.8)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE, redstoneAmount2));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
- if(getChance(2)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL, coalAmount2));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
- if(getChance(0.65)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, diamondAmount2));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
- if(getChance(0.65)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, diamondAmount3));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
- if(getChance(1.5)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE, ironAmount3));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
- if(getChance(0.2)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD, emeraldAmount3));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
- if(getChance(0.8)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE, redstoneAmount3));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
- if(getChance(2)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL, coalAmount3));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
- }
- }
- }
- }
- }
- if(b.getLocation().getBlockY() <= 64){
- if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
- if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
- if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
- if(getChance(0.55)){
- b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE, goldAmount3));
- p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
- }
- }
- }
- }
- }
- }
- if(b.getType() == Material.IRON_ORE || b.getType() == Material.DIAMOND_ORE || b.getType() == Material.GOLD_ORE || b.getType() == Material.LAPIS_ORE || b.getType() == Material.EMERALD_ORE || b.getType() == Material.REDSTONE_ORE || b.getType() == Material.COAL_ORE){
- b.setType(Material.AIR);
- p.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "Na tym Serwerze jest drop ze stone !" + ChatColor.GREEN + " Zapoznaj sie z nim /drop");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement