kevinatoranator

plantBiomes.java v.06

Jul 1st, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.51 KB | None | 0 0
  1. package me.kevinatoranator.AGTV;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Location;
  6. import org.bukkit.Material;
  7. import org.bukkit.block.Biome;
  8. import org.bukkit.block.Block;
  9. //import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.BlockBreakEvent;
  13. import org.bukkit.inventory.ItemStack;
  14.  
  15. public class plantBiomes implements Listener {
  16.     AGTV plugin;
  17.     Random rand = new Random();
  18.     int num = 0;
  19.     ItemStack melonDrop = new ItemStack(Material.MELON, 2);
  20.     ItemStack wheatDrop = new ItemStack(Material.WHEAT, 1);
  21.     ItemStack caneDrop = new ItemStack(Material.SUGAR_CANE, 1);
  22.     ItemStack pumpkinDrop = new ItemStack(Material.PUMPKIN, 1);
  23.  
  24.     public plantBiomes(AGTV instance) {
  25.         plugin = instance;
  26.     }
  27.  
  28.     @EventHandler
  29.     public void plantDrop(BlockBreakEvent event) {
  30.         // Player player = event.getPlayer();
  31.         if (plugin.getConfig().getBoolean("enableBiomeDrops") == true) {
  32.             Block plant = event.getBlock();
  33.             Material plantType = plant.getType();
  34.             Biome biome = plant.getBiome();
  35.             Location bloc = plant.getLocation();
  36.             // player.sendMessage("you broke a block");
  37.             if (plantType == Material.MELON_BLOCK) {
  38.                 // player.sendMessage("you broke a melon");
  39.                 if (biome == Biome.DESERT || biome == Biome.DESERT_HILLS
  40.                         || biome == Biome.BEACH || biome == Biome.ICE_MOUNTAINS|| biome == Biome.ICE_PLAINS
  41.                         || biome == Biome.ICE_DESERT || biome == Biome.TUNDRA) {
  42.                     // player.sendMessage("No melon for you");
  43.                     event.setCancelled(true);
  44.                     plant.setType(Material.AIR);
  45.                     num = rand.nextInt(100);
  46.                     if (num < plugin.getConfig().getInt("PoorMelonDropChance")) {
  47.                         plant.getWorld().dropItemNaturally(bloc, melonDrop);
  48.                         // player.sendMessage("Just kidding here is some melon");
  49.                     }
  50.                 }
  51.             }
  52.             if (plantType == Material.CROPS && plant.getData() == 7) {
  53.                 // player.sendMessage("you broke fully grown crops");
  54.                 if (biome == Biome.FROZEN_RIVER || biome == Biome.ICE_DESERT
  55.                         || biome == Biome.ICE_MOUNTAINS|| biome == Biome.ICE_PLAINS
  56.                         || biome == Biome.SWAMPLAND || biome == Biome.TUNDRA) {
  57.                     event.setCancelled(true);
  58.                     plant.setType(Material.AIR);
  59.                     num = rand.nextInt(100);
  60.                     if (num < plugin.getConfig().getInt("PoorWheatDropChance")) {
  61.                         // player.sendMessage("lucky wheat");
  62.                         plant.getWorld().dropItemNaturally(bloc, wheatDrop);
  63.                     }
  64.                 }
  65.             }
  66.             if (plantType == Material.SUGAR_CANE_BLOCK) {
  67.                 if (biome == Biome.DESERT || biome == Biome.DESERT_HILLS|| biome == Biome.FROZEN_RIVER
  68.                         || biome == Biome.FROZEN_OCEAN|| biome == Biome.ICE_DESERT
  69.                         || biome == Biome.ICE_MOUNTAINS|| biome == Biome.ICE_PLAINS || biome == Biome.PLAINS
  70.                         || biome == Biome.SAVANNA || biome == Biome.SHRUBLAND
  71.                         || biome == Biome.TAIGA || biome == Biome.TAIGA_HILLS
  72.                         || biome == Biome.TUNDRA) {
  73.                     event.setCancelled(true);
  74.                     plant.setType(Material.AIR);
  75.                     num = rand.nextInt(100);
  76.                     if (num < plugin.getConfig().getInt("PoorSugarCaneDropChance")) {
  77.                         plant.getWorld().dropItemNaturally(bloc, caneDrop);
  78.                     }
  79.                 }
  80.             }
  81.             if (plantType == Material.PUMPKIN) {
  82.                 if (biome == Biome.DESERT || biome == Biome.DESERT_HILLS
  83.                         || biome == Biome.SWAMPLAND || biome == Biome.TUNDRA) {
  84.                     event.setCancelled(true);
  85.                     plant.setType(Material.AIR);
  86.                     num = rand.nextInt(100);
  87.                     if (num < plugin.getConfig().getInt("PoorPumpkinDropChance")) {
  88.                         plant.getWorld().dropItemNaturally(bloc, pumpkinDrop);
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment