Class PlayerSelectFileEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.ui.PlayerSelectFileEvent
Called when a player selected a file in the file browser (or closed the file browser without
selecting a file). The file browser can be opened via
Player.showFileBrowser(java.lang.String, java.lang.String[], 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: Let the player select a model file
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetFile()Gets the file the player has selected.booleanGets whether or not the player closed the file browser without selecting a file.booleanGets whether or not the selected file exceeds the size limit of the file browser (seePlayer.showFileBrowser(java.lang.String, java.lang.String[], long, net.risingworld.api.callbacks.Callback)and the server limitPlugins_MaxFileUploadSize).voidrequestFileUpload(String targetDirectory, long maxBytes, Callback<PlayerFileUploadEvent> callback) Uploads the selected file into the provided directory on the server.Methods inherited from class PlayerEvent
getPlayer
-
Method Details
-
getFile
Gets the file the player has selected. The returned object stays valid after the event (until the player disconnects or the plugins are reloaded).- Returns:
- the selected file, or null if the player closed the file browser without selecting a file.
-
isAborted
public boolean isAborted()Gets whether or not the player closed the file browser without selecting a file. This is also the case if the platform of the player has no file system (consoles), if the selected file did not match the provided file extensions, or if it could not be read by the player.- Returns:
- true if no file was selected, false if not.
-
isTooLarge
public boolean isTooLarge()Gets whether or not the selected file exceeds the size limit of the file browser (seePlayer.showFileBrowser(java.lang.String, java.lang.String[], long, net.risingworld.api.callbacks.Callback)and the server limitPlugins_MaxFileUploadSize). In this case the file is still available viagetFile()(name and size), but it has no checksum and cannot be uploaded.- Returns:
- true if the file is too large, false if not.
-
requestFileUpload
public void requestFileUpload(String targetDirectory, long maxBytes, Callback<PlayerFileUploadEvent> callback) Uploads the selected file into the provided directory on the server. This is just a shortcut forgetFile().upload(targetDirectory, maxBytes, callback), seeClientFile.upload(java.lang.String, long, net.risingworld.api.callbacks.Callback). Note that the upload can also be started at a later time (theClientFileobject stays valid).- Parameters:
targetDirectory- the directory on the server where the file should be stored.maxBytes- the max allowed file size (bytes). Set to 0 to use the limit of the server.callback- optional callback which is invoked once the upload is finished. May be null.- Throws:
IllegalStateException- if no file was selected (seeisAborted()), or another upload of this player is still active.IllegalArgumentException- if the target directory is null, empty or not a valid path.
-