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