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>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.4.0</version>
<version>1.5.0</version>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<pluginRepositories>
@ -34,8 +34,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.9.0</version>
<configuration>
<source>16</source>
<target>16</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>

View File

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

View File

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

View File

@ -7,4 +7,14 @@ import org.jetbrains.annotations.NotNull;
/**
* 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;
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;
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
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();
return;
}
ServerConnection connection = ((ServerConnection)event.getSource());
event.setResult(PluginMessageEvent.ForwardResult.handled());
@ -47,24 +48,24 @@ public class PluginMessageListener {
final String sChannel = input.readUTF();
final Player loggedPlayer = connection.getPlayer();
switch(sChannel){
case "LOGIN" -> {
case "LOGIN" :
if (AuthmeVelocityAPI.addPlayer(loggedPlayer)){
createServerConnectionRequest(loggedPlayer, config, proxy, logger, connection);
}
continuation.resume();
}
case "LOGOUT" -> {
break;
case "LOGOUT":
if(AuthmeVelocityAPI.removePlayer(loggedPlayer)){
proxy.getEventManager().fireAndForget(new ProxyLogoutEvent(loggedPlayer));
}
continuation.resume();
}
case "REGISTER" -> {
break;
case "REGISTER":
proxy.getEventManager().fireAndForget(new ProxyRegisterEvent(loggedPlayer));
continuation.resume();
}
break;
default -> continuation.resume();
default: continuation.resume();
}
}

View File

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