GreenThumbTimer.java 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.gmail.nossr50.skills.herbalism;
  2. import org.bukkit.CropState;
  3. import org.bukkit.Material;
  4. import org.bukkit.block.Block;
  5. import com.gmail.nossr50.config.AdvancedConfig;
  6. import com.gmail.nossr50.datatypes.PlayerProfile;
  7. import com.gmail.nossr50.skills.utilities.AbilityType;
  8. import com.gmail.nossr50.skills.utilities.SkillType;
  9. public class GreenThumbTimer implements Runnable {
  10. private Block block;
  11. private PlayerProfile profile;
  12. private Material type;
  13. public GreenThumbTimer(Block block, PlayerProfile profile, Material material) {
  14. this.block = block;
  15. this.profile = profile;
  16. this.type = material;
  17. }
  18. @Override
  19. public void run() {
  20. if (this.block.getType() != this.type) {
  21. this.block.setType(this.type);
  22. }
  23. int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM);
  24. int greenThumbStage = (int) ((double) skillLevel / (double) AdvancedConfig.getInstance().getGreenThumbStageChange());
  25. if (greenThumbStage > 4) {
  26. greenThumbStage = 4;
  27. }
  28. switch(this.type) {
  29. case CROPS:
  30. case CARROT:
  31. case POTATO:
  32. //This replants the wheat at a certain stage in development based on Herbalism Skill
  33. if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
  34. if (greenThumbStage == 3) {
  35. this.block.setData(CropState.MEDIUM.getData());
  36. }
  37. else if (greenThumbStage == 2) {
  38. this.block.setData(CropState.SMALL.getData());
  39. }
  40. else if (greenThumbStage == 1) {
  41. this.block.setData(CropState.VERY_SMALL.getData());
  42. }
  43. else {
  44. this.block.setData(CropState.GERMINATED.getData());
  45. }
  46. }
  47. else {
  48. this.block.setData(CropState.MEDIUM.getData());
  49. }
  50. break;
  51. case NETHER_WARTS:
  52. if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
  53. if (greenThumbStage == 3) {
  54. this.block.setData((byte) 2);
  55. }
  56. else if (greenThumbStage == 2) {
  57. this.block.setData((byte) 1);
  58. }
  59. else {
  60. this.block.setData((byte) 0);
  61. }
  62. }
  63. else {
  64. this.block.setData((byte) 2);
  65. }
  66. break;
  67. case COCOA:
  68. if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
  69. if (greenThumbStage == 3) {
  70. this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
  71. }
  72. else if (greenThumbStage == 2) {
  73. this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
  74. }
  75. else {
  76. this.block.setData((byte) (this.block.getData() ^ ((byte) 0xc)));
  77. }
  78. }
  79. else {
  80. this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
  81. }
  82. break;
  83. default:
  84. break;
  85. }
  86. }
  87. }