mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
[WIP] Replacing MaterialData with Blockdata
This commit is contained in:
parent
20c355140e
commit
bd3d437a91
@ -8,7 +8,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.material.LongGrass;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.material.Tree;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -193,31 +193,32 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
|
||||
/* Materials */
|
||||
public int getXp(SkillType skill, MaterialData data)
|
||||
public int getXp(SkillType skill, BlockData data)
|
||||
{
|
||||
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialDataString(data);
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialDataString(data);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialDataString(data);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isSkillBlock(SkillType skill, MaterialData data)
|
||||
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.getExplicitConfigMaterialDataString(data);
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
return true;
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialDataString(data);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return true;
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialDataString(data);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return true;
|
||||
return false;
|
||||
|
@ -7,7 +7,7 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
@ -15,15 +15,15 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
public class CustomBlockConfig extends ConfigLoader {
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
public List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
public List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
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 HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
public HashMap<BlockData, CustomBlock> customBlockMap = new HashMap<BlockData, CustomBlock>();
|
||||
|
||||
protected CustomBlockConfig(String fileName) {
|
||||
super("mods", fileName);
|
||||
@ -44,7 +44,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
||||
private void loadBlocks(String skillType, List<BlockData> blockList) {
|
||||
if (needsUpdate) {
|
||||
return;
|
||||
}
|
||||
@ -73,10 +73,10 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||
BlockData blockBlockData = blockMaterial.createBlockData();
|
||||
|
||||
if (blockList != null) {
|
||||
blockList.add(blockMaterialData);
|
||||
blockList.add(blockBlockData);
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
@ -87,20 +87,20 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
int smeltingXp = 0;
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterialData);
|
||||
customOres.add(blockBlockData);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockMaterialData);
|
||||
customLogs.add(blockBlockData);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockMaterialData);
|
||||
customLeaves.add(blockBlockData);
|
||||
xp = 0; // Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
customBlockMap.put(blockBlockData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.gmail.nossr50.config.mods;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
@ -54,7 +54,7 @@ public class CustomEntityConfig extends ConfigLoader {
|
||||
canBeSummoned = false;
|
||||
}
|
||||
|
||||
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
|
||||
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new ItemStack(callOfTheWildMaterial) : null), callOfTheWildAmount);
|
||||
|
||||
customEntityTypeMap.put(entityTypeName, entity);
|
||||
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
||||
|
@ -15,7 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
@ -53,7 +53,6 @@ public class TreasureConfig extends ConfigLoader {
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
|
||||
double totalEnchantDropRate = 0;
|
||||
double totalItemDropRate = 0;
|
||||
@ -234,33 +233,33 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
} else if (materialName.contains("INK_SAC")) {
|
||||
String color = materialName.substring(9);
|
||||
|
||||
try {
|
||||
Dye dye = new Dye();
|
||||
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
||||
|
||||
item = dye.toItemStack(amount);
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<String>();
|
||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Dye_Color: " + color);
|
||||
}
|
||||
// } else if (materialName.contains("INK_SAC")) {
|
||||
// String color = materialName.substring(9);
|
||||
//
|
||||
// try {
|
||||
// Dye dye = new Dye();
|
||||
// dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
||||
//
|
||||
// item = dye.toItemStack(amount);
|
||||
//
|
||||
// if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
// ItemMeta itemMeta = item.getItemMeta();
|
||||
// itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
// item.setItemMeta(itemMeta);
|
||||
// }
|
||||
//
|
||||
// if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
// ItemMeta itemMeta = item.getItemMeta();
|
||||
// List<String> lore = new ArrayList<String>();
|
||||
// for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
// lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
// }
|
||||
// itemMeta.setLore(lore);
|
||||
// item.setItemMeta(itemMeta);
|
||||
// }
|
||||
// } catch (IllegalArgumentException ex) {
|
||||
// reason.add("Invalid Dye_Color: " + color);
|
||||
// }
|
||||
} else if (material != null) {
|
||||
item = new ItemStack(material, amount, data);
|
||||
|
||||
@ -316,16 +315,40 @@ public class TreasureConfig extends ConfigLoader {
|
||||
continue;
|
||||
}
|
||||
if (dropper.equals("Flowers")) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialDataString(new MaterialData(Material.ROSE_RED, (byte) i)), hylianTreasure);
|
||||
}
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POPPY), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.DANDELION), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.BLUE_ORCHID), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.ALLIUM), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.AZURE_BLUET), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.ORANGE_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.PINK_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.RED_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.WHITE_TULIP), hylianTreasure);
|
||||
continue;
|
||||
}
|
||||
if (dropper.equals("Pots")) {
|
||||
for (int i = 0; i < 14; i++) {
|
||||
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialDataString(new MaterialData(Material.FLOWER_POT, (byte) i)), hylianTreasure);
|
||||
}
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.FLOWER_POT), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_DANDELION), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_POPPY), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_BLUE_ORCHID), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_ALLIUM), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_AZURE_BLUET), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_RED_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_ORANGE_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_WHITE_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_PINK_TULIP), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_OXEYE_DAISY), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_OAK_SAPLING), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_SPRUCE_SAPLING), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_BIRCH_SAPLING), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_JUNGLE_SAPLING), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_OXEYE_DAISY), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_OXEYE_DAISY), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_FERN), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_DEAD_BUSH), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_RED_MUSHROOM), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_BROWN_MUSHROOM), hylianTreasure);
|
||||
AddHylianTreasure(StringUtils.getPrettyItemString(Material.POTTED_CACTUS), hylianTreasure);
|
||||
continue;
|
||||
}
|
||||
AddHylianTreasure(dropper, hylianTreasure);
|
||||
|
@ -191,10 +191,12 @@ 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);
|
||||
}
|
||||
|
||||
@ -203,6 +205,7 @@ public class BlockListener implements Listener {
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (SkillType.HERBALISM.getPermissions(player)) {
|
||||
System.out.println(">>Pee pee");
|
||||
herbalismManager.herbalismBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,16 @@ public class Excavation {
|
||||
* @return the list of treasures that could be found
|
||||
*/
|
||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||
String friendly = StringUtils.getFriendlyConfigMaterialDataString(blockState.getData());
|
||||
System.out.print(">>4");
|
||||
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
||||
if (TreasureConfig.getInstance().excavationMap.containsKey(friendly))
|
||||
return TreasureConfig.getInstance().excavationMap.get(friendly);
|
||||
return new ArrayList<ExcavationTreasure>();
|
||||
}
|
||||
|
||||
protected static int getBlockXP(BlockState blockState) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getData());
|
||||
System.out.print(">>5");
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getBlockData());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
|
@ -279,7 +279,7 @@ public class FishingManager extends SkillManager {
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
this.fishingCatch = fishingCatch;
|
||||
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getData());
|
||||
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getType().createBlockData());
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
@ -142,7 +142,7 @@ public class HerbalismManager extends SkillManager {
|
||||
if(material == Material.CHORUS_FLOWER && blockState.getRawData() != 5) {
|
||||
return;
|
||||
}
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getData());
|
||||
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getBlockData());
|
||||
|
||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
||||
drops = blockState.getBlock().getDrops();
|
||||
@ -199,7 +199,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
String friendly = StringUtils.getFriendlyConfigMaterialDataString(blockState.getData());
|
||||
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
||||
if (!TreasureConfig.getInstance().hylianMap.containsKey(friendly))
|
||||
return false;
|
||||
List<HylianTreasure> treasures = TreasureConfig.getInstance().hylianMap.get(friendly);
|
||||
@ -324,7 +324,7 @@ public class HerbalismManager extends SkillManager {
|
||||
case CARROT:
|
||||
case BEETROOTS:
|
||||
case WHEAT:
|
||||
Crops crops = (Crops) blockState.getData();
|
||||
Crops crops = (Crops) blockState.getBlockData();
|
||||
|
||||
if (greenTerra) {
|
||||
crops.setState(CropState.MEDIUM);
|
||||
@ -349,7 +349,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return true;
|
||||
|
||||
case NETHER_WART_BLOCK:
|
||||
NetherWarts warts = (NetherWarts) blockState.getData();
|
||||
NetherWarts warts = (NetherWarts) blockState.getBlockData();
|
||||
|
||||
if (greenTerra || greenThumbStage > 2) {
|
||||
warts.setState(NetherWartsState.STAGE_TWO);
|
||||
@ -364,7 +364,7 @@ public class HerbalismManager extends SkillManager {
|
||||
return true;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getBlockData();
|
||||
|
||||
if (greenTerra || getGreenThumbStage() > 1) {
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Mining {
|
||||
|
||||
@ -15,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.getData());
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getBlockData());
|
||||
|
||||
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
@ -86,12 +87,12 @@ public class Mining {
|
||||
case REDSTONE_ORE:
|
||||
case STONE:
|
||||
case PRISMARINE:
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), blockState.getData().toItemStack(1));
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
|
||||
return;
|
||||
|
||||
default:
|
||||
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), blockState.getData().toItemStack(1));
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -146,7 +147,7 @@ public class MiningManager extends SkillManager {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
}
|
||||
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), blockState.getData().toItemStack(1)); // Initial block that would have been dropped
|
||||
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||
for (int i = 1; i < dropMultiplier; i++) {
|
||||
|
@ -22,7 +22,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -89,7 +89,7 @@ public class RepairManager extends SkillManager {
|
||||
|
||||
Material repairMaterial = repairable.getRepairMaterial();
|
||||
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
|
||||
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
|
||||
ItemStack toRemove = new ItemStack(repairMaterial);
|
||||
|
||||
short startDurability = item.getDurability();
|
||||
|
||||
|
@ -20,7 +20,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -108,9 +108,7 @@ public class SalvageManager extends SkillManager {
|
||||
enchantBook = arcaneSalvageCheck(enchants);
|
||||
}
|
||||
|
||||
byte salvageMaterialMetadata = (salvageable.getSalvageMaterialMetadata() != (byte) -1) ? salvageable.getSalvageMaterialMetadata() : 0;
|
||||
|
||||
ItemStack salvageResults = new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount);
|
||||
ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), salvageableAmount);
|
||||
|
||||
//Call event
|
||||
if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
@ -47,7 +47,7 @@ public class Smelting {
|
||||
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
|
||||
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
MaterialData data = smelting.getData();
|
||||
BlockData data = smelting.getType().createBlockData();
|
||||
|
||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, data);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class UnarmedManager extends SkillManager {
|
||||
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
|
||||
@ -59,7 +59,7 @@ public class UnarmedManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialData data = blockState.getData();
|
||||
BlockData data = blockState.getBlockData();
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case STONE_BRICKS:
|
||||
|
@ -44,7 +44,7 @@ public final class Woodcutting {
|
||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getData());
|
||||
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getBlockData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,7 +134,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.getData());
|
||||
return MaterialUtils.isOre(blockState.getBlockData());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,8 +170,11 @@ 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.getData()))
|
||||
System.out.print(">>Fuckin hell dude");
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getBlockData())) {
|
||||
System.out.print(">>Does it work?");
|
||||
return true;
|
||||
}
|
||||
|
||||
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
||||
}
|
||||
@ -185,7 +188,7 @@ public final class BlockUtils {
|
||||
* otherwise
|
||||
*/
|
||||
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.MINING, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.MINING, blockState.getBlockData()))
|
||||
return true;
|
||||
|
||||
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
|
||||
@ -200,7 +203,7 @@ public final class BlockUtils {
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.EXCAVATION, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.EXCAVATION, blockState.getBlockData()))
|
||||
return true;
|
||||
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
||||
}
|
||||
@ -213,7 +216,7 @@ public final class BlockUtils {
|
||||
* @return true if the block is a log, false otherwise
|
||||
*/
|
||||
public static boolean isLog(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.WOODCUTTING, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.WOODCUTTING, blockState.getBlockData()))
|
||||
return true;
|
||||
return mcMMO.getModManager().isCustomLog(blockState);
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isSmeltable(ItemStack item) {
|
||||
return item != null && MaterialUtils.isOre(item.getData());
|
||||
return item != null && MaterialUtils.isOre(item.getType().createBlockData());
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack item) {
|
||||
@ -520,7 +520,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) {
|
||||
if (recipe instanceof FurnaceRecipe && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getData())) {
|
||||
if (recipe instanceof FurnaceRecipe && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType().createBlockData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public final class MaterialUtils {
|
||||
private MaterialUtils() {}
|
||||
|
||||
protected static boolean isOre(MaterialData data) {
|
||||
switch (data.getItemType()) {
|
||||
protected static boolean isOre(BlockData data) {
|
||||
switch (data.getMaterial()) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case NETHER_QUARTZ_ORE:
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -33,14 +33,14 @@ public class ModManager {
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
// Block Mods
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
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>();
|
||||
|
||||
// Entity Mods
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
@ -130,7 +130,7 @@ public class ModManager {
|
||||
return Config.getInstance().getToolModsEnabled() && customSwords.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomOre(MaterialData data) {
|
||||
public boolean isCustomOre(BlockData data) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customOres.contains(data);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public class ModManager {
|
||||
return customBlockMap.get(state.getData());
|
||||
}
|
||||
|
||||
public CustomBlock getBlock(MaterialData data) {
|
||||
public CustomBlock getBlock(BlockData data) {
|
||||
return customBlockMap.get(data);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
@ -37,16 +37,16 @@ public class StringUtils {
|
||||
return createPrettyEnumString(species.toString());
|
||||
}
|
||||
|
||||
public static String getWildcardConfigMaterialDataString(MaterialData data) {
|
||||
return StringUtils.getPrettyItemString(data.getItemType()).replace(" ", "_") + "|*";
|
||||
public static String getWildcardConfigBlockDataString(BlockData data) {
|
||||
return StringUtils.getPrettyItemString(data.getMaterial()).replace(" ", "_") + "|*";
|
||||
}
|
||||
|
||||
public static String getFriendlyConfigMaterialDataString(MaterialData data) {
|
||||
return getPrettyItemString(data.getItemType()).replace(" ", "_");
|
||||
public static String getFriendlyConfigBlockDataString(BlockData data) {
|
||||
return getPrettyItemString(data.getMaterial()).replace(" ", "_");
|
||||
}
|
||||
|
||||
public static String getExplicitConfigMaterialDataString(MaterialData data) {
|
||||
return StringUtils.getPrettyItemString(data.getItemType()).replace(" ", "_") + "|" + data.getData();
|
||||
public static String getExplicitConfigBlockDataString(BlockData data) {
|
||||
return StringUtils.getPrettyItemString(data.getMaterial()).replace(" ", "_");
|
||||
}
|
||||
|
||||
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
|
||||
|
@ -25,7 +25,7 @@ import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@ -278,7 +278,7 @@ public class SkillUtils {
|
||||
item.setDurability((short) 0);
|
||||
|
||||
int quantity = 0;
|
||||
MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null;
|
||||
BlockData repairData = repairMaterial != null ? repairMaterial.createBlockData() : null;
|
||||
List<Recipe> recipes = mcMMO.p.getServer().getRecipesFor(item);
|
||||
|
||||
if (recipes.isEmpty()) {
|
||||
@ -289,14 +289,14 @@ public class SkillUtils {
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ Skills:
|
||||
Summon_Length: 240
|
||||
Summon_Max_Amount: 10
|
||||
Ocelot:
|
||||
Item_Material: RAW_FISH
|
||||
Item_Material: COD
|
||||
Item_Amount: 10
|
||||
Summon_Amount: 1
|
||||
Summon_Length: 240
|
||||
|
@ -46,19 +46,19 @@ Repairables:
|
||||
# Wooden repairables
|
||||
###
|
||||
# Tools
|
||||
WOOD_SWORD:
|
||||
WOODEN_SWORD:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .25
|
||||
WOOD_SHOVEL:
|
||||
WOODEN_SHOVEL:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .16
|
||||
WOOD_PICKAXE:
|
||||
WOODEN_PICKAXE:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .5
|
||||
WOOD_AXE:
|
||||
WOODEN_AXE:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .5
|
||||
WOOD_HOE:
|
||||
WOODEN_HOE:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .25
|
||||
#
|
||||
|
@ -46,19 +46,19 @@ Salvageables:
|
||||
# Wooden salvageables
|
||||
###
|
||||
# Tools
|
||||
WOOD_SWORD:
|
||||
WOODEN_SWORD:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .25
|
||||
WOOD_SHOVEL:
|
||||
WOODEN_SHOVEL:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .16
|
||||
WOOD_PICKAXE:
|
||||
WOODEN_PICKAXE:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .5
|
||||
WOOD_AXE:
|
||||
WOODEN_AXE:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .5
|
||||
WOOD_HOE:
|
||||
WOODEN_HOE:
|
||||
MinimumLevel: 0
|
||||
XpMultiplier: .25
|
||||
#
|
||||
|
@ -39,7 +39,6 @@ Fishing:
|
||||
Amount: 1
|
||||
XP: 200
|
||||
Rarity: COMMON
|
||||
//!!
|
||||
LAPIS_LAZULI:
|
||||
Amount: 20
|
||||
XP: 200
|
||||
@ -773,7 +772,7 @@ Shake:
|
||||
XP: 0
|
||||
Drop_Chance: 30.0
|
||||
Drop_Level: 0
|
||||
RAW_BEEF:
|
||||
BEEF:
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 30.0
|
||||
@ -867,7 +866,7 @@ Shake:
|
||||
XP: 0
|
||||
Drop_Chance: 3.0
|
||||
Drop_Level: 0
|
||||
SNOW_BALL:
|
||||
SNOWBALL:
|
||||
Amount: 2
|
||||
XP: 0
|
||||
Drop_Chance: 97.0
|
||||
|
@ -379,7 +379,7 @@ public class PotionConfigGenerator {
|
||||
children.put(new Ingredient(Material.RABBIT_FOOT), new WriteablePotion(current.mat, PotionType.JUMP));
|
||||
children.put(new Ingredient(Material.MAGMA_CREAM), new WriteablePotion(current.mat, PotionType.FIRE_RESISTANCE));
|
||||
children.put(new Ingredient(Material.SUGAR), new WriteablePotion(current.mat, PotionType.SPEED));
|
||||
children.put(new Ingredient(Material.RAW_FISH, 3), new WriteablePotion(current.mat, PotionType.WATER_BREATHING));
|
||||
children.put(new Ingredient(Material.COD, 3), new WriteablePotion(current.mat, PotionType.WATER_BREATHING));
|
||||
children.put(new Ingredient(Material.SPECKLED_MELON), new WriteablePotion(current.mat, PotionType.INSTANT_HEAL));
|
||||
children.put(new Ingredient(Material.SPIDER_EYE), new WriteablePotion(current.mat, PotionType.POISON));
|
||||
children.put(new Ingredient(Material.GHAST_TEAR), new WriteablePotion(current.mat, PotionType.REGEN));
|
||||
|
Loading…
Reference in New Issue
Block a user