本文整理汇总了Java中org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason类的典型用法代码示例。如果您正苦于以下问题:Java RegainReason类的具体用法?Java RegainReason怎么用?Java RegainReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegainReason类属于org.bukkit.event.entity.EntityRegainHealthEvent包,在下文中一共展示了RegainReason类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@Override
public void call(Event event) {
if (event instanceof EntityRegainHealthEvent) {
EntityRegainHealthEvent erhe = (EntityRegainHealthEvent) event;
if (erhe.getRegainReason() == RegainReason.SATIATED) {
/*
* Player is regenerating health because their hunger is full.
*/
final double health = profile.getPlayer().getHealth();
if (!isAcceptable(health, erhe.getAmount())) {
callback(true);
}
lastTime = System.currentTimeMillis();
}
}
}
示例2: applyInstantEffect
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) {
// CraftBukkit end
int j;
if ((this.id != HEAL.id || entityliving1.aR()) && (this.id != HARM.id || !entityliving1.aR())) {
if (this.id == HARM.id && !entityliving1.aR() || this.id == HEAL.id && entityliving1.aR()) {
j = (int) (d0 * (double) (6 << i) + 0.5D);
if (entityliving == null) {
entityliving1.damageEntity(DamageSource.MAGIC, (float) j);
} else {
// CraftBukkit - The "damager" needs to be the potion
entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), (float) j);
}
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
entityliving1.heal((float) j, RegainReason.MAGIC); // CraftBukkit
}
}
示例3: tick
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
if (this.id == REGENERATION.id) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
} else if (this.id == POISON.id) {
if (entityliving.getHealth() > 1.0F) {
entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
} else if (this.id == WITHER.id) {
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
} else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
((EntityHuman) entityliving).a(0.025F * (float) (i + 1));
} else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) {
if (!entityliving.world.isStatic) {
((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
}
} else if ((this.id != HEAL.id || entityliving.aM()) && (this.id != HARM.id || !entityliving.aM())) {
if (this.id == HARM.id && !entityliving.aM() || this.id == HEAL.id && entityliving.aM()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
}
} else {
entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
}
}
示例4: applyInstantEffect
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) {
// CraftBukkit end
int j;
if ((this.id != HEAL.id || entityliving1.aM()) && (this.id != HARM.id || !entityliving1.aM())) {
if (this.id == HARM.id && !entityliving1.aM() || this.id == HEAL.id && entityliving1.aM()) {
j = (int) (d0 * (double) (6 << i) + 0.5D);
if (entityliving == null) {
entityliving1.damageEntity(DamageSource.MAGIC, (float) j);
} else {
// CraftBukkit - The "damager" needs to be the potion
entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), (float) j);
}
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
entityliving1.heal((float) j, RegainReason.MAGIC);
}
}
示例5: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
/**
* On entity regain health.
*
* @param event the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
Entity entity = event.getEntity();
Player player;
IPlayerConfEntry entry;
if(entity != null && event.getEntity() instanceof Player
&& (event.getRegainReason() == RegainReason.REGEN
|| event.getRegainReason() == RegainReason.SATIATED)
&& (entry = playerConf.get((player = (Player) event.getEntity()))) != null
&& !entry.isAdminMod()) {
IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(player.getLocation());
if (!checkPermission(land, player, PermissionList.FOOD_HEAL.getPermissionType())) {
event.setCancelled(true);
}
}
}
示例6: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
Player player = (Player) event.getEntity();
if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
CheckResult result = getBackend().checkFastHeal(player);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_HEAL);
} else {
decrease(player);
getBackend().logHeal(player);
}
}
}
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
示例7: applyInstantEffect
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(@Nullable Entity entity, @Nullable Entity entity1, EntityLiving entityliving, int i, double d0) {
int j;
if ((this != MobEffects.HEAL || entityliving.bQ()) && (this != MobEffects.HARM || !entityliving.bQ())) {
if (this == MobEffects.HARM && !entityliving.bQ() || this == MobEffects.HEAL && entityliving.bQ()) {
j = (int) (d0 * (double) (6 << i) + 0.5D);
if (entity == null) {
entityliving.damageEntity(DamageSource.MAGIC, (float) j);
} else {
entityliving.damageEntity(DamageSource.b(entity, entity1), (float) j);
}
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit
}
}
示例8: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
if (event.getRegainReason() != RegainReason.SATIATED) {
return;
}
Player player = (Player) event.getEntity();
int proteinValue = plugin.getValueManager().getValue(FoodType.PROTEIN, player);
Random ran = new Random();
if (proteinValue <= -7) {
if (ran.nextInt(2) == 0) {
event.setCancelled(true);
}
} else if (proteinValue <= -6) {
if (ran.nextInt(4) > 0) {
event.setCancelled(true);
}
}
}
示例9: onEnderDragonRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
/**
* Handle EnderDragon regen
*
* @param event an EntityRegainHealthEvent
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonRegainHealth(final EntityRegainHealthEvent event) {
if (event.getEntityType() == EntityType.ENDER_DRAGON && event.getRegainReason() == RegainReason.ENDER_CRYSTAL) {
final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getEntity().getLocation().getWorld().getName()));
if (handler != null) {
final float rate = handler.getConfig().getEcHealthRegainRate();
if (rate < 1.0) {
if (RANDOM.nextFloat() >= rate) {
event.setCancelled(true);
}
} else if (rate > 1.0) {
event.setAmount((int)(rate * event.getAmount()));
}
}
}
}
示例10: tick
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
if (this.id == REGENERATION.id) {
if (entityliving.getHealth() < entityliving.maxHealth) { // CraftBukkit - .getMaxHealth() -> .maxHealth
entityliving.heal(1, RegainReason.MAGIC_REGEN); // CraftBukkit
}
} else if (this.id == POISON.id) {
if (entityliving.getHealth() > 1) {
entityliving.damageEntity(CraftEventFactory.POISON, 1); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
} else if (this.id == WITHER.id) {
entityliving.damageEntity(DamageSource.WITHER, 1);
} else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
((EntityHuman) entityliving).j(0.025F * (float) (i + 1));
} else if ((this.id != HEAL.id || entityliving.bD()) && (this.id != HARM.id || !entityliving.bD())) {
if (this.id == HARM.id && !entityliving.bD() || this.id == HEAL.id && entityliving.bD()) {
entityliving.damageEntity(DamageSource.MAGIC, 6 << i);
}
} else {
entityliving.heal(6 << i, RegainReason.MAGIC); // CraftBukkit
}
}
示例11: applyInstantEffect
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) {
// CraftBukkit end
int j;
if ((this.id != HEAL.id || entityliving1.bD()) && (this.id != HARM.id || !entityliving1.bD())) {
if (this.id == HARM.id && !entityliving1.bD() || this.id == HEAL.id && entityliving1.bD()) {
j = (int) (d0 * (double) (6 << i) + 0.5D);
if (entityliving == null) {
entityliving1.damageEntity(DamageSource.MAGIC, j);
} else {
// CraftBukkit - The "damager" needs to be the potion
entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), j);
}
}
} else {
j = (int) (d0 * (double) (6 << i) + 0.5D);
entityliving1.heal(j, RegainReason.MAGIC); // CraftBukkit
}
}
示例12: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player)
{
final ISettings settings = ess.getSettings();
final IUser user = ess.getUserMap().getUser((Player)event.getEntity());
if (user.getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers())
{
event.setCancelled(true);
}
}
}
示例13: healthRegen
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler
public void healthRegen(EntityRegainHealthEvent event){
if(event.getRegainReason().equals(RegainReason.SATIATED)){
event.setCancelled(true);
}
if(event.getRegainReason().equals(RegainReason.REGEN)){
event.setCancelled(true);
}
}
示例14: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onEntityRegainHealth(cn.nukkit.event.entity.EntityRegainHealthEvent event) {
if (canIgnore(PlayerInteractEvent.getHandlerList())) {
return;
}
int reason = event.getRegainReason();
RegainReason bukkitReason = RegainReason.EATING;
switch (reason) {
case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_MAGIC:
bukkitReason = RegainReason.MAGIC;
break;
case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_CUSTOM:
bukkitReason = RegainReason.CUSTOM;
break;
case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_EATING:
bukkitReason = RegainReason.EATING;
break;
case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_REGEN:
bukkitReason = RegainReason.REGEN;
break;
}
EntityRegainHealthEvent bukkitEvent = new EntityRegainHealthEvent(PokkitEntity.toBukkit(event.getEntity()), event.getAmount(), bukkitReason);
callCancellable(event, bukkitEvent);
}
示例15: tick
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
if (this.id == REGENERATION.id) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
} else if (this.id == POISON.id) {
if (entityliving.getHealth() > 1.0F) {
entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
} else if (this.id == WITHER.id) {
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
} else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
((EntityHuman) entityliving).applyExhaustion(0.025F * (float) (i + 1));
} else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) {
if (!entityliving.world.isStatic) {
// CraftBukkit start
EntityHuman entityhuman = (EntityHuman) entityliving;
int oldFoodLevel = entityhuman.getFoodData().foodLevel;
org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);
if (!event.isCancelled()) {
entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
}
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
// CraftBukkit end
}
} else if ((this.id != HEAL.id || entityliving.aR()) && (this.id != HARM.id || !entityliving.aR())) {
if (this.id == HARM.id && !entityliving.aR() || this.id == HEAL.id && entityliving.aR()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
}
} else {
entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
}
}