Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags #3

Open
inxomnyaa opened this issue Dec 17, 2022 · 1 comment
Open

Tags #3

inxomnyaa opened this issue Dec 17, 2022 · 1 comment

Comments

@inxomnyaa
Copy link

Is your feature request related to a problem? Please describe.
I have faced 3 issues with i.e. values that come from saved configs marshaled via libMarshal:

  • A new version of a config might rename, remove or change the type of a value
  • Config values that are optional are hard to implement without assigning null as default, causing a trail of null checks
  • Sometimes you'd want specific values to be saved in different configs or arrays/json, i.e. a Tool (in MagicWE2, item with interactions. Brush might be the best example) should have runtime options and config options, one being used as file on disk and one i.e. as an array that is being serialized for async tasks.

Describe the solution you'd like
A possible solution i propose is adding an optional tags <list<string>> parameter. Then when using marshal() you can pass a list of tags you want serialized.

Describe alternatives you've considered
So far, none

Additional context
I got stuck at implementing libMarshal into MagicWE2 due to this. Right now the code isn't public though.

But an example is the usersessions: https://github.com/thebigsmileXD/MagicWE2/blob/experiment/libMarshal/src/xenialdan/MagicWE2/session/UserSession.php#L29-L42
Some of those values are optional, for example $brushes. The brushcollection holds brushes, https://github.com/thebigsmileXD/MagicWE2/blob/experiment%2FlibMarshal/src/xenialdan/MagicWE2/session/data/BrushCollection.php#L28. These already have some kind of versioning implemented, but.. honestly not in a great way, they can't really be upgraded yet.

The current format Session->save() produces is also not compatible with unmarshal due to some object arrays like BrushCollection being boiled down to an array that is not nested https://github.com/thebigsmileXD/MagicWE2/blob/0ed0c1a67c99314bcfbeafc36d4e826e1398e0a0/src/xenialdan/MagicWE2/session/UserSession.php#L279

@inxomnyaa
Copy link
Author

Here are 2 versions of configs saved with libMarshal, the first one is a new session file generated by libMarshal and the second is imported and then exported - notice i.e. latestSelection, which libMarshal wants to save all the time (as object), but MagicWE2's old config only saved the UUID of it.
This creates conflicts aside from the problems mentioned above, not sure if this should be a separate issue though. It is due to the last point i mentioned above, saving and loading data differently.

