本文整理汇总了Java中org.spongepowered.api.event.entity.DamageEntityEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java DamageEntityEvent.isCancelled方法的具体用法?Java DamageEntityEvent.isCancelled怎么用?Java DamageEntityEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.entity.DamageEntityEvent
的用法示例。
在下文中一共展示了DamageEntityEvent.isCancelled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDamageEntity
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void onDamageEntity(DamageEntityEvent event) {
if (event.isCancelled()) {
return;
}
if (!(event.getTargetEntity() instanceof Player)) {
return;
}
Optional<Player> damagerOpt = event.getCause().first(Player.class);
if (!damagerOpt.isPresent()) {
return;
}
Player victim = (Player) event.getTargetEntity();
Player damager = damagerOpt.get();
ClanPlayerImpl victimClanPlayer = ClansImpl.getInstance().getClanPlayer(victim.getUniqueId());
if (victimClanPlayer == null) {
victimClanPlayer = ClansImpl.getInstance().createClanPlayer(victim.getUniqueId(), victim.getName());
}
victimClanPlayer.setLastPlayerDamage(damager.getUniqueId());
}
示例2: onEntityDamage
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityDamage(DamageEntityEvent event) {
if (event.isCancelled() || event.getFinalDamage() == 0) {
return;
}
if (event.getTargetEntity().getType() == EntityTypes.PLAYER) {
UUID id = event.getTargetEntity().getUniqueId();
IActiveCharacter character = characterService.getCharacter(id);
IEffectContainer container = character.getEffect(name);
if (container == null)
return;
if (!event.getCause().first(SoulBindEffect.class).isPresent()) {
event.setBaseDamage(event.getBaseDamage() * .5);
SoulBindEffect effect = (SoulBindEffect) container;
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
if (effect.getConsumer() == character) {
effect.getTarget().getEntity().damage(event.getBaseDamage(), builder.build());
} else {
effect.getConsumer().getEntity().damage(event.getBaseDamage(), builder.build());
}
}
}
}
示例3: damageCheck
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
/**
* Attempts to damage the defending LivingEntity, this allows for various protection plugins to
* cancel damage events.
*
* @param attacking attempting to deal the damage
* @param defenderLE entity being damaged
*
* @return true if the damage check was successful
*/
public static boolean damageCheck(Insentient attacking, Living defenderLE) {
if (attacking.getEntity().get().equals(defenderLE)) {
return false;
}
if (defenderLE instanceof Player && attacking instanceof Champion) {
if (!attacking.getWorld().getProperties().isPVPEnabled()) {
((Champion) attacking).sendMessage(Texts.of(TextColors.RED, "PVP is disabled!"));
return false;
}
}
DamageEntityEvent event = SpongeEventFactory
.createDamageEntityEvent(Cause.of(NamedCause.source(DamageSource.builder().type
(DamageTypes.MAGIC))),
ImmutableList.<Tuple<DamageModifier, Function<? super Double, Double>>>of(),
defenderLE, 0);
Sponge.getEventManager().post(event);
return event.isCancelled();
}
示例4: onEntityDamaged
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityDamaged(DamageEntityEvent evt) {
EntityDamagedScriptEvent event = (EntityDamagedScriptEvent) clone();
event.internal = evt;
event.entity = new EntityTag(evt.getTargetEntity());
event.damage = new NumberTag(evt.getFinalDamage());
event.cancelled = evt.isCancelled();
// TODO: Cause viewing
event.run();
evt.setCancelled(event.cancelled);
}
示例5: onEntityKilled
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityKilled(DamageEntityEvent evt) {
if (!evt.willCauseDeath()) {
return;
}
EntityKilledScriptEvent event = (EntityKilledScriptEvent) clone();
event.internal = evt;
event.entity = new EntityTag(evt.getTargetEntity());
event.damage = new NumberTag(evt.getFinalDamage());
event.cancelled = evt.isCancelled();
// TODO: Cause viewing
event.run();
evt.setCancelled(event.cancelled);
}
示例6: onAttackEntity
import org.spongepowered.api.event.entity.DamageEntityEvent; //导入方法依赖的package包/类
@Listener
public void onAttackEntity(DamageEntityEvent event) {
if (event.isCancelled()) return;
if (!(event.getTargetEntity() instanceof Living)) return;
Living target = (Living)event.getTargetEntity();
if (VillagerShops.isNPCused(target)) event.setCancelled(true);
}