mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Fixed most block based experience gain
This commit is contained in:
parent
bd3d437a91
commit
32db56abe5
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ public class Excavation {
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
protected static List<ExcavationTreasure> 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)) {
|
||||
|
@ -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<ItemStack> 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();
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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(" ", "_");
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user