diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java new file mode 100644 index 000000000..b29c05c3e --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenTerraTimer.java @@ -0,0 +1,46 @@ +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; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java new file mode 100644 index 000000000..1cd2b6301 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/GreenThumbTimer.java @@ -0,0 +1,64 @@ +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; + } + } +}