Skript
Skript copied to clipboard
Stop using String for enum serialization
Description
So this is some unfortunate news. We've for some reason started to adapt the usage of the EnumSerializer class in the past few years. I've been working on revamping the entire variable API system, and the reason this class existed was actually for versions older than 2.1 to be converting Strings to their enum. Well now that a large amount of classes use this EnumSerializer that means that a large majority of enums for users are stored as raw strings.
This means that the delay of the removal of deserialize(String)
is going to be even more delayed.
This pull request makes the EnumSerializer use proper serialization methods. It still supports deserializing from String, but when it goes to serialize again after usage, it'll use the proper serialization methods.
When it comes to updating variables from past versions there are a two things that have to be dealt with. FlatFile (CSV) and SQL. FlatFile we don't have to worry about as all variables get loaded on start, and will serialize to the proper type on restart, so for the majority of users this pull request works and no action will be needed. As for SQL, well what Njol did in 2.1 when he changed the serialize type from String to byte[] is that he just changes the table name and had a check that updated all values to the new format. I don't think we'll need to change the table name, but we'll have to select all values and update them, what is everyones thoughts on that? This pull request doesn't handle that, but it can.
These changes need to be done in order for any variable database updating. We're done with deserialize(String) we need to stop using it. Yggdrasil doesn't even use it. Njol has removed deserialize(String) from Yggdrasil a long time ago. It's only around in Skript to deal with old old old versions.
Notes:
- Forces YggdrasilSerializer to stop using deserialize(String). No addon should be using this class as it's for Skript classes only.
- Removed deserialize(String) from all classes in SkriptClasses as only versions older than 2.1 will ever call this method.
- If a class extends YggdrasilExtendedSerializable Yggdrasil will handle it's serialization automatically. This is basically every Skript class; Time, Timespan, ItemType etc.
How to test: 1.) Set a bunch of variables with an enum based classinfo like difficulty, itemtype etc. 2.) Stop server. 3.) Install this pull request jar and start the server. 4.) All CSV variables will be converted on server stop.
I've tested with my server, which has a fairly large amount of variables, and I had no issues.
For those that want to help test (Jar is from first commit as of time you're seeing this): skript-nightly.zip