33
33
* information for events being thrown. This allows plugins to attach more
34
34
* contextual information to events which may be triggered from their api
35
35
* interactions.
36
- *
36
+ *
37
37
* <p>For example a plugin may wish to push a player into the cause stack before
38
38
* spawning an entity to expose to any plugin listening for SpawnEntityEvents
39
39
* that the player is the reason that the entity was spawned.</p>
40
- *
40
+ *
41
41
* <p>This system will automatically handle associating a plugin with actions
42
42
* performed inside of event listeners, command executors, and scheduled
43
43
* tasks.</p>
@@ -46,23 +46,23 @@ public interface CauseStackManager {
46
46
47
47
/**
48
48
* Gets the current {@link Cause} object from the current cause stack.
49
- *
49
+ *
50
50
* @return A cause of the current stack.
51
51
*/
52
52
Cause currentCause ();
53
53
54
54
/**
55
55
* Gets an {@link EventContext} object on the current contextual
56
56
* information.
57
- *
57
+ *
58
58
* @return The current event context
59
59
*/
60
60
EventContext currentContext ();
61
61
62
62
/**
63
63
* Pushes an object to the current cause stack which will associate it with
64
64
* all events through from api actions until it is popped off again.
65
- *
65
+ *
66
66
* @param obj The object to push to the stack
67
67
* @return The cause stack manager, for chaining
68
68
*/
@@ -71,28 +71,28 @@ public interface CauseStackManager {
71
71
/**
72
72
* Pops the most recently pushed cause object off of the stack and returns
73
73
* it.
74
- *
74
+ *
75
75
* @return The last pushed object
76
76
*/
77
77
Object popCause ();
78
78
79
79
/**
80
80
* Pops the most recently <b>n</b> pushed cause objects off of the stack.
81
- *
81
+ *
82
82
* @param n The number of causes to pop
83
83
*/
84
84
void popCauses (int n );
85
85
86
86
/**
87
87
* Retrieves but does not remove the most recently pushed cause object.
88
- *
88
+ *
89
89
* @return The last pushed object
90
90
*/
91
91
Object peekCause ();
92
92
93
93
/**
94
94
* Pushes a frame of the current cause stack and context state.
95
- *
95
+ *
96
96
* @return A handle for the frame which must be passed back to pop the frame
97
97
* from the stack
98
98
*/
@@ -101,19 +101,19 @@ public interface CauseStackManager {
101
101
/**
102
102
* Replaces the current cause stack and context with the cause frame at the
103
103
* top of the frame stack.
104
- *
104
+ *
105
105
* <p>The frame handle is required to ensure that frames are popped of in
106
106
* order and are not left in the stack. If an attempt is made to pop a frame
107
107
* which is not the head of the frame stack then an error will be thrown as
108
108
* this indicates that a frame was not popped properly.</p>
109
- *
109
+ *
110
110
* @param handle The frame handle to pop
111
111
*/
112
112
void popCauseFrame (StackFrame handle );
113
113
114
114
/**
115
115
* Adds the given object to the current context under the given key.
116
- *
116
+ *
117
117
* @param key The context key
118
118
* @param value The object
119
119
* @param <T> The type of the value stored with the event context key
@@ -163,7 +163,7 @@ default <T> CauseStackManager addContext(Supplier<EventContextKey<T>> key, Suppl
163
163
164
164
/**
165
165
* Gets the context value with the given key.
166
- *
166
+ *
167
167
* @param key The context key
168
168
* @param <T> The type of the value stored with the event context key
169
169
* @return The context object, if present
@@ -183,10 +183,10 @@ default <T> Optional<T> context(Supplier<EventContextKey<T>> key) {
183
183
184
184
/**
185
185
* Gets the context value with the given key.
186
- *
186
+ *
187
187
* <p>If the key is not available, {@link NoSuchElementException} will be
188
188
* thrown.</p>
189
- *
189
+ *
190
190
* @param key The context key
191
191
* @param <T> The type of the value stored with the event context key
192
192
* @return The context object, if present
@@ -220,7 +220,7 @@ default <T> T requireContext(Supplier<EventContextKey<T>> key) {
220
220
221
221
/**
222
222
* Removes the given context key from the current context.
223
- *
223
+ *
224
224
* @param key The key to clear
225
225
* @param <T> The type of the value stored with the event context key
226
226
* @return The existing context value, if it was present
0 commit comments