3434import net .md_5 .bungee .api .plugin .Listener ;
3535import net .md_5 .bungee .event .EventHandler ;
3636
37- import java .net .InetSocketAddress ;
3837import java .net .SocketAddress ;
39- import java .util .Optional ;
4038
4139public class PostLoginListener implements Listener {
4240
@@ -56,31 +54,37 @@ public void onEvent(PostLoginEvent event) {
5654 return ;
5755 }
5856
57+ event .registerIntent (this .plugin );
58+
5959 this .plugin .getProxy ().getScheduler ().runAsync (this .plugin , () -> {
60- NetworkFilterResult result = NetworkFilterCommon .getInstance ().check (address );
60+ try {
61+ NetworkFilterResult result = NetworkFilterCommon .getInstance ().check (address );
6162
62- if (!result .blocked ()) {
63- return ;
64- }
63+ if (!result .blocked ()) {
64+ return ;
65+ }
6566
66- if (NetworkFilterCommon .getConfig ().getConsequences ().getKick ().getEnabled ()) {
67- String rawMessage = NetworkFilterCommon .getConfig ().getConsequences ().getKick ().getMessage ();
68- String message = PlaceholderUtil .replace (rawMessage , result , player .getName (), player .getUniqueId ());
67+ if (NetworkFilterCommon .getConfig ().getConsequences ().getKick ().getEnabled ()) {
68+ String rawMessage = NetworkFilterCommon .getConfig ().getConsequences ().getKick ().getMessage ();
69+ String message = PlaceholderUtil .replace (rawMessage , result , player .getName (), player .getUniqueId ());
6970
70- player .disconnect (TextComponent .fromLegacyText (message ));
71- }
71+ player .disconnect (TextComponent .fromLegacyText (message ));
72+ }
73+
74+ for (String rawCommand : NetworkFilterCommon .getConfig ().getConsequences ().getCommands ()) {
75+ if (rawCommand .isBlank ()) {
76+ continue ;
77+ }
7278
73- for ( String rawCommand : NetworkFilterCommon . getConfig (). getConsequences (). getCommands ()) {
74- if ( rawCommand . isBlank ()) {
75- continue ;
79+ String command = PlaceholderUtil . replace ( rawCommand , result , player . getName (), player . getUniqueId ());
80+ this . plugin . getProxy (). getPluginManager (). dispatchCommand (
81+ this . plugin . getProxy (). getConsole (), command ) ;
7682 }
7783
78- String command = PlaceholderUtil . replace ( rawCommand , result , player .getName (), player .getUniqueId ());
79- this . plugin . getProxy (). getPluginManager (). dispatchCommand (
80- this . plugin . getProxy (). getConsole (), command );
84+ NetworkFilterCommon . getInstance (). sendNotify ( result , player .getName (), player .getUniqueId ());
85+ } finally {
86+ event . completeIntent ( this . plugin );
8187 }
82-
83- NetworkFilterCommon .getInstance ().sendNotify (result , player .getName (), player .getUniqueId ());
8488 });
8589 }
8690}
0 commit comments