當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。