public void applyAttributes(LivingEntity entity) { if (attributes != null) { for (Map.Entry<Attribute, Double> entry : attributes.entrySet()) { AttributeInstance attribute = entity.getAttribute(entry.getKey()); if (attribute != null) { attribute.setBaseValue(entry.getValue()); } } } }
@Override public void setMaxHealth(double health) { getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(health); if (this.health > health) { this.health = health; } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerQuit(PlayerQuitEvent e){ Player player = e.getPlayer(); AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); double baseValue = attribute.getBaseValue(); if(baseValue != 4){ //If basevalue is not 1.9 default, set it back attribute.setBaseValue(4); player.saveData(); } }
/** * Gives an increased max health reward to a player. * * @param player * @param amount * @return the reward text to display to the player */ @SuppressWarnings("deprecation") private String rewardMaxHealth(Player player, int amount) { if (serverVersion >= 9) { AttributeInstance playerAttribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); playerAttribute.setBaseValue(playerAttribute.getBaseValue() + amount); } else { player.setMaxHealth(player.getMaxHealth() + amount); } return ChatColor.translateAlternateColorCodes('&', StringUtils.replaceOnce(langIncreaseMaxHealthRewardReceived, "AMOUNT", Integer.toString(amount))); }
private void checkAttackSpeed(Player player){ World world = player.getWorld(); //If module is disabled, set attack speed to 1.9 default double attackSpeed = Config.moduleEnabled("disable-attack-cooldown", world) ? module().getDouble("generic-attack-speed") : 4; AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); double baseValue = attribute.getBaseValue(); if(baseValue != attackSpeed){ attribute.setBaseValue(attackSpeed); player.saveData(); } }
attribute.setBaseValue(GAS); p.saveData(); Messenger.send(p, message);
AttributeInstance knockBackAttribute = livingTarget.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE); previousKnockbackResistance = knockBackAttribute.getBaseValue(); knockBackAttribute.setBaseValue(knockbackResistance); if (knockbackResistance != null && livingTarget != null) { AttributeInstance knockBackAttribute = livingTarget.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE); knockBackAttribute.setBaseValue(previousKnockbackResistance);
player.setExp(data.getOldExp()); if (is1_9) { player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(data.getOldMaxHealth()); player.setHealth(data.getOldHealth() <= data.getOldMaxHealth() ? data.getOldHealth() : data.getOldMaxHealth()); } else {
attribute.setBaseValue(tmhor.getHorseHealth()); equine.setHealth(tmhor.getHealth()); Inventory inv = equine.getInventory(); ee.setStyle(tmhor.getHorseStyle()); equine.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(tmhor.getSpeed()); equine.setTamed(true); equine.setOwner(p);
attribute.setBaseValue(e.getHorseHealth()); equine.setHealth(e.getHealth()); String name = e.getName(); p.updateInventory(); equine.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(e.getSpeed()); equine.setRemoveWhenFarAway(false); }); attribute.setBaseValue(ll.getHorseHealth()); cria.setHealth(ll.getHealth()); String name = ll.getName(); p.updateInventory(); cria.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(ll.getSpeed()); cria.setRemoveWhenFarAway(false); });
attribute.setBaseValue(tmlla.getHorseHealth()); String name = tmlla.getName(); if (name != null && !name.isEmpty()) { player.updateInventory(); llama.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(tmlla.getSpeed()); ent.remove(); break;