Conversation
Author
|
I have tested this new version on my own Minecraft server for some hours, and it works well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #72, allowing players to upload images directly from their computer without uploading to an image hosting service. This offers players a great deal of convenience.
Clients running the new version can upload a local image directly with
/image2map create dither C:/Some-Dir/image.png, or use/image2map create ditherto open a file picker and select a local image.While the older version of the client mod (or not install the client mod) is still compatible. The
image2mapcommands remain server-side.Local upload flow
Players use
/image2map createor/image2map previewwith a local path, or omit the path to open a file picker. The client displays the supplied path for confirmation, or opens a file picker and asks the player to confirm their selection.Upload with local-path

... or leave the path blank to use a file picker to choose a local image

After confirmation, the client reads and validates the image, then sends its metadata (e.g. format, size and dimensions) to the server. Once the server accepts this information, the client transfers the image in small chunks (16 KB) to the server. The server checks the received content and continues with map creation or preview.
Safety & lifecycle
To protect the server from attacks, upload messages must match a player's active
createrequest. The actual image format and dimensions are verified before decoding, with the same checks applied to downloaded and server-local images.These checks are coordinated by a per-player state machine:
IDLE → CLIENT_SELECTING_IMAGE → GETTING_IMAGE → PROCESSING_IMAGE → PREVIEWING (optional) → IDLE. Each player can have one image operation or preview open at a time. All the situations like completion, cancellation, failure, transfer timeout, disconnect and preview closure are well-handled for this state machine.Meanwhile, to protect clients from malicious servers, file contents are read by client mod only after explicit player confirmation.
Configurations
This PR updates the configuration to version 2, adds some new options and renames some existing options to clarify their purpose. To be specific,
maxSizebecomesimageMaxWidthHeight, retaining its role as the output dimension limit.allowLocalFilesbecomesallowServerLocalFiles.An example of the new configuration is shown below:
{ "version": 2, "allowServerLocalFiles": false, "allowClientUploadFiles": true, "minPermLevel": 4, "imageMaxWidthHeight": 2048, "imageFileMaxSize": 20480, "allowedImageFormats": [ "png", "jpeg", "gif", "bmp", "webp" ], "imageOperationCooldownSeconds": 5, "networkTimeout": 30 }Existing configurations without a
versionfield are migrated automatically, preserving the renamed values and filling new settings with defaults.