Eclipse is dumb and wasn't including these two files for some reason.

This commit is contained in:
GJ 2013-02-25 07:30:06 -05:00
parent 219667965f
commit da1e03cbfc
2 changed files with 110 additions and 0 deletions

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}