mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Add leaf-decay flag
Stop leaves from decaying.
This commit is contained in:
parent
70fb86a1c3
commit
4f60da292a
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<LeafDecayFlag> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -653,6 +653,7 @@
|
||||
"flags.flag_description_keep": "<gray>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).</gray>",
|
||||
"flags.flag_description_keep_inventory": "<gray>Prevents players from dropping their items when they die inside of the plot.</gray>",
|
||||
"flags.flag_description_prevent_creative_copy": "<gray>Prevents people from copying item NBT data in the plot unless they're added as members.</gray>",
|
||||
"flags.flag_description_leaf_decay": "<gray>Set to `false` to prevent leaves from decaying.",
|
||||
|
||||
"flags.flag_error_boolean": "<prefix>Flag value must be a boolean (true | false).",
|
||||
"flags.flag_error_enum": "<prefix>Must be one of: <list>",
|
||||
|
Loading…
Reference in New Issue
Block a user