Stop chickens from laying eggs

Discussion in 'Archived: Plugin Requests' started by lauris3722, Feb 1, 2012.

  1. Offline

    lauris3722

    Hello..
    I have a plugin, that gives random items when you crush the egg, but there's the problem. Chicken Farms are against the server rules in my server, but players are still making them to get eggs. I could fix that by simply disabling chickens from laying eggs, but I need a plugin for that.. Anyone?
    Thanks.

    Edit: Players will be able to still get eggs from killing the chicken (Custom Drops) or buying in shop.
     
  2. Offline

    AStevensTaylor

    Ok, I'll give this a go.
    ETA 24 Hours.

    Its a tad hackish, Any Devs have any ideas on Event to be called, currently it is onItemSpawn(ItemSpawnEvent event){}

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  3. Offline

    uruhax

    Try using a CreatureSpawnEvent checking if the creature is a chicken and if so cast it to Chicken and use the setBreed(Boolean b) method to disallow it from breeding.

    If you ever have a difficulty finding a certain thing to use with bukkit try finding it on this page: http://jd.bukkit.org/apidocs/
     
  4. Offline

    AStevensTaylor

    I'm not sure why CreatureSpawnEvent is the one I want, I want it to be thrown when an egg is laid, you know the normal egg, not the spawn one.
    It seems like there is no event for when the eggs are laid, perhaps the hackish way will work.

    Ok, I have made it, but I am not sure whether it actually works, Its a tad difficult to test it on a 2GB machine, whith that many mobs. This is BETA: It shouldn't break anything, but I am not responsible for any damage.
    http://dl.dropbox.com/u/25736905/Bukkit Downloads/NoChickenLay-1.0.jar

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  5. Offline

    lauris3722

    Thank you, I will give a try and write feedback.
     
  6. Offline

    AStevensTaylor

    For anyone concerned with the hackish manner it works, here is an extract of the source which the plugin uses to check for egg laying.
     
    AndyMcB1 likes this.
  7. Offline

    lauris3722

    Seems to not work.

    1.1-R3
    2012-02-04_19.44.51.png
     
  8. Offline

    gablank

  9. Offline

    AStevensTaylor

    Dispensers can only 'throw', plugins can also spawn eggs.

    Edit: I have looked through the source from the other plugin, they had the same idea as me, I just used it badly :(, but their plugin won't accommodate for other plugins spawning eggs as items, therefore I have modified mine to accommodate for them.

    Second Edit: Just download using the same link.
     

Share This Page