mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 03:04:44 +02:00
Update configurations and skill block checks to be more configurable.
This commit is contained in:
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.excavation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -11,6 +10,7 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class Excavation {
|
||||
/**
|
||||
@ -20,47 +20,14 @@ public class Excavation {
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case DIRT:
|
||||
return blockState.getRawData() == 0x2 ? TreasureConfig.getInstance().excavationFromPodzol : TreasureConfig.getInstance().excavationFromDirt;
|
||||
|
||||
case GRASS:
|
||||
case GRASS_PATH:
|
||||
return TreasureConfig.getInstance().excavationFromGrass;
|
||||
|
||||
case SAND:
|
||||
return blockState.getRawData() == 0x1 ? TreasureConfig.getInstance().excavationFromRedSand : TreasureConfig.getInstance().excavationFromSand;
|
||||
|
||||
case GRAVEL:
|
||||
return TreasureConfig.getInstance().excavationFromGravel;
|
||||
|
||||
case CLAY:
|
||||
return TreasureConfig.getInstance().excavationFromClay;
|
||||
|
||||
case MYCEL:
|
||||
return TreasureConfig.getInstance().excavationFromMycel;
|
||||
|
||||
case SOUL_SAND:
|
||||
return TreasureConfig.getInstance().excavationFromSoulSand;
|
||||
|
||||
case SNOW:
|
||||
return TreasureConfig.getInstance().excavationFromSnow;
|
||||
|
||||
default:
|
||||
return new ArrayList<ExcavationTreasure>();
|
||||
}
|
||||
String friendly = StringUtils.getFriendlyConfigMaterialDataString(blockState.getData());
|
||||
if (TreasureConfig.getInstance().excavationMap.containsKey(friendly))
|
||||
return TreasureConfig.getInstance().excavationMap.get(friendly);
|
||||
return new ArrayList<ExcavationTreasure>();
|
||||
}
|
||||
|
||||
protected static int getBlockXP(BlockState blockState) {
|
||||
Material material = blockState.getType();
|
||||
int xp;
|
||||
|
||||
if (material == Material.DIRT || material == Material.SAND) {
|
||||
xp = ExperienceConfig.getInstance().getDirtAndSandXp(blockState.getData());
|
||||
}
|
||||
else {
|
||||
xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, material);
|
||||
}
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getData());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
|
@ -300,7 +300,7 @@ public class FishingManager extends SkillManager {
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
this.fishingCatch = fishingCatch;
|
||||
int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
|
||||
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getData());
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
@ -151,16 +151,10 @@ public class HerbalismManager extends SkillManager {
|
||||
processGreenThumbPlants(blockState, greenTerra);
|
||||
}
|
||||
|
||||
if (material == Material.DOUBLE_PLANT || material == Material.RED_ROSE || material == Material.LONG_GRASS) {
|
||||
xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData());
|
||||
}
|
||||
else {
|
||||
if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, material);
|
||||
if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) {
|
||||
return;
|
||||
}
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getData());
|
||||
|
||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
||||
drops = blockState.getBlock().getDrops();
|
||||
|
@ -18,8 +18,7 @@ public class Mining {
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public static int getBlockXp(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getData());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
|
@ -48,8 +48,7 @@ public class Smelting {
|
||||
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
MaterialData data = smelting.getData();
|
||||
Material resourceType = smelting.getType();
|
||||
|
||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
|
||||
|
||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, data);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -40,29 +41,11 @@ public final class Woodcutting {
|
||||
* @return Amount of experience
|
||||
*/
|
||||
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
||||
// Mushrooms aren't trees so we could never get species data from them
|
||||
switch (blockState.getType()) {
|
||||
case HUGE_MUSHROOM_1:
|
||||
return ExperienceConfig.getInstance().getWoodcuttingXPHugeBrownMushroom();
|
||||
|
||||
case HUGE_MUSHROOM_2:
|
||||
return ExperienceConfig.getInstance().getWoodcuttingXPHugeRedMushroom();
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
//TODO Remove this workaround when casting to Tree works again
|
||||
TreeSpecies species = TreeSpecies.GENERIC;
|
||||
if (blockState.getData() instanceof Tree) {
|
||||
species = ((Tree) blockState.getData()).getSpecies();
|
||||
}
|
||||
|
||||
return ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user