Skip to content

Commit bbe389f

Browse files
committed
feat: Add proxy plugin for BungeeCord/Velocity support
- Check docs/proxies/configuration.md
1 parent 476b7dc commit bbe389f

53 files changed

Lines changed: 4238 additions & 175 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ You can also create your own translation file and, if you want, you can share it
5353
<li>Custom MySQL tables/columns names (useful with forum databases)</li>
5454
<li><strong>Cached database queries!</strong></li>
5555
<li><strong>Fully compatible with Citizens2, CombatTag, CombatTagPlus!</strong></li>
56+
<li><strong>Velocity proxy bridge for inter-server authentication.</strong></li>
5657
<li>Compatible with Minecraft mods like <strong>BuildCraft or RedstoneCraft</strong></li>
5758
<li>Graphical login/register dialogs, with optional Paper/Folia pre-join dialogs</li>
5859
<li>Restricted users (associate a username with an IP)</li>
@@ -123,8 +124,8 @@ AuthMe can display graphical login/register dialogs instead of chat-based prompt
123124
## Requirements
124125

125126
##### Compiling requirements:
126-
>- JDK 17+ for `authme-core` and `authme-spigot-legacy`
127-
>- JDK 21+ for the full multi-module build (`authme-spigot-1.21`, `authme-paper-common`, `authme-paper`, `authme-folia`)
127+
>- JDK 17+ for `authme-core`, `authme-tools`, and `authme-spigot-legacy`
128+
>- JDK 21+ for the full multi-module build (`authme-bungee`, `authme-spigot-1.21`, `authme-paper-common`, `authme-paper`, `authme-folia`, `authme-velocity`)
128129
>- Maven (3.8.8+)
129130
>- Git/GitHub (Optional)
130131
@@ -139,6 +140,8 @@ AuthMe can display graphical login/register dialogs instead of chat-based prompt
139140
>- Use the jar matching your server platform/version
140141
>- Java 17+ for `AuthMe-*-Spigot-Legacy.jar` (Spigot 1.16.x – 1.19.x)
141142
>- Java 21+ for:
143+
> - `AuthMe-*-Bungee.jar` (BungeeCord / Waterfall-compatible 1.19 API)
144+
> - `AuthMe-*-Velocity.jar` (Velocity 3.4+ proxy bridge)
142145
> - `AuthMe-*-Spigot-1.21.jar` (Spigot 1.20.x – 1.21.x)
143146
> - `AuthMe-*-Paper.jar` (Paper 1.21+)
144147
> - `AuthMe-*-Folia.jar` (Folia 1.21+)

