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


Java DamageCause.FALL属性代码示例

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


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

示例1: Stomper

@EventHandler
public void Stomper(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		Player p = (Player) e.getEntity();
		if (Kit.getKit(p).getName().equalsIgnoreCase("stomper")) {
			if (e.getCause() == DamageCause.FALL) {
				List<Entity> nearbyEntities = e.getEntity()
						.getNearbyEntities(5, 5, 5);
				for (Entity target : nearbyEntities) {
					if (target instanceof Player) {
						Player t = (Player) target;
						if (Team.getTeam(p) == Team.getTeam(t))
							continue;
						if (t.isSneaking())
							t.damage(e.getDamage() / 2, e.getEntity());
						else
							t.damage(e.getDamage(), e.getEntity());
					}
				}
				e.setDamage(0);
			}
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:24,代码来源:KitEvents.java

示例2: onCancell

@EventHandler
public void onCancell(EntityDamageEvent event){
Entity e = event.getEntity();
if(!(e instanceof Player)){
	return;
}
Player p = (Player)e;
Arena a = new ArenaManager().getArena(p);

if(a==null){
	event.setCancelled(true);
	return;
}
if(a.isEnd()){
	event.setCancelled(true);
	
}
if(a.fallMode()==true){
	if(event.getCause() == DamageCause.FALL||event.getCause() == DamageCause.VOID){
	event.setCancelled(true);
	}
}
}
 
开发者ID:SpikyBite,项目名称:BiteSkywars,代码行数:23,代码来源:PlayerListener.java

示例3: test

@Test
public void test() {
	final Object[] random = {
			// Java
			(byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37,
			"String",
			
			// Skript
			Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER,
			new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000),
			new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}),
			new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50),
			
			// Bukkit - simple classes only
			GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL,
			
			// there is also at least one variable for each class on my test server which are tested whenever the server shuts down.
	};
	
	for (final Object o : random) {
		Classes.serialize(o); // includes a deserialisation test
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:23,代码来源:ClassesTest.java

示例4: onEntityDamage

@SuppressWarnings("deprecation")
public void onEntityDamage(EntityDamageEvent event) {
	if (event.getEntity() instanceof Player) {
		if (event.getCause() == DamageCause.FALL) {
			Location l = event.getEntity().getLocation().add(0, -1, 0);
			Material mBelow = l.getBlock().getType();
			if (mBelow == Material.SPONGE) {
				event.setCancelled(true);
				Player player = (Player) event.getEntity();
				if (!player.isSneaking()) {
					player.setVelocity(new Vector(player.getVelocity().getX(), 1.3D, player.getVelocity().getZ()));
					if (player.hasPermission("customplugin.crazytramp") || l.getBlock().getData() == (byte) 1)
						player.setVelocity(new Vector(player.getVelocity().getX(), 10D, player.getVelocity().getZ()));
					player.getWorld().playEffect(l, Effect.STEP_SOUND, 19);
				}
			}
		}
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:19,代码来源:Trampoline.java

示例5: onDamage

@EventHandler
public void onDamage(EntityDamageEvent event)
{
    if (!(event.getEntity() instanceof Player))
        return;

    BytecraftPlayer player = plugin.getPlayer((Player) event.getEntity());

    if (event.getCause() == DamageCause.FALL) {
        event.setCancelled(false);
        return;
    }

    if (player.getRank().isImmortal()) {
        if (!player.hasFlag(Flag.IMMORTAL)) {
            return;
        }
        event.setCancelled(true);
    }

}
 
开发者ID:sabersamus,项目名称:Bytecraft,代码行数:21,代码来源:BytecraftPlayerListener.java

示例6: onPlayerFall

@EventHandler(priority = EventPriority.HIGHEST)
private void onPlayerFall(EntityDamageEvent event) {
    if (event.getCause() != DamageCause.FALL)
        return;

    if (!(event.getEntity() instanceof Player))
        return;

    IArenaPlayer player = ArenaPlayer.get((Player) event.getEntity());
    if (player == null)
        return;

    IArena arena = player.getArena();
    if (arena == null)
        return;

    IContextSettings settings = player.getContextSettings();
    if (settings == null)
        return;

    if (!settings.hasFallDamage()) {
        event.setDamage(0.0D);
        event.setCancelled(true);
    }
}
 
开发者ID:JCThePants,项目名称:PV-Star,代码行数:25,代码来源:PlayerEventListener.java

示例7: onPlayerFall

@EventHandler(priority = EventPriority.HIGH)
public void onPlayerFall(EntityDamageEvent e) {
    if (e.getEntity() instanceof Player) {
        Player player = (Player) e.getEntity();
        if (e.getCause() == DamageCause.FALL) {
            PlayerInventory inv = player.getInventory();
            int heldSlot = inv.getHeldItemSlot();
            ItemStack sourceStack = inv.getItem(heldSlot);
            if (sourceStack == null || sourceStack.getType() == Material.SNOW_BALL) {
                InventorySlice slice = InventorySlice.fromSlot(player, heldSlot).skip(1);
                if (slice.getBottomItem().getType() == Material.FIREWORK) {
                    player.setFallDistance(0);
                    e.setCancelled(true);
                    //if we have the jetpack engaged, we're free from any fall damage.
                }
            }
        }
        return;
    } else {
        return;
    }
}
 
开发者ID:danieljohnson2,项目名称:SnowballMadness,代码行数:22,代码来源:SnowballMadness.java

示例8: onPlayerDamage

@EventHandler
public void onPlayerDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		Player player = (Player) e.getEntity();
		if (e.getCause() == DamageCause.FALL) {
			boolean noDamage = false;
			
			for (Projectile proj : plugin.airship) {
				if (proj.getShooter() == player) {
					noDamage = true;
					break;
				}
			}
			
			if (noDamage || plugin.noFallDamage.contains(player.getUniqueId())) {
				e.setDamage(0);
				e.setCancelled(true);
				plugin.noFallDamage.remove(player.getUniqueId());
			}
		}
	}
}
 
开发者ID:SugarCaney,项目名称:DirtyArrows,代码行数:22,代码来源:PlayerDamageListener.java

示例9: PlayerDamage

@EventHandler
public void PlayerDamage(EntityDamageEvent event){
	PluginManager pm = Bukkit.getServer().getPluginManager();
	if(event.getEntity() instanceof Player){
		Player player = (Player)event.getEntity();
		if(userManager.getUser(player.getUniqueId()).isGod()){
			event.setCancelled(true);
		}
	    if (event.getCause() == DamageCause.FALL) {
	    	double dmg = event.getDamage();
	    	int count =1;
	    	while(dmg>count){
	    		count++;
	    	}
	    	SkillXPGainEvent skillevent = new SkillXPGainEvent(player.getUniqueId(), SkillType.ACROBATICS, count);
	    	pm.callEvent(skillevent);
	    	event.setDamage(damageUtil.getFallDamage(player, event.getDamage()));
	    }
	}
}
 
开发者ID:cblacks26,项目名称:VSkills,代码行数:20,代码来源:PlayerListener.java

示例10: onDamage

@EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
    if (event.getCause() != DamageCause.FALL) {
        return;
    }

    if (!(event.getEntity() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (!game.isPlayerTurn(player)) {
        return;
    }

    if (!(arena.isIn(player.getWorld()) && arena.getSurroundingRegion()
            .contains(player))) {
        return;
    }

    game.onJumpFail(player);
    event.setCancelled(true);
}
 
开发者ID:Loscillo,项目名称:DACv2-temp,代码行数:23,代码来源:GameListener.java

示例11: onEntityDamageLowest

@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamageLowest(EntityDamageEvent event)
{
	if (event.isCancelled() || event.getDamage() <= 0 || ! gracefulRollEnabled)
		return;

	if (event.getCause() != DamageCause.FALL)
		return;

	Entity entity = event.getEntity();
	if (plugin.isDisabledWorld(entity))
		return;

	if (entity instanceof Player)
	{
		if (Util.random(gracefulRollOdds) == 0)
		{
			event.setDamage(0);
			Player player = (Player) entity;
			player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("graceful_roll")));
		}
	}
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:23,代码来源:EntityListener.java

示例12: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof Player)) {
		return;
	}

	if (event.getCause() == DamageCause.FALL) {
		final Player player = (Player) event.getEntity();

		final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();

		behaviour.getMotion().setLastY(player.getLocation().getY());
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:14,代码来源:BehaviourListeners.java

示例13: resolve

public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent.getCause() == DamageCause.FALL) {
        float fallDistance = Math.max(0, entity.getFallDistance());

        return new SimpleFallDamageInfo(null, fallDistance);
    }

    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:10,代码来源:FallDamageResolver.java

示例14: entityDamageEvent

@EventHandler
public void entityDamageEvent(final EntityDamageEvent event) {
    if (this.isPet(event.getEntity())) {
        final PetBlock petBlock = this.getPet(event.getEntity());
        if (petBlock == null)
            return;
        if (event.getCause() != DamageCause.FALL)
            petBlock.damage(event.getFinalDamage());
        else if (event.getCause() == DamageCause.FALL)
            petBlock.damage(-2.0);
        event.setCancelled(true);
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:13,代码来源:PetBlockListener.java

示例15: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent e) {
	if(e.getEntity() instanceof ArmorStand || e.getEntity() instanceof Item)
		e.setCancelled(true);
	
	if(e.getEntity() instanceof Player) {
		e.setCancelled(true);
		if(e.getCause() == DamageCause.FALL) {
			GamePlayer player = Absorption.getPlayer((Player) e.getEntity());
			
			if(player == null) return;
			player.damage((int) e.getDamage()); 
		}
	}
}
 
开发者ID:SamaGames,项目名称:Absorption,代码行数:15,代码来源:PlayerListener.java


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