Prevent accidentally breaking regrown crops

Adds #828
This commit is contained in:
TfT_02
2014-04-06 14:41:40 +02:00
parent 56e625a9df
commit 618cfad100
5 changed files with 22 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.skills.SkillUtils;
public class Herbalism {
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
@ -93,4 +94,14 @@ public class Herbalism {
return false;
}
}
/**
* Check if the block has a recently grown crop from Green Thumb
*
* @param blockState The {@link BlockState} to check green thumb regrown for
* @return true if the block is recently regrown, false otherwise
*/
public static boolean isRecentlyRegrown(BlockState blockState) {
return blockState.hasMetadata(mcMMO.greenThumbDataKey) && !SkillUtils.cooldownExpired(blockState.getMetadata(mcMMO.greenThumbDataKey).get(0).asInt(), 1);
}
}

View File

@ -14,6 +14,7 @@ import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import org.bukkit.material.Crops;
import org.bukkit.material.NetherWarts;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@ -330,6 +331,8 @@ public class HerbalismManager extends SkillManager {
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
byte greenThumbStage = getGreenThumbStage();
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
switch (blockState.getType()) {
case CROPS:
Crops crops = (Crops) blockState.getData();