mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
We don't need this anymore.
This commit is contained in:
parent
8a2c5fb051
commit
6eaec5ffab
@ -1,77 +0,0 @@
|
|||||||
package com.gmail.nossr50.skills.herbalism;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
public enum HerbalismBlock {
|
|
||||||
BROWN_MUSHROOM(Material.BROWN_MUSHROOM),
|
|
||||||
CACTUS(Material.CACTUS),
|
|
||||||
CARROT(Material.CARROT, Material.CARROT_ITEM),
|
|
||||||
COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())),
|
|
||||||
CROPS(Material.CROPS, Material.WHEAT),
|
|
||||||
MELON_BLOCK(Material.MELON_BLOCK, Material.MELON),
|
|
||||||
NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK),
|
|
||||||
POTATO(Material.POTATO, Material.POTATO_ITEM),
|
|
||||||
PUMPKIN(Material.PUMPKIN),
|
|
||||||
RED_MUSHROOM(Material.RED_MUSHROOM),
|
|
||||||
RED_ROSE(Material.RED_ROSE),
|
|
||||||
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE),
|
|
||||||
VINE(Material.VINE),
|
|
||||||
WATER_LILY(Material.WATER_LILY),
|
|
||||||
YELLOW_FLOWER(Material.YELLOW_FLOWER);
|
|
||||||
|
|
||||||
private Material blockType;
|
|
||||||
private ItemStack dropItem;
|
|
||||||
|
|
||||||
private final static Map<Material, HerbalismBlock> BY_MATERIAL = Maps.newHashMap();
|
|
||||||
|
|
||||||
private HerbalismBlock(Material blockType) {
|
|
||||||
this(blockType, new ItemStack(blockType));
|
|
||||||
}
|
|
||||||
|
|
||||||
private HerbalismBlock(Material blockType, Material dropType) {
|
|
||||||
this(blockType, new ItemStack(dropType));
|
|
||||||
}
|
|
||||||
|
|
||||||
private HerbalismBlock(Material blockType, ItemStack dropItem) {
|
|
||||||
this.blockType = blockType;
|
|
||||||
this.dropItem = dropItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
for (HerbalismBlock herbalismBlock : values()) {
|
|
||||||
BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getDropItem() {
|
|
||||||
return dropItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getXpGain() {
|
|
||||||
return ExperienceConfig.getInstance().getXp(SkillType.HERBALISM, blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canDoubleDrop() {
|
|
||||||
return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasGreenThumbPermission(Player player) {
|
|
||||||
return Permissions.greenThumbPlant(player, blockType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HerbalismBlock getHerbalismBlock(Material blockType) {
|
|
||||||
return BY_MATERIAL.get(blockType);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills.herbalism;
|
package com.gmail.nossr50.skills.herbalism;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.CropState;
|
import org.bukkit.CropState;
|
||||||
@ -17,8 +18,8 @@ import org.bukkit.material.NetherWarts;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
@ -116,6 +117,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
*/
|
*/
|
||||||
public void herbalismBlockCheck(BlockState blockState) {
|
public void herbalismBlockCheck(BlockState blockState) {
|
||||||
|
Player player = getPlayer();
|
||||||
Material material = blockState.getType();
|
Material material = blockState.getType();
|
||||||
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
|
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
|
||||||
|
|
||||||
@ -127,21 +129,28 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material);
|
Collection<ItemStack> drops = null;
|
||||||
ItemStack drop = null;
|
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
int xp = 0;
|
int xp = 0;
|
||||||
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
|
||||||
|
|
||||||
if (herbalismBlock != null) {
|
if (ModUtils.isCustomHerbalismBlock(blockState)) {
|
||||||
if (herbalismBlock.hasGreenThumbPermission(getPlayer())) {
|
xp = ModUtils.getCustomBlock(blockState).getXpGain();
|
||||||
|
|
||||||
|
// XXX: Add double drop check to blocks.yml
|
||||||
|
if (Permissions.doubleDrops(player, skill)) {
|
||||||
|
drops = blockState.getBlock().getDrops();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (Permissions.greenThumbPlant(player, material)) {
|
||||||
processGreenThumbPlants(blockState, greenTerra);
|
processGreenThumbPlants(blockState, greenTerra);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp = herbalismBlock.getXpGain();
|
xp = ExperienceConfig.getInstance().getXp(skill, material);
|
||||||
|
|
||||||
if (herbalismBlock.canDoubleDrop() && Permissions.doubleDrops(getPlayer(), skill)) {
|
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.doubleDrops(player, skill)) {
|
||||||
drop = herbalismBlock.getDropItem();
|
drops = blockState.getBlock().getDrops();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oneBlockPlant) {
|
if (!oneBlockPlant) {
|
||||||
@ -149,27 +158,18 @@ public class HerbalismManager extends SkillManager {
|
|||||||
xp *= amount;
|
xp *= amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
|
|
||||||
xp = customBlock.getXpGain();
|
|
||||||
|
|
||||||
if (Permissions.doubleDrops(getPlayer(), skill)) {
|
|
||||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
|
||||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
|
||||||
drop = customBlock.getItemDrop();
|
|
||||||
amount = Misc.getRandom().nextInt(maximumDropAmount - minimumDropAmount + 1) + minimumDropAmount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
applyXpGain(xp);
|
applyXpGain(xp);
|
||||||
|
|
||||||
if (drop == null) {
|
if (drops == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
|
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
|
||||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||||
Misc.dropItems(blockState.getLocation(), drop, amount);
|
for (ItemStack item : drops) {
|
||||||
|
Misc.dropItems(blockState.getLocation(), item, amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +279,28 @@ public class HerbalismManager extends SkillManager {
|
|||||||
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
PlayerInventory playerInventory = player.getInventory();
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
ItemStack seed = (blockState.getType() == Material.CROPS) ? new ItemStack(Material.SEEDS) : HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
|
ItemStack seed = null;
|
||||||
|
|
||||||
|
switch (blockState.getType()) {
|
||||||
|
case CARROT:
|
||||||
|
seed = new ItemStack(Material.CARROT_ITEM);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CROPS:
|
||||||
|
seed = new ItemStack(Material.SEEDS);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NETHER_WARTS:
|
||||||
|
seed = new ItemStack(Material.NETHER_STALK);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case POTATO:
|
||||||
|
seed = new ItemStack(Material.POTATO_ITEM);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user