下面列出了怎么用org.bukkit.entity.AreaEffectCloud的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler
public void onPotionLinger(final AreaEffectCloudApplyEvent event) {
final AreaEffectCloud cloud = event.getEntity();
if(PotionClassification.classify(cloud) != PotionClassification.HARMFUL) return;
for(Iterator<LivingEntity> iterator = event.getAffectedEntities().iterator(); iterator.hasNext(); ) {
final LivingEntity victim = iterator.next();
final ParticipantState victimState = getMatch().getParticipantState(victim);
final DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.MAGIC, victim, cloud);
if(victimState != null && queryDamage(event, victimState, damageInfo).isDenied()) {
iterator.remove();
}
}
}
private void effect(Event event, Player player, ItemStack tool, Location location) {
if (!player.hasPermission("minetinker.modifiers.shrouded.use")) {
return;
}
if (!modManager.hasMod(tool, this)) {
return;
}
int level = modManager.getModLevel(tool, this);
AreaEffectCloud cloud = (AreaEffectCloud) location.getWorld().spawnEntity(location, EntityType.AREA_EFFECT_CLOUD);
int duration = (int) Math.round(this.duration * Math.pow(this.durationMultiplier, level));
float radius = (float) (this.radiusPerLevel * level);
cloud.clearCustomEffects();
cloud.setColor(Color.BLACK);
cloud.setRadius(radius);
cloud.setDuration(duration);
cloud.addCustomEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration, 0, false, false), true);
ArrayList<String> extras = new ArrayList<>();
if (modManager.hasMod(tool, Glowing.instance()) && player.hasPermission("minetinker.modifiers.glowing.use")) {
extras.add(Glowing.instance().getKey());
cloud.addCustomEffect(Glowing.instance().getPotionEffect(null, null, player, tool), true);
}
if (modManager.hasMod(tool, Poisonous.instance()) && player.hasPermission("minetinker.modifiers.poisonous.use")) {
extras.add(Poisonous.instance().getKey());
cloud.addCustomEffect(Poisonous.instance().getPotionEffect(null, null, player, tool), true);
}
if (modManager.hasMod(tool, Shulking.instance()) && player.hasPermission("minetinker.modifiers.shulking.use")) {
extras.add(Shulking.instance().getKey());
cloud.addCustomEffect(Shulking.instance().getPotionEffect(null, null, player, tool), true);
}
if (modManager.hasMod(tool, Webbed.instance()) && player.hasPermission("minetinker.modifiers.webbed.use")) {
extras.add(Webbed.instance().getKey());
cloud.addCustomEffect(Webbed.instance().getPotionEffect(null, null, player, tool), true);
}
if (modManager.hasMod(tool, Withered.instance()) && player.hasPermission("minetinker.modifiers.withered.use")) {
extras.add(Withered.instance().getKey());
cloud.addCustomEffect(Withered.instance().getPotionEffect(null, null, player, tool), true);
}
StringBuilder ex = new StringBuilder();
for (String s : extras) {
ex.append(s).append("/");
}
if (!extras.isEmpty()) ex.deleteCharAt(ex.length() - 1);
ChatWriter.logModifier(player, event, this, tool,
String.format("Radius(%.2f)", radius),
"Duration(" + duration + ")",
"Extras(" + ex.toString() + ")");
}
public LingeringPotionSplashEvent(final ThrownPotion potion, final AreaEffectCloud entity) {
super(potion);
this.entity = entity;
}
public AreaEffectCloudApplyEvent(final AreaEffectCloud entity, final List<LivingEntity> affectedEntities) {
super(entity);
this.affectedEntities = affectedEntities;
}
@Override
public AreaEffectCloud getEntity() {
return (AreaEffectCloud) entity;
}
public static Collection<PotionEffect> effects(AreaEffectCloud cloud) {
return effects(cloud.getBasePotionData(), cloud.getCustomEffects());
}
/**
* Gets the AreaEffectCloud spawned
*
* @return The spawned AreaEffectCloud
*/
public AreaEffectCloud getAreaEffectCloud() {
return entity;
}