From fbdbdbaddd6ff5863d347da5c07db529d724c156 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 2 Dec 2013 12:08:12 -0500 Subject: [PATCH] Update mcMMO for Minecraft 1.7.2 --- Changelog.txt | 7 + .../config/experience/ExperienceConfig.java | 131 +++++++++++++++--- .../skills/fishing/FishingManager.java | 3 +- .../skills/herbalism/HerbalismManager.java | 7 +- .../gmail/nossr50/skills/mining/Mining.java | 18 ++- .../skills/woodcutting/Woodcutting.java | 27 +--- .../com/gmail/nossr50/util/BlockUtils.java | 9 +- .../com/gmail/nossr50/util/ItemUtils.java | 14 +- .../com/gmail/nossr50/util/StringUtils.java | 5 + src/main/resources/experience.yml | 33 ++++- 10 files changed, 198 insertions(+), 56 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index f8727f0bd..adc2e814c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,13 @@ Key: - Removal Version 1.5.00-dev + + Added Hardened Clay, Stained Clay, and Packed Ice to Mining blocks + + Added Acacia and Dark Oak to Woodcutting blocks + + Added Salmon, Clownfish, and Pufferfish to Fishing XP + + Added new flowers and grasses to Herbalism XP + ! Fishing XP now depends on the type of fish. + ! Woodcutting XP in experience.yml now uses the tree species names. Oak is now Generic, and Spruce is now Redwood. + ! Red_Rose was replaced by Poppy, and so the key in experience.yml has been updated accordingly. - Removed deprecated permission nodes Version 1.4.08-dev diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index 60b5f1a9c..e0c348395 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -4,7 +4,10 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Material; +import org.bukkit.TreeSpecies; import org.bukkit.entity.EntityType; +import org.bukkit.material.LongGrass; +import org.bukkit.material.MaterialData; import com.gmail.nossr50.config.AutoUpdateConfigLoader; import com.gmail.nossr50.datatypes.experience.FormulaType; @@ -103,9 +106,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { } /* Fishing */ - if (getFishingBaseXP() <= 0) { - reason.add("Experience.Fishing.Base should be greater than 0!"); - } + // TODO: Add validation for each fish type once enum is available. if (getFishingShakeXP() <= 0) { reason.add("Experience.Fishing.Shake should be greater than 0!"); @@ -126,20 +127,12 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { } /* Woodcutting */ - if (getWoodcuttingXPOak() <= 0) { - reason.add("Experience.Woodcutting.Oak should be greater than 0!"); - } + for (TreeSpecies species : TreeSpecies.values()) { + String key = "Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_"); - if (getWoodcuttingXPBirch() <= 0) { - reason.add("Experience.Woodcutting.Birch should be greater than 0!"); - } - - if (getWoodcuttingXPSpruce() <= 0) { - reason.add("Experience.Woodcutting.Spruce should be greater than 0!"); - } - - if (getWoodcuttingXPJungle() <= 0) { - reason.add("Experience.Woodcutting.Jungle should be greater than 0!"); + if (config.getInt(key) <= 0) { + reason.add(key + " should be greater than 0!"); + } } if (getWoodcuttingXPHugeBrownMushroom() <= 0) { @@ -211,9 +204,108 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public double getPotionXP() { return config.getDouble("Experience.Alchemy.Potion", 150D); } /* Fishing */ - public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); } + public int getFishXp(MaterialData data) { + switch (data.getData()) { + case 0x0: + return config.getInt("Experience.Fishing.Raw_Fish", 800); + + case 0x1: + return config.getInt("Experience.Fishing.Raw_Salmon", 800); + + case 0x2: + return config.getInt("Experience.Fishing.Clownfish", 800); + + case 0x3: + return config.getInt("Experience.Fishing.Pufferfish", 800); + + default: + return 0; + } + } + public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); } + /* Herbalism */ + public int getFlowerAndGrassXp(MaterialData data) { + Material type = data.getItemType(); + + if (type == Material.RED_ROSE) { + switch (data.getData()) { + case 0x0: + return config.getInt("Experience.Herbalism.Poppy", 100); + + case 0x1: + return config.getInt("Experience.Herbalism.Blue_Orchid", 150); + + case 0x2: + return config.getInt("Experience.Herbalism.Allium", 300); + + case 0x3: + return config.getInt("Experience.Herbalism.Azure_Bluet", 150); + + case 0x4: + return config.getInt("Experience.Herbalism.Red_Tulip", 150); + + case 0x5: + return config.getInt("Experience.Herbalism.Orange_Tulip", 150); + + case 0x6: + return config.getInt("Experience.Herbalism.White_Tulip", 150); + + case 0x7: + return config.getInt("Experience.Herbalism.Pink_Tulip", 150); + + case 0x8: + return config.getInt("Experience.Herbalism.Oxeye_Daisy", 150); + + default: + return 0; + } + + } + else if (type == Material.LONG_GRASS) { + switch (((LongGrass) data).getSpecies()) { + case DEAD: + return config.getInt("Experience.Herbalism.Dead_Bush", 100); + + case FERN_LIKE: + return config.getInt("Experience.Herbalism.Small_Fern", 100); + + case NORMAL: + return config.getInt("Experience.Herbalism.Small_Grass", 100); + + default: + return 0; + } + } + else if (type == Material.DOUBLE_PLANT) { + switch (data.getData()) { + case 0x0: + return config.getInt("Experience.Herbalism.Sunflower", 50); + + case 0x1: + return config.getInt("Experience.Herbalism.Lilac", 50); + + case 0x2: + return config.getInt("Experience.Herbalism.Tall_Grass", 50); + + case 0x3: + return config.getInt("Experience.Herbalism.Tall_Fern", 50); + + case 0x4: + return config.getInt("Experience.Herbalism.Rose_Bush", 50); + + case 0x5: + return config.getInt("Experience.Herbalism.Peony", 50); + + default: + return 0; + } + } + + return 0; + } + /* Repair */ public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); } public double getRepairXP(RepairMaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); } @@ -224,10 +316,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); } /* Woodcutting */ - public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); } - public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); } - public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); } - public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); } + public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); } public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); } public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 1df238c01..632859e4e 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -304,6 +304,7 @@ public class FishingManager extends SkillManager { */ public void handleFishing(Item fishingCatch) { this.fishingCatch = fishingCatch; + int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData()); int treasureXp = 0; Player player = getPlayer(); FishingTreasure treasure = null; @@ -351,7 +352,7 @@ public class FishingManager extends SkillManager { } } - applyXpGain(ExperienceConfig.getInstance().getFishingBaseXP() + treasureXp); + applyXpGain(fishXp + treasureXp); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 6d3395cf1..09949bd4d 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -148,7 +148,12 @@ public class HerbalismManager extends SkillManager { processGreenThumbPlants(blockState, greenTerra); } - xp = ExperienceConfig.getInstance().getXp(skill, material); + if (material == Material.DOUBLE_PLANT || material == Material.RED_ROSE || material == Material.LONG_GRASS) { + xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData()); + } + else { + xp = ExperienceConfig.getInstance().getXp(skill, material); + } if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) { drops = blockState.getBlock().getDrops(); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index d442e9322..04e65a9e1 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -39,11 +39,13 @@ public class Mining { switch (blockType) { case ENDER_STONE: case GOLD_ORE: + case HARD_CLAY: case IRON_ORE: case MOSSY_COBBLESTONE: case NETHERRACK: case OBSIDIAN: case SANDSTONE: + case STAINED_CLAY: handleMiningDrops(blockState); return; @@ -55,12 +57,13 @@ public class Mining { case COAL_ORE: case DIAMOND_ORE: - case REDSTONE_ORE: + case EMERALD_ORE: case GLOWSTONE: case LAPIS_ORE: - case STONE: - case EMERALD_ORE: + case PACKED_ICE: case QUARTZ_ORE: + case REDSTONE_ORE: + case STONE: Misc.dropItem(blockState.getLocation(), new ItemStack(blockType)); return; @@ -82,17 +85,20 @@ public class Mining { case COAL_ORE: case DIAMOND_ORE: case EMERALD_ORE: - case GLOWSTONE: - case LAPIS_ORE: - case STONE: case ENDER_STONE: + case GLOWSTONE: case GOLD_ORE: + case HARD_CLAY: case IRON_ORE: + case LAPIS_ORE: case MOSSY_COBBLESTONE: case NETHERRACK: case OBSIDIAN: + case PACKED_ICE: case REDSTONE_ORE: case SANDSTONE: + case STAINED_CLAY: + case STONE: case QUARTZ_ORE: Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); return; diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 057bdf65f..717c39219 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; import org.bukkit.Material; +import org.bukkit.TreeSpecies; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.inventory.ItemStack; @@ -55,28 +56,14 @@ public final class Woodcutting { return mcMMO.getModManager().getBlock(blockState).getXpGain(); } - switch (((Tree) blockState.getData()).getSpecies()) { - case GENERIC: - return ExperienceConfig.getInstance().getWoodcuttingXPOak(); + TreeSpecies species = ((Tree) blockState.getData()).getSpecies(); + int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species); - case REDWOOD: - return ExperienceConfig.getInstance().getWoodcuttingXPSpruce(); - - case BIRCH: - return ExperienceConfig.getInstance().getWoodcuttingXPBirch(); - - case JUNGLE: - int xp = ExperienceConfig.getInstance().getWoodcuttingXPJungle(); - - if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) { - xp *= 0.5; - } - - return xp; - - default: - return 0; + if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) { + xp *= 0.5; } + + return xp; } /** diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index a7c5733ff..a00fd1ba7 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -112,7 +112,9 @@ public final class BlockUtils { switch (blockState.getType()) { case BROWN_MUSHROOM: case CACTUS: + case DOUBLE_PLANT: case MELON_BLOCK: + case LONG_GRASS: case PUMPKIN: case RED_MUSHROOM: case RED_ROSE: @@ -150,10 +152,13 @@ public final class BlockUtils { switch (blockState.getType()) { case ENDER_STONE: case GLOWSTONE: + case HARD_CLAY: case MOSSY_COBBLESTONE: case NETHERRACK: case OBSIDIAN: + case PACKED_ICE: case SANDSTONE: + case STAINED_CLAY: case STONE: return true; @@ -195,6 +200,7 @@ public final class BlockUtils { public static boolean isLog(BlockState blockState) { switch (blockState.getType()) { case LOG: + case LOG_2: case HUGE_MUSHROOM_1: case HUGE_MUSHROOM_2: return true; @@ -213,6 +219,7 @@ public final class BlockUtils { public static boolean isLeaves(BlockState blockState) { switch (blockState.getType()) { case LEAVES: + case LEAVES_2: return true; default: @@ -275,7 +282,7 @@ public final class BlockUtils { * Determine if a given block can be made into Mycelium * * @param blockState The {@link BlockState} of the block to check - * @return true if the block can be made in Mycelium, false otherwise + * @return true if the block can be made into Mycelium, false otherwise */ public static boolean canMakeShroomy(BlockState blockState) { switch (blockState.getType()) { diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 1116018e8..8775e48e5 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -1,12 +1,14 @@ package com.gmail.nossr50.util; import org.bukkit.ChatColor; +import org.bukkit.CoalType; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.Coal; import org.bukkit.material.Dye; import com.gmail.nossr50.mcMMO; @@ -590,6 +592,8 @@ public final class ItemUtils { case PUMPKIN_SEEDS: case WATER_LILY: case VINE: + case LONG_GRASS: + case DOUBLE_PLANT: return true; case INK_SACK: @@ -618,7 +622,6 @@ public final class ItemUtils { case PORK: case GRILLED_PORK: case WOOL: - case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism case IRON_INGOT: case SNOW_BALL: case BLAZE_ROD: @@ -631,12 +634,17 @@ public final class ItemUtils { case ARROW: case SLIME_BALL: case NETHER_STAR: - case COAL: // Not sure we should include this, as it will also trigger when mining case ROTTEN_FLESH: case GOLD_NUGGET: case EGG: return true; + case COAL: // Not sure we should include this, as it will also trigger when mining + return (((Coal) item.getData()).getType() == CoalType.COAL); + + case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism + return (item.getData().getData() == 0x0); + default: return false; } @@ -651,7 +659,9 @@ public final class ItemUtils { public static boolean isWoodcuttingDrop(ItemStack item) { switch (item.getType()) { case LOG: + case LOG_2: case LEAVES: + case LEAVES_2: case SAPLING: case APPLE: return true; diff --git a/src/main/java/com/gmail/nossr50/util/StringUtils.java b/src/main/java/com/gmail/nossr50/util/StringUtils.java index 6deb97f54..8863c0ca8 100644 --- a/src/main/java/com/gmail/nossr50/util/StringUtils.java +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util; import org.bukkit.Material; +import org.bukkit.TreeSpecies; import org.bukkit.entity.EntityType; import com.gmail.nossr50.datatypes.party.PartyFeature; @@ -30,6 +31,10 @@ public class StringUtils { return createPrettyEnumString(ability.toString()); } + public static String getPrettyTreeSpeciesString(TreeSpecies species) { + return createPrettyEnumString(species.toString()); + } + public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) { switch (secondaryAbility) { case HERBALISM_DOUBLE_DROPS: diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index cbd58644e..c120a81c1 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -82,7 +82,10 @@ Experience: Alchemy: Potion: 120 Fishing: - Base: 800 + Raw_Fish: 800 + Raw_Salmon: 800 + Clownfish: 800 + Pufferfish: 800 Shake: 50 Excavation: Clay: 40 @@ -95,27 +98,46 @@ Experience: Snow_Block: 40 Soul_Sand: 40 Woodcutting: - Oak: 70 - Spruce: 80 + Acacia: 90 Birch: 90 + Dark_Oak: 90 + Generic: 70 Jungle: 100 + Redwood: 80 Huge_Mushroom_Red: 70 Huge_Mushroom_Brown: 70 Herbalism: + Allium: 300 + Azure_Bluet: 150 + Blue_Orchid: 150 Brown_Mushroom: 150 Cactus: 30 Carrot: 50 Cocoa: 30 Crops: 50 + Dead_Bush: 100 + Lilac: 50 Melon_Block: 20 Nether_Warts: 50 + Orange_Tulip: 150 + Oxeye_Daisy: 150 + Peony: 50 + Pink_Tulip: 150 + Poppy: 100 Potato: 50 Pumpkin: 20 Red_Mushroom: 150 - Red_Rose: 100 + Red_Tulip: 150 + Rose_Bush: 50 + Small_Fern: 100 + Small_Grass: 100 Sugar_Cane_Block: 30 + Sunflower: 50 + Tall_Grass: 50 + Tall_Fern: 50 Vine: 10 Water_Lily: 100 + White_Tulip: 150 Yellow_Flower: 100 Mining: Coal_Ore: 100 @@ -124,14 +146,17 @@ Experience: Ender_Stone: 150 Glowstone: 30 Gold_Ore: 350 + Hard_Clay: 30 Iron_Ore: 250 Lapis_Ore: 400 Mossy_Cobblestone: 30 Netherrack: 30 Obsidian: 150 + Packed_Ice: 50 Quartz_Ore: 250 Redstone_Ore: 150 Sandstone: 30 + Stained_Clay: 50 Stone: 30 Repair: Base: 1000.0