Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7858

Bukkit Runnable Potion Effects Seemingly Staying After Death

XMLWordPrintable

    • 1.21-R0.1-SNAPSHOT
    • Locally Created (Not public)
    • Yes

      Currently in 1.21 an observed behavior when a player is given a potion effect relating to the player's speed in a BukkitRunnable and the player dies while the runnable is active and respawns. Their movement speed is still effected, such as for speed they are walking faster than normal or slowness makes them slower than normal.

      To recreate:
      1. Make a BukkitRunnable that applies a speed or slowness potion effect to another Player using{{ .addPotionEffect}} method
      2. Kill the Player with the potion effect applied to them
      3. Occasionally (Often enough to be observed) the base walking speed of the player will be affected to be faster or slower than the normal movement speed.
      4. Player cannot change movement speed themselves even with commands

      This is an example of how we are applying this kind of effect

      public void testBug(Player player) {
      
              new BukkitRunnable() {
                  int ticks = 0;
                  Location location = player.getLocation();
      
                  @Override
                  public void run() {
                      // Get their location
                      location = player.getLocation();
                      // Check if they are dead or if the ability is done
                      if (player.isDead() || ticks >= 140) {
                          cancel();
                          return;
                      }
                      // Every second run this check
                      if (ticks % 20 == 0) {
                          // Get nearby entities
                          Collection<Entity> nearbyEntities = player.getWorld()
                                  .getNearbyEntities(location, 5, 5, 5);
                          // Check each entity nearby
                          for (Entity e : nearbyEntities) {
                              if (e instanceof LivingEntity) {
                                  ((LivingEntity) e).addPotionEffect(new PotionEffect(
                                          PotionEffectType.SLOWNESS, 60,
                                          2, false, false));
      
                              }
                          }
                      }
                  }
              }.runTaskTimer(getPlugin(), 0, 1);
          }
      

            Unassigned Unassigned
            idysfunctional Parker B
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: