From 7f0243b2dfb221ee8bbffd4a16dfbfa35841f351 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 3 May 2013 18:16:42 -0400 Subject: [PATCH] For Iaccidentally. --- src/main/java/com/gmail/nossr50/config/Config.java | 3 +++ .../com/gmail/nossr50/listeners/InventoryListener.java | 10 ++++++++++ src/main/resources/config.yml | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 1de923c27..5d450a963 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -46,6 +46,9 @@ public class Config extends AutoUpdateConfigLoader { public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); } + public boolean getPotatoEnabled() { return config.getBoolean("General.Config.Potato_Explosion_Enabled", true); } + public int getPotatoChance() { return config.getInt("General.Config.Potato_Explosion_Chance", 1); } + public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); } public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); } diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index c9929d4bb..b2eaf31ea 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.listeners; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; @@ -21,6 +22,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.util.ItemUtils; @@ -118,6 +120,14 @@ public class InventoryListener implements Listener { if (furnaceState instanceof Furnace) { ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting(); + if (Config.getInstance().getPotatoEnabled() && smelting.getType() == Material.POTATO_ITEM) { + if ((Config.getInstance().getPotatoChance() / 100.0) >= Misc.getRandom().nextDouble()) { + event.setCancelled(true); + furnaceState.getWorld().createExplosion(furnaceState.getLocation(), 4F, true); + return; + } + } + if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) { // We can make this assumption because we (should) be the only ones using this exact metadata Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString()); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f287d0421..4641c86c9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -26,6 +26,9 @@ General: Verbose_Logging: false # Should mcMMO over-write configs to update, or make new ones ending in .new? Config_Update_Overwrite: true + # Enable potato easter egg? + Potato_Explosion_Enabled: true + Potato_Explosion_Chance: 1 Scoreboards: Inspect: