mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Smelting now works with custom ores.
Also fixed exploit where smelting XP could be awarded for some non-smeltable materials.
This commit is contained in:
parent
1785bab504
commit
de3c4f8fd7
@ -10,9 +10,11 @@ Key:
|
||||
Version 1.4.08-dev
|
||||
+ Added the possibility to gain experience when using Fishing "Shake"
|
||||
+ Added config options to disable various sound effects
|
||||
+ Smelting now works with custom ores - add smelting XP value to blocks.yml, or it will default to 1/10th of normal XP.
|
||||
= Fixed bug with toggle commands not properly displaying the success message.
|
||||
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
|
||||
= Fixed bug with Salvage not reading the config value for the anvil material.
|
||||
= Fixed exploit where you could receive smelting XP for improper items
|
||||
|
||||
Version 1.4.07
|
||||
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
|
||||
|
@ -92,9 +92,11 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
|
||||
int smeltingXp = 0;
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockMaterialData);
|
||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
@ -106,7 +108,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
|
||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,12 @@ package com.gmail.nossr50.datatypes.mods;
|
||||
public class CustomBlock {
|
||||
private int xpGain;
|
||||
private boolean canDoubleDrop;
|
||||
private int smeltingXpGain;
|
||||
|
||||
public CustomBlock(int xpGain, boolean canDoubleDrop) {
|
||||
public CustomBlock(int xpGain, boolean canDoubleDrop, int smeltingXpGain) {
|
||||
this.xpGain = xpGain;
|
||||
this.canDoubleDrop = canDoubleDrop;
|
||||
this.smeltingXpGain = smeltingXpGain;
|
||||
}
|
||||
|
||||
public int getXpGain() {
|
||||
@ -16,4 +18,8 @@ public class CustomBlock {
|
||||
public boolean isDoubleDropEnabled() {
|
||||
return canDoubleDrop;
|
||||
}
|
||||
|
||||
public int getSmeltingXpGain() {
|
||||
return smeltingXpGain;
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class InventoryListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
ItemStack smelting = Misc.getSmeltingFromFurnace(furnaceBlock);
|
||||
ItemStack smelting = event.getSource();
|
||||
|
||||
if (!ItemUtils.isSmeltable(smelting)) {
|
||||
return;
|
||||
@ -95,7 +95,7 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting.getType(), event.getResult()));
|
||||
event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
@ -22,16 +22,11 @@ public class Mining {
|
||||
*/
|
||||
protected static int getBlockXp(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType);
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
|
||||
|
||||
if (xp == 0) {
|
||||
if (blockType == Material.GLOWING_REDSTONE_ORE) {
|
||||
xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
|
||||
}
|
||||
else if (ModUtils.isCustomMiningBlock(blockState)) {
|
||||
if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) {
|
||||
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
|
||||
public class Smelting {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
@ -46,11 +48,13 @@ public class Smelting {
|
||||
public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel();
|
||||
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
|
||||
|
||||
protected static int getResourceXp(Material resourceType) {
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType);
|
||||
protected static int getResourceXp(ItemStack smelting) {
|
||||
Material resourceType = smelting.getType();
|
||||
|
||||
if (resourceType == Material.GLOWING_REDSTONE_ORE) {
|
||||
xp = ExperienceConfig.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE);
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
|
||||
|
||||
if (xp == 0 && ModUtils.isCustomOreBlock(smelting)) {
|
||||
xp = ModUtils.getCustomSmeltingBlock(smelting).getSmeltingXpGain();
|
||||
}
|
||||
|
||||
return xp;
|
||||
|
@ -81,10 +81,10 @@ public class SmeltingManager extends SkillManager {
|
||||
return (int) (burnTime * burnModifier);
|
||||
}
|
||||
|
||||
public ItemStack smeltProcessing(Material resourceType, ItemStack result) {
|
||||
public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) {
|
||||
Player player = getPlayer();
|
||||
|
||||
applyXpGain(Smelting.getResourceXp(resourceType));
|
||||
applyXpGain(Smelting.getResourceXp(smelting));
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
|
||||
ItemStack newResult = result.clone();
|
||||
|
@ -1,14 +1,22 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.CoalType;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Coal;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
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;
|
||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -514,7 +522,7 @@ public class ItemUtils {
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
return Config.getInstance().getBlockModsEnabled() && CustomBlockConfig.getInstance().isCustomOre(item.getData());
|
||||
}
|
||||
}
|
||||
|
||||
@ -525,6 +533,8 @@ public class ItemUtils {
|
||||
|
||||
switch (item.getType()) {
|
||||
case COAL:
|
||||
return ((Coal) item.getData()).getType() == CoalType.COAL;
|
||||
|
||||
case DIAMOND:
|
||||
case REDSTONE:
|
||||
case GOLD_INGOT:
|
||||
@ -537,6 +547,14 @@ public class ItemUtils {
|
||||
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
|
||||
|
||||
default:
|
||||
List<Recipe> recipeList = mcMMO.p.getServer().getRecipesFor(item);
|
||||
|
||||
for (Recipe recipe : recipeList) {
|
||||
if (recipe instanceof FurnaceRecipe) {
|
||||
return Config.getInstance().getBlockModsEnabled() && CustomBlockConfig.getInstance().isCustomOre(((FurnaceRecipe) recipe).getInput().getData());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,9 @@ import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
|
||||
|
||||
public final class ModUtils {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
|
||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||
private static boolean customEntitiesEnabled = configInstance.getEntityModsEnabled();
|
||||
private static boolean customToolsEnabled = Config.getInstance().getToolModsEnabled();
|
||||
private static boolean customBlocksEnabled = Config.getInstance().getBlockModsEnabled();
|
||||
private static boolean customEntitiesEnabled = Config.getInstance().getEntityModsEnabled();
|
||||
|
||||
private ModUtils() {}
|
||||
|
||||
@ -57,6 +55,10 @@ public final class ModUtils {
|
||||
return CustomBlockConfig.getInstance().getCustomBlock(blockState.getData());
|
||||
}
|
||||
|
||||
public static CustomBlock getCustomSmeltingBlock(ItemStack smelting) {
|
||||
return CustomBlockConfig.getInstance().getCustomBlock(smelting.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a woodcutting block.
|
||||
*
|
||||
@ -137,6 +139,16 @@ public final class ModUtils {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomOre(blockState.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an ore block.
|
||||
*
|
||||
* @param item The ItemStack of the block to check
|
||||
* @return true if the block represents an ore, false otherwise
|
||||
*/
|
||||
public static boolean isCustomOreBlock(ItemStack item) {
|
||||
return customBlocksEnabled && CustomBlockConfig.getInstance().isCustomOre(item.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
|
@ -28,10 +28,12 @@ Mining:
|
||||
XP_Gain: 99
|
||||
Double_Drops_Enabled: true
|
||||
Is_Ore: true
|
||||
Smelting_XP_Gain: 9
|
||||
Block_2|0:
|
||||
XP_Gain: 99
|
||||
Double_Drops_Enabled: true
|
||||
Is_Ore: true
|
||||
Smelting_XP_Gain: 9
|
||||
|
||||
#
|
||||
# Settings for Custom Woodcutting Blocks
|
||||
|
Loading…
Reference in New Issue
Block a user