Check when potion expires?

Discussion in 'Plugin Development' started by Edvio, Sep 23, 2016.

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

    Edvio

    How can I check when a potion effect expires?
    I need to add back the potion effects the players given the effect had before the effect was given.

    Code:
    Code:
            if(item.getType() == Material.SUGAR) {
                p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6&m--*--------------*--"));
                p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bSpeed &e» "));
                p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9Clickable&7: &bSpeed II &7(6s)"));
                p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9Energy Cost&7: &f40"));
                p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6&m--*--------------*--"));
                for (Entity all : p.getNearbyEntities(15.0, 15.0, 15.0)) {
                    if(p != all && faction != null && faction.getOnlinePlayers().contains(all) && !((Player) all).hasPotionEffect(PotionEffectType.SPEED)) {
                        ((Player) all).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 1));
                    }
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Edvio

  4. Offline

    timtower Administrator Administrator Moderator

    @Edvio What is the goal? Because I gave the exact thing that you asked for:
     
  5. Offline

    Edvio

    I need to be able to rollback the potion effects a player had. If a special player holds sugar it will give the players around them speed for example. if the player already has speed and it's given, the original speed will get removed. You can hold the sugar again tho, and it will continue giving players speed. After it's run out I want to give back the effects the player had before. Sry for bad explenation
     
  6. Offline

    timtower Administrator Administrator Moderator

    @Edvio Get the time before you give the new effect, save it in a map, give the effect, if the effect runs off, give effect in map again.
     
Thread Status:
Not open for further replies.

Share This Page