Skip to content

API can't escape certain characters. #237

Open
@Cryptite

Description

@Cryptite

I have the following two methods that I use to take in-game items' lores and publish them to the webui, allowing players to edit the lore, save a link, and then refresh their lores in-game.

private void onCommandLoreEdit(Player p) {
    ItemStack itemInHand = p.getInventory().getItemInMainHand();
    String title = getFriendlyName(itemInHand);
    startSession(p, p.getUniqueId(), miniMessage().serialize(builder().build().deserialize(title.replace("\"", ""))));
}

private void startSession(Player p, UUID uuid, List<String> lore) {
    editor.startSession(String.join("\n", lore),
                    "/lore update {token}",
                    "Loka")
            .thenAccept(token -> {
                //On success stuff
            }).exceptionally(throwable -> {
                //On fail stuff
            });
}

Without the part where I strip the use of quotation marks ", this will fail and create invalid json in Route.installEditor()'s input serialization at: val input = Serializers.json.tryDecodeFromString<EditorInput>(call.receiveText()).

Not sure whether I should be trying to do something to somehow escape these characters more easily, or whether this is something that should maybe be done when receiveText() is done, and before tryDecodeFromString is done, but it does have me a bit stuck right now for players who have used " in their lores.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions