Browse Source

Fixed bug where Green Terra could possibly activate on crops that
weren't fully grown. Also fixed crop growth rates being checked twice.

GJ 12 years ago
parent
commit
cc6850b37d

+ 3 - 2
Changelog.txt

@@ -13,7 +13,9 @@ Version 1.4.00-dev
  + Added config options for Hylian Luck skill
  + Added config options for Hylian Luck skill
  + Added display values to Unarmed command for Iron Grip
  + Added display values to Unarmed command for Iron Grip
  + Added '/party create <name>' command, use this to create a party
  + Added '/party create <name>' command, use this to create a party
- + Added '/party disband' command, kicks out all members and deletes the party
+ + Added '/party disband' command, kicks out all members and deletes the party
+ = Fixed mod config files loading / generating when they shouldn't have
+ = Fixed bug where Green Terra could activate on crops that weren't fully grown.
  = Fixed several typos relating to locale string display
  = Fixed several typos relating to locale string display
  = Fixed bug where all skill guide headers appeared as "Skillname Guide Guide"
  = Fixed bug where all skill guide headers appeared as "Skillname Guide Guide"
  = Fixed bug where Impact was applied incorrectly due to an inverted method call
  = Fixed bug where Impact was applied incorrectly due to an inverted method call
@@ -162,7 +164,6 @@ Version 1.3.10
  + Added Ability API functions
  + Added Ability API functions
  + Added 50% & 150% XP boost perks
  + Added 50% & 150% XP boost perks
  + Added "lucky" perk for donors
  + Added "lucky" perk for donors
- = Fixed mod config files loading / generating when they shouldn't have
  = Fixed /inspect not working on offline players
  = Fixed /inspect not working on offline players
  = Fixed custom blocks, tools and armors not loading properly
  = Fixed custom blocks, tools and armors not loading properly
  = Fixed duplication bug with sticky pistons
  = Fixed duplication bug with sticky pistons

+ 23 - 33
src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java

@@ -173,13 +173,11 @@ public class Herbalism {
             break;
             break;
 
 
         case CROPS:
         case CROPS:
-            if (data == CropState.RIPE.getData()) {
-                mat = Material.WHEAT;
-                xp = Config.getInstance().getHerbalismXPWheat();
+            mat = Material.WHEAT;
+            xp = Config.getInstance().getHerbalismXPWheat();
 
 
-                if (Permissions.greenThumbWheat(player)) {
-                    greenThumbWheat(block, player, event, plugin);
-                }
+            if (Permissions.greenThumbWheat(player)) {
+                greenThumbWheat(block, player, event, plugin);
             }
             }
             break;
             break;
 
 
@@ -191,13 +189,11 @@ public class Herbalism {
             break;
             break;
 
 
         case NETHER_WARTS:
         case NETHER_WARTS:
-            if (data == (byte) 0x3) {
-                mat = Material.NETHER_STALK;
-                xp = Config.getInstance().getHerbalismXPNetherWart();
+            mat = Material.NETHER_STALK;
+            xp = Config.getInstance().getHerbalismXPNetherWart();
 
 
-                if (Permissions.greenThumbNetherwart(player)) {
-                    greenThumbWheat(block, player, event, plugin);
-                }
+            if (Permissions.greenThumbNetherwart(player)) {
+                greenThumbWheat(block, player, event, plugin);
             }
             }
             break;
             break;
 
 
@@ -246,42 +242,36 @@ public class Herbalism {
             break;
             break;
 
 
         case COCOA:
         case COCOA:
-            CocoaPlant plant = (CocoaPlant) block.getState().getData();
+            mat = type;
+            xp = Config.getInstance().getHerbalismXPCocoa();
 
 
-            if (plant.getSize() == CocoaPlantSize.LARGE) {
-                mat = type;
-                xp = Config.getInstance().getHerbalismXPCocoa();
-
-                if (Permissions.greenThumbCocoa(player)) {
-                    greenThumbWheat(block, player, event, plugin);
-                }
+            if (Permissions.greenThumbCocoa(player)) {
+                greenThumbWheat(block, player, event, plugin);
             }
             }
             break;
             break;
 
 
         case CARROT:
         case CARROT:
-            if (data == CropState.RIPE.getData()) {
-                mat = Material.CARROT;
-                xp = Config.getInstance().getHerbalismXPCarrot();
+            mat = Material.CARROT;
+            xp = Config.getInstance().getHerbalismXPCarrot();
 
 
-
-                if (Permissions.greenThumbCarrots(player)) {
-                    greenThumbWheat(block, player, event, plugin);
-                }
+            if (Permissions.greenThumbCarrots(player)) {
+                greenThumbWheat(block, player, event, plugin);
             }
             }
             break;
             break;
 
 
         case POTATO:
         case POTATO:
-            if (data == CropState.RIPE.getData()) {
-                mat = Material.POTATO;
-                xp = Config.getInstance().getHerbalismXPPotato();
+            mat = Material.POTATO;
+            xp = Config.getInstance().getHerbalismXPPotato();
 
 
-                if (Permissions.greenThumbPotatoes(player)) {
-                    greenThumbWheat(block, player, event, plugin);
-                }
+            if (Permissions.greenThumbPotatoes(player)) {
+                greenThumbWheat(block, player, event, plugin);
             }
             }
             break;
             break;
 
 
         default:
         default:
+            // We REALLY shouldn't have to check this again, given that we check it in the BlockChecks before this function is even called.
+            // Safe to remove?
+
             ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
             ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
 
 
             if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {
             if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {

+ 17 - 4
src/main/java/com/gmail/nossr50/util/BlockChecks.java

@@ -4,7 +4,9 @@ import org.bukkit.CropState;
 import org.bukkit.Material;
 import org.bukkit.Material;
 import org.bukkit.block.Block;
 import org.bukkit.block.Block;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.ItemStack;
+import org.bukkit.material.CocoaPlant;
 import org.bukkit.material.MaterialData;
 import org.bukkit.material.MaterialData;
+import org.bukkit.material.CocoaPlant.CocoaPlantSize;
 
 
 import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.config.mods.CustomBlocksConfig;
 import com.gmail.nossr50.config.mods.CustomBlocksConfig;
@@ -179,7 +181,6 @@ public final class BlockChecks {
         case BROWN_MUSHROOM:
         case BROWN_MUSHROOM:
         case CACTUS:
         case CACTUS:
         case MELON_BLOCK:
         case MELON_BLOCK:
-        case NETHER_WARTS:
         case PUMPKIN:
         case PUMPKIN:
         case RED_MUSHROOM:
         case RED_MUSHROOM:
         case RED_ROSE:
         case RED_ROSE:
@@ -187,16 +188,28 @@ public final class BlockChecks {
         case VINE:
         case VINE:
         case WATER_LILY:
         case WATER_LILY:
         case YELLOW_FLOWER:
         case YELLOW_FLOWER:
-        case COCOA:
-        case CARROT:
-        case POTATO:
             return true;
             return true;
 
 
+        case CARROT:
         case CROPS:
         case CROPS:
+        case POTATO:
             if (block.getData() == CropState.RIPE.getData()) {
             if (block.getData() == CropState.RIPE.getData()) {
                 return true;
                 return true;
             }
             }
+            return false;
+
+        case NETHER_WARTS:
+            if (block.getData() == (byte) 0x3) {
+                return true;
+            }
+            return false;
 
 
+        case COCOA:
+            CocoaPlant plant = (CocoaPlant) block.getState().getData();
+
+            if (plant.getSize() == CocoaPlantSize.LARGE) {
+                return true;
+            }
             return false;
             return false;
 
 
         default:
         default: