Bukkit/CraftBukkit — pull request #1177 by jb-aero (2013-06-19 10:48:11+00:00)
Title: [C] Use ambient setting of potion effects. Fixes BUKKIT-4357 and BUKKIT-3653

# Issue
When 1.4 came out, and ambient potion effects were introducted, getActivePotionEffects() and addPotionEffect(PotionEffect, boolean) in LivingEntity were not updated to use the new MobEffect and PotionEffect constructors. This causes all potion effects applied by the api to be non-ambient, and all potion effects gotten from mobs and players to be read as ambient.

# Justification
The last constructor for PotionEffect implies that the plugin can choose whether to make their effect translucent like the ones beacons create. Checking this effect with isAmbient() will be accurate after construction, but when the effect is applied, it uses a constructor for MobEffect that uses the default (false) for the ambient setting.

The API method isAmbient() in PotionEffect states that it will return true if the effect is the type that has translucent particles, however this is only correct for plugin-created effects that have not yet been applied to a living entity. All effects are considered ambient when read from the entity.

# PR Breakdown
This changes livingEntity.addPotionEffect(PotionEffect, boolean) to construct the MobEffect using the constructor that includes the ambient setting as supplied by the PotionEffect. This makes it possible to create beacon-like potion effects.

This also changes livingEntity.getActivePotionEffects() to construct the PotionEffects using the ambient setting supplied by the MobEffects. This makes isAmbient() accurate when checking effects on living entities.

# Test Code:
```java
PotionEffect potion1 = new PotionEffect(PotionEffectType.getByName("JUMP"), 200, 0, true);
PotionEffect potion2 = new PotionEffect(PotionEffectType.getByName("SPEED"), 200, 0, false);
Player player = Bukkit.getPlayer("jb_aero");
potion1.apply(player);
potion2.apply(player);

player.sendMessage("Choice: " + amb)
player.sendMessage("Potion 1 Ambience: " + potion1.isAmbient());
player.sendMessage("Potion 2 Ambience: " + potion2.isAmbient());

for(PotionEffect effect : player.getActivePotionEffects(){
player.sendMessage("Ambience of " + effect.getPotionEffectType.getName() + ": " + it.isAmbient())
}
```
Before this PR, potion 1 will correspond to true, potion 2 to false, jump to true, and speed to true;
After this PR, potion 1 will correspond to true, potion 2 to false, jump to true, and speed to false;

# Leaky Tickets
[BUKKIT-4357](https://bukkit.atlassian.net/browse/BUKKIT-4357)

[BUKKIT-3653](https://bukkit.atlassian.net/browse/BUKKIT-3653)
This one was misunderstood, but it put me on the right track. What the reporter was saying, is that the entire problem was that the API was wrong, and isAmbient() was not distinguishing between player-brewed potions and beacon effects.