diff --git a/src/main/java/in/arcadelabs/labaide/namespacedkey/NamespacedKeyBuilder.java b/src/main/java/in/arcadelabs/labaide/namespacedkey/NamespacedKeyBuilder.java new file mode 100644 index 0000000..7763dea --- /dev/null +++ b/src/main/java/in/arcadelabs/labaide/namespacedkey/NamespacedKeyBuilder.java @@ -0,0 +1,51 @@ +/* + * LabAide - Common utility library for our products. + * Copyright (C) 2022 ArcadeLabs Production. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package in.arcadelabs.labaide.namespacedkey; + +import org.bukkit.NamespacedKey; +import org.bukkit.plugin.java.JavaPlugin; + +/** + * Builder util for {@link NamespacedKey}s. + */ +public final class NamespacedKeyBuilder { + private final String keyPrefix; + private final JavaPlugin plugin; + + /** + * Instantiates a new Namespaced key builder. + * + * @param keyPrefix the key prefix + * @param plugin the plugin + */ + public NamespacedKeyBuilder(final String keyPrefix, final JavaPlugin plugin) { + this.keyPrefix = keyPrefix.toLowerCase(); + this.plugin = plugin; + } + + /** + * Gets new key. + * + * @param key the key + * @return the new key + */ + public NamespacedKey getNewKey(final String key) { + return new NamespacedKey(this.plugin, this.keyPrefix + "_" + key.toLowerCase()); + } +} \ No newline at end of file