MASSIVE config overhaul - most keys are now based on the "proper" name

given to a material or entity by Bukkit.

This WILL wipe some custom values you may have set, so please verify
that your values are what you want them to be after the new config file
is generated.
This commit is contained in:
GJ
2013-02-20 16:44:15 -05:00
parent 17a85c94c6
commit c589c5556b
21 changed files with 356 additions and 780 deletions

View File

@ -6,7 +6,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
@ -18,12 +17,9 @@ import com.gmail.nossr50.util.Misc;
public class Mining {
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private static Config config = Config.getInstance();
public static int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel();
public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance();
public static boolean doubleDropsDisabled = config.miningDoubleDropsDisabled();
public static final int DIAMOND_TOOL_TIER = 4;
public static final int IRON_TOOL_TIER = 3;
@ -36,71 +32,13 @@ public class Mining {
* @param block The block to award XP for
*/
protected static void miningXP(McMMOPlayer mcMMOPlayer, Block block, Material type) {
int xp = 0;
int xp = Config.getInstance().getXp(SkillType.MINING, type);
switch (type) {
case COAL_ORE:
xp += config.getMiningXPCoalOre();
break;
case DIAMOND_ORE:
xp += config.getMiningXPDiamondOre();
break;
case ENDER_STONE:
xp += config.getMiningXPEndStone();
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
xp += config.getMiningXPRedstoneOre();
break;
case GLOWSTONE:
xp += config.getMiningXPGlowstone();
break;
case GOLD_ORE:
xp += config.getMiningXPGoldOre();
break;
case IRON_ORE:
xp += config.getMiningXPIronOre();
break;
case LAPIS_ORE:
xp += config.getMiningXPLapisOre();
break;
case MOSSY_COBBLESTONE:
xp += config.getMiningXPMossyStone();
break;
case NETHERRACK:
xp += config.getMiningXPNetherrack();
break;
case OBSIDIAN:
xp += config.getMiningXPObsidian();
break;
case SANDSTONE:
xp += config.getMiningXPSandstone();
break;
case STONE:
xp += config.getMiningXPStone();
break;
case EMERALD_ORE:
xp += config.getMiningXPEmeraldOre();
break;
default:
if (ModChecks.isCustomMiningBlock(block)) {
xp += ModChecks.getCustomBlock(block).getXpGain();
}
break;
if (type == Material.GLOWING_REDSTONE_ORE) {
xp = Config.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
}
else if (xp == 0 && ModChecks.isCustomMiningBlock(block)) {
xp = ModChecks.getCustomBlock(block).getXpGain();
}
mcMMOPlayer.beginXpGain(SkillType.MINING, xp);
@ -116,6 +54,10 @@ public class Mining {
protected static void silkTouchDrops(Block block, Location location, Material type) {
ItemStack item = new ItemStack(type);
if (type != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, type)) {
return;
}
switch (type) {
case ENDER_STONE:
case GOLD_ORE:
@ -127,52 +69,25 @@ public class Mining {
miningDrops(block, location, type);
break;
case COAL_ORE:
if (config.getCoalDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case DIAMOND_ORE:
if (config.getDiamondDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
Misc.dropItem(location, item);
}
break;
case COAL_ORE:
case DIAMOND_ORE:
case REDSTONE_ORE:
if (config.getRedstoneDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case GLOWSTONE:
if (config.getGlowstoneDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case LAPIS_ORE:
if (config.getLapisDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case STONE:
if (config.getStoneDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case EMERALD_ORE:
if (config.getEmeraldDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
Misc.dropItem(location, item);
break;
default:
if (ModChecks.isCustomMiningBlock(block)) {
ItemStack dropItem = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
ItemStack dropItem = new ItemStack(block.getTypeId(), 1, block.getData());
Misc.dropItem(location, dropItem);
}
@ -188,33 +103,31 @@ public class Mining {
* @param type The material type of the block
*/
protected static void miningDrops(Block block, Location location, Material type) {
if (type != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, type)) {
return;
}
ItemStack item = new ItemStack(type);
switch (type) {
case COAL_ORE:
if (config.getCoalDoubleDropsEnabled()) {
item = (new MaterialData(Material.COAL, CoalType.COAL.getData())).toItemStack(1);
Misc.dropItem(location, item);
}
item = new ItemStack(Material.COAL, 1, CoalType.COAL.getData());
Misc.dropItem(location, item);
break;
case DIAMOND_ORE:
if (config.getDiamondDoubleDropsEnabled()) {
item = new ItemStack(Material.DIAMOND);
Misc.dropItem(location, item);
}
item = new ItemStack(Material.DIAMOND);
Misc.dropItem(location, item);
break;
case ENDER_STONE:
if (config.getEndStoneDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
case EMERALD_ORE:
item = new ItemStack(Material.EMERALD);
Misc.dropItem(location, item);
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
if (config.getRedstoneDoubleDropsEnabled()) {
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
item = new ItemStack(Material.REDSTONE);
Misc.dropItems(location, item, 4);
Misc.randomDropItem(location, item, 50);
@ -222,69 +135,30 @@ public class Mining {
break;
case GLOWSTONE:
if (config.getGlowstoneDoubleDropsEnabled()) {
item = new ItemStack(Material.GLOWSTONE_DUST);
Misc.dropItems(location, item, 2);
Misc.randomDropItems(location, item, 2);
}
break;
case GOLD_ORE:
if (config.getGoldDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case IRON_ORE:
if (config.getIronDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
item = new ItemStack(Material.GLOWSTONE_DUST);
Misc.dropItems(location, item, 2);
Misc.randomDropItems(location, item, 2);
break;
case LAPIS_ORE:
if (config.getLapisDoubleDropsEnabled()) {
item = new ItemStack(Material.INK_SACK, 1, DyeColor.BLUE.getDyeData());
Misc.dropItems(location, item, 4);
Misc.randomDropItems(location, item, 4);
}
break;
case MOSSY_COBBLESTONE:
if (config.getMossyCobblestoneDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case NETHERRACK:
if (config.getNetherrackDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case OBSIDIAN:
if (config.getObsidianDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
break;
case SANDSTONE:
if (config.getSandstoneDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
item = new ItemStack(Material.INK_SACK, 1, DyeColor.BLUE.getDyeData());
Misc.dropItems(location, item, 4);
Misc.randomDropItems(location, item, 4);
break;
case STONE:
if (config.getStoneDoubleDropsEnabled()) {
item = new ItemStack(Material.COBBLESTONE);
Misc.dropItem(location, item);
}
item = new ItemStack(Material.COBBLESTONE);
Misc.dropItem(location, item);
break;
case EMERALD_ORE:
if (config.getEmeraldDoubleDropsEnabled()) {
item = new ItemStack(Material.EMERALD);
Misc.dropItem(location, item);
}
case ENDER_STONE:
case GOLD_ORE:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
Misc.dropItem(location, item);
break;
default:

View File

@ -92,7 +92,7 @@ public class MiningCommand extends SkillCommand {
canDemoExpert = Permissions.demolitionsExpertise(player);
canDoubleDrop = Permissions.doubleDrops(player, skill);
canSuperBreaker = Permissions.superBreaker(player);
doubleDropsDisabled = Mining.doubleDropsDisabled;
doubleDropsDisabled = skill.getDoubleDropsDisabled();
}
@Override