Added config options for specific double drops. Implements MCCORE-226

This commit is contained in:
GJ
2012-05-01 01:14:32 -04:00
parent c8ad2bb454
commit dbede7f81a
11 changed files with 441 additions and 192 deletions

View File

@ -28,28 +28,6 @@ public class Excavation {
private static Random random = new Random();
/**
* Check to see if a block can be broken by Giga Drill Breaker.
*
* @param material The type of block to check
* @return
*/
public static boolean canBeGigaDrillBroken(Material type) {
switch (type) {
case CLAY:
case DIRT:
case GRASS:
case GRAVEL:
case MYCEL:
case SAND:
case SOUL_SAND:
return true;
default:
return false;
}
}
/**
* Check to see if treasures were found.
*

View File

@ -62,52 +62,6 @@ public class Herbalism {
}
}
/**
* Check if a block can be made mossy.
*
* @param material The type of Block to check
* @return true if the block can be made mossy, false otherwise
*/
public static Boolean makeMossy(Material type) {
switch (type) {
case COBBLESTONE:
case DIRT:
case SMOOTH_BRICK:
return true;
default:
return false;
}
}
/**
* Check if a block is affected by Herbalism abilities.
*
* @param type The type of Block to check
* @return true if the block is affected, false otherwise
*/
public static Boolean canBeGreenTerra(Material type){
switch (type) {
case BROWN_MUSHROOM:
case CACTUS:
case CROPS:
case JACK_O_LANTERN:
case MELON_BLOCK:
case NETHER_WARTS:
case PUMPKIN:
case RED_MUSHROOM:
case RED_ROSE:
case SUGAR_CANE_BLOCK:
case VINE:
case WATER_LILY:
case YELLOW_FLOWER:
return true;
default:
return false;
}
}
/**
* Check for extra Herbalism drops.
*
@ -231,30 +185,89 @@ public class Herbalism {
if (mat == null) {
return;
} else if (Permissions.getInstance().herbalismDoubleDrops(player)) {
}
if (Permissions.getInstance().herbalismDoubleDrops(player)) {
ItemStack is = new ItemStack(mat);
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
if (type.equals(Material.CACTUS)) {
Misc.mcDropItems(loc, is, catciDrops);
}
else if (type.equals(Material.MELON_BLOCK)) {
Misc.mcDropItems(loc, is, 3);
Misc.mcRandomDropItems(loc, is, 50, 4);
}
else if (type.equals(Material.NETHER_WARTS)) {
Misc.mcDropItems(loc, is, 2);
Misc.mcRandomDropItems(loc, is, 50, 3);
}
else if (type.equals(Material.SUGAR_CANE_BLOCK)) {
Misc.mcDropItems(loc, is, caneDrops);
}
else {
Misc.mcDropItem(loc, is);
Config configInstance = Config.getInstance();
switch (type) {
case BROWN_MUSHROOM:
if (configInstance.getBrownMushroomsDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case CACTUS:
if (configInstance.getCactiDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, catciDrops);
}
break;
case CROPS:
if (configInstance.getWheatDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case MELON_BLOCK:
if (configInstance.getMelonsDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, 3);
Misc.mcRandomDropItems(loc, is, 50, 4);
}
break;
case NETHER_WARTS:
if (configInstance.getNetherWartsDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, 2);
Misc.mcRandomDropItems(loc, is, 50, 3);
}
break;
case PUMPKIN:
if (configInstance.getPumpkinsDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case RED_MUSHROOM:
if (configInstance.getRedMushroomsDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case SUGAR_CANE_BLOCK:
if (configInstance.getSugarCaneDoubleDropsEnabled()) {
Misc.mcDropItems(loc, is, caneDrops);
}
break;
case VINE:
if (configInstance.getVinesDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case WATER_LILY:
if (configInstance.getWaterLiliesDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
case YELLOW_FLOWER:
if (configInstance.getYellowFlowersDoubleDropsEnabled()) {
Misc.mcDropItem(loc, is);
}
break;
default:
break;
}
}
}
PP.addXP(SkillType.HERBALISM, xp);
Skills.XpCheckSkill(SkillType.HERBALISM, player);
}

View File

@ -13,6 +13,7 @@ import org.bukkit.enchantments.Enchantment;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
@ -34,44 +35,98 @@ public class Mining {
Location loc = block.getLocation();
Material type = block.getType();
ItemStack item = new ItemStack(type);
Config configInstance = Config.getInstance();
switch (type) {
case COAL_ORE:
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
Misc.mcDropItem(loc, item);
if (configInstance.getCoalDoubleDropsEnabled()) {
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
Misc.mcDropItem(loc, item);
}
break;
case DIAMOND_ORE:
item = new ItemStack(Material.DIAMOND);
Misc.mcDropItem(loc, item);
if (configInstance.getDiamondDoubleDropsEnabled()) {
item = new ItemStack(Material.DIAMOND);
Misc.mcDropItem(loc, item);
}
break;
case ENDER_STONE:
if (configInstance.getEndStoneDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
item = new ItemStack(Material.REDSTONE);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItem(loc, item, 50);
if (configInstance.getRedstoneDoubleDropsEnabled()) {
item = new ItemStack(Material.REDSTONE);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItem(loc, item, 50);
}
break;
case GLOWSTONE:
item = new ItemStack(Material.GLOWSTONE_DUST);
Misc.mcDropItems(loc, item, 2);
Misc.mcRandomDropItems(loc, item, 50, 2);
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
item = new ItemStack(Material.GLOWSTONE_DUST);
Misc.mcDropItems(loc, item, 2);
Misc.mcRandomDropItems(loc, item, 50, 2);
}
break;
case GOLD_ORE:
if (configInstance.getGoldDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case IRON_ORE:
if (configInstance.getIronDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case LAPIS_ORE:
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItems(loc, item, 50, 4);
if (configInstance.getLapisDoubleDropsEnabled()) {
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItems(loc, item, 50, 4);
}
break;
case MOSSY_COBBLESTONE:
if (configInstance.getMossyCobblestoneDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case NETHERRACK:
if (configInstance.getNetherrackDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case OBSIDIAN:
if (configInstance.getObsidianDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case SANDSTONE:
if (configInstance.getSandstoneDoubleDropsEnabled()) {
Misc.mcDropItem(loc, item);
}
break;
case STONE:
item = new ItemStack(Material.COBBLESTONE);
Misc.mcDropItem(loc, item);
if (configInstance.getStoneDoubleDropsEnabled()) {
item = new ItemStack(Material.COBBLESTONE);
Misc.mcDropItem(loc, item);
}
break;
default:
Misc.mcDropItem(loc, item);
break;
}
}
@ -162,7 +217,7 @@ public class Mining {
miningXP(player, block);
if (canBeSuperBroken(block.getType())) {
if (BlockChecks.canBeSuperBroken(block.getType())) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
@ -173,35 +228,6 @@ public class Mining {
}
}
/**
* Check to see if a block is broken by Super Breaker.
*
* @param type The type of Block to check
* @return true if the block would be broken by Super Breaker, false otherwise
*/
public static Boolean canBeSuperBroken(Material type) {
switch (type) {
case COAL_ORE:
case DIAMOND_ORE:
case ENDER_STONE:
case GLOWING_REDSTONE_ORE:
case GLOWSTONE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case REDSTONE_ORE:
case SANDSTONE:
case STONE:
return true;
default:
return false;
}
}
/**
* Handle the Super Breaker ability.
*

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.skills;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.block.Block;
@ -18,6 +19,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@ -140,8 +142,37 @@ public class WoodCutting {
x.setData((byte) 0x0);
x.setType(Material.AIR);
Config configInstance = Config.getInstance();
/* Drop the block */
Misc.mcDropItem(x.getLocation(), item);
switch (species) {
case GENERIC:
if (configInstance.getOakDoubleDropsEnabled()) {
Misc.mcDropItem(x.getLocation(), item);
}
break;
case REDWOOD:
if (configInstance.getSpruceDoubleDropsEnabled()) {
Misc.mcDropItem(x.getLocation(), item);
}
break;
case BIRCH:
if (configInstance.getBirchDoubleDropsEnabled()) {
Misc.mcDropItem(x.getLocation(), item);
}
break;
case JUNGLE:
if (configInstance.getJungleDoubleDropsEnabled()) {
Misc.mcDropItem(x.getLocation(), item);
}
break;
default:
break;
}
}
else if (x.getType() == Material.LEAVES) {
final int SAPLING_DROP_CHANCE = 10;
@ -156,25 +187,9 @@ public class WoodCutting {
}
}
PP.addXP(SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
}
/**
* Checks if the block is affected by Tree Feller.
*
* @param block Block to check
* @return true if the block is affected by Tree Feller, false otherwise
*/
private static boolean treeFellerCompatible(Block block) {
switch (block.getType()) {
case LOG:
case LEAVES:
case AIR:
return true;
default:
return false;
if (Permissions.getInstance().woodcutting(player)) {
PP.addXP(SkillType.WOODCUTTING, xp); //Tree Feller gives nerf'd XP
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
}
}
@ -202,24 +217,24 @@ public class WoodCutting {
Block yPositive = currentBlock.getRelative(0, 1, 0);
if (!currentBlock.hasMetadata("mcmmoPlacedBlock")) {
if (!isTooAggressive(currentBlock, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) {
if (!isTooAggressive(currentBlock, xPositive) && BlockChecks.treeFellerCompatible(xPositive.getType()) && !toBeFelled.contains(xPositive)) {
processTreeFelling(xPositive, toBeFelled);
}
if (!isTooAggressive(currentBlock, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) {
if (!isTooAggressive(currentBlock, xNegative) && BlockChecks.treeFellerCompatible(xNegative.getType()) && !toBeFelled.contains(xNegative)) {
processTreeFelling(xNegative, toBeFelled);
}
if (!isTooAggressive(currentBlock, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) {
if (!isTooAggressive(currentBlock, zPositive) && BlockChecks.treeFellerCompatible(zPositive.getType()) && !toBeFelled.contains(zPositive)) {
processTreeFelling(zPositive, toBeFelled);
}
if (!isTooAggressive(currentBlock, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) {
if (!isTooAggressive(currentBlock, zNegative) && BlockChecks.treeFellerCompatible(zNegative.getType()) && !toBeFelled.contains(zNegative)) {
processTreeFelling(zNegative, toBeFelled);
}
}
if (treeFellerCompatible(yPositive)) {
if (BlockChecks.treeFellerCompatible(yPositive.getType())) {
if(!currentBlock.hasMetadata("mcmmoPlacedBlock") && !toBeFelled.contains(yPositive)) {
processTreeFelling(yPositive, toBeFelled);
}
@ -258,9 +273,43 @@ public class WoodCutting {
byte type = block.getData();
Material mat = Material.getMaterial(block.getTypeId());
Tree tree = (Tree) block.getState().getData();
TreeSpecies species = tree.getSpecies();
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
Config configInstance = Config.getInstance();
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
Misc.mcDropItem(block.getLocation(), item);
Location location = block.getLocation();
/* Drop the block */
switch (species) {
case GENERIC:
if (configInstance.getOakDoubleDropsEnabled()) {
Misc.mcDropItem(location, item);
}
break;
case REDWOOD:
if (configInstance.getSpruceDoubleDropsEnabled()) {
Misc.mcDropItem(location, item);
}
break;
case BIRCH:
if (configInstance.getBirchDoubleDropsEnabled()) {
Misc.mcDropItem(location, item);
}
break;
case JUNGLE:
if (configInstance.getJungleDoubleDropsEnabled()) {
Misc.mcDropItem(location, item);
}
break;
default:
break;
}
}
}