import 'package:libac_dart/nbt/NbtUtils.dart'; import 'package:libac_dart/nbt/impl/CompoundTag.dart'; import 'package:libac_dart/nbt/impl/IntTag.dart'; import 'package:libac_dart/utils/TimeUtils.dart'; class AutomaticRestartInfo { Time time = Time(hours: 0, minutes: 0, seconds: 0); final bool enabled; AutomaticRestartInfo({required this.time, this.enabled = false}); static AutomaticRestartInfo deserialize(CompoundTag tag) { return AutomaticRestartInfo( time: Time( hours: tag.get(TAG_HOURS)?.asInt() ?? 12, minutes: tag.get(TAG_MINUTES)?.asInt() ?? 0, seconds: tag.get(TAG_SECONDS)?.asInt() ?? 0), enabled: NbtUtils.readBoolean(tag, TAG_ENABLED)); } CompoundTag serialize() { CompoundTag tag = CompoundTag(); tag.put(TAG_HOURS, IntTag.valueOf(time.hours)); tag.put(TAG_MINUTES, IntTag.valueOf(time.minutes)); tag.put(TAG_SECONDS, IntTag.valueOf(time.seconds)); NbtUtils.writeBoolean(tag, TAG_ENABLED, enabled); return tag; } static const TAG_NAME = "ari"; static const TAG_HOURS = "hours"; static const TAG_MINUTES = "minutes"; static const TAG_SECONDS = "seconds"; static const TAG_ENABLED = "enabled"; }