mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-25 18:17:46 +01:00
Some of these should not have been blockdata, also this should check age of crops.
This commit is contained in:
parent
2a43bce849
commit
5663b71387
@ -1,18 +1,17 @@
|
||||
package com.gmail.nossr50.config.experience;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
private static ExperienceConfig instance;
|
||||
@ -218,7 +217,20 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSkillBlock(SkillType skill, Material data)
|
||||
{
|
||||
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
return true;
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return true;
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||
return config.contains(wildcardString);
|
||||
}
|
||||
|
||||
public boolean isSkillBlock(SkillType skill, BlockData data)
|
||||
{
|
||||
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
@ -229,9 +241,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
if (config.contains(friendlyString))
|
||||
return true;
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return true;
|
||||
return false;
|
||||
return config.contains(wildcardString);
|
||||
}
|
||||
|
||||
/* Acrobatics */
|
||||
|
@ -1,29 +1,27 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<BlockData> customExcavationBlocks = new ArrayList<BlockData>();
|
||||
public List<BlockData> customHerbalismBlocks = new ArrayList<BlockData>();
|
||||
public List<BlockData> customMiningBlocks = new ArrayList<BlockData>();
|
||||
public List<BlockData> customOres = new ArrayList<BlockData>();
|
||||
public List<BlockData> customLogs = new ArrayList<BlockData>();
|
||||
public List<BlockData> customLeaves = new ArrayList<BlockData>();
|
||||
public List<BlockData> customAbilityBlocks = new ArrayList<BlockData>();
|
||||
public List<Material> customExcavationBlocks = new ArrayList<>();
|
||||
public List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||
public List<Material> customMiningBlocks = new ArrayList<>();
|
||||
public List<Material> customOres = new ArrayList<>();
|
||||
public List<Material> customLogs = new ArrayList<>();
|
||||
public List<Material> customLeaves = new ArrayList<>();
|
||||
public List<Material> customAbilityBlocks = new ArrayList<>();
|
||||
|
||||
public HashMap<BlockData, CustomBlock> customBlockMap = new HashMap<BlockData, CustomBlock>();
|
||||
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
|
||||
protected CustomBlockConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
@ -44,7 +42,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<BlockData> blockList) {
|
||||
private void loadBlocks(String skillType, List<Material> blockList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
@ -72,11 +70,8 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
continue;
|
||||
}
|
||||
|
||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
||||
BlockData blockBlockData = blockMaterial.createBlockData();
|
||||
|
||||
if (blockList != null) {
|
||||
blockList.add(blockBlockData);
|
||||
blockList.add(blockMaterial);
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
@ -87,20 +82,20 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
int smeltingXp = 0;
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockBlockData);
|
||||
customOres.add(blockMaterial);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockBlockData);
|
||||
customLogs.add(blockMaterial);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockBlockData);
|
||||
customLeaves.add(blockMaterial);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
customBlockMap.put(blockBlockData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
customBlockMap.put(blockMaterial, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.gmail.nossr50.skills.excavation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Excavation {
|
||||
/**
|
||||
@ -27,7 +26,7 @@ public class Excavation {
|
||||
}
|
||||
|
||||
protected static int getBlockXP(BlockState blockState) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getBlockData());
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
|
@ -13,15 +13,13 @@ import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
import org.bukkit.material.NetherWarts;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -136,10 +134,10 @@ public class HerbalismManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) {
|
||||
if (!BlockUtils.isHarvestable(blockState))
|
||||
return;
|
||||
}
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getBlockData());
|
||||
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getType());
|
||||
|
||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
||||
drops = blockState.getBlock().getDrops();
|
||||
|
@ -16,7 +16,7 @@ public class Mining {
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public static int getBlockXp(BlockState blockState) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getBlockData());
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getType());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Smelting {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
@ -23,7 +20,7 @@ public class Smelting {
|
||||
|
||||
int numerical;
|
||||
|
||||
private Tier(int numerical) {
|
||||
Tier(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
@ -47,8 +44,6 @@ public class Smelting {
|
||||
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
|
||||
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
BlockData data = smelting.getType().createBlockData();
|
||||
|
||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, data);
|
||||
return mcMMO.getModManager().isCustomOre(smelting.getType()) ? mcMMO.getModManager().getBlock(smelting.getType()).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, smelting.getType());
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public final class Woodcutting {
|
||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getBlockData());
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,8 @@ import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -134,7 +136,7 @@ public final class BlockUtils {
|
||||
* @return true if the block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(BlockState blockState) {
|
||||
return MaterialUtils.isOre(blockState.getBlockData());
|
||||
return MaterialUtils.isOre(blockState.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,7 +172,7 @@ public final class BlockUtils {
|
||||
* @return true if the block should affected by Green Terra, false otherwise
|
||||
*/
|
||||
public static boolean affectedByGreenTerra(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getBlockData())) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getType())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -352,4 +354,16 @@ public final class BlockUtils {
|
||||
|
||||
return transparentBlocks;
|
||||
}
|
||||
|
||||
public static boolean isHarvestable(BlockState blockState) {
|
||||
BlockData data = blockState.getBlockData();
|
||||
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE)
|
||||
return true;
|
||||
if (data instanceof Ageable)
|
||||
{
|
||||
Ageable ageable = (Ageable) data;
|
||||
return ageable.getAge() == ageable.getMaximumAge();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public final class MaterialUtils {
|
||||
private MaterialUtils() {}
|
||||
|
||||
protected static boolean isOre(BlockData data) {
|
||||
switch (data.getMaterial()) {
|
||||
protected static boolean isOre(Material data) {
|
||||
switch (data) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case NETHER_QUARTZ_ORE:
|
||||
|
@ -1,18 +1,5 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
||||
@ -21,7 +8,18 @@ import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ModManager {
|
||||
private List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
@ -33,14 +31,14 @@ public class ModManager {
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
// Block Mods
|
||||
private List<BlockData> customExcavationBlocks = new ArrayList<BlockData>();
|
||||
private List<BlockData> customHerbalismBlocks = new ArrayList<BlockData>();
|
||||
private List<BlockData> customMiningBlocks = new ArrayList<BlockData>();
|
||||
private List<BlockData> customOres = new ArrayList<BlockData>();
|
||||
private List<BlockData> customLogs = new ArrayList<BlockData>();
|
||||
private List<BlockData> customLeaves = new ArrayList<BlockData>();
|
||||
private List<BlockData> customAbilityBlocks = new ArrayList<BlockData>();
|
||||
private HashMap<BlockData, CustomBlock> customBlockMap = new HashMap<BlockData, CustomBlock>();
|
||||
private List<Material> customExcavationBlocks = new ArrayList<Material>();
|
||||
private List<Material> customHerbalismBlocks = new ArrayList<Material>();
|
||||
private List<Material> customMiningBlocks = new ArrayList<Material>();
|
||||
private List<Material> customOres = new ArrayList<Material>();
|
||||
private List<Material> customLogs = new ArrayList<Material>();
|
||||
private List<Material> customLeaves = new ArrayList<Material>();
|
||||
private List<Material> customAbilityBlocks = new ArrayList<Material>();
|
||||
private HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
|
||||
// Entity Mods
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
@ -130,39 +128,39 @@ public class ModManager {
|
||||
return Config.getInstance().getToolModsEnabled() && customSwords.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomOre(BlockData data) {
|
||||
public boolean isCustomOre(Material data) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customOres.contains(data);
|
||||
}
|
||||
|
||||
public boolean isCustomLog(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customLogs.contains(state.getData());
|
||||
return Config.getInstance().getBlockModsEnabled() && customLogs.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomLeaf(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customLeaves.contains(state.getData());
|
||||
return Config.getInstance().getBlockModsEnabled() && customLeaves.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomAbilityBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getData());
|
||||
return Config.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomExcavationBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getData());
|
||||
return Config.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomHerbalismBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getData());
|
||||
return Config.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public boolean isCustomMiningBlock(BlockState state) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getData());
|
||||
return Config.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getType());
|
||||
}
|
||||
|
||||
public CustomBlock getBlock(BlockState state) {
|
||||
return customBlockMap.get(state.getData());
|
||||
return customBlockMap.get(state.getType());
|
||||
}
|
||||
|
||||
public CustomBlock getBlock(BlockData data) {
|
||||
public CustomBlock getBlock(Material data) {
|
||||
return customBlockMap.get(data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user