Skip to content

Commit d3057ca

Browse files
stable bungeecord release
1 parent 2fa78fc commit d3057ca

File tree

8 files changed

+314
-89
lines changed

8 files changed

+314
-89
lines changed

bungeecord/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<artifactId>maven-compiler-plugin</artifactId>
2424
<version>3.8.1</version>
2525
<configuration>
26-
<source>1.8</source>
27-
<target>1.8</target>
26+
<source>17</source>
27+
<target>17</target>
2828
</configuration>
2929
</plugin>
3030
<plugin>
@@ -69,15 +69,15 @@
6969
<dependency>
7070
<groupId>net.md-5</groupId>
7171
<artifactId>bungeecord-api</artifactId>
72-
<version>1.19-R0.1-SNAPSHOT</version>
73-
<type>jar</type>
72+
<version>1.21-R0.2</version>
73+
<type>javadoc</type>
7474
<scope>provided</scope>
7575
</dependency>
7676
<dependency>
7777
<groupId>net.md-5</groupId>
7878
<artifactId>bungeecord-api</artifactId>
79-
<version>1.19-R0.1-SNAPSHOT</version>
80-
<type>javadoc</type>
79+
<version>1.21-R0.2</version>
80+
<type>jar</type>
8181
<scope>provided</scope>
8282
</dependency>
8383

@@ -94,7 +94,7 @@
9494
<groupId>org.projectlombok</groupId>
9595
<artifactId>lombok</artifactId>
9696
<version>1.18.30</version>
97-
<scope>compile</scope>
97+
<scope>provided</scope>
9898
</dependency>
9999
</dependencies>
100100
</project>
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
package today.netshield.bungee;
22

33
import lombok.Getter;
4+
import lombok.Setter;
5+
import lombok.SneakyThrows;
6+
import net.md_5.bungee.api.ProxyServer;
47
import net.md_5.bungee.api.plugin.Plugin;
58
import net.md_5.bungee.config.Configuration;
69
import net.md_5.bungee.config.ConfigurationProvider;
710
import net.md_5.bungee.config.YamlConfiguration;
8-
import today.netshield.bungee.listeners.PlayerListener;
11+
import today.netshield.bungee.commands.NetShieldCommand;
12+
import today.netshield.bungee.listeners.ConnectionListener;
913
import today.netshield.bungee.utils.ConfigFiles;
1014

1115
import java.io.File;
12-
import java.io.IOException;
1316

17+
@Getter @Setter
1418
public final class NetShield extends Plugin {
15-
@Getter
16-
private static NetShield instance;
17-
@Getter
19+
@Getter private static NetShield instance;
20+
1821
private Configuration config;
1922

23+
@SneakyThrows
2024
@Override
2125
public void onEnable() {
2226
instance = this;
2327

24-
try {
25-
new ConfigFiles().makeConfig();
26-
} catch (IOException e) {
27-
throw new RuntimeException(e);
28-
}
28+
new ConfigFiles().makeConfig();
29+
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
2930

30-
try {
31-
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
32-
} catch (IOException e) {
33-
throw new RuntimeException(e);
34-
}
31+
ProxyServer.getInstance().getPluginManager().registerCommand(this, new NetShieldCommand());
32+
getProxy().getPluginManager().registerListener(this, new ConnectionListener(this));
3533

36-
getProxy().getPluginManager().registerListener(this, new PlayerListener());
34+
getLogger().info("NetShield has been enabled!");
3735
}
3836
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package today.netshield.bungee.commands;
2+
3+
import lombok.SneakyThrows;
4+
import net.md_5.bungee.api.CommandSender;
5+
import net.md_5.bungee.api.chat.TextComponent;
6+
import net.md_5.bungee.api.plugin.Command;
7+
import net.md_5.bungee.config.ConfigurationProvider;
8+
import net.md_5.bungee.config.YamlConfiguration;
9+
import today.netshield.bungee.NetShield;
10+
import today.netshield.bungee.utils.CC;
11+
12+
import java.io.File;
13+
import java.util.regex.Matcher;
14+
import java.util.regex.Pattern;
15+
16+
/**
17+
* This code was made by jsexp, in case of any unauthorized
18+
* use, at least please leave credits.
19+
* Find more about me @ my <a href="https://github.com/hardcorefactions">GitHub</a> :D
20+
* © 2025 - jsexp
21+
*/
22+
public class NetShieldCommand extends Command {
23+
24+
public NetShieldCommand() {
25+
super("netshield", "netshield.admin", "nsreload");
26+
}
27+
28+
@SneakyThrows
29+
@Override
30+
public void execute(CommandSender sender, String[] args) {
31+
NetShield.getInstance().setConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(NetShield.getInstance().getDataFolder(), "config.yml")));
32+
sender.sendMessage(TextComponent.fromLegacyText(CC.colorize("&#20bd78La configuración de NetShield ha sido recargada con éxito.")));
33+
}
34+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package today.netshield.bungee.listeners;
2+
3+
import net.md_5.bungee.api.connection.ProxiedPlayer;
4+
import net.md_5.bungee.api.event.PostLoginEvent;
5+
import net.md_5.bungee.api.plugin.Listener;
6+
import net.md_5.bungee.event.EventHandler;
7+
import net.md_5.bungee.event.EventPriority;
8+
import today.netshield.bungee.NetShield;
9+
import today.netshield.bungee.utils.Authentication;
10+
11+
import java.util.concurrent.CompletableFuture;
12+
import java.util.concurrent.TimeUnit;
13+
14+
public class ConnectionListener implements Listener {
15+
private final NetShield plugin;
16+
private final Authentication authentication;
17+
18+
private static final long AUTH_TIMEOUT_MS = 3000;
19+
20+
public ConnectionListener(NetShield plugin) {
21+
this.plugin = plugin;
22+
this.authentication = new Authentication(plugin);
23+
}
24+
25+
@EventHandler(priority = EventPriority.HIGHEST)
26+
public void onPlayerLogin(PostLoginEvent event) {
27+
ProxiedPlayer player = event.getPlayer();
28+
plugin.getLogger().info("Player " + player.getName() + " is logging in, starting authentication check");
29+
30+
CompletableFuture<Void> authFuture = authentication.handleAsync(player);
31+
authFuture.orTimeout(AUTH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
32+
.exceptionally(ex -> {
33+
plugin.getLogger().info("Authentication timed out or failed for player " + player.getName() + ": " + ex.getMessage());
34+
return null;
35+
});
36+
}
37+
}

bungeecord/src/main/java/today/netshield/bungee/listeners/PlayerListener.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)