diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java
index 3abb3ad1c..e8a24c9aa 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java
@@ -41,6 +41,7 @@ import com.plotsquared.core.plot.flag.implementations.BlockBurnFlag;
import com.plotsquared.core.plot.flag.implementations.BlockIgnitionFlag;
import com.plotsquared.core.plot.flag.implementations.BreakFlag;
import com.plotsquared.core.plot.flag.implementations.CoralDryFlag;
+import com.plotsquared.core.plot.flag.implementations.CropGrowFlag;
import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
@@ -768,7 +769,17 @@ public class BlockEventListener implements Listener {
public void onGrow(BlockGrowEvent event) {
Block block = event.getBlock();
Location location = BukkitUtil.adapt(block.getLocation());
- if (location.isUnownedPlotArea()) {
+
+ PlotArea area = location.getPlotArea();
+ if (area == null) {
+ return;
+ }
+
+ Plot plot = location.getOwnedPlot();
+ if (plot == null || !plot.getFlag(CropGrowFlag.class)) {
+ if (plot != null) {
+ plot.debug("Crop grow event was cancelled because crop-grow = false");
+ }
event.setCancelled(true);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java b/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java
index 4e23c6717..603a85e6f 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/GlobalFlagContainer.java
@@ -36,6 +36,7 @@ import com.plotsquared.core.plot.flag.implementations.BlockedCmdsFlag;
import com.plotsquared.core.plot.flag.implementations.BreakFlag;
import com.plotsquared.core.plot.flag.implementations.ChatFlag;
import com.plotsquared.core.plot.flag.implementations.CoralDryFlag;
+import com.plotsquared.core.plot.flag.implementations.CropGrowFlag;
import com.plotsquared.core.plot.flag.implementations.DenyExitFlag;
import com.plotsquared.core.plot.flag.implementations.DenyTeleportFlag;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
@@ -183,6 +184,7 @@ public final class GlobalFlagContainer extends FlagContainer {
this.addFlag(KeepInventoryFlag.KEEP_INVENTORY_FALSE);
this.addFlag(PreventCreativeCopyFlag.PREVENT_CREATIVE_COPY_FALSE);
this.addFlag(LeafDecayFlag.LEAF_DECAY_TRUE);
+ this.addFlag(CropGrowFlag.CROP_GROW_TRUE);
// Enum Flags
this.addFlag(WeatherFlag.PLOT_WEATHER_FLAG_OFF);
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CropGrowFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CropGrowFlag.java
new file mode 100644
index 000000000..aa4334bc8
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/CropGrowFlag.java
@@ -0,0 +1,46 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * PlotSquared plot management system for Minecraft
+ * Copyright (C) 2021 IntellectualSites
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.plotsquared.core.plot.flag.implementations;
+
+import com.plotsquared.core.configuration.caption.TranslatableCaption;
+import com.plotsquared.core.plot.flag.types.BooleanFlag;
+import org.checkerframework.checker.nullness.qual.NonNull;
+
+public class CropGrowFlag extends BooleanFlag {
+
+ public static final CropGrowFlag CROP_GROW_TRUE = new CropGrowFlag(true);
+ public static final CropGrowFlag CROP_GROW_FALSE = new CropGrowFlag(false);
+
+ private CropGrowFlag(boolean value) {
+ super(value, TranslatableCaption.of("flags.flag_description_crop_grow"));
+ }
+
+ @Override
+ protected CropGrowFlag flagOf(@NonNull Boolean value) {
+ return value ? CROP_GROW_TRUE : CROP_GROW_FALSE;
+ }
+
+}
diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json
index 72915d9f7..e83452510 100644
--- a/Core/src/main/resources/lang/messages_en.json
+++ b/Core/src/main/resources/lang/messages_en.json
@@ -552,6 +552,7 @@
"flags.flag_description_snow_melt": "Set to `true` to allow snow to melt within the plot.",
"flags.flag_description_soil_dry": "Set to `true` to allow soil to dry within the plot.",
"flags.flag_description_coral_dry": "Set to `true` to allow coral blocks to dry within the plot.",
+ "flags.flag_description_crop_grow": "Set to `false` to disable crop growing on the plot",
"flags.flag_description_tamed_attack": "Set to `true` to allow guests to attack tamed animals in the plot.",
"flags.flag_description_tamed_interact": "Set to `true` to allow guests to interact with tamed animals in the plot.",
"flags.flag_description_time": "Set the time in the plot to a fixed value.",