Detect Sunlight ? Prevent underground farming

Discussion in 'Archived: Plugin Requests' started by H4Mm3r, Dec 29, 2011.

Thread Status:
Not open for further replies.
  1. Hello,

    I'm admin of an RP server, and economy is very important. I would like to know if it was possible to prevent underground farming by detecting the sunlight and stop vegetables growning if not under the sunlight ?

    Thanks a lot !
     
  2. Offline

    tomjw64

    I've tried to make this plugin for you. Since there is no way of detecting if the light reaching crops is from sunlight, the way I designed this is that every time that a plant tries to grow,it checks if there are blocks above it that block light. If there is, it prevents the crop from growing. I haven't tested it, so tell me if it works.

    <Edit by Moderator: Redacted mediafire url>

    If it does work, but you want some modification done, just let me know with a PM or reply
     
    Last edited by a moderator: Nov 11, 2016
  3. Offline

    Daniel Heppner

    Just check to see if every block above it is air.
     
    Last edited by a moderator: Nov 11, 2016
  4. Offline

    tomjw64

    It's almost that simple, and that is what I pretty much did, except you also have to account for transparent blocks.
     
  5. Offline

    Syd

  6. Offline

    Daniel Heppner

    Very good point. The only transparent blocks you need to check for is glass and iron bars, glass panes, signs, torches, redstone torches, levers, buttons... holy crap. A lot more than I thought.
     
  7. Thanks for all those answers ! I will try it right now !!!

    The AntiUGFarm don't prevent from growing if someone place the bloc and isolate it from the sun after, isn't it ?


    The SunGrow seems to be the one I expected, but, if we could choose which bloc not to check, it could be really cool ! (to let crop growing under leaves roof...)

    EDIT :
    2011-12-30 12:43:23 [SEVERE] Could not load 'plugins/SunGrow.jar' in folder 'plu
    gins':
    java.lang.UnsupportedClassVersionError: me/tomjw64/SunGrow/SunGrow : Unsupported
    major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
    1)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:36)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:24)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:170)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:215)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:136)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:151)
    at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:127)
    at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigur
    ationManager.java:52)
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)

    I'm using CB 1597.
     
  8. Offline

    Syd

    Thats right, but now as you say it I should update my Plugin as soon as possible. (I´m currently at vacations^^)

    Edit: It seems like there is only onStructureGrow which seems to be only for Trees and Huge Mushrooms. Don't know if weath is included to this, but I can't test it until I´m back at home.
     
  9. Really need it for my project :D
    Try not to forget :D
    Thank you very much !!!

    PS (I will remember you :D when do you go back home ? :))
     
  10. Offline

    tomjw64

    This means that you don't have JRE7 on your computer. But anyways, looks like your found a decent plugin.
     
  11. That's right, no stable packet for jre7 on Debian's repositories !
     
  12. Offline

    Syd

    I´ll be back at 2nd Jan 2012.

    @tomjw64
    I saw you used the onStructureGrow Event in your plugin.
    Have you tested it with weath? If yes: does it work?
     
  13. Offline

    tomjw64

    did you decompile the .jar? how do you do that?
    But idk, i never tested it, but I would assume it works for wheat. Sorry I can't help much.
     
  14. Offline

    Syd

    I just opend the jar with winrar and the class file with notepad.
    Not the sourcecode, but it's enough to see the used event.^^
     
  15. Hello, I reopen this thread because I'm still needing such a plugin.

    Any idea ?

    With AntiUGFarm, the players can't place the block, but what if they plant sometinhg and put some blocks after it ?

    Thanks in advance !
     
  16. Offline

    AndyMcB1

    Does the other plugin not work?
     
  17. Offline

    Jade

    Locked. Necro.
     
Thread Status:
Not open for further replies.

Share This Page