use of org.bukkit.potion.PotionEffect in project EliteMobs by MagmaGuy.
the class AttackConfusing method attackConfusing.
@EventHandler
public void attackConfusing(PlayerDamagedByEliteMobEvent event) {
if (event.isCancelled())
return;
AttackConfusing attackConfusing = (AttackConfusing) event.getEliteMobEntity().getPower(this);
if (attackConfusing == null)
return;
if (attackConfusing.isInGlobalCooldown())
return;
attackConfusing.doGlobalCooldown(20 * 10);
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 3));
}
use of org.bukkit.potion.PotionEffect in project Glowstone by GlowstoneMC.
the class ItemFishRaw method eat.
@Override
public boolean eat(GlowPlayer player, ItemStack item) {
if (!super.eat(player, item)) {
return false;
}
if (item.getData().getData() == 3) {
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, TickUtil.minutesToTicks(1), 3), true);
player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, TickUtil.secondsToTicks(15), 2), true);
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, TickUtil.secondsToTicks(15), 1), true);
}
return true;
}
use of org.bukkit.potion.PotionEffect in project Glowstone by GlowstoneMC.
the class ItemBowTest method testTippedArrow.
@Test
public void testTippedArrow() {
ItemStack arrow = new ItemStack(Material.TIPPED_ARROW, 1);
GlowMetaPotion potion = new GlowMetaPotion(arrow.getItemMeta());
potion.setColor(Color.PURPLE);
final PotionData potionData = new PotionData(PotionType.FIRE_RESISTANCE);
potion.setBasePotionData(potionData);
final PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10, 1);
potion.addCustomEffect(effect, false);
assertTrue(arrow.setItemMeta(potion));
inventory.addItem(arrow);
// Should now be able to start shooting
bow.startUse(player, bowItemStack);
verify(player, times(1)).setUsageItem(bowItemStack);
verify(player, times(1)).setUsageTime(anyInt());
when(player.getUsageTime()).thenReturn(10);
// Finish shooting
bow.endUse(player, bowItemStack);
verify(player, times(1)).launchProjectile(TippedArrow.class);
verify(launchedTippedArrow, times(1)).setColor(Color.PURPLE);
verify(launchedTippedArrow, times(1)).setBasePotionData(potionData);
verify(launchedTippedArrow, times(1)).addCustomEffect(eq(effect), anyBoolean());
verify(player, times(1)).setUsageItem(null);
verify(player, times(1)).setUsageTime(0);
checkInventory(inventory, 1, BOW_WITH_DAMAGE_1);
checkInventory(inventory, 0, BOW_WITH_DAMAGE_NOT_1);
checkInventory(inventory, 0, item -> ARROW_TYPES.contains(item.getType()));
}
use of org.bukkit.potion.PotionEffect in project Glowstone by GlowstoneMC.
the class GlowMetaPotion method copyFrom.
/**
* Copies potion data from another instance
*
* @param source The object to copy from
*/
public void copyFrom(PotionMeta source) {
setBasePotionData(source.getBasePotionData());
setColor(source.getColor());
for (PotionEffect effect : source.getCustomEffects()) {
addCustomEffect(effect, true);
}
}
use of org.bukkit.potion.PotionEffect in project Glowstone by GlowstoneMC.
the class GlowMetaPotion method fromNbt.
/**
* Reads a {@link PotionEffect} from an NBT compound tag.
*
* @param tag a potion effect NBT compound tag
* @return {@code tag} as a {@link PotionEffect}
*/
public static PotionEffect fromNbt(CompoundTag tag) {
PotionEffectType type = PotionEffectType.getById(tag.getByte("Id"));
int duration = tag.getInt("Duration");
int amplifier = tag.getByte("Amplifier");
boolean ambient = tag.getBoolean("Ambient", false);
boolean particles = tag.getBoolean("ShowParticles", true);
return new PotionEffect(type, duration, amplifier, ambient, particles);
}
Aggregations