本文整理汇总了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);
}
}
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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()));
}
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
}
示例12: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
event.setDamage(0);
}
示例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);
}
}
}
}