Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
35ff3503
Commit
35ff3503
authored
Apr 26, 2022
by
KingRainbow44
Browse files
Fix Javadoc & Update version
parent
82bca7a6
Changes
2
Show whitespace changes
Inline
Side-by-side
build.gradle
View file @
35ff3503
...
@@ -18,7 +18,7 @@ plugins {
...
@@ -18,7 +18,7 @@ plugins {
}
}
group
=
'tech.xigam'
group
=
'tech.xigam'
version
=
'1.0.
0
-dev'
version
=
'1.0.
1
-dev'
sourceCompatibility
=
17
sourceCompatibility
=
17
targetCompatibility
=
17
targetCompatibility
=
17
...
...
src/main/java/emu/grasscutter/plugin/PluginManager.java
View file @
35ff3503
...
@@ -17,11 +17,11 @@ import java.util.jar.JarFile;
...
@@ -17,11 +17,11 @@ import java.util.jar.JarFile;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
/**
/**
* Manages the server's plugins
&
the event system.
* Manages the server's plugins
and
the event system.
*/
*/
public
final
class
PluginManager
{
public
final
class
PluginManager
{
private
final
Map
<
String
,
Plugin
>
plugins
=
new
HashMap
<>();
private
final
Map
<
String
,
Plugin
>
plugins
=
new
HashMap
<>();
private
final
List
<
EventHandler
<?>
>
listeners
=
new
LinkedList
<>();
private
final
List
<
EventHandler
>
listeners
=
new
LinkedList
<>();
public
PluginManager
()
{
public
PluginManager
()
{
this
.
loadPlugins
();
// Load all plugins from the plugins directory.
this
.
loadPlugins
();
// Load all plugins from the plugins directory.
...
@@ -131,7 +131,7 @@ public final class PluginManager {
...
@@ -131,7 +131,7 @@ public final class PluginManager {
* Registers a plugin's event listener.
* Registers a plugin's event listener.
* @param listener The event listener.
* @param listener The event listener.
*/
*/
public
void
registerListener
(
EventHandler
<?>
listener
)
{
public
void
registerListener
(
EventHandler
listener
)
{
this
.
listeners
.
add
(
listener
);
this
.
listeners
.
add
(
listener
);
}
}
...
@@ -140,8 +140,8 @@ public final class PluginManager {
...
@@ -140,8 +140,8 @@ public final class PluginManager {
* @param event The event to invoke.
* @param event The event to invoke.
*/
*/
public
void
invokeEvent
(
Event
event
)
{
public
void
invokeEvent
(
Event
event
)
{
Stream
<
EventHandler
<?>
>
handlers
=
this
.
listeners
.
stream
()
Stream
<
EventHandler
>
handlers
=
this
.
listeners
.
stream
()
.
filter
(
handler
->
event
.
getClas
s
().
isInstance
(
event
));
.
filter
(
handler
->
handler
.
handle
s
().
isInstance
(
event
));
handlers
.
filter
(
handler
->
handler
.
getPriority
()
==
HandlerPriority
.
HIGH
)
handlers
.
filter
(
handler
->
handler
.
getPriority
()
==
HandlerPriority
.
HIGH
)
.
toList
().
forEach
(
handler
->
this
.
invokeHandler
(
event
,
handler
));
.
toList
().
forEach
(
handler
->
this
.
invokeHandler
(
event
,
handler
));
handlers
.
filter
(
handler
->
handler
.
getPriority
()
==
HandlerPriority
.
NORMAL
)
handlers
.
filter
(
handler
->
handler
.
getPriority
()
==
HandlerPriority
.
NORMAL
)
...
@@ -155,7 +155,7 @@ public final class PluginManager {
...
@@ -155,7 +155,7 @@ public final class PluginManager {
* @param event The event passed through to the handler.
* @param event The event passed through to the handler.
* @param handler The handler to invoke.
* @param handler The handler to invoke.
*/
*/
private
void
invokeHandler
(
Event
event
,
EventHandler
<?>
handler
)
{
private
void
invokeHandler
(
Event
event
,
EventHandler
handler
)
{
if
(!
event
.
isCanceled
()
||
if
(!
event
.
isCanceled
()
||
(
event
.
isCanceled
()
&&
handler
.
ignoresCanceled
())
(
event
.
isCanceled
()
&&
handler
.
ignoresCanceled
())
)
handler
.
getCallback
().
accept
(
event
);
)
handler
.
getCallback
().
accept
(
event
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment