本文整理匯總了Java中org.bukkit.event.entity.EntityDamageByEntityEvent.getDamager方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityDamageByEntityEvent.getDamager方法的具體用法?Java EntityDamageByEntityEvent.getDamager怎麽用?Java EntityDamageByEntityEvent.getDamager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityDamageByEntityEvent
的用法示例。
在下文中一共展示了EntityDamageByEntityEvent.getDamager方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EntityDamageByEntityListener
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void EntityDamageByEntityListener(EntityDamageByEntityEvent e) {
if (!GameManager.getGameSituation()) {
e.setCancelled(true);
}
if (e.getDamager() instanceof Player) {
if (e.getEntity() instanceof Player) {
Player damager = (Player) e.getDamager();
Player victim = (Player) e.getEntity();
if (SettingsManager.shotinfo) {
if (e.getCause() == DamageCause.PROJECTILE) {
if(victim.getLocation().distance(damager.getLocation()) < 20) {
Bukkit.broadcastMessage(SettingsManager.niceshot.replace("%s", victim.getName()).replace("%s", damager.getName()).replace("%d", String.valueOf(victim.getLocation().distance(damager.getLocation()))));
}
}
}
}
}
}
示例2: resolve
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
if(damageEvent instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;
if(event.getDamager() instanceof Projectile) {
Projectile projectile = (Projectile) event.getDamager();
Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
Double projectileDistance = null;
if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);
if(projectile.getShooter() instanceof LivingEntity) {
return new ProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance);
}
}
}
return null;
}
示例3: onDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageByEntityEvent event) {
// 處理實體受傷是實體所為事件
Entity entity = event.getEntity();
Entity damager = event.getDamager();
if(damager instanceof Snowball) {
Snowball snowball = (Snowball) damager;
if(snowball.getShooter() instanceof Player) {
event.setDamage(10d);
}
}
}
示例4: onHit
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST)
public void onHit(EntityDamageByEntityEvent e) {
if(e.isCancelled())return;
if (e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
// Player to = (Player) e.getEntity();
Player by = (Player) e.getDamager();
if (!e.isCancelled()) {
by.giveExp(5);
}
}
}
示例5: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack item = player.getItemInHand();
if(item.getType() == Material.WOOD_SPADE)
{
item.setDurability((short)(item.getDurability() - 2));
}
}
}
示例6: entityDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void entityDamage(final EntityDamageEvent event) {
if(!(event instanceof EntityDamageByEntityEvent)) return;
EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event;
if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return;
final Player damager = (Player) realEvent.getDamager();
final Player victim = (Player) realEvent.getEntity();
if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return;
if(!(Gizmos.gizmoMap.get(damager) instanceof PopperGizmo)) return;
if(damager.getItemInHand().getType() != this.getIcon()) return;
if(!damager.canSee(victim)) return;
damager.hidePlayer(victim);
damager.playSound(damager.getLocation(), Sound.BLOCK_LAVA_POP, 1f, 2f);
Integer count = poppedCount.get(damager);
if(count == null) count = 0;
count++;
poppedCount.put(damager, count);
if(count % 10 == 0) {
RaindropUtil.giveRaindrops(
Users.playerId(damager), 1, null,
new TranslatableComponent("gizmo.popper.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
);
}
event.setCancelled(true);
}
示例7: onPlayerHitBuffEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public static void onPlayerHitBuffEvent(EntityDamageByEntityEvent event) {
if (event.getEntityType() == EntityType.ENDER_CRYSTAL) {
if (event.getDamager() instanceof Player)
handleBuff(event.getDamager(), event.getEntity());
else if (event.getDamager() instanceof Projectile) {
if (((Projectile) event.getDamager()).getShooter() instanceof Player)
handleBuff(((Player) ((Projectile) event.getDamager()).getShooter()), event.getEntity());
}
event.setCancelled(true);
}
}
示例8: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onAttack(EntityDamageByEntityEvent e) {
if(!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
return;
}
Player p = (Player) e.getEntity();
Player attacker = (Player) e.getDamager();
for(PotionEffect effect : attacker.getActivePotionEffects()) {
if(effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
e.setDamage(e.getDamage() - (3 * effect.getAmplifier()));
}
}
}
示例9: 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);
}
}
示例10: 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());
}
}
}
示例11: playerShotEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void playerShotEvent(final EntityDamageByEntityEvent event) {
if (GameState.current() == GameState.LOBBY || GameState.current() == GameState.ENDED) {
return;
}
if (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE && event.getDamager() instanceof Arrow &&
((Arrow) event.getDamager()).getShooter() instanceof Player && event.getEntity() instanceof Player) {
Player shot = (Player) event.getEntity();
Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
shooter.sendMessage(ChatColor.GRAY + "➵ " + ChatColor.AQUA + shot.getName() + " " + ChatColor.RED +
new BigDecimal(shot.getHealth() / 2).setScale(1, BigDecimal.ROUND_HALF_UP));
}
}
示例12: onPlayerHitNPC
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerHitNPC(EntityDamageByEntityEvent event)
{
if (Reflection.getHandle(event.getEntity()) instanceof CustomNPC && event.getDamager() instanceof Player)
{
CustomNPC npc = (CustomNPC) Reflection.getHandle(event.getEntity());
npc.onInteract(false, (Player) event.getDamager());
}
}
示例13: onEntityDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler()
public void onEntityDamage(EntityDamageByEntityEvent e) {
if (!ClaimChunk.getInstance().getChunkHandler().isClaimed(e.getEntity().getLocation().getChunk())) {
return;
}
if (e.getDamager() instanceof Player && e.getEntity() instanceof Animals)
ChunkHelper.cancelAnimalDamage((Player) e.getDamager(), e.getDamager().getLocation().getChunk(), e);
}
示例14: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player) {
Player player = (Player) event.getDamager();
if (isSubclaimWand(player.getItemInHand())) {
player.setItemInHand(new ItemStack(Material.AIR, 1));
plugin.getClaimHandler().clearClaimSelection(player);
}
}
}
示例15: ZzzzPlayerAttackEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //導入方法依賴的package包/類
public ZzzzPlayerAttackEvent(EntityDamageByEntityEvent event, DamageCause cause) {
damager = event.getDamager();
damagee = event.getEntity();
this.cause = cause;
}