Java Code Examples for org.bukkit.attribute.AttributeModifier#Operation
The following examples show how to use
org.bukkit.attribute.AttributeModifier#Operation .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLUtils.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
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); }
Example 2
Source File: XMLUtils.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public static Map.Entry<String, AttributeModifier> parseCompactAttributeModifier( Node node, String text) throws InvalidXMLException { String[] parts = text.split(":"); if (parts.length != 3) { throw new InvalidXMLException("Bad attribute modifier format", node); } org.bukkit.attribute.Attribute attribute = parseAttribute(node, parts[0]); AttributeModifier.Operation operation = parseAttributeOperation(node, parts[1]); double amount = parseNumber(node, parts[2], Double.class); return new AbstractMap.SimpleImmutableEntry<>( attribute.getName(), new AttributeModifier("FromXML", amount, operation)); }
Example 3
Source File: XMLUtils.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public static Map.Entry<String, AttributeModifier> parseAttributeModifier(Element el) throws InvalidXMLException { String attribute = parseAttribute(new Node(el)).getName(); double amount = parseNumber(Node.fromRequiredAttr(el, "amount"), Double.class); AttributeModifier.Operation operation = parseAttributeOperation( Node.fromAttr(el, "operation"), AttributeModifier.Operation.ADD_NUMBER); return new AbstractMap.SimpleImmutableEntry<>( attribute, new AttributeModifier("FromXML", amount, operation)); }
Example 4
Source File: XMLUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
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); }
Example 5
Source File: Parser.java From CardinalPGM with MIT License | 5 votes |
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; }
Example 6
Source File: XMLUtils.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public static AttributeModifier.Operation parseAttributeOperation(Node node) throws InvalidXMLException { return parseAttributeOperation(node, node.getValueNormalize()); }
Example 7
Source File: XMLUtils.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
public static AttributeModifier.Operation parseAttributeOperation( Node node, AttributeModifier.Operation def) throws InvalidXMLException { return node == null ? def : parseAttributeOperation(node); }
Example 8
Source File: XMLUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static AttributeModifier.Operation parseAttributeOperation(Node node) throws InvalidXMLException { return parseAttributeOperation(node, node.getValueNormalize()); }
Example 9
Source File: XMLUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static AttributeModifier.Operation parseAttributeOperation(Node node, AttributeModifier.Operation def) throws InvalidXMLException { return node == null ? def : parseAttributeOperation(node); }