本文整理汇总了Java中org.bukkit.entity.LivingEntity.addPotionEffect方法的典型用法代码示例。如果您正苦于以下问题:Java LivingEntity.addPotionEffect方法的具体用法?Java LivingEntity.addPotionEffect怎么用?Java LivingEntity.addPotionEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.LivingEntity
的用法示例。
在下文中一共展示了LivingEntity.addPotionEffect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAttack
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack mainItem = player.getInventory().getItemInMainHand();
LivingEntity enemy = (LivingEntity)event.getEntity();
Random rand = new Random();
if(mainItem.getType() == Material.GOLD_AXE)
{
enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
}
}
}
示例2: onPotionSplash
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Patching witch's potions
*
* @param event Event
*/
@EventHandler
public void onPotionSplash(PotionSplashEvent event)
{
ThrownPotion potion = event.getPotion();
if (potion.getShooter() instanceof Witch)
{
event.setCancelled(true);
List<PotionEffectType> potionEffects = new ArrayList<>();
potionEffects.add(PotionEffectType.SLOW_DIGGING);
potionEffects.add(PotionEffectType.CONFUSION);
potionEffects.add(PotionEffectType.NIGHT_VISION);
potionEffects.add(PotionEffectType.HUNGER);
potionEffects.add(PotionEffectType.BLINDNESS);
PotionEffect selected = new PotionEffect(potionEffects.get(new Random().nextInt(potionEffects.size())), 20 * 15, 1);
for (LivingEntity ent : event.getAffectedEntities())
ent.addPotionEffect(selected);
}
}
示例3: execute
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void execute(KingdomFactionsPlayer player) {
setLocation(player.getPlayer().getTargetBlock((Set<Material>) null, 80).getLocation());
SpellExecuteEvent event = new SpellExecuteEvent(executeLocation, this, player);
if (event.isCancelled())
return;
playEffect(executeLocation);
for (Entity e : Utils.getInstance().getNearbyEntities(executeLocation, 3)) {
if (e instanceof LivingEntity) {
LivingEntity en = (LivingEntity) e;
if (e instanceof Player) {
Player p = (Player) e;
if (PlayerModule.getInstance().getPlayer(p).isVanished()) continue;
en.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 5 * 20, 1));
en.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 5 * 20, 1));
en.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 1));
}
}
}
}
示例4: onAttack
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack mainItem = player.getInventory().getItemInMainHand();
LivingEntity enemy = (LivingEntity)event.getEntity();
if(mainItem.getType() == Material.GOLD_SPADE)
{
enemy.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 100, 0, false));
enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 48, 2, true));
Location particleLoc = player.getLocation();
particleLoc.setY(particleLoc.getY() + 2);
ParticleEffect.HEART.display(0.5f, 0, 0.5f, 1, 2, particleLoc, 64);
}
}
}
示例5: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例6: onPotionEffectAdd
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPotionEffectAdd(PotionEffectAddEvent event) {
LivingEntity entity = event.getEntity();
if (entity instanceof Player && event.getCause() == PotionEffectAddEvent.EffectCause.BEACON) {
PotionEffect effect = event.getEffect();
if (effect.getAmplifier() > 1 && effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
entity.addPotionEffect(new PotionEffect(effect.getType(), effect.getDuration(), 0, effect.isAmbient()));
event.setCancelled(true);
}
}
}
示例7: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_9_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例8: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_9_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例9: apply
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void apply(LivingEntity entity) {
if (this.getFromId() != null && entity.hasPotionEffect(this.getFromId())) {
entity.removePotionEffect(this.getFromId());
}
entity.addPotionEffect(new PotionEffect(this.getFromId(), this.duration, this.strength, this.ambient));
}
示例10: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_10_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例11: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_12_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例12: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_12_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例13: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_11_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例14: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_11_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}
示例15: spawn
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Spawns the entity at the given location
*
* @param mLocation location
*/
@Override
public void spawn(Object mLocation) {
final Location location = (Location) mLocation;
final LivingEntity entity = (LivingEntity) this.getEntity();
final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
this.setPosition(location.getX(), location.getY(), location.getZ());
mcWorld.addEntity(this, SpawnReason.CUSTOM);
entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
entity.setMetadata("keep", this.getKeepField());
entity.setCustomNameVisible(false);
entity.setCustomName("PetBlockIdentifier");
}