authme-bungee/pom.xml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>fr.xephi</groupId>
9+
<artifactId>authme-parent</artifactId>
10+
<version>${revision}</version>
11+
</parent>
12+
13+
<artifactId>authme-bungee</artifactId>
14+
<packaging>jar</packaging>
15+
<name>AuthMeBungee</name>
16+
<description>AuthMe proxy bridge for BungeeCord</description>
17+
18+
<properties>
19+
<module.java.version>21</module.java.version>
20+
<module.classifier>Bungee</module.classifier>
21+
</properties>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>net.md-5</groupId>
26+
<artifactId>bungeecord-api</artifactId>
27+
<scope>provided</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>ch.jalu</groupId>
31+
<artifactId>configme</artifactId>
32+
<scope>compile</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.junit.jupiter</groupId>
36+
<artifactId>junit-jupiter</artifactId>
37+
<scope>test</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.mockito</groupId>
41+
<artifactId>mockito-core</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.mockito</groupId>
46+
<artifactId>mockito-junit-jupiter</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
</dependencies>
50+
51+
<build>
52+
<finalName>AuthMe-${project.version}-${module.classifier}</finalName>
53+
54+
<resources>
55+
<resource>
56+
<directory>..</directory>
57+
<filtering>false</filtering>
58+
<includes>
59+
<include>LICENSE</include>
60+
</includes>
61+
</resource>
62+
<resource>
63+
<directory>src/main/resources</directory>
64+
<filtering>true</filtering>
65+
</resource>
66+
</resources>
67+
68+
<plugins>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-shade-plugin</artifactId>
72+
<executions>
73+
<execution>
74+
<id>shade</id>
75+
<phase>package</phase>
76+
<goals>
77+
<goal>shade</goal>
78+
</goals>
79+
</execution>
80+
</executions>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-resources-plugin</artifactId>
85+
<executions>
86+
<execution>
87+
<id>generate-build-info-source</id>
88+
<phase>generate-sources</phase>
89+
<goals>
90+
<goal>copy-resources</goal>
91+
</goals>
92+
<configuration>
93+
<outputDirectory>${project.build.directory}/generated-sources/build-info</outputDirectory>
94+
<resources>
95+
<resource>
96+
<directory>src/main/java-templates</directory>
97+
<filtering>true</filtering>
98+
<includes>
99+
<include>**/*.java</include>
100+
</includes>
101+
</resource>
102+
</resources>
103+
</configuration>
104+
</execution>
105+
</executions>
106+
</plugin>
107+
<plugin>
108+
<groupId>org.codehaus.mojo</groupId>
109+
<artifactId>build-helper-maven-plugin</artifactId>
110+
<version>3.6.1</version>
111+
<executions>
112+
<execution>
113+
<id>add-generated-build-info-source</id>
114+
<phase>generate-sources</phase>
115+
<goals>
116+
<goal>add-source</goal>
117+
</goals>
118+
<configuration>
119+
<sources>
120+
<source>${project.build.directory}/generated-sources/build-info</source>
121+
</sources>
122+
</configuration>
123+
</execution>
124+
</executions>
125+
</plugin>
126+
<plugin>
127+
<groupId>org.apache.maven.plugins</groupId>
128+
<artifactId>maven-antrun-plugin</artifactId>
129+
<executions>
130+
<execution>
131+
<id>remove-original-shaded-jar</id>
132+
<phase>package</phase>
133+
<goals>
134+
<goal>run</goal>
135+
</goals>
136+
<configuration>
137+
<target>
138+
<delete file="${project.build.directory}/original-${project.build.finalName}.jar" quiet="true"/>
139+
</target>
140+
</configuration>
141+
</execution>
142+
</executions>
143+
</plugin>
144+
<plugin>
145+
<groupId>org.apache.maven.plugins</groupId>
146+
<artifactId>maven-source-plugin</artifactId>
147+
<configuration>
148+
<finalName>${project.build.finalName}</finalName>
149+
</configuration>
150+
<executions>
151+
<execution>
152+
<id>attach-sources</id>
153+
<goals>
154+
<goal>jar</goal>
155+
</goals>
156+
</execution>
157+
</executions>
158+
</plugin>
159+
<plugin>
160+
<groupId>org.apache.maven.plugins</groupId>
161+
<artifactId>maven-javadoc-plugin</artifactId>
162+
<configuration>
163+
<finalName>${project.build.finalName}</finalName>
164+
<source>${module.java.version}</source>
165+
<detectOfflineLinks>false</detectOfflineLinks>
166+
</configuration>
167+
<executions>
168+
<execution>
169+
<id>attach-javadoc</id>
170+
<goals>
171+
<goal>jar</goal>
172+
</goals>
173+
</execution>
174+
</executions>
175+
</plugin>
176+
</plugins>
177+
</build>
178+
179+
<repositories>
180+
<repository>
181+
<id>oss-repo</id>
182+
<url>https://oss.sonatype.org/content/groups/public</url>
183+
</repository>
184+
</repositories>
185+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package fr.xephi.authme.bungee;
2+
3+
import net.md_5.bungee.api.plugin.Plugin;
4+
5+
abstract class AbstractAuthMeBungeePlugin extends Plugin {
6+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package fr.xephi.authme.bungee;
2+
3+
public final class AuthMeBungeePlugin extends AbstractAuthMeBungeePlugin {
4+
5+
private BungeeConfigManager configManager;
6+
private BungeeProxyBridge proxyBridge;
7+
8+
@Override
9+
public void onEnable() {
10+
configManager = new BungeeConfigManager(getDataFolder().toPath());
11+
BungeeAuthenticationStore authenticationStore = new BungeeAuthenticationStore();
12+
proxyBridge = new BungeeProxyBridge(getProxy(), getLogger(), configManager.getConfiguration(), authenticationStore);
13+
getProxy().getPluginManager().registerListener(this, proxyBridge);
14+
getProxy().getPluginManager().registerCommand(this, new BungeeReloadCommand(configManager, proxyBridge));
15+
proxyBridge.logConfigurationDetails();
16+
proxyBridge.broadcastProxyStartedHandshake();
17+
}
18+
19+
@Override
20+
public void onDisable() {
21+
proxyBridge.shutdown();
22+
}
23+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package fr.xephi.authme.bungee;
2+
3+
import net.md_5.bungee.api.connection.ProxiedPlayer;
4+
5+
import java.util.Locale;
6+
import java.util.Set;
7+
import java.util.concurrent.ConcurrentHashMap;
8+
9+
final class BungeeAuthenticationStore {
10+
11+
private final Set<String> authenticatedPlayers = ConcurrentHashMap.newKeySet();
12+
13+
void markAuthenticated(String playerName) {
14+
authenticatedPlayers.add(normalizeName(playerName));
15+
}
16+
17+
void markLoggedOut(String playerName) {
18+
authenticatedPlayers.remove(normalizeName(playerName));
19+
}
20+
21+
boolean isAuthenticated(ProxiedPlayer player) {
22+
return isAuthenticated(player.getName());
23+
}
24+
25+
boolean isAuthenticated(String playerName) {
26+
return authenticatedPlayers.contains(normalizeName(playerName));
27+
}
28+
29+
void clear(ProxiedPlayer player) {
30+
markLoggedOut(player.getName());
31+
}
32+
33+
private static String normalizeName(String playerName) {
34+
return playerName.toLowerCase(Locale.ROOT);
35+
}
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package fr.xephi.authme.bungee;
2+
3+
import ch.jalu.configme.SettingsManager;
4+
import ch.jalu.configme.SettingsManagerBuilder;
5+
import fr.xephi.authme.bungee.config.BungeeConfigProperties;
6+
7+
import java.io.IOException;
8+
import java.nio.file.Files;
9+
import java.nio.file.Path;
10+
11+
final class BungeeConfigManager {
12+
13+
private final SettingsManager settingsManager;
14+
private final BungeeProxyConfiguration configuration;
15+
16+
BungeeConfigManager(Path dataDirectory) {
17+
try {
18+
Files.createDirectories(dataDirectory);
19+
} catch (IOException e) {
20+
throw new IllegalStateException("Could not create AuthMe Bungee data directory", e);
21+
}
22+
23+
this.settingsManager = SettingsManagerBuilder.withYamlFile(dataDirectory.resolve("config.yml").toFile())
24+
.configurationData(BungeeConfigProperties.class)
25+
.migrationService(new HmacSecretMigrationService())
26+
.create();
27+
this.configuration = BungeeProxyConfiguration.from(settingsManager);
28+
}
29+
30+
BungeeProxyConfiguration getConfiguration() {
31+
return configuration;
32+
}
33+
34+
BungeeProxyConfiguration reload() {
35+
settingsManager.reload();
36+
return BungeeProxyConfiguration.from(settingsManager);
37+
}
38+
}

0 commit comments

Comments
 (0)