Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.kevinatoranator.AGTV;
- import java.util.Random;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Biome;
- import org.bukkit.block.Block;
- //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 plantBiomes implements Listener {
- AGTV plugin;
- Random rand = new Random();
- int num = 0;
- ItemStack melonDrop = new ItemStack(Material.MELON, 2);
- ItemStack wheatDrop = new ItemStack(Material.WHEAT, 1);
- ItemStack caneDrop = new ItemStack(Material.SUGAR_CANE, 1);
- ItemStack pumpkinDrop = new ItemStack(Material.PUMPKIN, 1);
- public plantBiomes(AGTV instance) {
- plugin = instance;
- }
- @EventHandler
- public void plantDrop(BlockBreakEvent event) {
- // Player player = event.getPlayer();
- if (plugin.getConfig().getBoolean("enableBiomeDrops") == true) {
- Block plant = event.getBlock();
- Material plantType = plant.getType();
- Biome biome = plant.getBiome();
- Location bloc = plant.getLocation();
- // player.sendMessage("you broke a block");
- if (plantType == Material.MELON_BLOCK) {
- // player.sendMessage("you broke a melon");
- if (biome == Biome.DESERT || biome == Biome.DESERT_HILLS
- || biome == Biome.BEACH || biome == Biome.ICE_MOUNTAINS|| biome == Biome.ICE_PLAINS
- || biome == Biome.ICE_DESERT || biome == Biome.TUNDRA) {
- // player.sendMessage("No melon for you");
- event.setCancelled(true);
- plant.setType(Material.AIR);
- num = rand.nextInt(100);
- if (num < plugin.getConfig().getInt("PoorMelonDropChance")) {
- plant.getWorld().dropItemNaturally(bloc, melonDrop);
- // player.sendMessage("Just kidding here is some melon");
- }
- }
- }
- if (plantType == Material.CROPS && plant.getData() == 7) {
- // player.sendMessage("you broke fully grown crops");
- if (biome == Biome.FROZEN_RIVER || biome == Biome.ICE_DESERT
- || biome == Biome.ICE_MOUNTAINS|| biome == Biome.ICE_PLAINS
- || biome == Biome.SWAMPLAND || biome == Biome.TUNDRA) {
- event.setCancelled(true);
- plant.setType(Material.AIR);
- num = rand.nextInt(100);
- if (num < plugin.getConfig().getInt("PoorWheatDropChance")) {
- // player.sendMessage("lucky wheat");
- plant.getWorld().dropItemNaturally(bloc, wheatDrop);
- }
- }
- }
- if (plantType == Material.SUGAR_CANE_BLOCK) {
- if (biome == Biome.DESERT || biome == Biome.DESERT_HILLS|| biome == Biome.FROZEN_RIVER
- || biome == Biome.FROZEN_OCEAN|| biome == Biome.ICE_DESERT
- || biome == Biome.ICE_MOUNTAINS|| biome == Biome.ICE_PLAINS || biome == Biome.PLAINS
- || biome == Biome.SAVANNA || biome == Biome.SHRUBLAND
- || biome == Biome.TAIGA || biome == Biome.TAIGA_HILLS
- || biome == Biome.TUNDRA) {
- event.setCancelled(true);
- plant.setType(Material.AIR);
- num = rand.nextInt(100);
- if (num < plugin.getConfig().getInt("PoorSugarCaneDropChance")) {
- plant.getWorld().dropItemNaturally(bloc, caneDrop);
- }
- }
- }
- if (plantType == Material.PUMPKIN) {
- if (biome == Biome.DESERT || biome == Biome.DESERT_HILLS
- || biome == Biome.SWAMPLAND || biome == Biome.TUNDRA) {
- event.setCancelled(true);
- plant.setType(Material.AIR);
- num = rand.nextInt(100);
- if (num < plugin.getConfig().getInt("PoorPumpkinDropChance")) {
- plant.getWorld().dropItemNaturally(bloc, pumpkinDrop);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment