2012-03-11 04:21:53 +01:00
|
|
|
package com.gmail.nossr50.runnables;
|
|
|
|
|
2012-03-13 08:00:49 +01:00
|
|
|
import org.bukkit.CropState;
|
2012-03-11 04:21:53 +01:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
|
2013-01-02 02:10:16 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2012-03-27 08:33:35 +02:00
|
|
|
import com.gmail.nossr50.datatypes.AbilityType;
|
2012-03-11 04:21:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
|
|
|
|
|
|
public class GreenThumbTimer implements Runnable {
|
2013-01-02 02:10:16 +01:00
|
|
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
2012-03-11 04:21:53 +01:00
|
|
|
private Block block;
|
2012-07-03 16:04:04 +02:00
|
|
|
private PlayerProfile profile;
|
2012-11-10 01:37:12 +01:00
|
|
|
private Material type;
|
2012-03-11 04:21:53 +01:00
|
|
|
|
2012-11-10 01:37:12 +01:00
|
|
|
public GreenThumbTimer(Block block, PlayerProfile profile, Material material) {
|
2012-03-11 04:21:53 +01:00
|
|
|
this.block = block;
|
2012-07-03 16:04:04 +02:00
|
|
|
this.profile = profile;
|
2012-11-10 01:37:12 +01:00
|
|
|
this.type = material;
|
2012-03-11 04:21:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2013-01-10 05:03:17 +01:00
|
|
|
if (this.block.getType() != this.type)
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setType(this.type);
|
2012-03-11 04:21:53 +01:00
|
|
|
|
2013-01-02 02:10:16 +01:00
|
|
|
int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM);
|
|
|
|
|
|
|
|
final int STAGE_CHANGE = advancedConfig.getGreenThumbStageChange();
|
|
|
|
|
|
|
|
int greenThumbStage = (int) ((double) skillLevel / (double) STAGE_CHANGE);
|
|
|
|
if (greenThumbStage > 4) greenThumbStage = 4;
|
|
|
|
|
2012-11-10 01:37:12 +01:00
|
|
|
switch(this.type) {
|
|
|
|
case CROPS:
|
|
|
|
case CARROT:
|
|
|
|
case POTATO:
|
|
|
|
//This replants the wheat at a certain stage in development based on Herbalism Skill
|
|
|
|
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
2013-01-02 02:10:16 +01:00
|
|
|
if (greenThumbStage == 3) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData(CropState.MEDIUM.getData());
|
|
|
|
}
|
2013-01-02 02:10:16 +01:00
|
|
|
else if (greenThumbStage == 2) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData(CropState.SMALL.getData());
|
|
|
|
}
|
2013-01-02 02:10:16 +01:00
|
|
|
else if (greenThumbStage == 1) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData(CropState.VERY_SMALL.getData());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.block.setData(CropState.GERMINATED.getData());
|
|
|
|
}
|
2012-03-11 04:21:53 +01:00
|
|
|
}
|
2012-11-10 01:37:12 +01:00
|
|
|
else {
|
|
|
|
this.block.setData(CropState.MEDIUM.getData());
|
2012-03-11 04:21:53 +01:00
|
|
|
}
|
2012-11-10 01:37:12 +01:00
|
|
|
break;
|
|
|
|
case NETHER_WARTS:
|
|
|
|
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
2013-01-02 02:10:16 +01:00
|
|
|
if (greenThumbStage == 3) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData((byte) 2);
|
|
|
|
}
|
2013-01-02 02:10:16 +01:00
|
|
|
else if (greenThumbStage == 2) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData((byte) 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.block.setData((byte) 0);
|
|
|
|
}
|
2012-03-11 04:21:53 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData((byte) 2);
|
2012-03-11 04:21:53 +01:00
|
|
|
}
|
2012-11-10 01:37:12 +01:00
|
|
|
break;
|
|
|
|
case COCOA:
|
|
|
|
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
2013-01-02 02:10:16 +01:00
|
|
|
if (greenThumbStage == 3) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
|
|
|
}
|
2013-01-02 02:10:16 +01:00
|
|
|
else if (greenThumbStage == 2) {
|
2012-11-10 01:37:12 +01:00
|
|
|
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.block.setData((byte) (this.block.getData() ^ ((byte) 0xc)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
|
|
|
}
|
|
|
|
break;
|
2012-12-24 18:35:17 +01:00
|
|
|
default:
|
|
|
|
break;
|
2012-03-11 04:21:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|