Skip to content

Commit 9bb11be

Browse files
committed
Events and package JavaDocs
1 parent d53566a commit 9bb11be

File tree

15 files changed

+103
-9
lines changed

15 files changed

+103
-9
lines changed

src/main/java/module-info.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
* Copyright (c) Forge Development LLC
33
* SPDX-License-Identifier: LGPL-2.1-only
44
*/
5+
56
import org.jspecify.annotations.NullMarked;
67

8+
/**
9+
* The EventBus module is split into two distinct packages: the {@linkplain net.minecraftforge.eventbus.api API} and the
10+
* {@linkplain net.minecraftforge.eventbus.internal internal implementation}. The API contains the interfaces for
11+
* consumers to interact with. The internal implementation is never exported and should not be accessed as it can be
12+
* changed at any time, without prior warning, and for any reason.
13+
*
14+
* @see net.minecraftforge.eventbus.api
15+
*/
716
@NullMarked
817
module net.minecraftforge.eventbus {
918
requires java.logging;

src/main/java/net/minecraftforge/eventbus/api/bus/BusGroup.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
* A collection of {@link EventBus} instances that are grouped together for easier management.
1717
*/
1818
public sealed interface BusGroup permits BusGroupImpl {
19+
/**
20+
* The default BusGroup provided by EventBus. While it is recommended to create your own BusGroup, this can be used
21+
* as a safe default if necessary.
22+
*
23+
* @see #create(String)
24+
*/
1925
BusGroup DEFAULT = create("default");
2026

2127
/**
@@ -37,6 +43,7 @@ static BusGroup create(String name) {
3743
* @throws IllegalArgumentException If a BusGroup with the given name already exists
3844
* @apiNote In theory, it is possible to use any base type when creating a BusGroup. However, it is recommended to
3945
* either use a direct subtype of {@link Event} or use {@link #create(String)} which uses the default type.
46+
* @see #create(String)
4047
*/
4148
static BusGroup create(String name, Class<?> baseType) {
4249
return new BusGroupImpl(name, baseType);

src/main/java/net/minecraftforge/eventbus/api/bus/package-info.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
* Copyright (c) Forge Development LLC
33
* SPDX-License-Identifier: LGPL-2.1-only
44
*/
5+
/**
6+
* This package houses classes related to bus-specific APIs, such as
7+
* {@link net.minecraftforge.eventbus.api.bus.BusGroup BusGroup} and
8+
* {@link net.minecraftforge.eventbus.api.bus.EventBus}. These APIs are documented in extensive detail within their
9+
* respective classes.
10+
*/
511
@NullMarked
612
package net.minecraftforge.eventbus.api.bus;
713

src/main/java/net/minecraftforge/eventbus/api/event/InheritableEvent.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@
66

77
import net.minecraftforge.eventbus.internal.Event;
88

9+
/**
10+
* This top-level event implementation exists as a bare interface to allow events to implement it however they wish.
11+
* Unlike {@link MutableEvent}, which is an object that must be extended from, InheritableEvent can be applied to any
12+
* type that needs to have information sent to listeners via an
13+
* {@linkplain net.minecraftforge.eventbus.api.bus.EventBus event bus}.
14+
*
15+
* @see MutableEvent
16+
* @see RecordEvent
17+
*/
918
public non-sealed interface InheritableEvent extends Event {}

src/main/java/net/minecraftforge/eventbus/api/event/MutableEvent.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,16 @@
77
import net.minecraftforge.eventbus.internal.Event;
88
import net.minecraftforge.eventbus.internal.MutableEventInternals;
99

10+
/**
11+
* This top-level event implementation exists as a base object that can be expanded upon to contain information to be
12+
* sent to listeners via an {@linkplain net.minecraftforge.eventbus.api.bus.EventBus event bus}.
13+
* <p>The primary difference between MutableEvent and {@link InheritableEvent} is that MutableEvent is
14+
* {@linkplain net.minecraftforge.eventbus.api.event.characteristic.MonitorAware monitor-aware}. Although it is the
15+
* MonitorAware interface that enforces this contract, its default implementation works natively with MutableEvent
16+
* without needing any additional implementations from the consumer.</p>
17+
*
18+
* @see net.minecraftforge.eventbus.api.event.characteristic.MonitorAware MonitorAware
19+
* @see InheritableEvent
20+
* @see RecordEvent
21+
*/
1022
public non-sealed abstract class MutableEvent extends MutableEventInternals implements Event {}

src/main/java/net/minecraftforge/eventbus/api/event/RecordEvent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@
66

77
import net.minecraftforge.eventbus.internal.Event;
88

9+
/**
10+
* This top-level implementation is for records to directly implement. This is enforced at runtime, as any non-record
11+
* event that implements this interface will cause an {@link IllegalArgumentException} to be thrown when an
12+
* {@linkplain net.minecraftforge.eventbus.api.bus.EventBus event bus} is created for it.
13+
*
14+
* @apiNote Although records can inherit {@link InheritableEvent} without implementing RecordEvent, it is highly
15+
* recommended to implement this instead as it will boost performance drastically. EventBus is designed to take
16+
* advantage of the finalized state of records.
17+
* @see InheritableEvent
18+
* @see MutableEvent
19+
*/
920
public non-sealed interface RecordEvent extends Event {}

src/main/java/net/minecraftforge/eventbus/api/event/characteristic/Cancellable.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
import net.minecraftforge.eventbus.internal.Event;
99

1010
/**
11-
* A cancellable event returns {@code true} from {@link CancellableEventBus#post(Event)} if it was cancelled.
12-
* <p>When an event is cancelled, it will not be passed to any further non-monitor listeners.</p>
11+
* A cancellable event returns {@code true} from {@link CancellableEventBus#post(Event)} if it was cancelled. The
12+
* following key points must be known regarding cancellable events:
13+
* <ul>
14+
* <li>When an event is cancelled, it will not be passed to any further non-{@linkplain net.minecraftforge.eventbus.api.listener.Priority#MONITOR monitor} listeners.</li>
15+
* <li>Cancellable events <strong>must be used with a {@linkplain CancellableEventBus cancellable event bus}</strong> in order to function as intended.</li>
16+
* </ul>
17+
*
18+
* @see CancellableEventBus
1319
*/
1420
public non-sealed interface Cancellable extends EventCharacteristic {}

src/main/java/net/minecraftforge/eventbus/api/event/characteristic/MonitorAware.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
import net.minecraftforge.eventbus.internal.MutableEventInternals;
99

1010
/**
11-
* Experimental feature - may be removed, renamed or otherwise changed without notice.
12-
* <p>Events that are {@link MonitorAware} can provide stronger immutability guarantees to monitor listeners by
13-
* returning unmodifiable views or throwing exceptions on mutation attempts when monitoring.</p>
11+
* Events that are {@link MonitorAware} can provide stronger immutability guarantees to monitor listeners by returning
12+
* unmodifiable views or throwing exceptions on mutation attempts when monitoring.
1413
* <p>Only supported for {@link MutableEvent} at this time.</p>
14+
*
15+
* @apiNote <strong>This feature is experimental - it may be removed, renamed or otherwise changed without
16+
* notice.</strong>
17+
* @see MutableEvent
1518
*/
1619
public non-sealed interface MonitorAware extends EventCharacteristic {
1720
default boolean isMonitoring() {

src/main/java/net/minecraftforge/eventbus/api/event/characteristic/SelfPosting.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import net.minecraftforge.eventbus.internal.Event;
99

1010
/**
11-
* Experimental feature - may be removed, renamed or otherwise changed without notice.
12-
* <p>{@link SelfPosting} events are associated with a default {@link EventBus} in order to offer some convenience
13-
* instance methods.</p>
11+
* Self-posting events are associated with a default {@link EventBus} in order to offer some convenience
12+
* instance methods.
13+
* <p>
1414
* <u>Example</u>
1515
* {@snippet :
1616
* import net.minecraftforge.eventbus.api.event.RecordEvent;
@@ -31,6 +31,8 @@
3131
* // instead of this
3232
* ExampleEvent.BUS.post(new ExampleEvent());
3333
*}
34+
* @apiNote <strong>This feature is experimental - it may be removed, renamed or otherwise changed without
35+
* notice.</strong>
3436
*/
3537
public non-sealed interface SelfPosting<T extends Event> extends EventCharacteristic {
3638
/**

src/main/java/net/minecraftforge/eventbus/api/event/characteristic/package-info.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* Copyright (c) Forge Development LLC
33
* SPDX-License-Identifier: LGPL-2.1-only
44
*/
5+
/**
6+
* This package houses classes related to the characterists that
7+
* {@linkplain net.minecraftforge.eventbus.internal.Event events} can have.
8+
*/
59
@NullMarked
610
package net.minecraftforge.eventbus.api.event.characteristic;
711

0 commit comments

Comments
 (0)