Skip to content

Commit 8deaec9

Browse files
committed
Implemented bypass configuration
1 parent 5508aa1 commit 8deaec9

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# User-specific stuff
22
.idea/
3+
.vscode/
4+
.eclipse/
35

46
*.iml
57
*.ipr

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
1. **Install the plugin**
2121
Place the shaded JAR into your `plugins/` folder on your Velocity proxy.
2222

23-
2. **Configure MySQL**
24-
On first run, `plugins/sentinel/config.json` will be created. Fill in your database credentials and Discord token:
23+
2. **Configure MySQL and Discord**
24+
On first run, `plugins/sentinel/config.json` will be created. Fill in your database credentials, Discord token, and optionally specify bypass servers:
2525
```json
2626
{
2727
"mysql": {
@@ -31,7 +31,14 @@
3131
"username": "sentinel_user",
3232
"password": "password"
3333
},
34-
"discord_token": "your_discord_bot_token"
34+
"discord": {
35+
"token": "your_discord_bot_token"
36+
},
37+
"bypassServers": {
38+
"servers": ["lobby", "auth"]
39+
}
3540
}
3641
```
3742

43+
The `bypassServers` section allows you to specify server names that should bypass the Discord verification requirement. Players connecting to these servers will be allowed through without needing to link their Discord account. This may be useful for servers like lobbies or auth servers where you want to allow unverified players.
44+

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = 'com.confect1on'
10-
version = '1.0-SNAPSHOT'
10+
version = '1.0.0'
1111

1212
def targetJavaVersion = 17
1313

src/main/java/com/confect1on/sentinel/Sentinel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
3838
}
3939

4040
// register login guard
41-
server.getEventManager().register(this, new LoginListener(database, logger));
41+
server.getEventManager().register(this, new LoginListener(database, config, logger));
4242

4343
// start Discord if we have a token
4444
if (config.discord.token != null && !config.discord.token.isBlank()) {

src/main/java/com/confect1on/sentinel/config/SentinelConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public class SentinelConfig {
44
public MySQL mysql = new MySQL();
55
public Discord discord = new Discord();
6+
public BypassServers bypassServers = new BypassServers();
67

78
public static class MySQL {
89
public String host = "localhost";
@@ -15,4 +16,8 @@ public static class MySQL {
1516
public static class Discord {
1617
public String token = "";
1718
}
19+
20+
public static class BypassServers {
21+
public String[] servers = new String[0];
22+
}
1823
}

src/main/java/com/confect1on/sentinel/listener/LoginListener.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.confect1on.sentinel.listener;
22

33
import com.confect1on.sentinel.db.DatabaseManager;
4+
import com.confect1on.sentinel.config.SentinelConfig;
45
import com.velocitypowered.api.event.Subscribe;
56
import com.velocitypowered.api.event.connection.LoginEvent;
67
import com.velocitypowered.api.event.ResultedEvent.ComponentResult;
@@ -13,16 +14,35 @@ public class LoginListener {
1314

1415
private final DatabaseManager database;
1516
private final Logger logger;
17+
private final SentinelConfig config;
1618

17-
public LoginListener(DatabaseManager database, Logger logger) {
19+
public LoginListener(DatabaseManager database, SentinelConfig config, Logger logger) {
1820
this.database = database;
21+
this.config = config;
1922
this.logger = logger;
2023
}
2124

2225
@Subscribe
2326
public void onLogin(LoginEvent event) {
2427
UUID uuid = event.getPlayer().getGameProfile().getId();
2528
String username = event.getPlayer().getUsername();
29+
30+
// Get the virtual host they're connecting through
31+
String virtualHost = event.getPlayer().getVirtualHost()
32+
.map(host -> host.getHostString())
33+
.orElse("");
34+
35+
// Check if this is a bypass server based on the virtual host
36+
if (virtualHost != null && !virtualHost.isEmpty()) {
37+
for (String server : config.bypassServers.servers) {
38+
if (virtualHost.toLowerCase().contains(server.toLowerCase())) {
39+
logger.info("✅ {} ({}) connecting through bypass virtual host {}. Allowing login.",
40+
username, uuid, virtualHost);
41+
event.setResult(ComponentResult.allowed());
42+
return;
43+
}
44+
}
45+
}
2646

2747
try {
2848
if (database.isLinked(uuid)) {

0 commit comments

Comments
 (0)