mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 21:27:44 +01:00
parent
2ae36e737f
commit
ac1128506e
@ -0,0 +1,31 @@
|
||||
package world.bentobox.bentobox.listeners.flags.worldsettings;
|
||||
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
/**
|
||||
* Handles {@link Flags#OFFLINE_GROWTH} flag.
|
||||
* @author Poslovitch
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class OfflineGrowthListener extends FlagListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onCropGrow(BlockGrowEvent e) {
|
||||
if (!getIWM().inWorld(e.getBlock().getWorld()) || Flags.OFFLINE_GROWTH.isSetForWorld(e.getBlock().getWorld())) {
|
||||
// We do not want to run any check if this is not the right world or if it is allowed.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e.getBlock() instanceof Ageable)) {
|
||||
// Do nothing if the block is not "ageable" (and therefore not a crop).
|
||||
return;
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ import world.bentobox.bentobox.listeners.flags.worldsettings.ItemFrameListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.LiquidsFlowingOutListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.NaturalSpawningOutsideRangeListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.ObsidianScoopingListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineGrowthListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineRedstoneListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.PistonPushListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.RemoveMobsListener;
|
||||
@ -322,6 +323,14 @@ public final class Flags {
|
||||
public static final Flag OFFLINE_REDSTONE = new Flag.Builder("OFFLINE_REDSTONE", Material.COMPARATOR).type(Type.WORLD_SETTING)
|
||||
.listener(new OfflineRedstoneListener()).defaultSetting(true).build();
|
||||
|
||||
/**
|
||||
* If disabled, prevents crops/plants from growing on islands whose members are offline.
|
||||
* @since 1.4.0
|
||||
* @see OfflineGrowthListener
|
||||
*/
|
||||
public static final Flag OFFLINE_GROWTH = new Flag.Builder("OFFLINE_GROWTH", Material.WHEAT_SEEDS).type(Type.WORLD_SETTING)
|
||||
.listener(new OfflineGrowthListener()).defaultSetting(true).build();
|
||||
|
||||
public static final Flag CLEAN_SUPER_FLAT = new Flag.Builder("CLEAN_SUPER_FLAT", Material.BEDROCK).type(Type.WORLD_SETTING)
|
||||
.listener(new CleanSuperFlatListener()).build();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user