Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.79 KB | None | 0 0
  1. package me.smq.sdrop;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.apache.commons.lang.Validate;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.GameMode;
  8. import org.bukkit.Material;
  9. import org.bukkit.block.Block;
  10. import org.bukkit.enchantments.Enchantment;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.block.BlockBreakEvent;
  15. import org.bukkit.inventory.ItemStack;
  16.  
  17. public class Drop implements Listener{
  18.    
  19.     public static Main plugin;
  20.     public Drop(Main instance){}
  21.        
  22.         Random rand = new Random();
  23.        
  24.         public double getRandomDouble(double min, double max) throws IllegalArgumentException{
  25.             Validate.isTrue(max > min, "Max. jest mniejsze niz Min.");
  26.             return (rand.nextDouble() * (max - min) + min);    
  27. }
  28.        
  29.         public boolean getChance(double chance){
  30.             return (chance >= 100 || (chance >= getRandomDouble(0, 100)));     
  31. }
  32.        
  33.         @EventHandler
  34.         public void onBreak(BlockBreakEvent evt){
  35.             Player p = evt.getPlayer();
  36.             Block b = evt.getBlock();      
  37.            
  38.             int goldAmount1 = rand.nextInt(4) + 1;
  39.             int diamondAmount1 = rand.nextInt(4) + 1;
  40.             int emeraldAmount1 = rand.nextInt(4) + 1;
  41.             int redstoneAmount1 = rand.nextInt(8) + 3;
  42.             int coalAmount1 = rand.nextInt(4) + 1;
  43.             int ironAmount1 = rand.nextInt(4) + 1;
  44.            
  45.             int goldAmount2 = rand.nextInt(3) + 1;
  46.             int diamondAmount2 = rand.nextInt(3) + 1;
  47.             int emeraldAmount2 = rand.nextInt(3) + 1;
  48.             int redstoneAmount2 = rand.nextInt(6) + 2;
  49.             int coalAmount2 = rand.nextInt(3) + 1;
  50.             int ironAmount2 = rand.nextInt(3) + 1;
  51.            
  52.             int goldAmount3 = rand.nextInt(2) + 1;
  53.             int diamondAmount3 = rand.nextInt(2) + 1;
  54.             int emeraldAmount3 = rand.nextInt(2) + 1;
  55.             int redstoneAmount3 = rand.nextInt(4) + 1;
  56.             int coalAmount3 = rand.nextInt(2) + 1;
  57.             int ironAmount3 = rand.nextInt(2) + 1;
  58.            
  59.             if(b.getType() == Material.STONE){
  60.                 if(b.getLocation().getBlockY() <= 64){
  61.                     if(p.getGameMode() == GameMode.SURVIVAL){
  62.                         if(getChance(1.5)){
  63.                             if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE){
  64.                             b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE));
  65.                             p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
  66. }
  67. }                      
  68. }
  69.                        
  70. }
  71.                    
  72. }
  73.                
  74.  
  75.            
  76.  
  77.                 if(b.getLocation().getBlockY() <= 21){
  78.                     if(p.getGameMode() == GameMode.SURVIVAL){
  79.                         if(getChance(0.65)){
  80.                             if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
  81.                             b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND));
  82.                             p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
  83. }
  84.                                    
  85. }
  86. }                          
  87. }
  88.                        
  89.  
  90.                    
  91.  
  92.                
  93.  
  94.                 if(b.getLocation().getBlockY() <= 21){
  95.                     if(p.getGameMode() == GameMode.SURVIVAL){
  96.                         if(getChance(0.8)){
  97.                             if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
  98.                             b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE));
  99.                             p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
  100. }
  101.                                    
  102. }
  103. }                                                      
  104. }
  105.                        
  106.                
  107.                 if(b.getLocation().getBlockY() <= 21){
  108.                     if(p.getGameMode() == GameMode.SURVIVAL){
  109.                         if(getChance(0.55)){
  110.                             if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
  111.                             b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE));
  112.                             p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
  113.  
  114.                                    
  115.  
  116. }
  117. }  
  118.                        
  119. }
  120.                    
  121. }
  122.                
  123.                 if(b.getLocation().getBlockY() <= 64){
  124.                     if(p.getGameMode() == GameMode.SURVIVAL){
  125.                         if(getChance(2)){
  126.                             if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE || p.getItemInHand().getType() == Material.STONE_PICKAXE){
  127.                             b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL));
  128.                             p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");                              
  129. }
  130. }                          
  131.                        
  132. }
  133.                    
  134. }
  135.  
  136.                
  137.                 if(b.getLocation().getBlockY() <= 21){
  138.                     if(p.getGameMode() == GameMode.SURVIVAL){
  139.                         if(getChance(0.2)){
  140.                             if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE || p.getItemInHand().getType() == Material.IRON_PICKAXE){
  141.                             b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD));
  142.                             p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
  143. }
  144. }
  145.                        
  146. }
  147.                    
  148.                     if(b.getLocation().getBlockY() <= 21){
  149.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  150.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  151.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
  152.                                                 if(getChance(0.55)){
  153.                                                        
  154.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE, goldAmount1));
  155.                                                         p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
  156.                                                        
  157. }
  158.  
  159. }
  160. }
  161. }
  162. }          
  163.                     if(b.getLocation().getBlockY() <= 21){
  164.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  165.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  166.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
  167.                                                 if(getChance(0.65)){
  168.                                                        
  169.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, diamondAmount1));
  170.                                                         p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
  171.                                                        
  172. }
  173.  
  174. }
  175. }
  176. }
  177. }  
  178.                     if(b.getLocation().getBlockY() <= 21){
  179.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  180.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  181.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
  182.                                                 if(getChance(0.2)){
  183.                                                        
  184.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD, emeraldAmount1));
  185.                                                         p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
  186.                                                        
  187. }
  188.  
  189. }
  190. }
  191. }
  192. }  
  193.                     if(b.getLocation().getBlockY() <= 21){
  194.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  195.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  196.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
  197.                                                 if(getChance(0.8)){
  198.                                                        
  199.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE, redstoneAmount1));
  200.                                                         p.sendMessage(ChatColor.BOLD + "" +ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
  201.                                                        
  202. }
  203.  
  204. }
  205. }
  206. }
  207. }  
  208.                     if(b.getLocation().getBlockY() <= 64){
  209.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  210.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  211.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
  212.                                                 if(getChance(2)){
  213.                                                        
  214.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL, coalAmount1));
  215.                                                         p.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
  216.  
  217.                                                        
  218. }
  219.  
  220. }
  221. }
  222. }
  223. }  
  224.                     if(b.getLocation().getBlockY() <= 64){
  225.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  226.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  227.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3){
  228.                                                 if(getChance(1.5)){
  229.                                                        
  230.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE, ironAmount1));
  231.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
  232.                                                        
  233. }
  234.  
  235. }
  236. }
  237. }
  238. }
  239.                     if(b.getLocation().getBlockY() <= 64){
  240.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  241.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  242.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
  243.                                                 if(getChance(0.55)){
  244.                                                        
  245.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE, goldAmount2));
  246.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
  247.                                                        
  248. }
  249.  
  250. }
  251. }
  252. }
  253. }  
  254.                     if(b.getLocation().getBlockY() <= 64){
  255.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  256.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  257.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
  258.                                                 if(getChance(1.5)){
  259.                                                        
  260.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE, ironAmount2));
  261.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
  262.                                                        
  263. }
  264.  
  265. }
  266. }
  267. }
  268. }  
  269.                     if(b.getLocation().getBlockY() <= 64){
  270.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  271.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  272.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
  273.                                                 if(getChance(0.2)){
  274.                                                        
  275.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD, emeraldAmount2));
  276.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
  277.                                                        
  278. }
  279.  
  280. }
  281. }
  282. }
  283. }  
  284.                     if(b.getLocation().getBlockY() <= 64){
  285.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  286.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  287.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
  288.                                                 if(getChance(0.8)){
  289.                                                        
  290.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE, redstoneAmount2));
  291.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
  292.                                                        
  293. }
  294.  
  295. }
  296. }
  297. }
  298. }  
  299.                     if(b.getLocation().getBlockY() <= 64){
  300.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  301.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  302.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
  303.                                                 if(getChance(2)){
  304.                                                        
  305.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL, coalAmount2));
  306.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
  307.                                                        
  308. }
  309.  
  310. }
  311. }
  312. }
  313. }  
  314.                     if(b.getLocation().getBlockY() <= 64){
  315.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  316.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  317.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 2){
  318.                                                 if(getChance(0.65)){
  319.                                                        
  320.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, diamondAmount2));
  321.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
  322.                                                        
  323. }
  324.  
  325. }
  326. }
  327. }
  328. }  
  329.                     if(b.getLocation().getBlockY() <= 64){
  330.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  331.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  332.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
  333.                                                 if(getChance(0.65)){
  334.                                                        
  335.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, diamondAmount3));
  336.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.AQUA + "Diamenty");
  337.                                                        
  338. }
  339.  
  340. }
  341. }
  342. }
  343. }  
  344.                     if(b.getLocation().getBlockY() <= 64){
  345.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  346.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  347.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
  348.                                                 if(getChance(1.5)){
  349.                                                        
  350.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_ORE, ironAmount3));
  351.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GRAY + "Rude Zelaza");
  352.                                                        
  353. }
  354.  
  355. }
  356. }
  357. }
  358. }  
  359.                     if(b.getLocation().getBlockY() <= 64){
  360.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  361.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  362.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
  363.                                                 if(getChance(0.2)){
  364.                                                        
  365.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.EMERALD, emeraldAmount3));
  366.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GREEN + "Emeraldy");
  367.                                                        
  368. }
  369.  
  370. }
  371. }
  372. }
  373. }  
  374.                     if(b.getLocation().getBlockY() <= 64){
  375.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  376.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  377.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
  378.                                                 if(getChance(0.8)){
  379.                                                        
  380.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.REDSTONE, redstoneAmount3));
  381.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.RED + "Redstone");
  382.                                                        
  383. }
  384.  
  385. }
  386. }
  387. }
  388. }
  389.                     if(b.getLocation().getBlockY() <= 64){
  390.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  391.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  392.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
  393.                                                 if(getChance(2)){
  394.                                                        
  395.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.COAL, coalAmount3));
  396.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.BLACK + "Wegiel");
  397.                                                        
  398. }
  399.  
  400. }
  401. }
  402. }
  403. }
  404.                     if(b.getLocation().getBlockY() <= 64){
  405.                         if(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE){
  406.                                 if(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)){
  407.                                         if(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 1){
  408.                                                 if(getChance(0.55)){
  409.                                                        
  410.                                                         b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_ORE, goldAmount3));
  411.                                                         p.sendMessage(ChatColor.GREEN + "Trafiles na " + ChatColor.GOLD + "Rude Zlota");
  412.                                                        
  413. }
  414.  
  415. }
  416. }
  417. }
  418. }
  419.                    
  420. }
  421.  
  422.    
  423.                 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){
  424.                     b.setType(Material.AIR);
  425.                     p.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "Na tym Serwerze jest drop ze stone !" + ChatColor.GREEN + " Zapoznaj sie z nim /drop");
  426. }
  427.                
  428. }
  429. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement