How to make PlayerEggThrowEvent register when egg is thrown

Discussion in 'Plugin Development' started by jstN0body, Mar 27, 2020.

Thread Status:
Not open for further replies.
  1. Offline


    So basically what is happening and I don't know if this is supposed to happen, minecraft is only triggering the event of a player throwing an egg when it hits something, but I want it to trigger when the egg is thrown does anyone know of a way to do that? (Yes this is a super random plugin but I don't care)
    package me.jstN0body.rideableEggs.eggEvent;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Egg;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerEggThrowEvent;
    import me.jstN0body.rideableEggs.Main;
    public class OnThrowEgg implements Listener {
        private Main plugin;
        public OnThrowEgg(Main plugin) {
            this.plugin = plugin;
            Bukkit.getPluginManager().registerEvents(this, plugin);
        public void onEggThrown(PlayerEggThrowEvent event) {
            System.out.println("Egg was thrown");
            Player player = event.getPlayer();
            Egg egg = event.getEgg();
            if (egg.isDead() == true) {
  2. Offline


    Maybe listen to PlayerInteractEvent and check if the item equals an egg
  3. Offline


    @jstN0body I think the correct event for this is "ProjectileLaunchEvent", just check if the projectile is an instanceof Egg.
  4. Offline


  5. Offline


    I'd also add that you shouldn't suppress things the compiler bitches about. You're better off resolving the issues.
Thread Status:
Not open for further replies.

Share This Page