Skip to content

Commit

Permalink
Fixes UniqueAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign committed Aug 20, 2024
1 parent 4c69bf7 commit 2468fdd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/us/mytheria/bloblib/UniqueAPI.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package us.mytheria.bloblib;

import org.bukkit.NamespacedKey;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataHolder;
import org.bukkit.persistence.PersistentDataType;
import us.mytheria.bloblib.itemapi.DiscriminatorItemAPI;

import java.util.UUID;

public class UniqueAPI implements DiscriminatorItemAPI {
private static UniqueAPI instance;
private final NamespacedKey namespacedKey;
Expand All @@ -24,7 +29,19 @@ public static UniqueAPI getInstance() {
return getInstance(null);
}

@Override
public void set(PersistentDataHolder holder) {
UUID random = UUID.randomUUID();
holder.getPersistentDataContainer().set(namespacedKey, PersistentDataType.STRING, random.toString());
}

@Override
public boolean isInstance(PersistentDataHolder holder) {
PersistentDataContainer container = holder.getPersistentDataContainer();
return container.has(namespacedKey, PersistentDataType.STRING);
}

public NamespacedKey getNamespacedKey() {
return namespacedKey;
}
}
}

0 comments on commit 2468fdd

Please sign in to comment.