From 32db56abe5d82959166e8fbf102f70ed906a5325 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 26 Jul 2018 14:52:29 -0500 Subject: [PATCH] Fixed most block based experience gain --- .../config/experience/ExperienceConfig.java | 2 +- .../nossr50/listeners/BlockListener.java | 5 +-- .../nossr50/skills/excavation/Excavation.java | 2 -- .../skills/herbalism/HerbalismManager.java | 15 ++++++-- .../woodcutting/WoodcuttingManager.java | 1 + .../com/gmail/nossr50/util/BlockUtils.java | 2 -- .../com/gmail/nossr50/util/StringUtils.java | 15 ++++++++ src/main/resources/experience.yml | 36 +++++++++++-------- 8 files changed, 52 insertions(+), 26 deletions(-) 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 9906de585..6e75db8dc 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -195,6 +195,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { /* Materials */ public int getXp(SkillType skill, BlockData data) { + System.out.print(">>YUP>"+skill.toString()); String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data); if (config.contains(explicitString)) @@ -210,7 +211,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public boolean isSkillBlock(SkillType skill, BlockData data) { - System.out.print(">>\n\n"+config.toString()+"\n\n<<"); String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data); if (config.contains(explicitString)) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 7481d4d72..d7e03ee48 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -191,12 +191,10 @@ public class BlockListener implements Listener { /* HERBALISM */ if (BlockUtils.affectedByGreenTerra(blockState)) { - System.out.println(">>This Shit"); HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager(); /* Green Terra */ if (herbalismManager.canActivateAbility()) { - System.out.println(">>Sucks big ol"); mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM); } @@ -205,7 +203,7 @@ public class BlockListener implements Listener { * Instead, we check it inside the drops handler. */ if (SkillType.HERBALISM.getPermissions(player)) { - System.out.println(">>Pee pee"); + System.out.print(">>getPermissions"); herbalismManager.herbalismBlockCheck(blockState); } } @@ -219,7 +217,6 @@ public class BlockListener implements Listener { /* WOOD CUTTING */ else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); - if (woodcuttingManager.canUseTreeFeller(heldItem)) { woodcuttingManager.processTreeFeller(blockState); } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 5771866b8..daba54a66 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -20,7 +20,6 @@ public class Excavation { * @return the list of treasures that could be found */ protected static List getTreasures(BlockState blockState) { - System.out.print(">>4"); String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); if (TreasureConfig.getInstance().excavationMap.containsKey(friendly)) return TreasureConfig.getInstance().excavationMap.get(friendly); @@ -28,7 +27,6 @@ public class Excavation { } protected static int getBlockXP(BlockState blockState) { - System.out.print(">>5"); int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getBlockData()); if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) { 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 3ab74c2f2..cbd75636d 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -112,18 +112,22 @@ public class HerbalismManager extends SkillManager { * @param blockState The {@link BlockState} to check ability activation for */ public void herbalismBlockCheck(BlockState blockState) { + System.out.print(">>1"); Player player = getPlayer(); Material material = blockState.getType(); boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT || material == Material.SUGAR_CANE); // Prevents placing and immediately breaking blocks for exp if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) { + System.out.print(">>1.5"); return; } + System.out.print(">>2"); if (!canBlockCheck()) { return; } + System.out.print(">>3"); Collection drops = null; int amount = 1; @@ -131,6 +135,7 @@ public class HerbalismManager extends SkillManager { boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility()); if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) { + System.out.print(">>4"); CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState); xp = customBlock.getXpGain(); @@ -139,6 +144,7 @@ public class HerbalismManager extends SkillManager { } } else { + System.out.print(">>5"); if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) { return; } @@ -146,21 +152,26 @@ public class HerbalismManager extends SkillManager { if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) { drops = blockState.getBlock().getDrops(); + System.out.print(">>6"); } if (!oneBlockPlant) { + System.out.print(">>7"); amount = Herbalism.calculateMultiBlockPlantDrops(blockState); xp *= amount; } if (Permissions.greenThumbPlant(player, material)) { + System.out.print(">>8"); processGreenThumbPlants(blockState, greenTerra); } } + System.out.print(">>9"); applyXpGain(xp, XPGainReason.PVE); if (drops == null) { + System.out.print(">>10"); return; } @@ -320,8 +331,8 @@ public class HerbalismManager extends SkillManager { switch (blockState.getType()) { - case POTATO: - case CARROT: + case POTATOES: + case CARROTS: case BEETROOTS: case WHEAT: Crops crops = (Crops) blockState.getBlockData(); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index 98a841948..6e6bb8a7d 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -45,6 +45,7 @@ public class WoodcuttingManager extends SkillManager { * @param blockState Block being broken */ public void woodcuttingBlockCheck(BlockState blockState) { + System.out.print(">>HEYO"); int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT); switch (blockState.getType()) { diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index e8002f61f..3e8aa5405 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -170,9 +170,7 @@ public final class BlockUtils { * @return true if the block should affected by Green Terra, false otherwise */ public static boolean affectedByGreenTerra(BlockState blockState) { - System.out.print(">>Fuckin hell dude"); if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getBlockData())) { - System.out.print(">>Does it work?"); 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 a1a9b4715..a4ef5d922 100644 --- a/src/main/java/com/gmail/nossr50/util/StringUtils.java +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SecondaryAbility; import org.bukkit.Material; import org.bukkit.TreeSpecies; +import org.bukkit.block.data.Ageable; import org.bukkit.entity.EntityType; import org.bukkit.block.data.BlockData; @@ -42,6 +43,20 @@ public class StringUtils { } public static String getFriendlyConfigBlockDataString(BlockData data) { + Ageable isCrop = (Ageable) data; + switch(data.getMaterial()){ + case COCOA: + case WHEAT: + case BEETROOTS: + case CARROTS: + case POTATOES: + case NETHER_WART_BLOCK: { + if (isCrop.getAge() == isCrop.getMaximumAge()) { + return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ripe"; + } + return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ungrown"; + } + } return getPrettyItemString(data.getMaterial()).replace(" ", "_"); } diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 5f04a656e..324675004 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -140,48 +140,54 @@ Experience: Snow_Block: 40 Soul_Sand: 40 Woodcutting: - Acacia: 90 - Birch: 90 - Dark_Oak: 90 - Generic: 70 - Jungle: 100 - Redwood: 80 + Oak_Log: 70 + Spruce_Log: 80 + Birch_Log: 90 + Jungle_Log: 100 + Acacia_Log: 90 + Dark_Oak_Log: 90 + Stripped_Oak_Log: 70 + Stripped_Spruce_Log: 80 + Stripped_Birch_Log: 90 + Stripped_Jungle_Log: 100 + Stripped_Acacia_Log: 90 + Stripped_Dark_Oak_Log: 90 Huge_Mushroom_1: 70 Huge_Mushroom_2: 70 Herbalism: Allium: 300 Azure_Bluet: 150 - Beetroot_Block_Ripe: 50 + Beetroots_Ripe: 50 Blue_Orchid: 150 Brown_Mushroom: 150 Cactus: 30 - Carrot_Ripe: 50 + Carrots_Ripe: 50 Chorus_Flower: 25 Chorus_Plant: 1 Cocoa_Ripe: 30 - Crops_Ripe: 50 + Wheat_Ripe: 50 Dead_Bush: 30 Lilac: 50 Melon_Block: 20 - Nether_Warts_Ripe: 50 + Nether_Wart_Ripe: 50 Orange_Tulip: 150 Oxeye_Daisy: 150 Peony: 50 Pink_Tulip: 150 Poppy: 100 - Potato_Ripe: 50 + Potatoes_Ripe: 50 Pumpkin: 20 Red_Mushroom: 150 Red_Tulip: 150 Rose_Bush: 50 - Small_Fern: 10 - Small_Grass: 10 + Fern: 10 + Grass: 10 Sugar_Cane_Block: 30 Sunflower: 50 Tall_Grass: 50 - Tall_Fern: 50 + Large_Fern: 50 Vine: 10 - Water_Lily: 100 + Lily_Pad: 100 White_Tulip: 150 Dandelion: 100 Mining: