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 bab2106d24..5a6e621d58 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java +++ b/paper-api/src/main/java/org/bukkit/configuration/ConfigurationSection.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.inventory.ItemStack; @@ -882,6 +883,48 @@ public interface ConfigurationSection { */ public boolean isColor(@NotNull String path); + /** + * Gets the requested Location by path. + *

+ * If the Location does not exist but a default value has been specified, + * this will return the default value. If the Location does not exist and no + * default value was specified, this will return null. + * + * @param path Path of the Location to get. + * @return Requested Location. + */ + @Nullable + public Location getLocation(@NotNull String path); + + /** + * Gets the requested {@link Location} by path, returning a default value if + * not found. + *

+ * If the Location does not exist then the specified default value will + * returned regardless of if a default has been identified in the root + * {@link Configuration}. + * + * @param path Path of the Location to get. + * @param def The default value to return if the path is not found or is not + * a Location. + * @return Requested Location. + */ + @Nullable + public Location getLocation(@NotNull String path, @Nullable Location def); + + /** + * Checks if the specified path is a Location. + *

+ * If the path exists but is not a Location, this will return false. If the + * path does not exist, this will return false. If the path does not exist + * but a default value has been specified, this will check if that default + * value is a Location and return appropriately. + * + * @param path Path of the Location to check. + * @return Whether or not the specified path is a Location. + */ + public boolean isLocation(@NotNull String path); + /** * Gets the requested ConfigurationSection by path. *

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 89ea0e5d79..e9b6a12a8e 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java +++ b/paper-api/src/main/java/org/bukkit/configuration/MemorySection.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Set; import org.apache.commons.lang.Validate; import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.inventory.ItemStack; @@ -789,6 +790,23 @@ public class MemorySection implements ConfigurationSection { return getSerializable(path, Color.class) != null; } + @Override + @Nullable + public Location getLocation(@NotNull String path) { + return getSerializable(path, Location.class); + } + + @Override + @Nullable + public Location getLocation(@NotNull String path, @Nullable Location def) { + return getSerializable(path, Location.class, def); + } + + @Override + public boolean isLocation(@NotNull String path) { + return getSerializable(path, Location.class) != null; + } + @Override @Nullable public ConfigurationSection getConfigurationSection(@NotNull String path) {