2012-03-10 22:21:53 -05:00
|
|
|
package com.gmail.nossr50.runnables;
|
|
|
|
|
2012-03-13 03:00:49 -04:00
|
|
|
import org.bukkit.CropState;
|
2012-03-10 22:21:53 -05:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
|
2012-03-27 02:33:35 -04:00
|
|
|
import com.gmail.nossr50.datatypes.AbilityType;
|
2012-03-10 22:21:53 -05:00
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
|
|
|
|
|
|
public class GreenThumbTimer implements Runnable {
|
|
|
|
private Block block;
|
2012-07-03 10:04:04 -04:00
|
|
|
private PlayerProfile profile;
|
2012-11-09 16:37:12 -08:00
|
|
|
private Material type;
|
2012-03-10 22:21:53 -05:00
|
|
|
|
2012-11-09 16:37:12 -08:00
|
|
|
public GreenThumbTimer(Block block, PlayerProfile profile, Material material) {
|
2012-03-10 22:21:53 -05:00
|
|
|
this.block = block;
|
2012-07-03 10:04:04 -04:00
|
|
|
this.profile = profile;
|
2012-11-09 16:37:12 -08:00
|
|
|
this.type = material;
|
2012-03-10 22:21:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2012-11-09 16:37:12 -08:00
|
|
|
if(this.block.getType() != this.type)
|
|
|
|
this.block.setType(this.type);
|
2012-03-10 22:21:53 -05:00
|
|
|
|
2012-11-09 16:37:12 -08: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)) {
|
|
|
|
if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
|
|
|
this.block.setData(CropState.MEDIUM.getData());
|
|
|
|
}
|
|
|
|
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
|
|
|
this.block.setData(CropState.SMALL.getData());
|
|
|
|
}
|
|
|
|
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 200) {
|
|
|
|
this.block.setData(CropState.VERY_SMALL.getData());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.block.setData(CropState.GERMINATED.getData());
|
|
|
|
}
|
2012-03-10 22:21:53 -05:00
|
|
|
}
|
2012-11-09 16:37:12 -08:00
|
|
|
else {
|
|
|
|
this.block.setData(CropState.MEDIUM.getData());
|
2012-03-10 22:21:53 -05:00
|
|
|
}
|
2012-11-09 16:37:12 -08:00
|
|
|
break;
|
|
|
|
case NETHER_WARTS:
|
|
|
|
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
|
|
|
if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
|
|
|
this.block.setData((byte) 2);
|
|
|
|
}
|
|
|
|
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
|
|
|
this.block.setData((byte) 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.block.setData((byte) 0);
|
|
|
|
}
|
2012-03-10 22:21:53 -05:00
|
|
|
}
|
|
|
|
else {
|
2012-11-09 16:37:12 -08:00
|
|
|
this.block.setData((byte) 2);
|
2012-03-10 22:21:53 -05:00
|
|
|
}
|
2012-11-09 16:37:12 -08:00
|
|
|
break;
|
|
|
|
case COCOA:
|
|
|
|
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
|
|
|
if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
|
|
|
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
|
|
|
}
|
|
|
|
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
|
|
|
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-03-10 22:21:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|