forked from Ghost-chu/QuickShop-Reremake
-
Notifications
You must be signed in to change notification settings - Fork 73
Closed
Labels
Description
Data structure
Concepts: A new data structure for describing updating config (Json)
Version
The target version for updating from.
Condition
Opcodes
- EQUALS
- LOWER
- GREATER
- EQUALS_GREATER
- EQUALS_LOWER
Paths
The config path for comparing
Value
Values for comparing, see below for detailed value representation.
Opcodes
- NEW: Add a new option in configuration with default value
- DELETE: Delete an option in configuration
- PATCH: Change an option current value to other
Value
Value for this opcode, see below for detailed value representation.
Value representation
Needs register before by registering to Serializer which implement following interface:
interface ConfigValueSerializer {
String getTargetClassName();
int getVersion();
@Nullable Object fromString(int version, String input);
String toString();
}
Then it will be convert to this for example:
{
"version": 1,
"targetClass": "java.lang.Boolean",
"data": "true"
}
Example File
{
"configPatchList": [{
"version": 1,
"patchs": [{
"opcode": "NEW",
"path": "foo.example",
"value": {
"version": 1,
"targetClass": "java.lang.Boolean",
"data": "true"
},
"condition": {
"opcode": "equals",
"path": "foo.create",
"value": {
"version": 1,
"targetClass": "java.lang.Boolean",
"data": "true"
}
}
},
{
"version": 2,
"patchs": [{
"opcode": "PATCH",
"path": "foo.example",
"value": {
"version": 1,
"targetClass": "java.lang.Boolean",
"data": "false"
},
"condition": {
"opcode": "foo.example",
"path": "foo.create",
"value": {
"version": 1,
"targetClass": "java.lang.Boolean",
"data": "true"
}
}
}]
}
]
}]
}