Server
The running server: its players, world, settings, console and this plugin's own settings and log.
Everything a plugin does starts here. The server ticks 60 times a second and plugin code runs on the tick, so a plugin never has to lock anything to read the world.
A change a plugin makes takes effect at once, with one exception. Inside a listener for an event that can be stopped, the change takes effect when the listener returns.
Given to the plugin's enable.
Methods
| Method | Description |
|---|---|
fn title(&self) -> Result<String>String title() | The title players see when they look up the join code. |
fn description(&self) -> Result<String>String description() | The line under the title. |
fn join_code(&self) -> Result<String>String joinCode() | The six-character join code. |
fn max_players(&self) -> Result<i64>long maxPlayers() | Players allowed at once. |
fn version(&self) -> Result<String>String version() | The server's version; players run the same game version. |
fn tick(&self) -> Result<i64>long tick() | Ticks since the server started (60 a second). |
fn options(&self) -> Result<WorldOptions>WorldOptions options() | Difficulty, combat style, keep inventory, creative. |
fn players(&self) -> Result<Vec<Player>>List<Player> players() | Everyone in the world now. |
fn player(&self, id: PlayerId) -> Result<Option<Player>>Optional<Player> player(String id) | A player in the world, by their lasting ID. |
fn player_named(&self, name: &str) -> Result<Option<Player>>Optional<Player> playerNamed(String name) | A player in the world by what they are called (with its #number if two share a name). |
fn profile(&self, id: PlayerId) -> Result<Option<PlayerProfile>>Optional<PlayerProfile> profile(String id) | A player who has played here, in the world or not. |
fn world(&self) -> WorldWorld world() | The world. |
fn events(&self) -> EventsEvents events() | Where the plugin listens for Events. |
fn scheduler(&self) -> SchedulerScheduler scheduler() | Timed and repeating tasks. |
fn permissions(&self) -> PermissionsPermissions permissions() | Who may do what. |
fn storage(&self) -> StorageStorage storage() | This plugin's saved data, files and internet. |
fn messages(&self) -> MessagesMessages messages() | Notices, banners, labels and sounds. |
fn config(&self) -> Result<Value>Value config() | This plugin's config.toml, as a table (written from the plugin's config.default.toml the first time). |
fn reload_config(&self) -> Result<()>void reloadConfig() | Reads config.toml again. |
fn log_info(&self, text: &str) -> Result<()>void logInfo(String text) | A line in the console, marked with the plugin's name. |
fn log_warn(&self, text: &str) -> Result<()>void logWarn(String text) | A warning in the console. |
fn log_error(&self, text: &str) -> Result<()>void logError(String text) | An error in the console. |
fn broadcast(&self, text: &str) -> Result<()>void broadcast(String text) | A notice to every player in the world. |
fn register_command(&self, name: &str, usage: &str, run: impl FnMut(Vec<String>) -> Vec<String> + 'static) -> Result<()>void registerCommand(String name, String usage, Function<List<String>, List<String>> run) | Adds a console command; what it returns is printed. |
fn run_command(&self, line: &str) -> Result<Vec<String>>List<String> runCommand(String line) | Runs a console command as this tick ends, as if the owner had typed it; what it prints goes to the console, and the list returned is empty. plugin and pack commands are refused: approving plugins and packs is the owner's alone. |
fn set_title(&self, title: &str, description: &str) -> Result<()>void setTitle(String title, String description) | Changes what players see when they look up the code. |
fn set_creative(&self, on: bool) -> Result<()>void setCreative(boolean on) | Switches creative mode for everyone. |
fn set_combat(&self, style: CombatStyle) -> Result<()>void setCombat(CombatStyle style) | Switches the combat style (waits until no fight is under way). |
fn save(&self) -> Result<()>void save() | Saves the world now. |
fn stop(&self, reason: &str) -> Result<()>void stop(String reason) | Tells players, saves and stops the server. |
fn is_plugin_loaded(&self, id: &str) -> Result<bool>boolean isPluginLoaded(String id) | Whether another plugin is loaded. |
fn provide(&self, name: &str, handler: impl FnMut(String, Value) -> Option<Value> + 'static) -> Result<()>void provide(String name, BiFunction<String, Value, Value> handler) | Offers a service to other plugins under a name (economy, permissions). |
fn call_service(&self, name: &str, method: &str, argument: Value) -> Result<Option<Value>>Optional<Value> callService(String name, String method, Value argument) | Calls another plugin's service; nothing if none is offered under that name. |
Events
Related events: WorldSaved.