diff --git a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java index 5a6e621d58..715ef162da 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java +++ b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java @@ -9,6 +9,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -180,6 +181,7 @@ public interface ConfigurationSection { * @param def The default value to return if the path is not found. * @return Requested Object. */ + @Contract("_, !null -> !null") @Nullable public Object get(@NotNull String path, @Nullable Object def); @@ -254,6 +256,7 @@ public interface ConfigurationSection { * not a String. * @return Requested String. */ + @Contract("_, !null -> !null") @Nullable public String getString(@NotNull String path, @Nullable String def); @@ -456,6 +459,7 @@ public interface ConfigurationSection { * not a List. * @return Requested List. */ + @Contract("_, !null -> !null") @Nullable public List getList(@NotNull String path, @Nullable List def); @@ -677,6 +681,7 @@ public interface ConfigurationSection { * the path * @return Requested object */ + @Contract("_, _, !null -> !null") @Nullable public T getObject(@NotNull String path, @NotNull Class clazz, @Nullable T def); @@ -711,6 +716,7 @@ public interface ConfigurationSection { * the path * @return Requested {@link ConfigurationSerializable} object */ + @Contract("_, _, !null -> !null") @Nullable public T getSerializable(@NotNull String path, @NotNull Class clazz, @Nullable T def); @@ -740,6 +746,7 @@ public interface ConfigurationSection { * not a Vector. * @return Requested Vector. */ + @Contract("_, !null -> !null") @Nullable public Vector getVector(@NotNull String path, @Nullable Vector def); @@ -783,6 +790,7 @@ public interface ConfigurationSection { * not an OfflinePlayer. * @return Requested OfflinePlayer. */ + @Contract("_, !null -> !null") @Nullable public OfflinePlayer getOfflinePlayer(@NotNull String path, @Nullable OfflinePlayer def); @@ -825,6 +833,7 @@ public interface ConfigurationSection { * not an ItemStack. * @return Requested ItemStack. */ + @Contract("_, !null -> !null") @Nullable public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def); @@ -867,6 +876,7 @@ public interface ConfigurationSection { * not a Color. * @return Requested Color. */ + @Contract("_, !null -> !null") @Nullable public Color getColor(@NotNull String path, @Nullable Color def); @@ -909,6 +919,7 @@ public interface ConfigurationSection { * a Location. * @return Requested Location. */ + @Contract("_, !null -> !null") @Nullable public Location getLocation(@NotNull String path, @Nullable Location def); diff --git a/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java b/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java index f03dec0c9e..90cc523f65 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java +++ b/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java @@ -14,6 +14,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -230,6 +231,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public Object get(@NotNull String path, @Nullable Object def) { Validate.notNull(path, "Path cannot be null"); @@ -321,6 +323,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public String getString(@NotNull String path, @Nullable String def) { Object val = get(path, def); @@ -414,6 +417,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public List getList(@NotNull String path, @Nullable List def) { Object val = get(path, def); @@ -702,6 +706,7 @@ public class MemorySection implements ConfigurationSection { return getObject(path, clazz, (def != null && clazz.isInstance(def)) ? clazz.cast(def) : null); } + @Contract("_, _, !null -> !null") @Nullable @Override public T getObject(@NotNull String path, @NotNull Class clazz, @Nullable T def) { @@ -716,6 +721,7 @@ public class MemorySection implements ConfigurationSection { return getObject(path, clazz); } + @Contract("_, _, !null -> !null") @Nullable @Override public T getSerializable(@NotNull String path, @NotNull Class clazz, @Nullable T def) { @@ -729,6 +735,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public Vector getVector(@NotNull String path, @Nullable Vector def) { return getSerializable(path, Vector.class, def); @@ -746,6 +753,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public OfflinePlayer getOfflinePlayer(@NotNull String path, @Nullable OfflinePlayer def) { return getSerializable(path, OfflinePlayer.class, def); @@ -763,6 +771,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public ItemStack getItemStack(@NotNull String path, @Nullable ItemStack def) { return getSerializable(path, ItemStack.class, def); @@ -780,6 +789,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public Color getColor(@NotNull String path, @Nullable Color def) { return getSerializable(path, Color.class, def); @@ -797,6 +807,7 @@ public class MemorySection implements ConfigurationSection { } @Override + @Contract("_, !null -> !null") @Nullable public Location getLocation(@NotNull String path, @Nullable Location def) { return getSerializable(path, Location.class, def);