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.
| Example | Description | Concepts |
|---|---|---|
| Commands Example | Commands, raycast teleport, inventory GUIs, click events | @command, @event, Inventory, raycast, Player |
| Spawn Protect Example | Prevent building near spawn with block events | @event, event.cancel(), block coordinates |
| Tempban Example | Ban system with durations, persistence, and login enforcement | @command, @event, Player, state management |
| Dungeon Example | Procedural dungeon with rooms, loot, mobs, and lifecycle | Dungeon, ItemBuilder, @command, extension events |
Tips for Writing Scripts
- Always import from bridge:
from bridge import * - Use async/await: Most bridge methods return awaitables
- Name your event handlers after the event:
async def block_break(event)handlesblock_breakevents - Commands auto-register: The function name becomes the command name
- Cancel events to prevent default behavior:
event.cancel() - Use the
Configclass for persistence instead of global dictionaries