diff --git a/MCRandomizer/src/scramble/plugin/Template.java b/MCRandomizer/src/scramble/plugin/Template.java index 60acd96..8eab1da 100644 --- a/MCRandomizer/src/scramble/plugin/Template.java +++ b/MCRandomizer/src/scramble/plugin/Template.java @@ -64,6 +64,7 @@ public class Template public static boolean enableRecipeModifications = false; public static HashMap> monsterDropTable = new HashMap>(); public static HashMap furnaceRecipeTables = new HashMap(); + public static ItemStack randomMelonItem; PluginDescriptionFile pdfFile; @@ -384,6 +385,8 @@ public class Template ReadRecipeData(); AddInDefaultRecipes(); setBreedingTable(); + + randomMelonItem = new ItemStack(Material.getMaterial(Template.archivedshufflelist.get(Template.r.nextInt(Template.archivedshufflelist.size())))); for (String s : recipeTypeMap.keySet()) { Bukkit.getLogger().info(" Randomized " + recipeTypeMap.get(s) + " " + s + " recipes."); diff --git a/MCRandomizer/src/scramble/plugin/listener/ExampleListener.java b/MCRandomizer/src/scramble/plugin/listener/ExampleListener.java index 83e6369..e0dc998 100644 --- a/MCRandomizer/src/scramble/plugin/listener/ExampleListener.java +++ b/MCRandomizer/src/scramble/plugin/listener/ExampleListener.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.EntityBreedEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.VillagerAcquireTradeEvent; @@ -38,6 +39,21 @@ import scramble.plugin.Template; public class ExampleListener implements Listener { + @EventHandler + public void breakingTheMelons(BlockBreakEvent ev) { + if (ev.getBlock().getType()==Material.MELON) { + ev.setDropItems(false); + ev.getBlock().getWorld().dropItemNaturally(ev.getBlock().getLocation(), Template.randomMelonItem); + } + } + + @EventHandler + public void decayleave(LeavesDecayEvent ev) { + if (Template.r.nextInt(100)==0) { + ev.getBlock().getWorld().dropItemNaturally(ev.getBlock().getLocation(), new ItemStack(Material.getMaterial(Template.archivedshufflelist.get(Template.r.nextInt(Template.archivedshufflelist.size()))))); + } + } + @EventHandler public void AcquireTrades(VillagerAcquireTradeEvent ev) { //Bukkit.getLogger().info(ev.getEntity()+" getting "+ev.getRecipe());