org.bukkit.event.entity.PotionEffectRemoveEvent Java Examples

The following examples show how to use org.bukkit.event.entity.PotionEffectRemoveEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShieldPlayerModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
void onEvent(PotionEffectRemoveEvent event) {
  // The NMS code assumes that a potion effect is the only way to get
  // absorption hearts, so when the effect is removed, it simply removes
  // the same amount of absorption that it added initially. If any of that
  // eats into the shield, we refund the difference.
  if (PotionEffectType.ABSORPTION.equals(event.getEffect().getType())) {
    double newAbsorption =
        Math.max(0, getAbsorption() - 4 * (1 + event.getEffect().getAmplifier()));
    if (newAbsorption < shieldHealth) {
      logger.fine(
          "Compensating for removal of absorption "
              + event.getEffect().getAmplifier()
              + " effect, which will reduce absorption hearts to "
              + newAbsorption
              + ", which is below shield health of "
              + shieldHealth);
      addAbsorption(shieldHealth - newAbsorption);
    }
  }
}
 
Example #2
Source File: ShieldPlayerModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
void onEvent(PotionEffectRemoveEvent event) {
    // The NMS code assumes that a potion effect is the only way to get
    // absorption hearts, so when the effect is removed, it simply removes
    // the same amount of absorption that it added initially. If any of that
    // eats into the shield, we refund the difference.
    if(PotionEffectType.ABSORPTION.equals(event.getEffect().getType())) {
        double newAbsorption = Math.max(0, getAbsorption() - 4 * (1 + event.getEffect().getAmplifier()));
        if(newAbsorption < shieldHealth) {
            logger.fine("Compensating for removal of absorption " + event.getEffect().getAmplifier() +
                        " effect, which will reduce absorption hearts to " + newAbsorption +
                        ", which is below shield health of " + shieldHealth);
            addAbsorption(shieldHealth - newAbsorption);
        }
    }
}
 
Example #3
Source File: ShieldMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionRemove(PotionEffectRemoveEvent event) {
  ShieldPlayerModule shield = getShield(event.getEntity());
  if (shield != null) shield.onEvent(event);
}
 
Example #4
Source File: ShieldMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionRemove(PotionEffectRemoveEvent event) {
    ShieldPlayerModule shield = getShield(event.getEntity());
    if(shield != null) shield.onEvent(event);
}
 
Example #5
Source File: ObserverModule.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onViewingEntityRemoveEffect(PotionEffectRemoveEvent event) {
    if (event.getEntity() instanceof Player) {
        updateNextTick((Player)event.getEntity());
    }
}