How can you add more effects

Discussion in 'Plugin Development' started by HungerCraftNL, Jun 10, 2013.

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

    HungerCraftNL

    I want to add on a potion swiftness, jumpboost and fulling hungerbar, but how?
    Code now:
    Code:
                    Potion potion = new Potion(PotionType.SPEED, 2, false, true);
                    ItemStack potionstack = potion.toItemStack(1);
                    ItemMeta pmeta = potionstack.getItemMeta();
                    potionstack.setItemMeta(pmeta);
                    player.getInventory().addItem(potionstack);
    -Shadow

    Still need help.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    chasechocolate

    Maybe potion.getEffects().add(new PotionEffect(...)).
     
  3. Offline

    Compressions

    HungerCraftNL
    Code:
        @EventHandler
        public void onPlayerItemConsume(PlayerItemConsumeEvent e) {
            Player player = e.getPlayer();
            ItemStack item = e.getItem();
            if(item.getItemMeta().getDisplayName().contains("RedBull")) {
                player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 100, 0));
                player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 0));
                player.setFoodLevel(20);
            }
        }
        
     
  4. Offline

    GreySwordz

    Compressions Please don't give other people code, make them actually have to think a little and not copy paste.
     
  5. Offline

    HungerCraftNL

    Ty but I found him already xD

    Ty for all your help but I don't get it anymore I've now this but the potion don't get the effect 'JUMP'
    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(sender instanceof Player) {
                Player player = (Player) sender;
                if(label.equalsIgnoreCase("rb")) {
                    @SuppressWarnings("deprecation")
                    Potion potion = new Potion(PotionType.SPEED, 5, false, true);
                    potion.getEffects().add(new PotionEffect(PotionEffectType.JUMP, 5, 4));
                    ItemStack potionstack = potion.toItemStack(1);
                    ItemMeta pmeta = potionstack.getItemMeta();
                    pmeta.setDisplayName(ChatColor.DARK_RED + "RedBull");
                    potionstack.setItemMeta(pmeta);
                    player.getInventory().addItem(potionstack);
    Can someone help please?

    Bump :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  6. Offline

    HungerCraftNL

    I get the effect, but not ON the potion.
    Is that posseble?
     
  7. Offline

    slayr288

    GreySwordz

    Learning from code is a lot easier than learning from someone struggling to define something that can only be defined via code.
     
  8. Offline

    nisovin

  9. Offline

    Garris0n

    There are cases when people don't know java and are asking for entire plugins coded for them, and that's the case where I wouldn't give them code, but in this case it's perfectly fine to give a code snippet to use and learn from.
     
  10. Offline

    HungerCraftNL

    I don't want a full code, then you don't learn anything, you just get it.
     
Thread Status:
Not open for further replies.

Share This Page