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


Java EntityDamageEvent.setCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageEvent.setCancelled方法的具体用法?Java EntityDamageEvent.setCancelled怎么用?Java EntityDamageEvent.setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.EntityDamageEvent的用法示例。


在下文中一共展示了EntityDamageEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerFall

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerFall(EntityDamageEvent event) {
    if (event.getEntity().getType() == EntityType.PLAYER
            && event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        Player player = (Player) event.getEntity();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Modifier jumpModifier = ItemManager.getModifier(player, ItemStat.StatType.JUMP);
        double height = (1.5D + jumpModifier.getBonus()) * jumpModifier.getMultiplier() * 1.5;
        event.setDamage(event.getDamage() - height);

        if (event.getDamage() <= 0.0D) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:20,代码来源:ItemListener.java

示例2: onDamageWhenPlayerNotLoaded

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onDamageWhenPlayerNotLoaded(EntityDamageEvent event) {
    if (event.getEntityType() != EntityType.PLAYER) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        PlayerLoader.setDamageForPlayer(player, event.getFinalDamage());
    }

    event.setCancelled(true);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:18,代码来源:PlayerListener.java

示例3: onPlayerDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof Player))
		return;
	event.setCancelled(true);
	
	if (event.getCause()==DamageCause.VOID) {
		Location l = event.getEntity().getWorld().getSpawnLocation();
		l.setX(14.5);
		l.setY(10.5);
		l.setZ(-795.5);
		l.setPitch(0.5F);
		l.setYaw(90 * RandomUtil.between(1, 4));
		event.getEntity().teleport(l);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:17,代码来源:Events.java

示例4: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent e) {
	if(e.getEntity() instanceof Player) {
		Player player = (Player) e.getEntity();
		KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(player);
		switch (p.getSettingsProfile().getGodMode()) {
		case FAKEDAMAGE:
			e.setDamage(0);
			p.heal();
			break;
		case NODAMAGE:
			e.setCancelled(true);
			break;
		case NOGOD:
			return;
		default:
			return;
		
		}
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:22,代码来源:GodModeListener.java

示例5: onHit

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHit(EntityDamageEvent event)
{
	if(event.isCancelled()) return;
	Entity hitTarget = event.getEntity();
	if(hitTarget != null && hitTarget instanceof ArmorStand && hitTarget.getCustomName() == "Chair")
		// Chair entity is immune to damage.
		event.setCancelled(true);
	else if(hitTarget != null && hitTarget instanceof Player && hitTarget.getVehicle() != null)
	{
		// Let players stand up if receiving damage.
		Entity vehicle = hitTarget.getVehicle();
		if(vehicle != null && vehicle instanceof ArmorStand && vehicle.getCustomName() == "Chair")
			vehicle.remove();
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:17,代码来源:Chairs.java

示例6: onPlayerDamageEvent

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamageEvent(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {
        Game game;
        if ((game = this.controller.getGameFromPlayer((Player) event.getEntity())) != null) {
            if (!game.getArena().getTeamMeta().isDamageEnabled())
                event.setCancelled(true);
        } else if ((game = this.controller.isInGameLobby((Player) event.getEntity())) != null) {
            if (!game.getArena().getTeamMeta().isDamageEnabled())
                event.setCancelled(true);
        }
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:14,代码来源:GameListener.java

示例7: entityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void entityDamageEvent(EntityDamageEvent event) {
    if (this.isBall(event.getEntity())) {
        if (event.getCause() != null && event.getCause() != DamageCause.FALL)
            this.getBall(event.getEntity()).damage();
        event.setCancelled(true);
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:9,代码来源:BallListener.java

示例8: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityDamageByEntity(EntityDamageEvent event) {
    Player attacker = BukkitUtils.getFinalAttacker(event, true);
    if (attacker != null) {
        Long lastInteractTime = lastInteractTimes.get(attacker.getUniqueId());
        if (lastInteractTime != null && lastInteractTime - System.currentTimeMillis() > 0L) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:11,代码来源:BlockHitFixListener.java

示例9: onVoidDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVoidDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player && isSpectating((Player) event.getEntity())) {
        if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
            event.setCancelled(true); //
            event.getEntity().setVelocity(new Vector(event.getEntity().getVelocity().getX(),
                    event.getEntity().getVelocity().getZ() + 10.0, event.getEntity().getVelocity().getZ()));
            ((Player) event.getEntity()).setAllowFlight(true); // Prevent IllegalArgumentException: Cannot make player fly if getAllowFlight() is false.
            ((Player) event.getEntity()).setFlying(true);
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:13,代码来源:SpectatorModule.java

示例10: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
	PetInstance pet = null;
	for (PetInstance p : PetInstance.getList()) {
		if (p.getEntity() == null)
			continue;
		if (p.getEntity().getUniqueId().equals(event.getEntity().getUniqueId())) {
			pet = p;
			break;
		}
	}
	
	if (pet != null && event instanceof EntityDamageByEntityEvent == false)
		event.setCancelled(true);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:16,代码来源:PetEvents.java

示例11: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent event) {
	if (event.getEntity() instanceof Player) {
		Game game = Chambers.getInstance().getGameManager().getGame();
		if (game.getInvincibilityTime() > 0) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:10,代码来源:GameDamageListener.java

示例12: entityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void entityDamage(final EntityDamageEvent event) {
    if(!(event instanceof EntityDamageByEntityEvent)) return;
    EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event;
    if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return;

    final Player damager = (Player) realEvent.getDamager();
    final Player victim = (Player) realEvent.getEntity();

    if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return;

    if(!(Gizmos.gizmoMap.get(damager) instanceof PopperGizmo)) return;
    if(damager.getItemInHand().getType() != this.getIcon()) return;

    if(!damager.canSee(victim)) return;

    damager.hidePlayer(victim);
    damager.playSound(damager.getLocation(), Sound.BLOCK_LAVA_POP, 1f, 2f);

    Integer count = poppedCount.get(damager);
    if(count == null) count = 0;

    count++;
    poppedCount.put(damager, count);

    if(count % 10 == 0) {
        RaindropUtil.giveRaindrops(
            Users.playerId(damager), 1, null,
            new TranslatableComponent("gizmo.popper.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
        );
    }

    event.setCancelled(true);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:35,代码来源:PopperGizmo.java

示例13: entityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void entityDamage(final EntityDamageEvent event) {
    if(!(event instanceof EntityDamageByEntityEvent)) return;
    EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event;
    if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return;

    final Player damager = (Player) realEvent.getDamager();
    final Player victim = (Player) realEvent.getEntity();

    if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return;

    if(!(Gizmos.gizmoMap.get(damager) instanceof ChickenGizmo)) return;
    if(damager.getItemInHand().getType() != this.getIcon()) return;

    final Chicken chicken = chickens.computeIfAbsent(victim, Chicken::new);
    if(!chicken.add(damager)) return;

    chickendCount.compute(victim, (player, count) -> {
        count = count == null ? 0 : count + 1;
        if(count > 0 && count % 10 == 0) {
            RaindropUtil.giveRaindrops(
                Users.playerId(damager), 1, null,
                new TranslatableComponent("gizmo.chicken.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
            );
        }
        return count;
    });

    event.setCancelled(true);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:31,代码来源:ChickenGizmo.java

示例14: onDmg

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@SuppressWarnings("JavaDoc")
@GameEvent
public void onDmg(@Nonnull EntityDamageEvent event) {
    event.setCancelled(true);
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:6,代码来源:NoDamageFeature.java

示例15: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent evt) {
    evt.setCancelled(getToggle(evt.getEntity(), Toggle.GOD));
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:5,代码来源:Toggles.java


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