Skip to content

Commit e90a5d2

Browse files
authored
Merge pull request networkfilter#54 from ByteExceptionM/main
2 parents 59bbdba + 1ff866c commit e90a5d2

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

bungee/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>net.md-5</groupId>
2727
<artifactId>bungeecord-api</artifactId>
28-
<version>1.19-R0.1-SNAPSHOT</version>
28+
<version>1.21-R0.1-SNAPSHOT</version>
2929
<scope>provided</scope>
3030
</dependency>
3131

bungee/src/main/java/ls/ni/networkfilter/bungee/listeners/PostLoginListener.java

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
import net.md_5.bungee.api.plugin.Listener;
3535
import net.md_5.bungee.event.EventHandler;
3636

37-
import java.net.InetSocketAddress;
3837
import java.net.SocketAddress;
39-
import java.util.Optional;
4038

4139
public 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

Comments
 (0)