Skip to content

Commit

Permalink
feat: NamespacedKeyBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRONiN committed Aug 22, 2022
1 parent f53eb28 commit cac1799
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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());
}
}

0 comments on commit cac1799

Please sign in to comment.