Looking for a way to get potion effects remaining-time variables

Discussion in 'Spigot Plugin Help' started by CyanBillows, Jan 30, 2020.

  1. Hello,What i’m trying to do is catch variables that show the potion effects’ duration.
    And if u know about any plugins or methods that can do it,please leave them below.
    Thanks in advance:)
  2. I don't know if you're talking about coding your own plugin, but you would create a new Player instance and then check for the potion effect type and then get the duration.

    Code (Java):
  3. I'm noob on coding..Could u please send more details,like how to make duration a variable that can be used by other plugin?
    #3 CyanBillows, Jan 31, 2020
    Last edited: Jan 31, 2020
  4. You could assign it to an int or double variable depending on the return type of getDuration()

    So this is out of my EnchantsPlus plugin, the main thing to take out of this is where i declare the double dur
    Code (Java):
        public void WitheringShot(EntityDamageByEntityEvent event) {
            if(event.getDamager() instanceof Arrow) {
                if(((Arrow) event.getDamager()).getShooter() instanceof Player) {
                    Player player = (Player) ((Arrow) event.getDamager()).getShooter();
                    final int tier = CustomEnchantment.getEnchantTier("WitheringShot", player.getInventory().getItemInMainHand());
                    if(CustomEnchantment.hasEnchant("WitheringShot", player.getInventory().getItemInMainHand())) {
                        //Get the player that was shot
                        for(Player p : Bukkit.getOnlinePlayers()) {
                            if(player != p) {
                                double dur = p.getPotionEffect(PotionEffectType.BLINDNESS).getDuration();
  5. I don’t really understand.Is ‘var’ refers to the duration?
  6. If you gave more information I could make you a plugin. Where do you want to use these variables? On a scoreboard? Message to a player?
  7. Not sure if you mean't dur, but yes, dur once initialized, will hold the duration of the potion in memory until its overwritten or you shut the server off.
  8. Scoreboard,using resources called "kite board".I want to make it a PAPI external first,but failed cuz i'm not good at making plugin.
    I‘ll try later,thanks anyway.