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


Java EntityDamageEvent.setDamage方法代码示例

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


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

示例1: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if(event.getCause() == EntityDamageEvent.DamageCause.CUSTOM) return;
    if(Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().getGameState() != GameState.INGAME) {
        event.setCancelled(true);
    } else {
        if(!Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().getCurrentGame().allowPVP) event.setCancelled(true);
    }
    if(!event.isCancelled() && event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if((player.getHealth()-event.getDamage()) <= 0) {
            event.setDamage(0);
            if(Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().isAlive(player)) {
                Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().setAlive(player, false);
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:19,代码来源:DamageListener.java

示例2: 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

示例3: damage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public void damage(double amount)
{
	Map<DamageModifier, Double> modifiers = new EnumMap<>(DamageModifier.class);
	modifiers.put(DamageModifier.BASE, 1.0);
	Map<DamageModifier, Function<Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
	modifierFunctions.put(DamageModifier.BASE, damage -> damage);
	
	EntityDamageEvent event = new EntityDamageEvent(this, DamageCause.CUSTOM, modifiers, modifierFunctions);
	event.setDamage(amount);
	Bukkit.getPluginManager().callEvent(event);
	if (!event.isCancelled())
	{
		setHealth(health - amount);
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:17,代码来源:PlayerMock.java

示例4: Stomper

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@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,代码行数:25,代码来源:KitEvents.java

示例5: 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

示例6: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(
        priority = EventPriority.LOW
)
public void onEntityDamage(EntityDamageEvent event) {
    if (api.getGameManager().isLegacyPvP())
    {
        Entity entity = event.getEntity();
        if(entity instanceof Player) {
            Player player = (Player)entity;
            double baseDamage = event.getDamage(EntityDamageEvent.DamageModifier.BASE);
            int defensePoints = this.getDefensePoints(player.getInventory());
            double armorDamage = baseDamage * this.getLegacyDamageFactor(defensePoints);
            event.setDamage(EntityDamageEvent.DamageModifier.ARMOR, armorDamage - baseDamage);
        }
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:17,代码来源:ArmorModule.java

示例7: onAttack

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public void onAttack(EntityDamageEvent event) {
    super.onAttack(event);

    if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK) {
        event.setDamage(modifier.apply(event.getDamage()));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:MeleeSymptom.java

示例8: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamage(EntityDamageEvent e)
{
	if(e.isCancelled()) return;
	if(e.getEntity() instanceof Player)
	{
		Player player = (Player)e.getEntity();
		
		e.setDamage(e.getDamage() * addMultiplier(player));
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:12,代码来源:FoodDiversityConsume.java

示例9: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
	if (event.getEntity() instanceof Player) {
		Gamer g = Gamer.get((Player) event.getEntity());
		if (g.getVariable("spectator") != null)
			return;
		
		Kit kit = (Kit) g.getVariable("kit");
		if (kit.getName().equals("scout") && event.getCause() == DamageCause.FALL) {
			event.setDamage(0);
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:14,代码来源:KitEvents.java

示例10: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
/**
 * Cancel fall damages
 *
 * @param event Event instance
 */
@EventHandler
public void onDamage(EntityDamageEvent event)
{
    if (event.getEntityType() == EntityType.PLAYER && event.getCause() == EntityDamageEvent.DamageCause.FALL)
    {
        event.setCancelled(true);
        event.setDamage(0);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:15,代码来源:SuperheroesModule.java

示例11: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent event) {
    if (!(event.getEntity() instanceof Player)) return;
    Player player = (Player) event.getEntity();
    if (!TGM.get().getMatchManager().getMatch().getMatchStatus().equals(MatchStatus.MID) || teamManagerModule.getTeam(player).isSpectator()) return;
    if (player.getHealth() - event.getFinalDamage() >= 0.5) return;

    createDeath(event);
    removeLife(player);

    event.setDamage(0);
    TGM.get().getModule(SpawnPointHandlerModule.class).spawnPlayer(TGM.get().getPlayerManager().getPlayerContext(player), teamManagerModule.getTeam(player), false);

    if (getLives(player) <= 0) {
        player.setGameMode(GameMode.SPECTATOR);
        player.setAllowFlight(true);
        player.setFlying(true);
        player.getInventory().clear();

        if (player.getLocation().getY() < 0) {
            player.teleport(teamManagerModule.getTeam(player).getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
        }

        MatchTeam team = teamManagerModule.getTeam(player);
        updateScoreboardTeamLine(team, getAlivePlayers(team).size());

        Bukkit.broadcastMessage(team.getColor() + player.getName() + ChatColor.RED + " has been eliminated!");
        player.sendTitle("", ChatColor.RED + "You have been eliminated.");

    } else {
        showLives(player);
        player.teleport(teamManagerModule.getTeam(player).getSpawnPoints().get(0).getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
    }

    if (lastTeamAlive()) {
        MatchTeam winnerTeam = teamManagerModule.getTeams().stream().filter(matchTeam -> !matchTeam.isSpectator()).filter(matchTeam -> getAlivePlayers(matchTeam).size() > 0).findFirst().get();
        if (winnerTeam == null) {
            winnerTeam = teamManagerModule.getTeams().get(1);
        }
        TGM.get().getMatchManager().endMatch(winnerTeam);
        return;
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:44,代码来源:BlitzModule.java

示例12: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    event.setDamage(0);
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:5,代码来源:KingOfTheHillGame.java

示例13: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
	
	//cancel if on periscope
	if( event.getEntity() instanceof Player )
	{
		Player player = (Player)event.getEntity();


		for( Periscope p: NavyCraft.allPeriscopes )
		{
			if( p.user == player )
			{
				event.setCancelled(true);
    			return;
			}
		}
		
		if( event.getCause() == DamageCause.SUFFOCATION )
		{
			Craft c = Craft.getCraft(player.getLocation().getBlockX(),player.getLocation().getBlockY(), player.getLocation().getBlockZ());
			if( c != null )
			{
				event.setCancelled(true);
    			return;
			}
				
		}
		
	}
	
	if ( event instanceof EntityDamageByEntityEvent ) 
	{


		Entity attacker = ((EntityDamageByEntityEvent) event).getDamager();
		if( attacker instanceof Egg )
		{
			if( NavyCraft.explosiveEggsList.contains((Egg)attacker) )
			{	
				event.setDamage(5);
			}
		}
	}

}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:48,代码来源:MoveCraft_EntityListener.java


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