Adding potion effect to entity not working

Discussion in 'Plugin Development' started by 2zxr1, Aug 26, 2012.

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

    2zxr1

    I'm trying to add a potion effect to the player specified, for some reason its not working.
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player player = (Player) sender;
            if(commandLabel.equalsIgnoreCase("ge")) {
                if(args.length == 0) {
                   
                    Bukkit.getPlayer(args[0]).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 2), true);
                    Bukkit.getPlayer(args[0]).addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 0), true);
                    Bukkit.getPlayer(args[0]).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 200, 2), true);
                    player.sendMessage(ChatColor.RED + "Adding effect");
     
  2. Offline

    j_selby

    You don't need to go through the whole re-getting the player(well, I still kinda did), however, for example:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
      //etc...
      Bukkit.getPlayer(args[0]).addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 200, 200));
    }
     
  3. Offline

    2zxr1

    Ok, I updated the code but to no avail, still not working :(
     
  4. Offline

    j_selby

    Any errors?

    If you haven't added it to your plugin.yml, you have to. For example:
    Code:
    name: PluginName
    main: etc.etc.etc
    version: 0.1
    commands:
        commandnamehere:
            description: Something
    This is how I implemented it myself:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
        if(cmd.getName().equalsIgnoreCase("samecommandnameasinplugin.yml")){
            Bukkit.getPlayer(args[0]).addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 200, 5));
            return true;
        }
        return false;
    }
     
  5. Offline

    2zxr1

    I don't see any reason why it isn't working.
     
  6. Offline

    j_selby

    Did you add your command to the plugin.yml without a slash at the front?
     
  7. Offline

    2zxr1

    Yes, why would I that mistake.
     
  8. Offline

    whitehooder

    Upload code and plugin.yml and we will help you further...
     
Thread Status:
Not open for further replies.

Share This Page