-
Notifications
You must be signed in to change notification settings - Fork 11
List of proposals for v2 #7
Comments
Some static (companion object) methods for the NBTReader would also be nice e.g.
A better way could be returning a generic like |
Just a passerby from the Minestom Discord. It might be worth sealing these NBT classes. It's still a preview feature, but if you're thinking about managing instances to that extent, it's not a stretch to suggest managing classes too. |
Done in 088ebf6
Already present in v2:
Kotlin already has sealed classes, but Hephaistos cannot use it because mutable versions of tag (in v2) inherit both from MutableNBT and ImmutableNBT (two interfaces). Kotlin (like JVM-based languages) does not allow multiple superclasses, so sealing the base MutableNBT and ImmutableNBT is sadly not possible with the current state of the library. |
As of Kotlin 1.5, Kotlin now has sealed interfaces FYI. And sealed class/interface support has been extended, so now any members declared in the same package can participate in the heirachy, rather than just in the same class |
I was not aware about sealed interfaces in Kotlin 1.5, I'll have to see if it can apply. |
@jglrxavpok told me to make an issue with these, for easier tracking, so here we are.
Here's the list of proposals I have for things in v2:
NBTEnd
an object, since it only needs one instance and doesn't ever need to be copied.EMPTY
constant forNBTCompound
, which is an immutable compound with an empty backing map. Also add one forNBTList
, which is an immutable list with elements of typeTAG_End
backed by an empty list.ONE
andZERO
constants forNBTByte
, which are both immutable with backing values of 1 and 0 respectively (for easier boolean conversions).getBoolean
/setBoolean
.default
value, and these methods should never return null. For example,getString("my_key", "my_default")
would look for a string in the map with the key "my_key", or else it would return "my_default" if no such value was found.NBTList
andNBTCompound
that accept lists and maps respectively, for easier construction.NBTCompound
and the backing list of anNBTList
in some way, whether this be an immutable copy, or just the actual map itself.NBTReader
andNBTWriter
with aPath
object as well as with aFile
.getOrElse
andgetOrNull
on anNBTList
. Would probably be better ifNBTList
just implementedList<Tag>
instead ofIterable<Tag>
.Hope this helps you keep track of everything!
The text was updated successfully, but these errors were encountered: