Development Assistance Error, Eclipse is suggesting me to "Rename in file"

Discussion in 'Plugin Help/Development/Requests' started by MaskedPigman, Feb 19, 2015.

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

    MaskedPigman

    Hello, there! Here is my code.
    Code:
        @EventHandler
        public void onSneakEvent(PlayerToggleSneakEvent event) {
            Player p = event.getPlayer();
            if (p.isSneaking()) {
                p.addPotionEffect(PotionEffectType.INVISIBILITY, 1, 0);
            }
            else if (p.isSneaking()) {
                p.removePotionEffect(PotionEffectType.INVISIBILITY);
            }
        }
    I only have one error, and it's on this line:
    Code:
    p.addPotionEffect(PotionEffectType.INVISIBILITY, 1, 0);
    It's underlining addPotionEffect in red, and Eclipse is telling me to "rename in file". What does this mean?

    P.S. I'm a noob, so there may be other things not working properly. This error may be the only one Eclipse is giving me, but everything else still might not work.

    Thanks!
     
  2. Offline

    Gater12

    @MaskedPigman
    There is not a method defined to take in what you just supplied as parameters. The parameter required is PotionEffect. You insert your three parameters into the constructor of PotionEffect when you are creating the PotionEffect object. (Which you pass into addPotionEffect)
     
  3. Offline

    MaskedPigman

    @Gater12
    So, I would replace PotionEffectType with PotionEffect?
     
  4. Offline

    pie_flavor

    @MaskedPigman
    Code:
    p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1, 0));
     
  5. Offline

    MaskedPigman

    @pie_flavor
    Thank you! Eclipse is no longer giving me any errors, but when I sneak, I don't turn invisible. My plugin.yml has no problems, and I made sure I saved the code.
     
  6. Offline

    pie_flavor

    @MaskedPigman In pseudo code, here's what you're saying.
    Code:
    if the player is sneaking
       give them invisibility
    or else if the player is sneaking
       remove the invisibility
    I think there's a '!' that you're missing before the argument to the second if.
    Also, have you written in your onEnable()
    Code:
    getServer().getPluginManager().registerEvents(listener, plugin);
     
Thread Status:
Not open for further replies.

Share This Page