package common.tileentity;

import common.tags.TagObject;

public record Passcode(String code) {
	public static final Passcode EMPTY_CODE = new Passcode("");

	public boolean empty() {
		return this.code == null || this.code.isEmpty();
	}

	public void toNBT(TagObject tag) {
		tag.setString("Lock", this.code);
	}

	public static Passcode fromNBT(TagObject tag) {
		return tag.hasString("Lock") ? new Passcode(tag.getString("Lock")) : EMPTY_CODE;
	}
}
