Browse Source

Fix GT replant sometimes planting floating plants

nossr50 4 years ago
parent
commit
8f6819edc5

+ 4 - 1
Changelog.txt

@@ -1,10 +1,13 @@
 Version 2.1.156
 Version 2.1.156
+    Fixed a bug where Green Thumb would replant blocks floating in the air
     Fixed a bug where the admin and party chat toggles in chat.yml didn't function as intended
     Fixed a bug where the admin and party chat toggles in chat.yml didn't function as intended
+    * Fixed a bug where Master Angler rank 1 level requirement was set too high (default configs)
     Added some errors that trigger if a plugin hooking into mcMMO is grabbing leaderboards for child skills through our SQL/FlatFile class (which don't exist)
     Added some errors that trigger if a plugin hooking into mcMMO is grabbing leaderboards for child skills through our SQL/FlatFile class (which don't exist)
     mcMMO will automatically fix some errors in logic for user settings in skillranks.yml
     mcMMO will automatically fix some errors in logic for user settings in skillranks.yml
     Corrected some logic errors when checking for oddities in skillranks.yml
     Corrected some logic errors when checking for oddities in skillranks.yml
-    * Fixed a bug where Master Angler rank 1 was set too high (default configs)
     Removed incorrect translations of Master Angler from various locales
     Removed incorrect translations of Master Angler from various locales
+    Modified Master Angler stat lines in /fishing
+    Updated Green Thumb description to mention that it needs a hoe
 
 
     NOTES:
     NOTES:
     You don't need to touch your config files, this update handles everything automagically.
     You don't need to touch your config files, this update handles everything automagically.

+ 64 - 2
src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java

@@ -11,8 +11,11 @@ import org.bukkit.block.BlockState;
 import org.bukkit.block.data.Ageable;
 import org.bukkit.block.data.Ageable;
 import org.bukkit.block.data.BlockData;
 import org.bukkit.block.data.BlockData;
 import org.bukkit.block.data.Directional;
 import org.bukkit.block.data.Directional;
+import org.bukkit.block.data.type.Cocoa;
 import org.bukkit.event.block.BlockBreakEvent;
 import org.bukkit.event.block.BlockBreakEvent;
 import org.bukkit.scheduler.BukkitRunnable;
 import org.bukkit.scheduler.BukkitRunnable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 
 public class DelayedCropReplant extends BukkitRunnable {
 public class DelayedCropReplant extends BukkitRunnable {
 
 
@@ -21,7 +24,7 @@ public class DelayedCropReplant extends BukkitRunnable {
     private final Material cropMaterial;
     private final Material cropMaterial;
     private boolean wasImmaturePlant;
     private boolean wasImmaturePlant;
     private final BlockBreakEvent blockBreakEvent;
     private final BlockBreakEvent blockBreakEvent;
-    private BlockFace cropFace;
+    private @Nullable BlockFace cropFace;
 
 
     /**
     /**
      * Replants a crop after a delay setting the age to desiredCropAge
      * Replants a crop after a delay setting the age to desiredCropAge
@@ -48,6 +51,7 @@ public class DelayedCropReplant extends BukkitRunnable {
     public void run() {
     public void run() {
         Block cropBlock = cropLocation.getBlock();
         Block cropBlock = cropLocation.getBlock();
         BlockState currentState = cropBlock.getState();
         BlockState currentState = cropBlock.getState();
+        PlantAnchorType plantAnchorType = PlantAnchorType.NORMAL;
 
 
         //Remove the metadata marking the block as recently replanted
         //Remove the metadata marking the block as recently replanted
         new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(mcMMO.p, 10);
         new markPlantAsOld(blockBreakEvent.getBlock().getLocation()).runTaskLater(mcMMO.p, 10);
@@ -81,6 +85,10 @@ public class DelayedCropReplant extends BukkitRunnable {
                 directional.setFacing(cropFace);
                 directional.setFacing(cropFace);
 
 
                 newState.setBlockData(directional);
                 newState.setBlockData(directional);
+
+                if(newData instanceof Cocoa) {
+                    plantAnchorType = PlantAnchorType.COCOA;
+                }
             }
             }
 
 
             //Age the crop
             //Age the crop
@@ -89,15 +97,69 @@ public class DelayedCropReplant extends BukkitRunnable {
             newState.setBlockData(ageable);
             newState.setBlockData(ageable);
 
 
 
 
-            newState.update(true);
+            newState.update(true, true);
 
 
             //Play an effect
             //Play an effect
             ParticleEffectUtils.playGreenThumbEffect(cropLocation);
             ParticleEffectUtils.playGreenThumbEffect(cropLocation);
+            new PhysicsBlockUpdate(newState.getBlock(), cropFace, plantAnchorType).runTaskLater(mcMMO.p, 1);
+        }
+    }
+
+    private enum PlantAnchorType {
+        NORMAL,
+        COCOA
+    }
 
 
+    private static class PhysicsBlockUpdate extends BukkitRunnable {
+        private final Block plantBlock;
+        private final PlantAnchorType plantAnchorType;
+        private BlockFace plantFace;
+
+        private PhysicsBlockUpdate(@NotNull Block plantBlock, @Nullable BlockFace plantFace, @NotNull PlantAnchorType plantAnchorType) {
+            this.plantBlock = plantBlock;
+            this.plantAnchorType = plantAnchorType;
+
+            if(plantFace != null) {
+                this.plantFace = plantFace;
+            }
         }
         }
 
 
+        @Override
+        public void run() {
+            //Update neighbors
+            switch (plantAnchorType) {
+                case COCOA:
+                    checkPlantIntegrity(plantFace);
+                    break;
+                case NORMAL:
+                    checkPlantIntegrity(BlockFace.DOWN);
+                    break;
+            }
+        }
+
+        private void checkPlantIntegrity(@NotNull BlockFace blockFace) {
+            Block neighbor = plantBlock.getRelative(blockFace);
+
+            if(plantAnchorType == PlantAnchorType.COCOA) {
+                if(!neighbor.getType().toString().toLowerCase().contains("jungle")) {
+                    plantBlock.breakNaturally();
+                }
+            } else {
+                switch (neighbor.getType()) {
+                    case AIR:
+                    case CAVE_AIR:
+                    case WATER:
+                    case LAVA:
+                        plantBlock.breakNaturally();
+                        break;
+                    default:
+                }
+            }
+        }
     }
     }
 
 
+
+
     private static class markPlantAsOld extends BukkitRunnable {
     private static class markPlantAsOld extends BukkitRunnable {
 
 
         private final Location cropLoc;
         private final Location cropLoc;

+ 1 - 1
src/main/java/com/gmail/nossr50/util/text/StringUtils.java

@@ -28,7 +28,7 @@ public class StringUtils {
     }
     }
 
 
     public static String ticksToSeconds(double ticks) {
     public static String ticksToSeconds(double ticks) {
-        return shortDecimal.format(ticks / 20) + "s";
+        return shortDecimal.format(ticks / 20);
     }
     }
 
 
 
 

+ 3 - 3
src/main/resources/locale/locale_en_US.properties

@@ -252,8 +252,8 @@ Fishing.SubSkill.FishermansDiet.Description=Improves hunger restored from fished
 Fishing.SubSkill.FishermansDiet.Stat=Fisherman's Diet:&a Rank {0}
 Fishing.SubSkill.FishermansDiet.Stat=Fisherman's Diet:&a Rank {0}
 Fishing.SubSkill.MasterAngler.Name=Master Angler
 Fishing.SubSkill.MasterAngler.Name=Master Angler
 Fishing.SubSkill.MasterAngler.Description=Fish are caught more frequently
 Fishing.SubSkill.MasterAngler.Description=Fish are caught more frequently
-Fishing.SubSkill.MasterAngler.Stat=Fishing minimum wait time bonus: &a-{0} seconds
-Fishing.SubSkill.MasterAngler.Stat.Extra=Fishing maximum wait time bonus: &a-{0} seconds
+Fishing.SubSkill.MasterAngler.Stat=Fishing min wait time reduction: &a-{0} seconds
+Fishing.SubSkill.MasterAngler.Stat.Extra=Fishing max wait time reduction: &a-{0} seconds
 Fishing.SubSkill.IceFishing.Name=Ice Fishing
 Fishing.SubSkill.IceFishing.Name=Ice Fishing
 Fishing.SubSkill.IceFishing.Description=Allows you to fish in icy biomes
 Fishing.SubSkill.IceFishing.Description=Allows you to fish in icy biomes
 Fishing.SubSkill.IceFishing.Stat=Ice Fishing
 Fishing.SubSkill.IceFishing.Stat=Ice Fishing
@@ -274,7 +274,7 @@ Herbalism.SubSkill.GreenTerra.Name=Green Terra
 Herbalism.SubSkill.GreenTerra.Description=Spread the Terra, 3x Drops, Boosts Green Thumb
 Herbalism.SubSkill.GreenTerra.Description=Spread the Terra, 3x Drops, Boosts Green Thumb
 Herbalism.SubSkill.GreenTerra.Stat=Green Terra Duration
 Herbalism.SubSkill.GreenTerra.Stat=Green Terra Duration
 Herbalism.SubSkill.GreenThumb.Name=Green Thumb
 Herbalism.SubSkill.GreenThumb.Name=Green Thumb
-Herbalism.SubSkill.GreenThumb.Description=Auto-Plants crops when harvesting
+Herbalism.SubSkill.GreenThumb.Description=Auto-Plants crops when harvesting with hoe
 Herbalism.SubSkill.GreenThumb.Stat=Green Thumb Chance
 Herbalism.SubSkill.GreenThumb.Stat=Green Thumb Chance
 Herbalism.SubSkill.GreenThumb.Stat.Extra=Green Thumb Stage: &a Crops grow in stage {0}
 Herbalism.SubSkill.GreenThumb.Stat.Extra=Green Thumb Stage: &a Crops grow in stage {0}
 Herbalism.Effect.4=Green Thumb (Blocks)
 Herbalism.Effect.4=Green Thumb (Blocks)