need help adding a potion effect

Discussion in 'Plugin Development' started by KingMagnus, Sep 5, 2012.

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

    KingMagnus

    I'm trying to add a potion effect when sending a command but when I do it doesn't respond at all
    Code:
    if(cmd.getName().equalsIgnoreCase("Abilityspeed")){
                if(args.length== 0)   
                    player.sendMessage(ChatColor.BLUE + "Super Speed activated");
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,7200,4));
                if(player.getServer().getPlayer(args[0]) !=null) {
                    Player targetplayer = player.getServer().getPlayer(args[0]);
                    targetplayer.sendMessage(ChatColor.BLUE + "Super Speed activated");
                    targetplayer.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,7200,4));
    I have all the things imported yet when I do the command it won't respond any suggestions?
     
  2. Offline

    JazzaG

    Try adding curly brackets to your if statements. Remembering you don't need them if they only execute the one line of code.

    Are you receiving the "Super speed activated!" message?
     
  3. Offline

    KingMagnus

    I put brackets around the statement and it didn't work
    Code:
    if(cmd.getName().equalsIgnoreCase("Abilityspeed")){
                if(args.length== 0){
                    player.sendMessage(ChatColor.BLUE + "Super Speed activated");
                    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,7200,4));}
                if(player.getServer().getPlayer(args[0]) !=null) {
                    Player targetplayer = player.getServer().getPlayer(args[0]);
                    targetplayer.sendMessage(ChatColor.BLUE + "Super Speed activated");
                    targetplayer.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,7200,4));}
    It continued to not respond to me
     
  4. Offline

    _Waffles_

    Did you register the command in the plugin.yml?
     
  5. Offline

    KingMagnus

    Yes I did it shows up when I do the help command but when I actually run the command it still does nothing
     
  6. Offline

    ScottGambler

    When i'm at home,I give you a SourceCode of my plugin. it works. When you send a command, you recieve an PotionEffect.
     
  7. Offline

    Slipswhitley

    If your not already using it. Download eclipse IDE it will help with learning java and show you errors and where you can fix them.
     
Thread Status:
Not open for further replies.

Share This Page