mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 16:41:42 +01:00
Add ability to place glowberry cave vines if planting allowed.
This commit is contained in:
parent
2d44c5dbca
commit
7c3056b0e8
@ -21,7 +21,6 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
@ -81,7 +80,6 @@ public class BreakBlocksListener extends FlagListener {
|
||||
Player p = e.getPlayer();
|
||||
Location l = e.getClickedBlock().getLocation();
|
||||
Material m = e.getClickedBlock().getType();
|
||||
BentoBox.getInstance().logDebug(m);
|
||||
// Check for berry picking
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && (e.getClickedBlock().getType() == Material.CAVE_VINES || e.getClickedBlock().getType() == Material.CAVE_VINES_PLANT)) {
|
||||
if (!((CaveVinesPlant) e.getClickedBlock().getBlockData()).isBerries()) {
|
||||
|
@ -4,6 +4,7 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -15,6 +16,7 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
@ -23,7 +25,8 @@ import world.bentobox.bentobox.lists.Flags;
|
||||
*/
|
||||
public class PlaceBlocksListener extends FlagListener
|
||||
{
|
||||
public static final Set<Material> SEEDS = Set.of(Material.BEETROOT_SEEDS, Material.MELON_SEEDS, Material.WHEAT_SEEDS);
|
||||
public static final Set<Material> SEEDS = Set.of(Material.MELON_SEEDS, Material.WHEAT_SEEDS,
|
||||
Material.SWEET_BERRIES);
|
||||
/**
|
||||
* Check blocks being placed in general
|
||||
*
|
||||
@ -42,8 +45,15 @@ public class PlaceBlocksListener extends FlagListener
|
||||
// Books can only be placed on lecterns and as such are protected by the LECTERN flag.
|
||||
return;
|
||||
}
|
||||
// Glowberries
|
||||
if (e.getItemInHand().getType() == Material.GLOW_BERRIES
|
||||
&& e.getBlock().getRelative(BlockFace.UP).equals(e.getBlockAgainst())) {
|
||||
this.checkIsland(e, e.getPlayer(), e.getBlock().getLocation(), Flags.CROP_PLANTING);
|
||||
return;
|
||||
}
|
||||
// Crops
|
||||
if (against.equals(Material.FARMLAND) && SEEDS.contains(e.getItemInHand().getType())) {
|
||||
if (against.equals(Material.FARMLAND) && (SEEDS.contains(e.getItemInHand().getType())
|
||||
|| Tag.ITEMS_VILLAGER_PLANTABLE_SEEDS.isTagged(e.getItemInHand().getType()))) {
|
||||
this.checkIsland(e, e.getPlayer(), e.getBlock().getLocation(), Flags.CROP_PLANTING);
|
||||
} else {
|
||||
this.checkIsland(e, e.getPlayer(), e.getBlock().getLocation(), Flags.PLACE_BLOCKS);
|
||||
@ -59,6 +69,7 @@ public class PlaceBlocksListener extends FlagListener
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onHangingPlace(final HangingPlaceEvent e)
|
||||
{
|
||||
BentoBox.getInstance().logDebug(e.getEventName());
|
||||
this.checkIsland(e, e.getPlayer(), e.getBlock().getLocation(), Flags.PLACE_BLOCKS);
|
||||
}
|
||||
|
||||
|
@ -674,6 +674,7 @@ public final class Flags {
|
||||
/**
|
||||
* Crop Planting
|
||||
* Controls who gets to plant crops on tilled soil.
|
||||
* Listener is {@link PlaceBlockListener}
|
||||
* @since 1.23.0
|
||||
*/
|
||||
public static final Flag CROP_PLANTING = new Flag.Builder("CROP_PLANTING", Material.PUMPKIN_SEEDS).mode(Flag.Mode.BASIC).type(Type.PROTECTION).build();
|
||||
|
Loading…
Reference in New Issue
Block a user