From 102879ef3dfc1a15b22c1c9fe8097720faea46a6 Mon Sep 17 00:00:00 2001 From: HSGamer Date: Fri, 15 Mar 2024 11:46:34 +0700 Subject: [PATCH] remove bukkit-key moved to MineLib --- bukkit/bukkit-key/pom.xml | 17 -- .../hscore/bukkit/key/AbstractKeyManager.java | 27 --- .../hsgamer/hscore/bukkit/key/KeyManager.java | 46 ----- .../bukkit/key/MinecraftKeyManager.java | 13 -- .../hscore/bukkit/key/PluginKeyManager.java | 25 --- .../hscore/bukkit/key/PluginKeyPair.java | 160 ------------------ .../hscore/bukkit/key/PluginKeyUtils.java | 59 ------- .../hscore/bukkit/key/package-info.java | 4 - bukkit/pom.xml | 1 - 9 files changed, 352 deletions(-) delete mode 100644 bukkit/bukkit-key/pom.xml delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/AbstractKeyManager.java delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/KeyManager.java delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/MinecraftKeyManager.java delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyManager.java delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyPair.java delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyUtils.java delete mode 100644 bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/package-info.java diff --git a/bukkit/bukkit-key/pom.xml b/bukkit/bukkit-key/pom.xml deleted file mode 100644 index 70c1abddfc..0000000000 --- a/bukkit/bukkit-key/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - hscore-bukkit - me.hsgamer - 4.4.0-SNAPSHOT - - 4.0.0 - - hscore-bukkit-key - - - 1.14.4-R0.1-SNAPSHOT - - \ No newline at end of file diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/AbstractKeyManager.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/AbstractKeyManager.java deleted file mode 100644 index 7d836ac08c..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/AbstractKeyManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package me.hsgamer.hscore.bukkit.key; - -import org.bukkit.NamespacedKey; - -import java.util.HashMap; -import java.util.Map; - -/** - * The abstract key manager - */ -public abstract class AbstractKeyManager implements KeyManager { - private final Map namespacedKeyMap = new HashMap<>(); - - @Override - public NamespacedKey createKey(String key) { - return namespacedKeyMap.computeIfAbsent(key, this::newKey); - } - - /** - * Create a new key - * - * @param key the key - * - * @return the new key - */ - public abstract NamespacedKey newKey(String key); -} diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/KeyManager.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/KeyManager.java deleted file mode 100644 index 25ba9c10dc..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/KeyManager.java +++ /dev/null @@ -1,46 +0,0 @@ -package me.hsgamer.hscore.bukkit.key; - -import org.bukkit.NamespacedKey; -import org.bukkit.persistence.PersistentDataType; - -/** - * An interface for all {@link NamespacedKey} manager - */ -public interface KeyManager { - /** - * Create a new {@link NamespacedKey}. - * This should have a function to store the created {@link NamespacedKey} for later uses. - * - * @param key the key - * - * @return the {@link NamespacedKey} - */ - NamespacedKey createKey(String key); - - /** - * Create a new key pair - * - * @param key the key - * @param dataType the data type for the value - * @param defaultValue the default value if not found - * @param the retrieved object type when applying this data type - * - * @return the new key pair - */ - default PluginKeyPair createKeyPair(String key, PersistentDataType dataType, Z defaultValue) { - return new PluginKeyPair<>(createKey(key), dataType, defaultValue); - } - - /** - * Create a new key pair with null default value - * - * @param key the key - * @param dataType the data type for the value - * @param the retrieved object type when applying this data type - * - * @return the new key pair - */ - default PluginKeyPair createKeyPair(String key, PersistentDataType dataType) { - return createKeyPair(key, dataType, null); - } -} diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/MinecraftKeyManager.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/MinecraftKeyManager.java deleted file mode 100644 index 3cedb3d0c5..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/MinecraftKeyManager.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.hsgamer.hscore.bukkit.key; - -import org.bukkit.NamespacedKey; - -/** - * the {@link KeyManager} for default Minecraft - */ -public class MinecraftKeyManager extends AbstractKeyManager { - @Override - public NamespacedKey newKey(String key) { - return NamespacedKey.minecraft(key); - } -} diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyManager.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyManager.java deleted file mode 100644 index 77f201845b..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyManager.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.hsgamer.hscore.bukkit.key; - -import org.bukkit.NamespacedKey; -import org.bukkit.plugin.Plugin; - -/** - * A {@link KeyManager} for the {@link Plugin} - */ -public class PluginKeyManager extends AbstractKeyManager { - private final Plugin plugin; - - /** - * Create a new {@link NamespacedKey} manager - * - * @param plugin the holder plugin - */ - public PluginKeyManager(Plugin plugin) { - this.plugin = plugin; - } - - @Override - public NamespacedKey newKey(String key) { - return new NamespacedKey(plugin, key); - } -} diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyPair.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyPair.java deleted file mode 100644 index 8c6d21cfd3..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyPair.java +++ /dev/null @@ -1,160 +0,0 @@ -package me.hsgamer.hscore.bukkit.key; - -import org.bukkit.NamespacedKey; -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataHolder; -import org.bukkit.persistence.PersistentDataType; - -/** - * A pair of {@link NamespacedKey} and {@link PersistentDataType} - * - * @param the retrieved object type when applying this data type - */ -public class PluginKeyPair { - private final NamespacedKey key; - private final PersistentDataType dataType; - private final Z defaultValue; - - /** - * Create a new instance of {@link PluginKeyPair} - * - * @param key the key - * @param dataType the data type - * @param defaultValue the default value - */ - public PluginKeyPair(NamespacedKey key, PersistentDataType dataType, Z defaultValue) { - this.key = key; - this.dataType = dataType; - this.defaultValue = defaultValue; - } - - /** - * Get the key - * - * @return the key - */ - public NamespacedKey getKey() { - return key; - } - - /** - * Get the data type - * - * @return the data type - */ - public PersistentDataType getDataType() { - return dataType; - } - - /** - * Get the default value - * - * @return the default value - */ - public Z getDefaultValue() { - return defaultValue; - } - - /** - * Get the value from the container - * - * @param container the container - * - * @return the value - */ - public Z get(PersistentDataContainer container) { - return container.getOrDefault(key, dataType, defaultValue); - } - - /** - * Set the value to the container - * - * @param container the container - * @param value the value - */ - public void set(PersistentDataContainer container, Z value) { - if (value == null) { - remove(container); - } else { - container.set(key, dataType, value); - } - } - - /** - * Get the value from the holder - * - * @param holder the holder - * - * @return the value - */ - public Z get(PersistentDataHolder holder) { - return get(holder.getPersistentDataContainer()); - } - - /** - * Set the value to the holder - * - * @param holder the holder - * @param value the value - */ - public void set(PersistentDataHolder holder, Z value) { - set(holder.getPersistentDataContainer(), value); - } - - /** - * Check if the container contains the key - * - * @param container the container - */ - public boolean contains(PersistentDataContainer container) { - return container.has(key, dataType); - } - - /** - * Check if the holder contains the key - * - * @param holder the holder - */ - public boolean contains(PersistentDataHolder holder) { - return contains(holder.getPersistentDataContainer()); - } - - /** - * Copy the value from the source container to the target container - * - * @param fromContainer the source container - * @param toContainer the target container - */ - public void copy(PersistentDataContainer fromContainer, PersistentDataContainer toContainer) { - Z value = get(fromContainer); - set(toContainer, value); - } - - /** - * Copy the value from the source holder to the target holder - * - * @param fromHolder the source holder - * @param toHolder the target holder - */ - public void copy(PersistentDataHolder fromHolder, PersistentDataHolder toHolder) { - copy(fromHolder.getPersistentDataContainer(), toHolder.getPersistentDataContainer()); - } - - /** - * Remove the value from the container - * - * @param container the container - */ - public void remove(PersistentDataContainer container) { - container.remove(key); - } - - /** - * Remove the value from the holder - * - * @param holder the holder - */ - public void remove(PersistentDataHolder holder) { - remove(holder.getPersistentDataContainer()); - } -} diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyUtils.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyUtils.java deleted file mode 100644 index a2f24e895e..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/PluginKeyUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.hsgamer.hscore.bukkit.key; - -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataHolder; - -/** - * Methods to work with {@link PluginKeyPair} conveniently - */ -public final class PluginKeyUtils { - private PluginKeyUtils() { - // EMPTY - } - - /** - * Copy the {@link PluginKeyPair} from the source container to the target container - * - * @param fromContainer the source container - * @param toContainer the target container - * @param keyPairs the key pairs - */ - public static void copy(PersistentDataContainer fromContainer, PersistentDataContainer toContainer, PluginKeyPair... keyPairs) { - for (PluginKeyPair keyPair : keyPairs) { - keyPair.copy(fromContainer, toContainer); - } - } - - /** - * Copy the {@link PluginKeyPair} from the source holder to the target holder - * - * @param fromHolder the source holder - * @param toHolder the target holder - * @param keyPairs the key pairs - */ - public static void copy(PersistentDataHolder fromHolder, PersistentDataHolder toHolder, PluginKeyPair... keyPairs) { - copy(fromHolder.getPersistentDataContainer(), toHolder.getPersistentDataContainer(), keyPairs); - } - - /** - * Remove the {@link PluginKeyPair} from the container - * - * @param container the container - * @param keyPairs the key pairs - */ - public static void remove(PersistentDataContainer container, PluginKeyPair... keyPairs) { - for (PluginKeyPair keyPair : keyPairs) { - keyPair.remove(container); - } - } - - /** - * Remove the {@link PluginKeyPair} from the holder - * - * @param holder the holder - * @param keyPairs the key pairs - */ - public static void remove(PersistentDataHolder holder, PluginKeyPair... keyPairs) { - remove(holder.getPersistentDataContainer(), keyPairs); - } -} diff --git a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/package-info.java b/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/package-info.java deleted file mode 100644 index 2f234729b5..0000000000 --- a/bukkit/bukkit-key/src/main/java/me/hsgamer/hscore/bukkit/key/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains extended classes for {@link org.bukkit.NamespacedKey} - */ -package me.hsgamer.hscore.bukkit.key; \ No newline at end of file diff --git a/bukkit/pom.xml b/bukkit/pom.xml index de182674a8..357c412755 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -26,7 +26,6 @@ bukkit-gui bukkit-gui-button bukkit-channel - bukkit-key bukkit-block bukkit-variable bukkit-action