mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 22:27:32 +00:00
Merge pull request #176 from KAMKEEL/codex/fix-soulbind-requirement-system-validation
Fix soulbind apply logic
This commit is contained in:
1 file changed
+20
-1
+20
-1
@@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import kamkeel.npcs.controllers.data.attribute.requirement.IRequirementChecker;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -83,7 +84,25 @@ public class SoulbindRequirement implements IRequirementChecker {
|
||||
@Override
|
||||
public void apply(NBTTagCompound nbt, Object value) {
|
||||
if (value instanceof String) {
|
||||
nbt.setString(getKey(), (String) value);
|
||||
String entry = (String) value;
|
||||
if (entry.isEmpty())
|
||||
return;
|
||||
|
||||
// Check if the provided value is already a valid UUID
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = UUID.fromString(entry);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
// If not a UUID, attempt to treat the value as a username
|
||||
if (uuid == null) {
|
||||
uuid = ProfileController.Instance.getUUIDFromUsername(entry);
|
||||
}
|
||||
|
||||
if (uuid != null) {
|
||||
nbt.setString(getKey(), uuid.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user