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


Java EntityDamageByEntityEvent.setDamage方法代码示例

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


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

示例1: onDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
    if ((event.getDamager() instanceof Player)) {
        Player player = (Player) event.getDamager();
        if (player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_AXE) {
            event.setDamage(event.getDamage() - 6.0D + 3.0D);
        } else if (player.getInventory().getItemInMainHand().getType() == Material.IRON_AXE) {
            event.setDamage(event.getDamage() - 6.0D + 2.5D);
        } else if (player.getInventory().getItemInMainHand().getType() == Material.STONE_AXE) {
            event.setDamage(event.getDamage() - 6.0D + 2.0D);
        } else if ((player.getInventory().getItemInMainHand().getType() == Material.GOLD_AXE) ||
                (player.getInventory().getItemInMainHand().getType() == Material.WOOD_AXE)) {
            event.setDamage(event.getDamage() - 4.0D + 1.5D);
        } else if (player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_SPADE) {
            event.setDamage(event.getDamage() - 2.5D + 2.0D);
        } else if (player.getInventory().getItemInMainHand().getType() == Material.STONE_SPADE) {
            event.setDamage(event.getDamage() - 0.75D + 1.25D);
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:21,代码来源:LegacyDamageModule.java

示例2: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    Entity damager = event.getDamager();
    if (entity instanceof Player && damager instanceof Player) {
        Player attacker = (Player) damager;
        if (plugin.getPvpClassManager().getEquippedClass(attacker) == this) {
            ItemStack stack = attacker.getItemInHand();
            if (stack != null && stack.getType() == Material.GOLD_SWORD && stack.getEnchantments().isEmpty()) {
                Player player = (Player) entity;
                player.sendMessage(SettingsYML.ENEMY_COLOUR + attacker.getName() + ChatColor.YELLOW + " has backstabbed you.");
                player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                attacker.sendMessage(ChatColor.YELLOW + "You have backstabbed " + SettingsYML.ENEMY_COLOUR + player.getName() + ChatColor.YELLOW + '.');
                attacker.setItemInHand(new ItemStack(Material.AIR, 1));
                player.setHealth(12);
                attacker.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                event.setDamage(3.0);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:24,代码来源:RogueClass.java

示例3: onDamageEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamageEntity(EntityDamageByEntityEvent e){
    Player p;

    if (e.getDamager() instanceof Player && e.getEntity() instanceof Zombie){
        p = (Player)e.getDamager();
        Weapon weapon;

        if (p.getInventory().getItemInMainHand() == null || !Weapon.isWeapon(p.getInventory().getItemInMainHand())) return;
        if (Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand()) == null) {
            e.setDamage(0);
            return;
        }
        weapon = Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand());

        if (weapon.getId() != 0) return;

        e.setDamage(((Zombie) e.getEntity()).getMaxHealth());
    }

    if (e.getDamager() instanceof Zombie && e.getEntity() instanceof Player) {
        p = (Player) e.getEntity();
        if (this.plugin.getBlooding().contains(new TWDPlayer(p.getUniqueId()))) return;
        this.plugin.getBlooding().add(new TWDPlayer(p.getUniqueId()));
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:27,代码来源:Weapons.java

示例4: onEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
	if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
		e.setDamage(e.getDamage() + damage);
		if (effect != null) {

			((LivingEntity) e.getEntity()).addPotionEffect(effect);
		}
	}
	if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
		e.setDamage(e.getDamage() + damage);
	}
	if ((e.getDamager() instanceof Snowball) && (((Snowball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
		e.setDamage(e.getDamage() + damage);
	}

}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:18,代码来源:LongRangeWeapon.java

示例5: onProjectileHurtEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHurtEvent(EntityDamageByEntityEvent event) {
    if(!(event.getEntity() instanceof LivingEntity)) return;
    final LivingEntity damagedEntity = (LivingEntity) event.getEntity();

    final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(event.getDamager());
    if(projectileDefinition == null) return;

    if(!projectileDefinition.potion().isEmpty()) {
        damagedEntity.addPotionEffects(projectileDefinition.potion());
    }

    if(projectileDefinition.damage() != null) {
        event.setDamage(projectileDefinition.damage());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:ProjectileMatchModule.java

示例6: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Player attacker = getDamageSource(event.getDamager());
    Entity eDefender = event.getEntity();
    if (!(eDefender instanceof Player)) {
        forbidIfInProtectedTerritory(attacker, eDefender, event, ATTACK);
        return;
    }
    Player defender = (Player) eDefender;
    Faction aFaction = plugin.getFactionCache().getByMember(attacker);
    Faction dFaction = plugin.getFactionCache().getByMember(defender);
    Faction rFaction = plugin.getFactionCache().getByLocation(defender.getLocation());
    if (aFaction.getRelation(dFaction).isProtected()) {
        ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_PLAYER.getMessage(), dFaction);
        event.setCancelled(true);
    } else if (rFaction != null && rFaction.getRelation(dFaction).isProtected()) {
        if (plugin.getFConfig().isTerritoryProtectionEnabled() && (!plugin.getFConfig().isCapitalProtectionEnabled()
                || rFaction.getCapital().equals(plugin.getBoard().getByLocation(eDefender.getLocation())))) {
            ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_FACTION.getMessage(), rFaction);
            event.setCancelled(true);
        } else if (plugin.getFConfig().getTerritoryShield() != 0) {
            event.setDamage(event.getDamage() * plugin.getFConfig().getTerritoryShield());
        }
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:26,代码来源:EntityProtectionListener.java

示例7: damage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@Override
public void damage(double amount, Entity source)
{
	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);
	
	EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(source, this, DamageCause.ENTITY_ATTACK, modifiers, modifierFunctions);
	event.setDamage(amount);
	Bukkit.getPluginManager().callEvent(event);
	if (!event.isCancelled())
	{
		setHealth(health - amount);
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:17,代码来源:PlayerMock.java

示例8: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{
    if (api.getGameManager().isLegacyPvP()) {
        Entity attacker = event.getDamager();
        if (attacker instanceof Player) {
            Player player = (Player) attacker;
            ItemStack inHand = player.getInventory().getItemInMainHand();
            if (inHand != null) {
                double baseDamage = event.getDamage(EntityDamageEvent.DamageModifier.BASE);
                double currentDamage = this.getCurrentDamage(inHand.getType());
                if (currentDamage != 0.0D) {
                    double damageFactor = baseDamage / currentDamage;
                    double legacyDamage = this.getLegacyDamage(inHand.getType()) * damageFactor;
                    event.setDamage(EntityDamageEvent.DamageModifier.BASE, legacyDamage);
                }
            }
        }
    }
}
 
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:21,代码来源:CooldownModule.java

示例9: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	if ((event.getDamager() instanceof Player)) {
		Player p = (Player)event.getDamager();

		if (Kit.getKit(p).getName().equalsIgnoreCase("woodcutter") && (p.getItemInHand().getType().name().contains("_AXE"))) {
			Random r = new Random();

			double multiplier = 1.0D + 1.0D * r.nextDouble() - r.nextDouble() + 0.5D;

			if (multiplier < 1.0D)
				multiplier = 1.0D;
			if (multiplier >= 2.0D) {
				multiplier = 2.0D;
			}
			event.setDamage((int)(event.getDamage() * multiplier));
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:20,代码来源:KitEvents.java

示例10: offenseEffect

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@Override
public void offenseEffect(LivingEntity user, LivingEntity target, EntityDamageByEntityEvent event){
    double health = user.getHealth();
    if (health == 3.0 || health == 2.5) {
        event.setDamage(event.getDamage() + 0.5);
    } else if (health == 2.0 || health == 1.5) {
        event.setDamage(event.getDamage() + 1.0);
    } else if (health == 1.0){
        event.setDamage(event.getDamage() + 1.5);
    } else if (health == 0.5){
        event.setDamage(event.getDamage() + 2.0);
    }

}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:15,代码来源:LastHope.java

示例11: weakDamageDirectWithGun

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
/**
 * Doesn't seem to work right now but basically, if you smack someone over the head
 * with the gun instead of shoot it, do less damage.
 * 
 * @param event The hit event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void weakDamageDirectWithGun(EntityDamageByEntityEvent event) {
	if (event.getDamager() instanceof LivingEntity) {
		LivingEntity damager = (LivingEntity) event.getDamager();
		EntityEquipment equips = damager.getEquipment();
		StandardGun gun = findGun(equips.getItemInMainHand());
		if (gun != null) {
			// modify damage!
			event.setDamage(gun.getBluntDamage());
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:19,代码来源:Guns.java

示例12: weakDamageDirectWithGun

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
/**
 * Doesn't seem to work right now but basically, if you smack someone over the head
 * with the gun instead of shoot it, do less damage.
 * 
 * @param event The hit event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void weakDamageDirectWithGun(EntityDamageByEntityEvent event) {
	if (event.getDamager() instanceof LivingEntity) {
		LivingEntity damager = (LivingEntity) event.getDamager();
		EntityEquipment equips = damager.getEquipment();
		if (isGun(equips.getItemInMainHand())) {
			// modify damage!
			event.setDamage(this.bluntDamage);
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:18,代码来源:RailGun.java

示例13: onPlayerDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDamage(EntityDamageByEntityEvent event) {
    Entity damager = event.getDamager();
    if ((damager instanceof Player && ItemUtils.isWeapon(((Player) damager).getItemInHand())) ||
        (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Player)) {
        event.setDamage(DAMAGE);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:MutationModules.java

示例14: handlePlayerDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handlePlayerDamage(EntityDamageByEntityEvent event) {
    if(event.getDamager() instanceof Player) {
        if(((Player) event.getDamager()).getItemInHand().containsEnchantment(Enchantment.DAMAGE_ALL)) event.setDamage(1000);
    } else if(event.getDamager() instanceof Arrow && ((Arrow) event.getDamager()).getShooter() instanceof Player) {
        if(((Arrow) event.getDamager()).getDamage() > 2D) event.setDamage(1000);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:RageMatchModule.java

示例15: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
/**
 * Removes the hit cooldown upon a player attack and reduces the amount of damage dealt according to a modifier.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
  Entity entity = event.getEntity();
  if (entity instanceof Player
      && event.getDamager() instanceof Player
      && event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)) {
    event.setDamage(event.getDamage() * damageReduction);
    Bukkit.getScheduler().runTask(OpenUHC.getInstance(), () -> ((Player) entity).setNoDamageTicks(0));
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:16,代码来源:MeleeFun.java


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