Complete script examples

Examples

Full working scripts that demonstrate PyJavaBridge features. Each example is a standalone script you can drop into your plugins/PyJavaBridge/scripts/ folder.

ExampleDescriptionConcepts
Commands ExampleCommands, raycast teleport, inventory GUIs, click events@command, @event, Inventory, raycast, Player
Spawn Protect ExamplePrevent building near spawn with block events@event, event.cancel(), block coordinates
Tempban ExampleBan system with durations, persistence, and login enforcement@command, @event, Player, state management
Dungeon ExampleProcedural dungeon with rooms, loot, mobs, and lifecycleDungeon, ItemBuilder, @command, extension events

Tips for Writing Scripts

  1. Always import from bridge: from bridge import *
  2. Use async/await: Most bridge methods return awaitables
  3. Name your event handlers after the event: async def block_break(event) handles block_break events
  4. Commands auto-register: The function name becomes the command name
  5. Cancel events to prevent default behavior: event.cancel()
  6. Use the Config class for persistence instead of global dictionaries