本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageEvent.setCancelled方法的具体用法?Java EntityDamageEvent.setCancelled怎么用?Java EntityDamageEvent.setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDamageEvent
的用法示例。
在下文中一共展示了EntityDamageEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: onDamageWhenPlayerNotLoaded
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onDamageWhenPlayerNotLoaded(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) {
return;
}
Player player = (Player) event.getEntity();
if (InventoryManager.playerIsLoaded(player)) {
return;
}
if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
PlayerLoader.setDamageForPlayer(player, event.getFinalDamage());
}
event.setCancelled(true);
}
示例3: onPlayerDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player))
return;
event.setCancelled(true);
if (event.getCause()==DamageCause.VOID) {
Location l = event.getEntity().getWorld().getSpawnLocation();
l.setX(14.5);
l.setY(10.5);
l.setZ(-795.5);
l.setPitch(0.5F);
l.setYaw(90 * RandomUtil.between(1, 4));
event.getEntity().teleport(l);
}
}
示例4: 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;
}
}
}
示例5: onHit
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHit(EntityDamageEvent event)
{
if(event.isCancelled()) return;
Entity hitTarget = event.getEntity();
if(hitTarget != null && hitTarget instanceof ArmorStand && hitTarget.getCustomName() == "Chair")
// Chair entity is immune to damage.
event.setCancelled(true);
else if(hitTarget != null && hitTarget instanceof Player && hitTarget.getVehicle() != null)
{
// Let players stand up if receiving damage.
Entity vehicle = hitTarget.getVehicle();
if(vehicle != null && vehicle instanceof ArmorStand && vehicle.getCustomName() == "Chair")
vehicle.remove();
}
}
示例6: onPlayerDamageEvent
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamageEvent(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
Game game;
if ((game = this.controller.getGameFromPlayer((Player) event.getEntity())) != null) {
if (!game.getArena().getTeamMeta().isDamageEnabled())
event.setCancelled(true);
} else if ((game = this.controller.isInGameLobby((Player) event.getEntity())) != null) {
if (!game.getArena().getTeamMeta().isDamageEnabled())
event.setCancelled(true);
}
}
}
示例7: entityDamageEvent
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void entityDamageEvent(EntityDamageEvent event) {
if (this.isBall(event.getEntity())) {
if (event.getCause() != null && event.getCause() != DamageCause.FALL)
this.getBall(event.getEntity()).damage();
event.setCancelled(true);
}
}
示例8: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityDamageByEntity(EntityDamageEvent event) {
Player attacker = BukkitUtils.getFinalAttacker(event, true);
if (attacker != null) {
Long lastInteractTime = lastInteractTimes.get(attacker.getUniqueId());
if (lastInteractTime != null && lastInteractTime - System.currentTimeMillis() > 0L) {
event.setCancelled(true);
}
}
}
示例9: onVoidDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onVoidDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player && isSpectating((Player) event.getEntity())) {
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
event.setCancelled(true); //
event.getEntity().setVelocity(new Vector(event.getEntity().getVelocity().getX(),
event.getEntity().getVelocity().getZ() + 10.0, event.getEntity().getVelocity().getZ()));
((Player) event.getEntity()).setAllowFlight(true); // Prevent IllegalArgumentException: Cannot make player fly if getAllowFlight() is false.
((Player) event.getEntity()).setFlying(true);
}
}
}
示例10: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
PetInstance pet = null;
for (PetInstance p : PetInstance.getList()) {
if (p.getEntity() == null)
continue;
if (p.getEntity().getUniqueId().equals(event.getEntity().getUniqueId())) {
pet = p;
break;
}
}
if (pet != null && event instanceof EntityDamageByEntityEvent == false)
event.setCancelled(true);
}
示例11: onDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
Game game = Chambers.getInstance().getGameManager().getGame();
if (game.getInvincibilityTime() > 0) {
event.setCancelled(true);
}
}
}
示例12: entityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的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);
}
示例13: entityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的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 ChickenGizmo)) return;
if(damager.getItemInHand().getType() != this.getIcon()) return;
final Chicken chicken = chickens.computeIfAbsent(victim, Chicken::new);
if(!chicken.add(damager)) return;
chickendCount.compute(victim, (player, count) -> {
count = count == null ? 0 : count + 1;
if(count > 0 && count % 10 == 0) {
RaindropUtil.giveRaindrops(
Users.playerId(damager), 1, null,
new TranslatableComponent("gizmo.chicken.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
);
}
return count;
});
event.setCancelled(true);
}
示例14: onDmg
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@SuppressWarnings("JavaDoc")
@GameEvent
public void onDmg(@Nonnull EntityDamageEvent event) {
event.setCancelled(true);
}
示例15: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent evt) {
evt.setCancelled(getToggle(evt.getEntity(), Toggle.GOD));
}