Finish basic server and client impl
This commit is contained in:
parent
a082210fa9
commit
178cc201c1
4 changed files with 213 additions and 57 deletions
|
@ -1,7 +1,7 @@
|
|||
import 'package:libac_flutter/nbt/Stream.dart';
|
||||
import 'package:libac_flutter/nbt/Tag.dart';
|
||||
|
||||
class CompoundTag extends Tag {
|
||||
class CompoundTag extends Tag implements Map<String, Tag> {
|
||||
late final Map<String, Tag> value = {};
|
||||
|
||||
CompoundTag();
|
||||
|
@ -48,12 +48,8 @@ class CompoundTag extends Tag {
|
|||
tag.setKey(name);
|
||||
}
|
||||
|
||||
bool contains(String name) {
|
||||
return value.containsKey(name);
|
||||
}
|
||||
|
||||
Tag? get(String name) {
|
||||
if (contains(name)) {
|
||||
if (containsKey(name)) {
|
||||
return value[name] as Tag;
|
||||
} else {
|
||||
// Does not exist!
|
||||
|
@ -61,10 +57,6 @@ class CompoundTag extends Tag {
|
|||
}
|
||||
}
|
||||
|
||||
void remove(String name) {
|
||||
value.remove(name);
|
||||
}
|
||||
|
||||
@override
|
||||
TagType getTagType() {
|
||||
return TagType.Compound;
|
||||
|
@ -103,4 +95,99 @@ class CompoundTag extends Tag {
|
|||
}
|
||||
builder.append("\n${"".padLeft(indent - 1, '\t')}}");
|
||||
}
|
||||
|
||||
@override
|
||||
Tag? operator [](Object? key) {
|
||||
return value[key];
|
||||
}
|
||||
|
||||
@override
|
||||
void operator []=(String key, Tag value) {
|
||||
this.value[key] = value;
|
||||
}
|
||||
|
||||
@override
|
||||
void addAll(Map<String, Tag> other) {
|
||||
value.addAll(other);
|
||||
}
|
||||
|
||||
@override
|
||||
void addEntries(Iterable<MapEntry<String, Tag>> newEntries) {
|
||||
value.addEntries(newEntries);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<RK, RV> cast<RK, RV>() {
|
||||
return value.cast();
|
||||
}
|
||||
|
||||
@override
|
||||
void clear() {
|
||||
value.clear();
|
||||
}
|
||||
|
||||
@override
|
||||
bool containsKey(Object? key) {
|
||||
return value.containsKey(key);
|
||||
}
|
||||
|
||||
@override
|
||||
bool containsValue(Object? value) {
|
||||
return this.value.containsValue(value);
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<MapEntry<String, Tag>> get entries => value.entries;
|
||||
|
||||
@override
|
||||
void forEach(void Function(String key, Tag value) action) {
|
||||
value.forEach(action);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isEmpty => value.isEmpty;
|
||||
|
||||
@override
|
||||
bool get isNotEmpty => value.isNotEmpty;
|
||||
|
||||
@override
|
||||
Iterable<String> get keys => value.keys;
|
||||
|
||||
@override
|
||||
int get length => value.length;
|
||||
|
||||
@override
|
||||
Map<K2, V2> map<K2, V2>(
|
||||
MapEntry<K2, V2> Function(String key, Tag value) convert) {
|
||||
return value.map(convert);
|
||||
}
|
||||
|
||||
@override
|
||||
Tag putIfAbsent(String key, Tag Function() ifAbsent) {
|
||||
return this.value.putIfAbsent(key, ifAbsent);
|
||||
}
|
||||
|
||||
@override
|
||||
Tag? remove(Object? key) {
|
||||
return value.remove(key);
|
||||
}
|
||||
|
||||
@override
|
||||
void removeWhere(bool Function(String key, Tag value) test) {
|
||||
value.removeWhere(test);
|
||||
}
|
||||
|
||||
@override
|
||||
Tag update(String key, Tag Function(Tag value) update,
|
||||
{Tag Function()? ifAbsent}) {
|
||||
return value.update(key, update);
|
||||
}
|
||||
|
||||
@override
|
||||
void updateAll(Tag Function(String key, Tag value) update) {
|
||||
value.updateAll(update);
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<Tag> get values => value.values;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue