package de.cactus.stone;
import java.util.Map;
import java.util.Random;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
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;
import org.bukkit.inventory.meta.ItemMeta;
public class stone implements Listener{
public double getRandomDouble(double min, double max)
Validate.isTrue(max > min, "Max nie moze byc mniejszy niz min");
return this.rand.nextDouble() * (max - min) + min;
}
public boolean getChance(double chance){
return (chance >= 100.0D) || (chance >= getRandomDouble(0.0D, 100.0D));
}
@EventHandler
public void onBreak(BlockBreakEvent e){
Player p = e.getPlayer();
Block b = e.getBlock();
if (b.getType() == Material.STONE){
if ((b.getLocation().getBlockY() <= 64) &&
(p.getGameMode() == GameMode.SURVIVAL) &&
(getChance(50.0D))){
b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.IRON_INGOT, 1));
p.sendMessage(ChatColor.GRAY + "Znalazles zelazo :D");
}
if ((b.getLocation().getBlockY() <= 24) &&
(getChance(25.0D))){
b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.DIAMOND, 1));
p.sendMessage(ChatColor.AQUA + "Znalazles diament :D");
}
if ((b.getLocation().getBlockY() <= 30) &&
(p.getItemInHand().getType() == Material.DIAMOND_PICKAXE) &&
(p.getItemInHand().getItemMeta().getEnchants().containsKey(Enchantment.LOOT_BONUS_BLOCKS)) &&
(p.getItemInHand().getItemMeta().getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS) == 3) &&
(getChance(50.0D))){
int goldAmount = this.rand.nextInt(3) + 1;
b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(Material.GOLD_INGOT, goldAmount));
}
}
if ((b.getType() == Material.IRON_ORE) || (b.getType() == Material.DIAMOND_ORE)){
b.setType(Material.AIR);
p.sendMessage(ChatColor.GOLD + "Jest drop ze stone :D");
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}