Class PlayerFileUploadEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.ui.PlayerFileUploadEvent

public final class PlayerFileUploadEvent extends PlayerEvent
Called when the upload of a ClientFile is finished, i.e. either the file was uploaded successfully or the upload failed (see getResult()). Uploads can be started via ClientFile.upload(java.lang.String, long, net.risingworld.api.callbacks.Callback). If a callback was provided there, the callback receives the same event object before the event is triggered.
See Also:

Example: Upload a selected file into the plugin folder
1player.showFileBrowser("Select a model", new String[]{"fbx", "obj"}, (PlayerSelectFileEvent selectEvent) -> {
2 if (selectEvent.isAborted()) return;
3
4 //Upload the file (max 20 MB) into the "Models" folder of our plugin
5 selectEvent.getFile().upload(getPath() + "/Models", 20 * 1024 * 1024, (PlayerFileUploadEvent uploadEvent) -> {
6 if (uploadEvent.isSuccessful()) {
7 System.out.println("Upload completed: " + uploadEvent.getTargetFile());
8 }
9 else {
10 System.out.println("Upload failed: " + uploadEvent.getResult());
11 }
12 });
13});
  • Method Details

    • getFile

      public ClientFile getFile()
      Gets the file which was uploaded (or which should have been uploaded).
      Returns:
      the client file.
    • getResult

      public PlayerFileUploadEvent.Result getResult()
      Gets the result of the upload.
      Returns:
      the result of the upload.
    • isSuccessful

      public boolean isSuccessful()
      Gets whether or not the file was uploaded successfully. Same as getResult() == Result.Success.
      Returns:
      true if the upload was successful, false if not.
    • getTargetFile

      public File getTargetFile()
      Gets the uploaded file on the server.
      Returns:
      the uploaded file, or null if the upload was not successful.
    • getBytes

      public long getBytes()
      Gets the number of bytes which were received from the player.
      Returns:
      the number of received bytes.