Reduced Java 16 requirement to Java 11

This commit is contained in:
4drian3d 2022-02-11 18:07:41 -05:00
parent 1098852a58
commit b94c664101
9 changed files with 57 additions and 36 deletions

10
pom.xml
View File

@ -7,11 +7,11 @@
<groupId>com.glyart.authmevelocity</groupId> <groupId>com.glyart.authmevelocity</groupId>
<artifactId>parent</artifactId> <artifactId>parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.4.0</version> <version>1.5.0</version>
<properties> <properties>
<maven.compiler.source>16</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
</properties> </properties>
<pluginRepositories> <pluginRepositories>
@ -34,8 +34,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version> <version>3.9.0</version>
<configuration> <configuration>
<source>16</source> <source>11</source>
<target>16</target> <target>11</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -5,13 +5,13 @@
<parent> <parent>
<artifactId>parent</artifactId> <artifactId>parent</artifactId>
<groupId>com.glyart.authmevelocity</groupId> <groupId>com.glyart.authmevelocity</groupId>
<version>1.4.0</version> <version>1.5.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<properties> <properties>
<maven.compiler.source>16</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
</properties> </properties>
<artifactId>proxy</artifactId> <artifactId>proxy</artifactId>

View File

@ -13,12 +13,7 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment; import org.spongepowered.configurate.objectmapping.meta.Comment;
public class AuthMeConfig { public class AuthMeConfig {
private static final String HEADER = """ private static final String HEADER = "AuthmeVelocity Proxy\n\nOriginal Developer: xQuickGlare\nCurrent Developer: 4drian3d";
AuthmeVelocity Proxy
Original Developer: xQuickGlare
Current Developer: 4drian3d
""";
private static final HoconConfigurationLoader.Builder configBuilder = HoconConfigurationLoader.builder() private static final HoconConfigurationLoader.Builder configBuilder = HoconConfigurationLoader.builder()
.defaultOptions(opts -> opts .defaultOptions(opts -> opts
.shouldCopyDefaults(true) .shouldCopyDefaults(true)
@ -70,10 +65,7 @@ public class AuthMeConfig {
@Comment("Send logged in players to another server?") @Comment("Send logged in players to another server?")
private boolean sendToServerOnLogin = false; private boolean sendToServerOnLogin = false;
@Comment(""" @Comment("List of servers to send\nOne of these servers will be chosen at random")
List of servers to send
One of these servers will be chosen at random
""")
private List<String> teleportServers = List.of( private List<String> teleportServers = List.of(
"lobby1", "lobby1",
"lobby2" "lobby2"
@ -100,9 +92,7 @@ public class AuthMeConfig {
"captcha" "captcha"
); );
@Comment(""" @Comment("Sets the message to send in case a non-logged-in player executes an unauthorized command\nTo deactivate the message, leave it empty")
Sets the message to send in case a non-logged-in player executes an unauthorized command
To deactivate the message, leave it empty""")
private String blockedCommandMessage = "&4You cannot execute commands if you are not logged in yet"; private String blockedCommandMessage = "&4You cannot execute commands if you are not logged in yet";
public Set<String> getAllowedCommands(){ public Set<String> getAllowedCommands(){

View File

@ -11,7 +11,7 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
* Event to be executed just before sending a player to another server after login/registration. * Event to be executed just before sending a player to another server after login/registration.
* Here you have the ability to deny the event. * Here you have the ability to deny the event.
*/ */
public class PreSendOnLoginEvent implements ResultedEvent<GenericResult> { public final class PreSendOnLoginEvent implements ResultedEvent<GenericResult> {
private GenericResult result = GenericResult.allowed(); private GenericResult result = GenericResult.allowed();
private final Player player; private final Player player;

View File

@ -7,4 +7,14 @@ import org.jetbrains.annotations.NotNull;
/** /**
* Event executed in case the player is successfully logged in * Event executed in case the player is successfully logged in
*/ */
public record ProxyLoginEvent(@NotNull Player player) {} public final class ProxyLoginEvent {
private final Player player;
public ProxyLoginEvent(@NotNull Player player){
this.player = player;
}
public @NotNull Player getPlayer(){
return this.player;
}
}

View File

@ -4,4 +4,14 @@ import com.velocitypowered.api.proxy.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public record ProxyLogoutEvent(@NotNull Player player) {} public final class ProxyLogoutEvent {
private final Player player;
public ProxyLogoutEvent(@NotNull Player player){
this.player = player;
}
public @NotNull Player getPlayer(){
return this.player;
}
}

View File

@ -4,4 +4,14 @@ import com.velocitypowered.api.proxy.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public record ProxyRegisterEvent(@NotNull Player player){} public final class ProxyRegisterEvent {
private final Player player;
public ProxyRegisterEvent(@NotNull Player player){
this.player = player;
}
public @NotNull Player getPlayer(){
return this.player;
}
}

View File

@ -36,10 +36,11 @@ public class PluginMessageListener {
@Subscribe @Subscribe
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) { public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
if (!(event.getSource() instanceof ServerConnection connection) || !event.getIdentifier().getId().equals("authmevelocity:main")){ if (!(event.getSource() instanceof ServerConnection) || !event.getIdentifier().getId().equals("authmevelocity:main")){
continuation.resume(); continuation.resume();
return; return;
} }
ServerConnection connection = ((ServerConnection)event.getSource());
event.setResult(PluginMessageEvent.ForwardResult.handled()); event.setResult(PluginMessageEvent.ForwardResult.handled());
@ -47,24 +48,24 @@ public class PluginMessageListener {
final String sChannel = input.readUTF(); final String sChannel = input.readUTF();
final Player loggedPlayer = connection.getPlayer(); final Player loggedPlayer = connection.getPlayer();
switch(sChannel){ switch(sChannel){
case "LOGIN" -> { case "LOGIN" :
if (AuthmeVelocityAPI.addPlayer(loggedPlayer)){ if (AuthmeVelocityAPI.addPlayer(loggedPlayer)){
createServerConnectionRequest(loggedPlayer, config, proxy, logger, connection); createServerConnectionRequest(loggedPlayer, config, proxy, logger, connection);
} }
continuation.resume(); continuation.resume();
} break;
case "LOGOUT" -> { case "LOGOUT":
if(AuthmeVelocityAPI.removePlayer(loggedPlayer)){ if(AuthmeVelocityAPI.removePlayer(loggedPlayer)){
proxy.getEventManager().fireAndForget(new ProxyLogoutEvent(loggedPlayer)); proxy.getEventManager().fireAndForget(new ProxyLogoutEvent(loggedPlayer));
} }
continuation.resume(); continuation.resume();
} break;
case "REGISTER" -> { case "REGISTER":
proxy.getEventManager().fireAndForget(new ProxyRegisterEvent(loggedPlayer)); proxy.getEventManager().fireAndForget(new ProxyRegisterEvent(loggedPlayer));
continuation.resume(); continuation.resume();
} break;
default -> continuation.resume(); default: continuation.resume();
} }
} }

View File

@ -5,15 +5,15 @@
<parent> <parent>
<artifactId>parent</artifactId> <artifactId>parent</artifactId>
<groupId>com.glyart.authmevelocity</groupId> <groupId>com.glyart.authmevelocity</groupId>
<version>1.4.0</version> <version>1.5.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<properties> <properties>
<maven.compiler.source>16</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
</properties> </properties>
<repositories> <repositories>