本文整理汇总了Java中org.bukkit.attribute.AttributeModifier类的典型用法代码示例。如果您正苦于以下问题:Java AttributeModifier类的具体用法?Java AttributeModifier怎么用?Java AttributeModifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeModifier类属于org.bukkit.attribute包,在下文中一共展示了AttributeModifier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: reset
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static void reset(Player player, boolean heal) {
if (heal) player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
player.setFoodLevel(20);
player.setSaturation(20);
player.getInventory().clear();
player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
player.setItemOnCursor(new ItemStack(Material.AIR));
player.getActivePotionEffects().forEach(potionEffect -> {
try {
player.removePotionEffect(potionEffect.getType());
} catch (NullPointerException ignored) {}
});
player.setFireTicks(0);
player.setFallDistance(0);
player.setTotalExperience(0);
player.setExp(0);
player.setLevel(0);
player.setWalkSpeed(0.2F);
player.setFlySpeed(0.1F);
player.setSneaking(false);
player.setInvulnerable(false);
player.setCanPickupItems(true);
player.setCollidable(true);
player.setFlying(false);
player.setAllowFlight(false);
player.resetTitle();
for (Attribute attribute : Attribute.values()) {
if (player.getAttribute(attribute) == null) continue;
for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) {
player.getAttribute(attribute).removeModifier(modifier);
}
}
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 24.000D, AttributeModifier.Operation.ADD_SCALAR));
player.updateInventory();
}
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:42,代码来源:Players.java
示例2: parseAttributeOperation
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static AttributeModifier.Operation parseAttributeOperation(Node node, String text) throws InvalidXMLException {
switch(text.toLowerCase()) {
case "add": return AttributeModifier.Operation.ADD_NUMBER;
case "base": return AttributeModifier.Operation.ADD_SCALAR;
case "multiply": return AttributeModifier.Operation.MULTIPLY_SCALAR_1;
}
throw new InvalidXMLException("Unknown attribute modifier operation '" + text + "'", node);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:XMLUtils.java
示例3: parseCompactAttributeModifier
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static Pair<org.bukkit.attribute.Attribute, AttributeModifier> parseCompactAttributeModifier(Node node, String text) throws InvalidXMLException {
final String[] parts = text.split(":");
if(parts.length != 3) {
throw new InvalidXMLException("Bad attribute modifier format", node);
}
return Pair.create(
parseAttribute(node, parts[0]),
new AttributeModifier(
"FromXML",
parseNumber(node, parts[2], Double.class),
parseAttributeOperation(node, parts[1])
)
);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:XMLUtils.java
示例4: parseAttributeModifier
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static Pair<org.bukkit.attribute.Attribute, AttributeModifier> parseAttributeModifier(Element el) throws InvalidXMLException {
return Pair.create(
parseAttribute(new Node(el)),
new AttributeModifier(
"FromXML",
parseNumber(Node.fromRequiredAttr(el, "amount"), Double.class),
parseAttributeOperation(Node.fromAttr(el, "operation"), AttributeModifier.Operation.ADD_NUMBER)
)
);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:XMLUtils.java
示例5: addModifier0
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
private boolean addModifier0(Attribute attribute, AttributeModifier modifier) {
final AttributeInstance attributeInstance = player.getAttribute(attribute);
if(attributeInstance != null && !attributeInstance.getModifiers().contains(modifier)) {
attributeInstance.addModifier(modifier);
return true;
}
return false;
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:AttributePlayerFacet.java
示例6: removeModifier0
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
private boolean removeModifier0(Attribute attribute, AttributeModifier modifier) {
AttributeInstance attributeValue = player.getAttribute(attribute);
if(attributeValue != null && attributeValue.getModifiers().contains(modifier)) {
attributeValue.removeModifier(modifier);
return true;
}
return false;
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:AttributePlayerFacet.java
示例7: DungeonBoss
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public DungeonBoss(Location loc, EntityType type, String name, boolean finalBoss) {
super(loc, type, name);
this.finalBoss = finalBoss;
getBukkit().setCustomName(ChatColor.RED + name);
getBukkit().setCustomNameVisible(true);
AttributeInstance a = getLiving().getAttribute(Attribute.GENERIC_MAX_HEALTH);
a.addModifier(new AttributeModifier("mult", 1, AttributeModifier.Operation.ADD_SCALAR)); // Double boss health.
getLiving().setHealth(a.getValue()); // Max out health.
}
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:10,代码来源:DungeonBoss.java
示例8: clearStats
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
private void clearStats() {
Player player = this.player.getPlayer();
AttributeInstance speedAttribute = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
AttributeModifier rpgInvModifier = null;
for (AttributeModifier modifier : speedAttribute.getModifiers()) {
if (modifier.getUniqueId().compareTo(Attributes.SPEED_MODIFIER_ID) == 0) {
rpgInvModifier = modifier;
}
}
if (rpgInvModifier != null) {
speedAttribute.removeModifier(rpgInvModifier);
}
}
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:16,代码来源:PlayerWrapper.java
示例9: resetPlayer
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static void resetPlayer(Player player, boolean heal) {
if (heal) player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setSaturation(20);
player.getInventory().clear();
player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
for (PotionEffect effect : player.getActivePotionEffects()) {
try {
player.removePotionEffect(effect.getType());
} catch (NullPointerException ignored) {
}
}
player.setTotalExperience(0);
player.setExp(0);
player.setLevel(0);
player.setWalkSpeed(0.2F);
player.setFlySpeed(0.1F);
player.setFallDistance(0);
player.setFlying(false);
player.setAllowFlight(false);
player.setCollidable(true);
for (Attribute attribute : Attribute.values()) {
if (player.getAttribute(attribute) == null) continue;
for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) {
player.getAttribute(attribute).removeModifier(modifier);
}
}
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 4.001D, AttributeModifier.Operation.ADD_SCALAR));
}
开发者ID:Minehut,项目名称:GamePlate,代码行数:33,代码来源:Players.java
示例10: parseAttributes
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
private static List<ItemAttributeModifier> parseAttributes(String attributes) {
List<ItemAttributeModifier> list = Lists.newArrayList();
for (String attribute : attributes.split(";")) {
String[] attr = attribute.split(":");
list.add(new ItemAttributeModifier(null,
new AttributeModifier(UUID.randomUUID(), attr[0], Numbers.parseDouble(attr[2]), getOperation(attr[1]))));
}
return list;
}
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:10,代码来源:DocumentItems.java
示例11: getOperation
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static AttributeModifier.Operation getOperation(String operation) {
if (Numbers.isNumber(operation)) {
return AttributeModifier.Operation.fromOpcode(Integer.parseInt(operation));
} else {
switch (operation.toLowerCase()) {
case ("base"):
return AttributeModifier.Operation.ADD_SCALAR;
case ("multiply"):
return AttributeModifier.Operation.MULTIPLY_SCALAR_1;
case ("add"):
default:
return AttributeModifier.Operation.ADD_NUMBER;
}
}
}
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:16,代码来源:DocumentItems.java
示例12: setAttributeModifier
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
/**
* Sets the provided attribute up with a modifier by the given name (overwriting one if it exists)
* for the given amount.
* <b>This is done</b> under the {@link AttributeModifier.Operation#ADD_SCALAR} operation!
*/
public static void setAttributeModifier(AttributeInstance attribute, String name, double amt) {
Collection<AttributeModifier> mods = attribute.getModifiers();
for (AttributeModifier mod : mods) {
if (mod.getName().equals(name)) {
attribute.removeModifier(mod);
break;
}
}
attribute.addModifier(new AttributeModifier(name, amt, AttributeModifier.Operation.ADD_SCALAR));
}
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:18,代码来源:Skill.java
示例13: resetPlayer
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static void resetPlayer(Player player, boolean heal) {
if (heal) player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setSaturation(20);
player.getInventory().clear();
player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
for (PotionEffect effect : player.getActivePotionEffects()) {
try {
player.removePotionEffect(effect.getType());
} catch (NullPointerException ignored) {
}
}
player.setTotalExperience(0);
player.setExp(0);
player.setLevel(0);
player.setPotionParticles(false);
player.setWalkSpeed(0.2F);
player.setFlySpeed(0.1F);
player.setKnockbackReduction(0);
player.setArrowsStuck(0);
player.hideTitle();
player.setFastNaturalRegeneration(false);
for (Attribute attribute : Attribute.values()) {
if (player.getAttribute(attribute) == null) continue;
for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) {
player.getAttribute(attribute).removeModifier(modifier);
}
}
player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 4.001D, AttributeModifier.Operation.ADD_SCALAR));
player.getAttribute(Attribute.ARROW_ACCURACY).addModifier(new AttributeModifier(UUID.randomUUID(), "sportbukkit.arrowAccuracy", -1D, AttributeModifier.Operation.ADD_NUMBER));
player.getAttribute(Attribute.ARROW_VELOCITY_TRANSFER).addModifier(new AttributeModifier(UUID.randomUUID(), "sportbukkit.arrowVelocityTransfer", -1D, AttributeModifier.Operation.ADD_NUMBER));
}
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:36,代码来源:Players.java
示例14: parseAttributes
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
private static List<ItemAttributeModifier> parseAttributes(String attributes) {
List<ItemAttributeModifier> list = new ArrayList<>();
for (String attribute : attributes.split(";")) {
String[] attr = attribute.split(":");
list.add(new ItemAttributeModifier(null, new AttributeModifier(UUID.randomUUID(), attr[0], Double.parseDouble(attr[2]), getOperation(attr[1]))));
}
return list;
}
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:9,代码来源:Parser.java
示例15: getOperation
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static AttributeModifier.Operation getOperation(String operation) {
if (NumberUtils.isNumber(operation)) {
return AttributeModifier.Operation.fromOpcode(Integer.parseInt(operation));
} else {
switch (operation.toLowerCase()) {
case("add"):
return AttributeModifier.Operation.ADD_NUMBER;
case("base"):
return AttributeModifier.Operation.ADD_SCALAR;
case("multiply"):
return AttributeModifier.Operation.MULTIPLY_SCALAR_1;
}
}
return AttributeModifier.Operation.ADD_NUMBER;
}
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:16,代码来源:Parser.java
示例16: getModifiers
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
@Override
public Collection<AttributeModifier> getModifiers() {
List<AttributeModifier> result = new ArrayList<AttributeModifier>();
for (net.minecraft.server.AttributeModifier nms : handle.c()) {
result.add(convert(nms));
}
return result;
}
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:10,代码来源:CraftAttributeInstance.java
示例17: AttributeKit
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public AttributeKit(Pair<Attribute, AttributeModifier> pair) {
this(pair.first, pair.second);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:AttributeKit.java
示例18: addModifier
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public boolean addModifier(Attribute attribute, AttributeModifier modifier) {
return modifiers.put(attribute, modifier) && addModifier0(attribute, modifier);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:AttributePlayerFacet.java
示例19: removeModifier
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public boolean removeModifier(Attribute attribute, AttributeModifier modifier) {
return modifiers.remove(attribute, modifier) && removeModifier0(attribute, modifier);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:AttributePlayerFacet.java
示例20: removeModifier
import org.bukkit.attribute.AttributeModifier; //导入依赖的package包/类
public static void removeModifier(Attributable attributable, AttributeModifier modifier) {
for(Attribute attribute : Attribute.values()) {
final AttributeInstance instance = attributable.getAttribute(attribute);
if(instance != null) instance.removeModifier(modifier);
}
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:AttributeUtils.java
注:本文中的org.bukkit.attribute.AttributeModifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论