53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
import 'package:libac_dart/nbt/NbtUtils.dart';
|
|
import 'package:libac_dart/nbt/impl/CompoundTag.dart';
|
|
import 'package:libac_dart/nbt/impl/LongTag.dart';
|
|
import 'package:libac_dart/nbt/impl/StringTag.dart';
|
|
import 'package:libac_dart/utils/uuid/UUID.dart';
|
|
|
|
class Mod {
|
|
String mod_name = "";
|
|
int mod_id = 0;
|
|
String mod_pak = "";
|
|
String mod_hash = "";
|
|
bool enabled = true;
|
|
|
|
bool newMod = false;
|
|
UUID _id = UUID.ZERO;
|
|
String mod_instance_id() {
|
|
if (_id.toString() == UUID.ZERO.toString()) {
|
|
_id = UUID.generate(4);
|
|
}
|
|
|
|
return _id.toString();
|
|
}
|
|
|
|
Mod(
|
|
{this.mod_name = "undef",
|
|
this.mod_id = 0,
|
|
this.newMod = false,
|
|
this.mod_pak = "Not Initialized",
|
|
this.mod_hash = "",
|
|
this.enabled = true});
|
|
|
|
CompoundTag serialize() {
|
|
CompoundTag tag = CompoundTag();
|
|
tag.put("name", StringTag.valueOf(mod_name));
|
|
tag.put("id", LongTag.valueOf(mod_id));
|
|
tag.put("pak", StringTag.valueOf(mod_pak));
|
|
tag.put("hash", StringTag.valueOf(mod_hash));
|
|
NbtUtils.writeBoolean(tag, "enabled", enabled);
|
|
|
|
return tag;
|
|
}
|
|
|
|
static Mod deserialize(CompoundTag tag) {
|
|
CompoundTag ct = tag;
|
|
|
|
return Mod(
|
|
mod_name: ct.get("name")!.asString(),
|
|
mod_id: ct.get("id")!.asLong(),
|
|
mod_pak: ct.get("pak")!.asString(),
|
|
mod_hash: ct.get("hash")!.asString(),
|
|
enabled: NbtUtils.readBoolean(tag, "enabled"));
|
|
}
|
|
}
|