Is it possible to design a plugin that prevents crops from growing if there are blocks above them? I want a plugin for my server that limits the ability to grow crops unless their is only air above them. The reason for this is that I don't want players to be able to build tiers of farms on top of each other or underground farms, since it doesn't make sense that crops grow without sunlight. I figured the easiest way to limit the capability would be to implement some system in which crops can only grow if there is no block above them. I was just wondering if this (or a similar functionality that would accomplish my goal) was possible, and if so, if someone could undertake the project or direct me to something that would accomplish the same function. Thank you!
Working on this now. Here it is. If you ever need any updates or anything, PM me. Also, I have not tested this at all so it might not work Source if anyone is interested Code:java package me.C0nsole.NoUndergroundGrowth; import org.bukkit.Location;import org.bukkit.World;import org.bukkit.block.Block;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.BlockGrowEvent;import org.bukkit.plugin.java.JavaPlugin; public class NoUndergroundGrowth extends JavaPlugin implements Listener{ @Overridepublic void onDisable() {System.out.println("[NoUndergroundGrowth] v1.0 enabled");} @Overridepublic void onEnable() {System.out.println("[NoUndergroundGrowth] v1.0 disabled");} @EventHandlerpublic void onBlockGrow(BlockGrowEvent event){ Block block = event.getBlock(); World world = block.getWorld(); Location loc = block.getLocation(); double y = loc.getY(); double highesty = world.getHighestBlockYAt(loc); if(highesty > y){ event.setCancelled(true); }} } EDIT by Moderator: merged posts, please use the edit button instead of double posting.