当前位置: 首页>>代码示例>>Java>>正文


Java DamageEntityEvent.isCancelled方法代码示例

本文整理汇总了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());
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:25,代码来源:UpdateLastPlayerDamageListener.java

示例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());
			}
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:25,代码来源:SkillSoulbind.java

示例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();
}
 
开发者ID:AfterKraft,项目名称:KraftRPG-API,代码行数:28,代码来源:SkillUtils.java

示例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);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntityDamagedScriptEvent.java

示例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);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:15,代码来源:EntityKilledScriptEvent.java

示例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);
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:9,代码来源:EventListeners.java


注:本文中的org.spongepowered.api.event.entity.DamageEntityEvent.isCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。