API Specstable
2 min read time

Documentation

Bukkit API

Direct access to the Bukkit server instance for advanced server interactions.

apibukkitserver

The "Bukkit" API

The Bukkit object provides direct access to the Bukkit server instance, giving you full control over server-level operations. This is a powerful API that exposes all methods available on the Bukkit Server interface.

Accessing the Bukkit Server with Bukkit

The Bukkit object is automatically available in all scripts and provides access to the server instance without any imports or setup required. You can use it to interact with players, worlds, plugins, and other server-level features.

// Get all online players const onlinePlayers = Bukkit. getOnlinePlayers(); console.log(`There are ${onlinePlayers. size()} players online`); // Broadcast a message to all players Bukkit.broadcastMessage('§6Server announcement: §eMaintenance in 5 minutes!');

Common Use Cases

Working with Players

// Send a message to all online players Bukkit.getOnlinePlayers().forEach(player => { player.sendMessage(`Hello ${player.getName()}!`); }); // Find a specific player by name const player = Bukkit.getPlayer('Notch'); if (player !== null && player.isOnline()) { player.sendMessage('§aYou are the chosen one!'); } // Get all operators Bukkit.getOperators().forEach(op => { console.log(`Operator: ${op.getName()}`); });

Managing Worlds

// Get a specific world const world = Bukkit.getWorld('world'); if (world !== null) { console.log(`World: ${world.getName()}`); console.log(`Time: ${world.getTime()}`); console.log(`Players in world: ${world.getPlayers().size()}`); } // List all loaded worlds Bukkit.getWorlds().forEach(world => { console. log(`World: ${world.getName()}, Environment: ${world.getEnvironment()}`); }); // Set the time in a world const overworld = Bukkit.getWorld('world'); overworld.setTime(1000); // Set to morning

Server Information

// Get server version and type console.log(`Server version: ${Bukkit.getVersion()}`); console.log(`Bukkit version: ${Bukkit.getBukkitVersion()}`); console.log(`Server name: ${Bukkit.getName()}`); // Get server configuration const maxPlayers = Bukkit.getMaxPlayers(); const viewDistance = Bukkit.getViewDistance(); console.log(`Max players: ${maxPlayers}`); console.log(`View distance: ${viewDistance}`); // Check if server is in online mode console.log(`Online mode: ${Bukkit.getOnlineMode()}`);

Scheduling and Commands

// Dispatch a console command Bukkit.dispatchCommand(Bukkit.getConsoleSender(), 'say Hello from PixelScript!'); // Get the scheduler for task management const scheduler = Bukkit.getScheduler(); // Note: Use the dedicated scheduler API for more convenient task scheduling

Plugin and Service Management

// Get information about loaded plugins const pluginManager = Bukkit.getPluginManager(); const plugins = pluginManager.getPlugins(); plugins.forEach(plugin => { console.log(`Plugin: ${plugin.getName()} v${plugin.getDescription().getVersion()}`); }); // Check if a specific plugin is loaded const hasVault = pluginManager.getPlugin('Vault') !== null; console.log(`Vault is ${hasVault ? 'loaded' : 'not loaded'}`);
Documentation in early stages. Not meant for public consumption.