40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
import 'package:libac_flutter/nbt/NbtUtils.dart';
|
|
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
|
import 'package:libac_flutter/nbt/impl/IntTag.dart';
|
|
|
|
class AutomaticRestartInfo {
|
|
final int hours;
|
|
final int minutes;
|
|
final int seconds;
|
|
final bool enabled;
|
|
|
|
const AutomaticRestartInfo(
|
|
{this.hours = 0,
|
|
this.minutes = 0,
|
|
this.seconds = 0,
|
|
this.enabled = false});
|
|
|
|
static AutomaticRestartInfo deserialize(CompoundTag tag) {
|
|
return AutomaticRestartInfo(
|
|
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(hours));
|
|
tag.put(TAG_MINUTES, IntTag.valueOf(minutes));
|
|
tag.put(TAG_SECONDS, IntTag.valueOf(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";
|
|
}
|