SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Concrete implementation of an attribute modifier.
|
||||
@@ -20,15 +22,15 @@ public class AttributeModifier implements ConfigurationSerializable {
|
||||
private final Operation operation;
|
||||
private final EquipmentSlot slot;
|
||||
|
||||
public AttributeModifier(String name, double amount, Operation operation) {
|
||||
public AttributeModifier(@NotNull String name, double amount, @NotNull Operation operation) {
|
||||
this(UUID.randomUUID(), name, amount, operation);
|
||||
}
|
||||
|
||||
public AttributeModifier(UUID uuid, String name, double amount, Operation operation) {
|
||||
public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation) {
|
||||
this(uuid, name, amount, operation, null);
|
||||
}
|
||||
|
||||
public AttributeModifier(UUID uuid, String name, double amount, Operation operation, EquipmentSlot slot) {
|
||||
public AttributeModifier(@NotNull UUID uuid, @NotNull String name, double amount, @NotNull Operation operation, @Nullable EquipmentSlot slot) {
|
||||
Validate.notNull(uuid, "UUID cannot be null");
|
||||
Validate.notEmpty(name, "Name cannot be empty");
|
||||
Validate.notNull(operation, "Operation cannot be null");
|
||||
@@ -44,6 +46,7 @@ public class AttributeModifier implements ConfigurationSerializable {
|
||||
*
|
||||
* @return unique id
|
||||
*/
|
||||
@NotNull
|
||||
public UUID getUniqueId() {
|
||||
return uuid;
|
||||
}
|
||||
@@ -53,6 +56,7 @@ public class AttributeModifier implements ConfigurationSerializable {
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -71,6 +75,7 @@ public class AttributeModifier implements ConfigurationSerializable {
|
||||
*
|
||||
* @return operation
|
||||
*/
|
||||
@NotNull
|
||||
public Operation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
@@ -81,10 +86,12 @@ public class AttributeModifier implements ConfigurationSerializable {
|
||||
*
|
||||
* @return the slot
|
||||
*/
|
||||
@Nullable
|
||||
public EquipmentSlot getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
@@ -130,7 +137,8 @@ public class AttributeModifier implements ConfigurationSerializable {
|
||||
+ "}";
|
||||
}
|
||||
|
||||
public static AttributeModifier deserialize(Map<String, Object> args) {
|
||||
@NotNull
|
||||
public static AttributeModifier deserialize(@NotNull Map<String, Object> args) {
|
||||
if (args.containsKey("slot")) {
|
||||
return new AttributeModifier(UUID.fromString((String) args.get("uuid")), (String) args.get("name"), NumberConversions.toDouble(args.get("amount")), Operation.values()[NumberConversions.toInt(args.get("operation"))], EquipmentSlot.valueOf((args.get("slot").toString().toUpperCase())));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user