{
    "sidebar": {},
    "debug": {
        "id": 280,
        "nbt_b64": "CgAACgcAZGlzcGxheQgEAE5hbWUoAMKncsKnbMKnNltNYWdpY1dFMl3Cp3IgwqdswqdkRGVidWcgU3RpY2sJBABMb3JlCAQAAAAsAMKnckxlZnQgY2xpY2sgYSBibG9jayB0byBzZWxlY3QgYSBibG9ja3N0YXRlOADCp3JSaWdodCBjbGljayBhIGJsb2NrIHRvIGFkdmFuY2UgdGhlIGJsb2Nrc3RhdGUncyB2YWx1ZR0AwqdyU25lYWsgdG8gcmV2ZXJzZSB0aGUgb3JkZXIxAMKnclVzZSAvL3RvZ2dsZWRlYnVnIHRvIHRvZ2dsZSBpdCdzIGZ1bmN0aW9uYWxpdHkACQQAZW5jaAoBAAAAAgIAaWTJAAIDAGx2bAEAAAoMAE1hZ2ljV0VEZWJ1ZwAKBwBNYWdpY1dFAAoNAERlYnVnUHJvcGVydHkIFQBtaW5lY3JhZnQ6d29vZGVuX3NsYWIJAHdvb2RfdHlwZQgiAG1pbmVjcmFmdDptb3NzeV9zdG9uZV9icmlja19zdGFpcnMPAHVwc2lkZV9kb3duX2JpdAgPAG1pbmVjcmFmdDpzdG9uZQoAc3RvbmVfdHlwZQgUAG1pbmVjcmFmdDpzdG9uZWJyaWNrEABzdG9uZV9icmlja190eXBlCBcAbWluZWNyYWZ0OnN0YWluZWRfZ2xhc3MFAGNvbG9yCBwAbWluZWNyYWZ0OnN0b25lX2JyaWNrX3N0YWlycw8AdXBzaWRlX2Rvd25fYml0CBUAbWluZWNyYWZ0Om1vbnN0ZXJfZWdnFgBtb25zdGVyX2VnZ19zdG9uZV90eXBlCBUAbWluZWNyYWZ0OmNvcmFsX2Jsb2NrCABkZWFkX2JpdAgQAG1pbmVjcmFmdDpiYXJyZWwIAG9wZW5fYml0CA8AbWluZWNyYWZ0OmZyYW1lEABmYWNpbmdfZGlyZWN0aW9uAAA="
    },
    "uuid": "03f9e6ad-5915-3584-bb1d-30345cef6d95",
    "selections": {
        "7c34f7fc-3b53-4c99-9059-0ed1abc53108": {
            "worldId": 1,
            "pos1": {
                "x": 252,
                "y": 4,
                "z": 157
            },
            "pos2": {
                "x": 252,
                "y": 4,
                "z": 155
            },
            "uuid": "7c34f7fc-3b53-4c99-9059-0ed1abc53108",
            "sessionUUID": "03f9e6ad-5915-3584-bb1d-30345cef6d95",
            "shape": {
                "width": 1,
                "height": 1,
                "depth": 3,
                "pasteVector": {
                    "x": 252,
                    "y": 4,
                    "z": 156
                }
            },
            "shapeClass": "xenialdan\\MagicWE2\\selection\\shape\\Cuboid"
        }
    },
    "latestselection": "7c34f7fc-3b53-4c99-9059-0ed1abc53108",
    "currentClipboard": null,
    "undoHistory": {},
    "redoHistory": {}
}
{
    "wandEnabled": true,
    "debugToolEnabled": true,
    "wailaEnabled": true,
    "sidebarEnabled": true,
    "outlineEnabled": true,
    "brushes": {
        "4d515225-5838-4da5-8800-4ebd4ef301cc": {
            "properties": {
                "version": 1,
                "customName": "Sphere Brush",
                "shape": "xenialdan\\MagicWE2\\selection\\shape\\Sphere",
                "shapeProperties": {
                    "diameter": 10
                },
                "action": "xenialdan\\MagicWE2\\task\\action\\SetBlockAction",
                "actionProperties": [],
                "hollow": false,
                "blocks": "tnt,redstone_block,wooden_slab[top=true],stone[type=andesite]%40",
                "filter": "",
                "biomeId": 1,
                "uuid": "4d515225-5838-4da5-8800-4ebd4ef301cc"
            }
        }
    },
    "language": "eng",
    "debug": {
        "id": 280,
        "nbt_b64": "CgAACgcAZGlzcGxheQgEAE5hbWUoAMKncsKnbMKnNltNYWdpY1dFMl3Cp3IgwqdswqdkRGVidWcgU3RpY2sJBABMb3JlCAQAAAAsAMKnckxlZnQgY2xpY2sgYSBibG9jayB0byBzZWxlY3QgYSBibG9ja3N0YXRlOADCp3JSaWdodCBjbGljayBhIGJsb2NrIHRvIGFkdmFuY2UgdGhlIGJsb2Nrc3RhdGUncyB2YWx1ZR0AwqdyU25lYWsgdG8gcmV2ZXJzZSB0aGUgb3JkZXIxAMKnclVzZSAvL3RvZ2dsZWRlYnVnIHRvIHRvZ2dsZSBpdCdzIGZ1bmN0aW9uYWxpdHkACQQAZW5jaAoBAAAAAgIAaWTJAAIDAGx2bAEAAAoMAE1hZ2ljV0VEZWJ1ZwAKBwBNYWdpY1dFAAoNAERlYnVnUHJvcGVydHkIFQBtaW5lY3JhZnQ6d29vZGVuX3NsYWIJAHdvb2RfdHlwZQgiAG1pbmVjcmFmdDptb3NzeV9zdG9uZV9icmlja19zdGFpcnMPAHVwc2lkZV9kb3duX2JpdAgPAG1pbmVjcmFmdDpzdG9uZQoAc3RvbmVfdHlwZQgUAG1pbmVjcmFmdDpzdG9uZWJyaWNrEABzdG9uZV9icmlja190eXBlCBcAbWluZWNyYWZ0OnN0YWluZWRfZ2xhc3MFAGNvbG9yCBwAbWluZWNyYWZ0OnN0b25lX2JyaWNrX3N0YWlycw8AdXBzaWRlX2Rvd25fYml0CBUAbWluZWNyYWZ0Om1vbnN0ZXJfZWdnFgBtb25zdGVyX2VnZ19zdG9uZV90eXBlCBUAbWluZWNyYWZ0OmNvcmFsX2Jsb2NrCABkZWFkX2JpdAgQAG1pbmVjcmFmdDpiYXJyZWwIAG9wZW5fYml0CA8AbWluZWNyYWZ0OmZyYW1lEABmYWNpbmdfZGlyZWN0aW9uAAA="
    },
    "uuid": "03f9e6ad-5915-3584-bb1d-30345cef6d95",
    "latestSelection": {
        "worldId": 1,
        "pos1": {
            "x": 252,
            "y": 4,
            "z": 157
        },
        "pos2": {
            "x": 252,
            "y": 4,
            "z": 155
        },
        "uuid": "13b9e781-b0be-4f51-9bcc-6e4794e5f98c",
        "sessionUUID": "03f9e6ad-5915-3584-bb1d-30345cef6d95",
        "shape": {
            "width": 1,
            "height": 1,
            "depth": 3,
            "pasteVector": {
                "x": 252,
                "y": 4,
                "z": 156
            }
        },
        "shapeClass": "xenialdan\\MagicWE2\\selection\\shape\\Cuboid"
    },
    "currentClipboard": null
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant