Alright, i'm back. i need help again.

Discussion in 'Programming' started by Discordgoat, Jul 31, 2020 at 10:24 AM.

  1. So, i'm basically trying to modify a recent plugin i made to shoot end rod particles everywhere on a PlayerItemConsumeEvent. can anyone tell me whats wrong with my code?

    package fasteat;



    import org.bukkit.event.Listener;
    import org.bukkit.Particle;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerBedEnterEvent;
    import org.bukkit.event.player.PlayerItemConsumeEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;


    public final class Events implements Listener {

    @EventHandler
    public void normalLogin(PlayerItemConsumeEvent event) {


    Player p = event.getPlayer();
    p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1));
    p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 300, 0));
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 0));
    p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 100, 100));

    //this part
    public static void onEat(PlayerItemConsumeEvent event1) {
    Player player = event1.getPlayer();
    player.getWorld().spawnParticle(Particle.END_ROD, player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), 50, 0, 0, 0);
    }

    }
    }
     
  2. You can't put a listener in another listener... also you forgot @EventHandler, also wrong section: use spigot plugin development.
     
  3. alrighty then. thanks for the tips. ill move over to spigot plugin development. also, thanks!
    should i delete this then?
     
  4. I believe you can just report it and a mod will move it for you.
     
  5. Strahan

    Benefactor

    That aside, why are you trying that anyway? They both are the same event, so there is absolutely no need for that. Just perform all the functions in the same event.

    Code (Text):
    @EventHandler
    public void normalLogin(PlayerItemConsumeEvent event) {
      Player p = event.getPlayer();
      p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 1));
      p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 300, 0));
      p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 0));
      p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 100, 100));
      player.getWorld().spawnParticle(Particle.END_ROD, player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), 50, 0, 0, 0);
    }
    Also, not that it makes any difference, but why did you name the event function "normalLogin"? Consuming has nothing to do with logging in. Though as I said, it makes not a difference. There are several plugins of mine where it was being a pain in my rear that you'll see things like public void eatShitandDie(PlayerInteractEvent e) lol