Skip to content

Commit c0f65a1

Browse files
committed
Add javadocs for NotifyNeighborBlockEvent
1 parent 3caa5c7 commit c0f65a1

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

src/main/java/org/spongepowered/api/block/transaction/NotificationTicket.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,60 @@
2828
import org.spongepowered.api.world.LocatableBlock;
2929
import org.spongepowered.math.vector.Vector3i;
3030

31+
/**
32+
* Represents a notification that is being proposed to the engine.
33+
*/
3134
public interface NotificationTicket {
3235

36+
/**
37+
* Gets the notifier block that scheduled this notification.
38+
*
39+
* @return The notifier block
40+
*/
3341
LocatableBlock notifier();
3442

43+
/**
44+
* Gets the notifier position that scheduled this notification.
45+
*
46+
* @return The notifier position
47+
*/
3548
default Vector3i notifierPosition() {
3649
return this.notifier().blockPosition();
3750
}
3851

52+
/**
53+
* Gets the target block of this notification.
54+
*
55+
* @return The target block
56+
*/
3957
BlockSnapshot target();
4058

59+
/**
60+
* Gets the target position of this notification.
61+
*
62+
* @return The target position
63+
*/
4164
default Vector3i targetPosition() {
4265
return this.target().position();
4366
}
4467

68+
/**
69+
* Gets whether this ticket is marked as valid.
70+
*
71+
* @return The valid state of this ticket
72+
*/
4573
boolean valid();
4674

75+
/**
76+
* Sets whether this ticket is valid or not.
77+
*
78+
* @param valid The valid state of this ticket
79+
*/
4780
void setValid(boolean valid);
4881

82+
/**
83+
* Invalidates this ticket.
84+
*/
4985
default void invalidate() {
5086
this.setValid(false);
5187
}

src/main/java/org/spongepowered/api/event/block/NotifyNeighborBlockEvent.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,30 @@
3333
import java.util.function.Predicate;
3434

3535
/**
36-
*
36+
* Fired when a neighbour notification is being proposed to the engine.
3737
*/
3838
public interface NotifyNeighborBlockEvent extends Event, Cancellable {
3939

40+
/**
41+
* Gets a list of the {@link NotificationTicket}s for this event.
42+
* If a ticket is requested to be marked as "invalid",
43+
* {@link NotificationTicket#setValid(boolean)} can be used.
44+
*
45+
* @return The unmodifiable list of tickets
46+
*/
4047
List<NotificationTicket> tickets();
4148

49+
/**
50+
* Applies the provided {@link Predicate} to the {@link List} of
51+
* {@link NotificationTicket}s from {@link #tickets()} such that
52+
* any time that {@link Predicate#test(Object)} returns {@code false}
53+
* on the location of the {@link NotificationTicket}, the
54+
* {@link NotificationTicket} is marked as "invalid".
55+
*
56+
* <p>{@link NotificationTicket#targetPosition()} is used to get the {@link Vector3i}</p>
57+
*
58+
* @param predicate The predicate to use for filtering
59+
*/
4260
default void filterTargetPositions(final Predicate<Vector3i> predicate) {
4361
this.tickets().forEach(ticket -> {
4462
if (!predicate.test(ticket.targetPosition())) {
@@ -47,6 +65,15 @@ default void filterTargetPositions(final Predicate<Vector3i> predicate) {
4765
});
4866
}
4967

68+
/**
69+
* Applies the provided {@link Predicate} to the {@link List} of
70+
* {@link NotificationTicket}s from {@link #tickets()} such that
71+
* any time that {@link Predicate#test(Object)} returns {@code false}
72+
* on the location of the {@link NotificationTicket}, the
73+
* {@link NotificationTicket} is marked as "invalid".
74+
*
75+
* @param predicate The predicate to use for filtering
76+
*/
5077
default void filterTickets(final Predicate<NotificationTicket> predicate) {
5178
this.tickets().forEach(ticket -> {
5279
if (!predicate.test(ticket)) {

0 commit comments

Comments
 (0)