im making a plugin that gives you nausea for about 10 seconds if the player gets regeneration

Discussion in 'Plugin Development' started by kyue_, Aug 23, 2020.

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

    kyue_

    im making a plugin that gives you nausea for about 10 seconds if the player gets regeneration

    I originally hopped to use .getPotionEffects and .addPotionEffects but I was having issues with static and non static references or something so I switched to onConsume(PlayerItemConsumeEvent). I still cant get it to work. heres my code:
    Code:
    public class vodkaplugin {
    
    }
        public class Main extends JavaPlugin implements Listener {
    
        @Override
        public void onEnable() {
        Bukkit.getPluginManager().registerEvents(onConsume, this);
        }
    
        @EventHandler
        public void onConsume(PlayerItemConsumeEvent e) {
            if (e.getItem().equals(new ItemStack(Material.POTION, (byte) 9))) {
                e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 60, 3, true));
                }
        }
        }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @kyue_ Why do you have a class in a class?
    And you register the class, not the function.
     
  3. Offline

    kyue_

    im not sure why I had a class in a class, I fixed that and I got help on the javahelp sub saying to replace the first this with the listener onConsume. it looked like this b4:
    Bukkit.getPluginManager().registerEvents(this, this);

    @timtower

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 23, 2020
  4. Offline

    timtower Administrator Administrator Moderator

    @kyue_ That is correct, that is how it should be
     
  5. Offline

    kyue_

    thanks bro
     
Thread Status:
Not open for further replies.

Share This Page