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 863c786df..baa63254c 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java
@@ -48,6 +48,7 @@ import com.plotsquared.core.plot.flag.implementations.IceFormFlag;
import com.plotsquared.core.plot.flag.implementations.IceMeltFlag;
import com.plotsquared.core.plot.flag.implementations.InstabreakFlag;
import com.plotsquared.core.plot.flag.implementations.KelpGrowFlag;
+import com.plotsquared.core.plot.flag.implementations.LeafDecayFlag;
import com.plotsquared.core.plot.flag.implementations.LiquidFlowFlag;
import com.plotsquared.core.plot.flag.implementations.MycelGrowFlag;
import com.plotsquared.core.plot.flag.implementations.PlaceFlag;
@@ -96,6 +97,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.EntityBlockFormEvent;
+import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.material.Directional;
import org.bukkit.projectiles.BlockProjectileSource;
@@ -1082,4 +1084,23 @@ public class BlockEventListener implements Listener {
}
}
}
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onLeavesDecay(LeavesDecayEvent event) {
+ Block block = event.getBlock();
+ Location location = BukkitUtil.adapt(block.getLocation());
+
+ PlotArea area = location.getPlotArea();
+ if (area == null) {
+ return;
+ }
+
+ Plot plot = location.getOwnedPlot();
+ if (plot == null || !plot.getFlag(LeafDecayFlag.class)) {
+ if (plot != null) {
+ plot.debug("Leaf decaying was cancelled because leaf-decay = true");
+ }
+ 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 d71c09f33..d068fb3d1 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
@@ -68,6 +68,7 @@ import com.plotsquared.core.plot.flag.implementations.ItemDropFlag;
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
import com.plotsquared.core.plot.flag.implementations.KeepInventoryFlag;
import com.plotsquared.core.plot.flag.implementations.KelpGrowFlag;
+import com.plotsquared.core.plot.flag.implementations.LeafDecayFlag;
import com.plotsquared.core.plot.flag.implementations.LiquidFlowFlag;
import com.plotsquared.core.plot.flag.implementations.MiscBreakFlag;
import com.plotsquared.core.plot.flag.implementations.MiscCapFlag;
@@ -187,6 +188,7 @@ public final class GlobalFlagContainer extends FlagContainer {
this.addFlag(MiscInteractFlag.MISC_INTERACT_FALSE);
this.addFlag(KeepInventoryFlag.KEEP_INVENTORY_FALSE);
this.addFlag(PreventCreativeCopyFlag.PREVENT_CREATIVE_COPY_FALSE);
+ this.addFlag(LeafDecayFlag.LEAF_DECAY_TRUE);
// Enum Flags
this.addFlag(WeatherFlag.PLOT_WEATHER_FLAG_OFF);
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LeafDecayFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LeafDecayFlag.java
new file mode 100644
index 000000000..e3903cee1
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/LeafDecayFlag.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 javax.annotation.Nonnull;
+
+public class LeafDecayFlag extends BooleanFlag {
+
+ public static final LeafDecayFlag LEAF_DECAY_TRUE = new LeafDecayFlag(true);
+ public static final LeafDecayFlag LEAF_DECAY_FALSE = new LeafDecayFlag(false);
+
+ private LeafDecayFlag(boolean value) {
+ super(value, TranslatableCaption.of("flags.flag_description_leaf_decay"));
+ }
+
+ @Override protected LeafDecayFlag flagOf(@Nonnull Boolean value) {
+ return value ? LEAF_DECAY_TRUE : LEAF_DECAY_FALSE;
+ }
+
+}
diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json
index 6b3bd8a52..6ffe0ccc0 100644
--- a/Core/src/main/resources/lang/messages_en.json
+++ b/Core/src/main/resources/lang/messages_en.json
@@ -653,6 +653,7 @@
"flags.flag_description_keep": "Prevents the plot from expiring. Can be set to: true, false, the number of milliseconds to keep the plot for or a timestamp (3w 2d 5h).",
"flags.flag_description_keep_inventory": "Prevents players from dropping their items when they die inside of the plot.",
"flags.flag_description_prevent_creative_copy": "Prevents people from copying item NBT data in the plot unless they're added as members.",
+ "flags.flag_description_leaf_decay": "Set to `false` to prevent leaves from decaying.",
"flags.flag_error_boolean": "Flag value must be a boolean (true | false).",
"flags.flag_error_enum": "Must be one of: ",