You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
+96-24Lines changed: 96 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,11 @@ PyJavaBridge is a java plugin that manages and exposes APIs to python scripts vi
29
29
-[Team](#team)
30
30
-[Advancement](#advancement)
31
31
-[AdvancementProgress](#advancementprogress)
32
-
-[ItemMeta](#itemmeta)
33
32
-[Difficulty](#difficulty)
34
33
-[Objective](#objective)
34
+
-[Chat](#chat)
35
+
-[Raycast](#raycast)
36
+
-[RaycastResult](#raycastresult)
35
37
-[Enums](#enums)
36
38
-[EntityType](#entitytype)
37
39
-[EffectType](#effecttype)
@@ -53,11 +55,16 @@ Base event proxy. Event payloads may expose additional fields depending on event
53
55
-`location`: [`Location`](#location) — The location involved in the event, if any.
54
56
-`player`: [`Player`](#player) — The player involved in the event, if any.
55
57
-`world`: [`World`](#world) — The world involved in the event, if any.
58
+
-`slot`: int — Slot index for inventory click events.
56
59
57
60
### Methods
58
61
59
62
-`cancel()` — Cancel the event if it is cancellable. Returns an awaitable that resolves to `None`.
60
63
64
+
### Chat formatting
65
+
66
+
For `player_chat` handlers, returning a string will cancel the original chat event and broadcast the returned string instead. Returning `None` (or no return value) leaves chat unchanged.
67
+
61
68
### Event types
62
69
63
70
Events are resolved dynamically from handler names using snake_case to PascalCase plus `Event` (for example, `player_join` → `PlayerJoinEvent`).
-`custom_model_data`: int | None — Custom model data.
104
+
-`attributes`: list[dict] — Attribute modifiers.
105
+
-`nbt`: dict — Serialized NBT map.
96
106
97
107
### Methods
98
108
109
+
-`clone()` — Clone this item. Returns an awaitable that resolves to [`Item`](#item).
110
+
-`is_similar(other: [`Item`](#item))` — Check if items are similar. Returns an awaitable that resolves to bool.
111
+
-`max_stack_size()` — Get max stack size. Returns an awaitable that resolves to int.
112
+
-`set_amount(value: int)` — Set item amount. Returns an awaitable that resolves to `None`.
113
+
-`set_name(name: str)` — Set display name. Returns an awaitable that resolves to `None`.
114
+
-`set_lore(lore: list[str])` — Set lore. Returns an awaitable that resolves to `None`.
115
+
-`set_custom_model_data(value: int)` — Set custom model data. Returns an awaitable that resolves to `None`.
116
+
-`set_attributes(attributes: list[dict])` — Set attribute modifiers. Returns an awaitable that resolves to `None`.
117
+
-`set_nbt(nbt: dict)` — Set NBT map. Returns an awaitable that resolves to `None`.
99
118
-`broadcast(message: str)` — Broadcast a message to all players and console. Returns an awaitable that resolves to `None`.
100
119
-`create_boss_bar(title: str, color: [`BarColor`](#barcolor), style: [`BarStyle`](#barstyle))` — Create a boss bar. Returns an awaitable that resolves to [`BossBar`](#bossbar).
101
120
-`get_advancement(key: str)` — Get an advancement by namespaced key. Returns an awaitable that resolves to [`Advancement`](#advancement).
-`players()` — Return the online players. Returns an awaitable that resolves to a list of [`Player`](#player).
105
124
-`scoreboard_manager()` — Get the scoreboard manager. Returns an awaitable that resolves to a scoreboard manager object.
106
125
-`scheduler()` — Get the server scheduler. Returns an awaitable that resolves to a server scheduler object.
126
+
-`wait(ticks: int = 1, after: callable | None = None)` — Wait for ticks then optionally run a callback. Returns an awaitable that resolves to `None`.
127
+
-`frame()` — Async context manager that batches calls into one send.
128
+
-`atomic()` — Async context manager that batches calls as an atomic group.
129
+
-`flush()` — Send all pending batched requests immediately. Returns an awaitable that resolves to `None`.
107
130
-`world(name: str)` — Get a world by name. Returns an awaitable that resolves to [`World`](#world).
108
131
-`worlds()` — Return all loaded worlds. Returns an awaitable that resolves to a list of [`World`](#world).
109
132
@@ -124,6 +147,7 @@ Base entity proxy.
124
147
-`custom_name()` — Get custom name. Returns an awaitable that resolves to any name value.
125
148
-`fire_ticks()` — Get fire ticks. Returns an awaitable that resolves to int.
126
149
-`is_dead()` — Check if entity is dead. Returns an awaitable that resolves to bool.
150
+
-`is_alive()` — Check if entity is alive. Returns an awaitable that resolves to bool.
127
151
-`is_valid()` — Check if entity is valid. Returns an awaitable that resolves to bool.
128
152
-`passengers()` — Get passengers. Returns an awaitable that resolves to a list of [`Entity`](#entity).
129
153
-`remove()` — Remove the entity. Returns an awaitable that resolves to `None`.
@@ -139,6 +163,10 @@ Base entity proxy.
139
163
140
164
`Player` API (inherits [`Entity`](#entity)).
141
165
166
+
### Constructor
167
+
168
+
-`Player(uuid: str | None = None, name: str | None = None)` — Resolve a player by UUID or name.
169
+
142
170
### Attributes
143
171
144
172
-`food_level`: int — Hunger level.
@@ -158,6 +186,14 @@ Base entity proxy.
158
186
-`exp()` — Get experience progress $0..1$. Returns an awaitable that resolves to float.
159
187
-`give_exp(amount: int)` — Give raw experience points. Returns an awaitable that resolves to `None`.
160
188
-`has_permission(permission: str)` — Check a permission. Returns an awaitable that resolves to bool.
189
+
-`is_alive()` — Check if the player is alive. Returns an awaitable that resolves to bool.
190
+
-`add_permission(permission: str, value: bool = True)` — Add or set a permission (LuckPerms-aware). Returns an awaitable that resolves to bool.
191
+
-`remove_permission(permission: str)` — Remove a permission (LuckPerms-aware). Returns an awaitable that resolves to bool.
192
+
-`permission_groups()` — Get permission groups (LuckPerms-aware). Returns an awaitable that resolves to list of str.
193
+
-`primary_group()` — Get primary permission group (LuckPerms-aware). Returns an awaitable that resolves to str or `None`.
194
+
-`has_group(group: str)` — Check group membership (LuckPerms-only). Returns an awaitable that resolves to bool.
195
+
-`add_group(group: str)` — Add a permission group (LuckPerms-only). Returns an awaitable that resolves to bool.
196
+
-`remove_group(group: str)` — Remove a permission group (LuckPerms-only). Returns an awaitable that resolves to bool.
161
197
-`is_flying()` — Check if the player is flying. Returns an awaitable that resolves to bool.
162
198
-`is_op()` — Check if the player is op. Returns an awaitable that resolves to bool.
163
199
-`is_sneaking()` — Check if sneaking. Returns an awaitable that resolves to bool.
@@ -286,16 +322,24 @@ Item (ItemStack) API.
286
322
### Attributes
287
323
288
324
-`amount`: int — Stack amount.
289
-
-`meta`: [`ItemMeta`](#itemmeta) — Item metadata.
290
325
-`type`: [`Material`](#material) — Item material.
326
+
-`name`: str | None — Display name.
327
+
-`lore`: list[str] — Lore lines.
328
+
-`custom_model_data`: int | None — Custom model data.
329
+
-`attributes`: list[dict] — Attribute modifiers.
330
+
-`nbt`: dict — Serialized NBT map.
291
331
292
332
### Methods
293
333
294
334
-`clone()` — Clone this item. Returns an awaitable that resolves to [`Item`](#item).
295
335
-`is_similar(other: [`Item`](#item))` — Check if items are similar. Returns an awaitable that resolves to bool.
296
336
-`max_stack_size()` — Get max stack size. Returns an awaitable that resolves to int.
297
337
-`set_amount(value: int)` — Set item amount. Returns an awaitable that resolves to `None`.
298
-
-`set_meta(meta: [`ItemMeta`](#itemmeta))` — Set item meta. Returns an awaitable that resolves to `None`.
338
+
-`set_name(name: str)` — Set display name. Returns an awaitable that resolves to `None`.
339
+
-`set_lore(lore: list[str])` — Set lore. Returns an awaitable that resolves to `None`.
340
+
-`set_custom_model_data(value: int)` — Set custom model data. Returns an awaitable that resolves to `None`.
341
+
-`set_attributes(attributes: list[dict])` — Set attribute modifiers. Returns an awaitable that resolves to `None`.
342
+
-`set_nbt(nbt: dict)` — Set NBT map. Returns an awaitable that resolves to `None`.
299
343
300
344
## Chunk
301
345
@@ -368,6 +412,10 @@ None.
368
412
369
413
Active potion effect.
370
414
415
+
### Constructor
416
+
417
+
-`Effect(effect_type: EffectType | str, duration: int = 0, amplifier: int = 0, ambient: bool = False, particles: bool = True, icon: bool = True)` — Create a value effect.
418
+
371
419
### Attributes
372
420
373
421
-`ambient`: bool — Whether the effect is ambient.
@@ -386,26 +434,37 @@ Active potion effect.
386
434
387
435
Inventory. Can belong to an entity or block entity, or exist as a standalone open inventory screen.
388
436
437
+
### Constructor
438
+
439
+
-`Inventory(size: int = 9, title: str = "", contents: list[Item] | None = None)` — Create a value inventory.
440
+
389
441
### Attributes
390
442
391
443
-`contents`: list of [`Item`](#item) — Inventory contents.
392
444
-`holder`: any — Inventory holder.
393
445
-`size`: int — Inventory size.
446
+
-`title`: str — Inventory title.
394
447
395
448
### Methods
396
449
397
450
-`add_item(item: [`Item`](#item))` — Add an item to the inventory. Returns an awaitable that resolves to any add result.
398
451
-`clear()` — Clear inventory contents. Returns an awaitable that resolves to `None`.
452
+
-`close(player: [`Player`](#player) | None = None)` — Close this inventory for a player. Returns an awaitable that resolves to `None`.
399
453
-`contains(material: [`Material`](#material), amount: int = 1)` — Check if inventory contains a material. Returns an awaitable that resolves to bool.
400
454
-`first_empty()` — Get first empty slot index. Returns an awaitable that resolves to int.
401
455
-`get_item(slot: int)` — Get item in a slot. Returns an awaitable that resolves to [`Item`](#item).
456
+
-`open(player: [`Player`](#player))` — Open this inventory for a player. Returns an awaitable that resolves to any open result.
402
457
-`remove_item(item: [`Item`](#item))` — Remove an item from the inventory. Returns an awaitable that resolves to any remove result.
403
458
-`set_item(slot: int, item: [`Item`](#item))` — Set item in a slot. Returns an awaitable that resolves to `None`.
404
459
405
460
## Material
406
461
407
462
Material enum proxy, such as diamond, netherite, wood.
408
463
464
+
### Constructor
465
+
466
+
-`Material(name: str)` — Create a material enum value (case-insensitive).
467
+
409
468
### Attributes
410
469
411
470
None.
@@ -540,21 +599,6 @@ None.
540
599
-`remaining_criteria()` — Get remaining criteria. Returns an awaitable that resolves to a set of str.
541
600
-`revoke_criteria(name: str)` — Revoke a criterion. Returns an awaitable that resolves to bool.
542
601
543
-
## ItemMeta
544
-
545
-
Item metadata proxy.
546
-
547
-
### Attributes
548
-
549
-
-`custom_model_data`: int — Custom model data value.
550
-
-`has_custom_model_data`: bool — Whether custom model data exists.
551
-
552
-
### Methods
553
-
554
-
-`has_lore()` — Check if lore exists. Returns an awaitable that resolves to bool.
555
-
-`lore()` — Get lore lines. Returns an awaitable that resolves to a list of str.
556
-
-`set_custom_model_data(value: int)` — Set custom model data. Returns an awaitable that resolves to `None`.
557
-
-`set_lore(lore: list[str])` — Set lore lines. Returns an awaitable that resolves to `None`.
558
602
559
603
## Difficulty
560
604
@@ -585,6 +629,34 @@ None.
585
629
-`set_display_name(name: str)` — Set display name. Returns an awaitable that resolves to `None`.
586
630
-`set_display_slot(slot: any)` — Set display slot. Returns an awaitable that resolves to `None`.
587
631
632
+
## Chat
633
+
634
+
Chat helper API.
635
+
636
+
### Methods
637
+
638
+
-`broadcast(message: str)` — Broadcast a chat message to all players and console. Returns an awaitable that resolves to `None`.
639
+
640
+
## Raycast
641
+
642
+
Raycast helpers.
643
+
644
+
### Methods
645
+
646
+
-`raycast(world, start, direction, max_distance=64.0, ray_size=0.2, include_entities=True, include_blocks=True, ignore_passable=True)` — Raycast in a world. `world` can be a world object or name. `direction` is a `(yaw, pitch)` tuple. Returns an awaitable that resolves to a [`RaycastResult`](#raycastresult) or `None` when no hit.
647
+
648
+
## RaycastResult
649
+
650
+
Raycast result data.
651
+
652
+
### Attributes
653
+
654
+
-`x`, `y`, `z`: float — Hit position.
655
+
-`entity`: [`Entity`](#entity) | None — Hit entity.
0 commit comments