mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Squashed commit of the following:
commit cb3e057dee1f2b29838ab654a526baac1baab7d6 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:43:57 2013 -0500 1.4.00 release commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:07:30 2013 -0500 \r -> \n commit b2ca22e0477c747143b0f08a28a096967ee6ffd7 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:53:56 2013 -0500 Commented-out code shouldn't be done like that. commit 92f131712cc671e3e616c14a22e22769ef6d6d0b Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:45:36 2013 -0500 More things we missed. commit 408b03766f6261a03a862a1ab7f5835772feda4a Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 23:20:13 2013 -0500 Format: util through spout and backup lib commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:50:08 2013 -0500 The things we missed the first time through... commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:05:29 2013 -0500 Formatting: Skills commit c097a6e188a7b760dd1b4389ed81dca417146b16 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:30:12 2013 -0500 Organize imports. commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:45 2013 -0500 Fixed a missing fallthrough comment from ChatCommand commit b4a76c9f022a2fd98bdd8f083accfea03becfd71 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:36 2013 -0500 Formatting: datatypes.* through events.* commit 3e57dd41d3265a7c8106c7eb026df926770a4d15 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:56:15 2013 -0500 Fix issue with bad rebase commit e8c8e06b2971555b7334e49128257e3af6f36892 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 17:35:32 2013 -0500 Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and PlayerStat commit 13ecf1cc41f377a12991e357ac10abdcda24d6de Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:31:43 2013 -0500 Format: listeners.* through runnables.* commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:13:57 2013 -0500 Format PartyLockCommand commit d50abed10bf94e1a88df3dc5cc07c259aea920ea Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 16:54:08 2013 -0500 Format: base through config.* commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:21:40 2013 -0500 Example of using spaces to align like things commit 534190cfe2481e466fe459d65628550458cc2993 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:12:19 2013 -0500 Capitalization commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:07:43 2013 -0500 Updated readme, added standards.md commit 5ec0df70fb82c527420a2f437f27f31bd758f884 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 14:42:16 2013 -0500 Markdown was here, Creole is a loser commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 13:46:24 2013 -0500 Move MCStats shading to .metrics.mcstats commit eb9d67e66b1659d6abd2397ecf403343cfeffdda Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 13:37:37 2013 -0500 Move ALL the packages! commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 12:37:12 2013 -0500 /r/n -> /n
This commit is contained in:
@ -1,46 +0,0 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
|
||||
/**
|
||||
* Convert plants affected by the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public class GreenTerraTimer implements Runnable {
|
||||
private BlockState blockState;
|
||||
|
||||
public GreenTerraTimer(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
switch (blockState.getType()) {
|
||||
case CROPS:
|
||||
case CARROT:
|
||||
case POTATO:
|
||||
blockState.setRawData(CropState.MEDIUM.getData());
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case NETHER_WARTS:
|
||||
blockState.setRawData((byte) 0x2);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
blockState.setData(plant);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.CocoaPlant;
|
||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||
|
||||
/**
|
||||
* Convert plants affected by the Green Thumb ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @param skillLevel The player's Herbalism skill level
|
||||
*/
|
||||
public class GreenThumbTimer implements Runnable {
|
||||
private BlockState blockState;
|
||||
private int skillLevel;
|
||||
|
||||
public GreenThumbTimer(BlockState blockState, int skillLevel) {
|
||||
this.blockState = blockState;
|
||||
this.skillLevel = skillLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
|
||||
|
||||
switch(blockState.getType()) {
|
||||
case CROPS:
|
||||
case CARROT:
|
||||
case POTATO:
|
||||
blockState.setRawData((byte) greenThumbStage);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (greenThumbStage > 2) {
|
||||
blockState.setRawData((byte) 0x2);
|
||||
}
|
||||
else if (greenThumbStage == 2) {
|
||||
blockState.setRawData((byte) 0x1);
|
||||
}
|
||||
else {
|
||||
blockState.setRawData((byte) 0x0);
|
||||
}
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
case COCOA:
|
||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
||||
|
||||
if (greenThumbStage > 1) {
|
||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
||||
}
|
||||
else {
|
||||
plant.setSize(CocoaPlantSize.SMALL);
|
||||
}
|
||||
blockState.setData(plant);
|
||||
blockState.update(true);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,108 +1,108 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class Herbalism {
|
||||
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
||||
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
|
||||
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
|
||||
|
||||
public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange();
|
||||
public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4;
|
||||
|
||||
public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax();
|
||||
public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel();
|
||||
|
||||
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax();
|
||||
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel();
|
||||
|
||||
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
|
||||
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
|
||||
|
||||
public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax();
|
||||
public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel();
|
||||
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case COBBLE_WALL:
|
||||
case SMOOTH_BRICK:
|
||||
blockState.setRawData((byte) 0x1);
|
||||
return true;
|
||||
|
||||
case DIRT:
|
||||
blockState.setType(Material.GRASS);
|
||||
return true;
|
||||
|
||||
case COBBLESTONE:
|
||||
blockState.setType(Material.MOSSY_COBBLESTONE);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
||||
* @return the number of bonus drops to award from the blocks in this plant
|
||||
*/
|
||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
Material blockType = blockState.getType();
|
||||
int dropAmount = 0;
|
||||
|
||||
// Handle the original block
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
dropAmount++;
|
||||
}
|
||||
|
||||
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
||||
for (int y = 1; y < 3; y++) {
|
||||
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
||||
Material relativeBlockType = relativeBlock.getType();
|
||||
|
||||
// If the first one is air, so is the next one
|
||||
if (relativeBlockType == Material.AIR) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
|
||||
dropAmount++;
|
||||
}
|
||||
}
|
||||
|
||||
return dropAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||
switch (blockState.getType()){
|
||||
case DIRT:
|
||||
case GRASS:
|
||||
blockState.setType(Material.MYCEL);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
|
||||
public class Herbalism {
|
||||
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
||||
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
|
||||
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
|
||||
|
||||
public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange();
|
||||
public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4;
|
||||
|
||||
public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel();
|
||||
public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax();
|
||||
|
||||
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel();
|
||||
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax();
|
||||
|
||||
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
|
||||
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
|
||||
|
||||
public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel();
|
||||
public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax();
|
||||
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case COBBLE_WALL:
|
||||
case SMOOTH_BRICK:
|
||||
blockState.setRawData((byte) 0x1);
|
||||
return true;
|
||||
|
||||
case DIRT:
|
||||
blockState.setType(Material.GRASS);
|
||||
return true;
|
||||
|
||||
case COBBLESTONE:
|
||||
blockState.setType(Material.MOSSY_COBBLESTONE);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
|
||||
*
|
||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
||||
* @return the number of bonus drops to award from the blocks in this plant
|
||||
*/
|
||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
Material blockType = blockState.getType();
|
||||
int dropAmount = 0;
|
||||
|
||||
// Handle the original block
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
dropAmount++;
|
||||
}
|
||||
|
||||
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
||||
for (int y = 1; y < 3; y++) {
|
||||
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
||||
Material relativeBlockType = relativeBlock.getType();
|
||||
|
||||
// If the first one is air, so is the next one
|
||||
if (relativeBlockType == Material.AIR) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
|
||||
dropAmount++;
|
||||
}
|
||||
}
|
||||
|
||||
return dropAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||
switch (blockState.getType()) {
|
||||
case DIRT:
|
||||
case GRASS:
|
||||
blockState.setType(Material.MYCEL);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,75 +1,75 @@
|
||||
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.skills.utilities.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 Config.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);
|
||||
}
|
||||
}
|
||||
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.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 Config.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,180 +0,0 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HerbalismCommand extends SkillCommand {
|
||||
private String greenTerraLength;
|
||||
private String greenTerraLengthEndurance;
|
||||
private String greenThumbChance;
|
||||
private String greenThumbChanceLucky;
|
||||
private String greenThumbStage;
|
||||
private String farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String hylianLuckChance;
|
||||
private String hylianLuckChanceLucky;
|
||||
private String shroomThumbChance;
|
||||
private String shroomThumbChanceLucky;
|
||||
|
||||
private boolean hasHylianLuck;
|
||||
private boolean canGreenTerra;
|
||||
private boolean canGreenThumbWheat;
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canShroomThumb;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
public HerbalismCommand() {
|
||||
super(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//GREEN TERRA
|
||||
String[] greenTerraStrings = calculateLengthDisplayValues();
|
||||
greenTerraLength = greenTerraStrings[0];
|
||||
greenTerraLengthEndurance = greenTerraStrings[1];
|
||||
|
||||
//FARMERS DIET
|
||||
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
|
||||
|
||||
//GREEN THUMB
|
||||
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
|
||||
|
||||
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance);
|
||||
greenThumbChance = greenThumbStrings[0];
|
||||
greenThumbChanceLucky = greenThumbStrings[1];
|
||||
|
||||
//DOUBLE DROPS
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
|
||||
//HYLIAN LUCK
|
||||
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
|
||||
hylianLuckChance = hylianLuckStrings[0];
|
||||
hylianLuckChanceLucky = hylianLuckStrings[1];
|
||||
|
||||
//SHROOM THUMB
|
||||
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
|
||||
shroomThumbChance = shroomThumbStrings[0];
|
||||
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
hasHylianLuck = Permissions.hylianLuck(player);
|
||||
canGreenTerra = Permissions.greenTerra(player);
|
||||
canGreenThumbWheat = Permissions.greenThumbPlant(player, Material.CROPS); //TODO: This isn't really accurate - they could have perms for other crops but not wheat.
|
||||
canGreenThumbBlocks = (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK));
|
||||
canFarmersDiet = Permissions.farmersDiet(player);
|
||||
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
||||
doubleDropsDisabled = skill.getDoubleDropsDisabled();
|
||||
canShroomThumb = Permissions.shroomThumb(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
|
||||
}
|
||||
|
||||
if (hasHylianLuck) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
|
||||
}
|
||||
|
||||
if (canShroomThumb) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
if (hasEndurance) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
|
||||
}
|
||||
|
||||
if (hasHylianLuck) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShroomThumb) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,306 +1,308 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class HerbalismManager extends SkillManager {
|
||||
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
public boolean canBlockCheck() {
|
||||
return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle());
|
||||
}
|
||||
|
||||
public boolean canGreenThumbBlock(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
return player.getItemInHand().getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
|
||||
}
|
||||
|
||||
public boolean canUseShroomThumb(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
Material itemType = player.getItemInHand().getType();
|
||||
|
||||
return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockChecks.canMakeShroomy(blockState) && Permissions.shroomThumb(player);
|
||||
}
|
||||
|
||||
public boolean canUseHylianLuck() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return ItemChecks.isSword(player.getItemInHand()) && Permissions.hylianLuck(player);
|
||||
}
|
||||
|
||||
public boolean canGreenTerraBlock(BlockState blockState) {
|
||||
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(blockState);
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canGreenTerraPlant() {
|
||||
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Farmer's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
||||
return SkillTools.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenTerra(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!Permissions.greenThumbBlock(player, blockState.getType())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack seed = new ItemStack(Material.SEEDS);
|
||||
|
||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
|
||||
return false;
|
||||
}
|
||||
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
return Herbalism.convertGreenTerraBlocks(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process double drops & XP gain for Herbalism.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
Material blockType = blockState.getType();
|
||||
|
||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType);
|
||||
CustomBlock customBlock = null;
|
||||
|
||||
int xp = 0;
|
||||
int dropAmount = 1;
|
||||
ItemStack dropItem = null;
|
||||
|
||||
if (herbalismBlock != null) {
|
||||
if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
||||
xp = herbalismBlock.getXpGain() * dropAmount;
|
||||
}
|
||||
else if (herbalismBlock.hasGreenThumbPermission(player)){
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
xp = herbalismBlock.getXpGain();
|
||||
processGreenThumbPlants(blockState);
|
||||
}
|
||||
else {
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
xp = herbalismBlock.getXpGain();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
customBlock = ModChecks.getCustomBlock(blockState);
|
||||
dropItem = customBlock.getItemDrop();
|
||||
xp = customBlock.getXpGain();
|
||||
}
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
|
||||
Misc.dropItems(location, dropItem, dropAmount);
|
||||
}
|
||||
else if (customBlock != null){
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
|
||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Green Thumb ability for blocks.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return Herbalism.convertGreenTerraBlocks(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Hylian Luck ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processHylianLuck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!SkillTools.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case DEAD_BUSH:
|
||||
case LONG_GRASS:
|
||||
case SAPLING:
|
||||
treasures = TreasuresConfig.getInstance().hylianFromBushes;
|
||||
break;
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (mcMMO.placeStore.isTrue(blockState)) {
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
return false;
|
||||
}
|
||||
|
||||
treasures = TreasuresConfig.getInstance().hylianFromFlowers;
|
||||
break;
|
||||
|
||||
case FLOWER_POT:
|
||||
treasures = TreasuresConfig.getInstance().hylianFromPots;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (treasures.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
blockState.setRawData((byte) 0x0);
|
||||
blockState.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Shroom Thumb ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processShroomThumb(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
|
||||
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
|
||||
return false;
|
||||
}
|
||||
|
||||
playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
|
||||
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
||||
player.updateInventory();
|
||||
|
||||
if (!SkillTools.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return Herbalism.convertShroomThumb(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Green Thumb ability for plants.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
private void processGreenThumbPlants(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
|
||||
|
||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = Users.getPlayer(player).getProfile();
|
||||
|
||||
if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimer(blockState), 0);
|
||||
return;
|
||||
}
|
||||
else if (SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimer(blockState, getSkillLevel()), 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
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.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
|
||||
import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class HerbalismManager extends SkillManager {
|
||||
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
public boolean canBlockCheck() {
|
||||
return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle());
|
||||
}
|
||||
|
||||
public boolean canGreenThumbBlock(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
return player.getItemInHand().getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
|
||||
}
|
||||
|
||||
public boolean canUseShroomThumb(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
Material itemType = player.getItemInHand().getType();
|
||||
|
||||
return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.shroomThumb(player);
|
||||
}
|
||||
|
||||
public boolean canUseHylianLuck() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return ItemUtils.isSword(player.getItemInHand()) && Permissions.hylianLuck(player);
|
||||
}
|
||||
|
||||
public boolean canGreenTerraBlock(BlockState blockState) {
|
||||
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState);
|
||||
}
|
||||
|
||||
public boolean canActivateAbility() {
|
||||
return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canGreenTerraPlant() {
|
||||
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Farmer's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int farmersDiet(int rankChange, int eventFoodLevel) {
|
||||
return SkillUtils.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Green Terra ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenTerra(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!Permissions.greenThumbBlock(player, blockState.getType())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack seed = new ItemStack(Material.SEEDS);
|
||||
|
||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
|
||||
return false;
|
||||
}
|
||||
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
return Herbalism.convertGreenTerraBlocks(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process double drops & XP gain for Herbalism.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public void herbalismBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
Material blockType = blockState.getType();
|
||||
|
||||
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType);
|
||||
CustomBlock customBlock = null;
|
||||
|
||||
int xp = 0;
|
||||
int dropAmount = 1;
|
||||
ItemStack dropItem = null;
|
||||
|
||||
if (herbalismBlock != null) {
|
||||
if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
||||
xp = herbalismBlock.getXpGain() * dropAmount;
|
||||
}
|
||||
else if (herbalismBlock.hasGreenThumbPermission(player)) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
xp = herbalismBlock.getXpGain();
|
||||
processGreenThumbPlants(blockState);
|
||||
}
|
||||
else {
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
dropItem = herbalismBlock.getDropItem();
|
||||
xp = herbalismBlock.getXpGain();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
customBlock = ModUtils.getCustomBlock(blockState);
|
||||
dropItem = customBlock.getItemDrop();
|
||||
xp = customBlock.getXpGain();
|
||||
}
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
|
||||
Misc.dropItems(location, dropItem, dropAmount);
|
||||
}
|
||||
else if (customBlock != null) {
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
|
||||
Misc.dropItems(location, dropItem, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Green Thumb ability for blocks.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processGreenThumbBlocks(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return Herbalism.convertGreenTerraBlocks(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Hylian Luck ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processHylianLuck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case DEAD_BUSH:
|
||||
case LONG_GRASS:
|
||||
case SAPLING:
|
||||
treasures = TreasureConfig.getInstance().hylianFromBushes;
|
||||
break;
|
||||
|
||||
case RED_ROSE:
|
||||
case YELLOW_FLOWER:
|
||||
if (mcMMO.placeStore.isTrue(blockState)) {
|
||||
mcMMO.placeStore.setFalse(blockState);
|
||||
return false;
|
||||
}
|
||||
|
||||
treasures = TreasureConfig.getInstance().hylianFromFlowers;
|
||||
break;
|
||||
|
||||
case FLOWER_POT:
|
||||
treasures = TreasureConfig.getInstance().hylianFromPots;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (treasures.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
blockState.setRawData((byte) 0x0);
|
||||
blockState.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Shroom Thumb ability.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @return true if the ability was successful, false otherwise
|
||||
*/
|
||||
public boolean processShroomThumb(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
|
||||
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
|
||||
return false;
|
||||
}
|
||||
|
||||
playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
|
||||
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
|
||||
player.updateInventory();
|
||||
|
||||
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return Herbalism.convertShroomThumb(blockState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Green Thumb ability for plants.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
private void processGreenThumbPlants(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
|
||||
|
||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0);
|
||||
return;
|
||||
}
|
||||
else if (SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimerTask(blockState, getSkillLevel()), 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user