diff --git a/build.gradle.kts b/build.gradle.kts index 18b1b66..fbcc458 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "com.actualplayer" -version = "1.0" +version = "1.1" description = "A way for the user to login to the server he last connected to." repositories { @@ -31,16 +31,13 @@ dependencies { compileOnly("com.velocitypowered:velocity-api:1.0.3-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:1.0.3-SNAPSHOT") - implementation("org.spongepowered:configurate-yaml:3.6") { - exclude(group = "org.checkerframework", module = "checker-qual") - exclude(group = "com.google.guava", module = "guava") - } + implementation("org.yaml:snakeyaml:1.18") testImplementation("junit", "junit", "4.12") } blossom { - replaceToken("@ID@", name.toLowerCase()) + replaceToken("@ID@", name.replace(" ", "").toLowerCase()) replaceToken("@NAME@", name) replaceToken("@VERSION@", version) replaceToken("@DESCRIPTION@", description) diff --git a/settings.gradle b/settings.gradle index 0141a8a..5529693 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -rootProject.name = 'rememberme' +rootProject.name = 'Remember Me' diff --git a/src/main/java/com/actualplayer/rememberme/RememberMe.java b/src/main/java/com/actualplayer/rememberme/RememberMe.java index 3a646f9..729c289 100644 --- a/src/main/java/com/actualplayer/rememberme/RememberMe.java +++ b/src/main/java/com/actualplayer/rememberme/RememberMe.java @@ -18,7 +18,7 @@ import org.slf4j.Logger; import java.nio.file.Path; -@Plugin(id = "@ID@", name = "@NAME@", version = "@VERSION@", description = "@Description@", authors = {"ActualPlayer"}, dependencies = { @Dependency(id = "luckperms", optional = true) }) +@Plugin(id = "@ID@", name = "@NAME@", version = "@VERSION@", description = "@DESCRIPTION@", authors = {"ActualPlayer"}, dependencies = { @Dependency(id = "luckperms", optional = true) }) public class RememberMe { @Getter diff --git a/src/main/java/com/actualplayer/rememberme/handlers/IRememberMeHandler.java b/src/main/java/com/actualplayer/rememberme/handlers/IRememberMeHandler.java index 244ea8d..44d8af0 100644 --- a/src/main/java/com/actualplayer/rememberme/handlers/IRememberMeHandler.java +++ b/src/main/java/com/actualplayer/rememberme/handlers/IRememberMeHandler.java @@ -5,7 +5,17 @@ import java.util.concurrent.CompletableFuture; public interface IRememberMeHandler { + /** + * Get the user's last server name + * @param uuid user's UUID + * @return A future that contains a String with the last server's name once resolved or NULL + */ CompletableFuture getLastServerName(UUID uuid); + /** + * Sets the user's last server on server switch + * @param uuid user's UUID + * @param serverName name of the server the user moved to + */ void setLastServerName(UUID uuid, String serverName); } diff --git a/src/main/java/com/actualplayer/rememberme/handlers/LuckPermsHandler.java b/src/main/java/com/actualplayer/rememberme/handlers/LuckPermsHandler.java index fe7b2e4..574ed75 100644 --- a/src/main/java/com/actualplayer/rememberme/handlers/LuckPermsHandler.java +++ b/src/main/java/com/actualplayer/rememberme/handlers/LuckPermsHandler.java @@ -20,7 +20,6 @@ public class LuckPermsHandler implements IRememberMeHandler { this.api = api; } - @Override public CompletableFuture getLastServerName(UUID uuid) { UserManager userManager = api.getUserManager(); @@ -43,6 +42,10 @@ public class LuckPermsHandler implements IRememberMeHandler { public void setLastServerName(UUID uuid, String serverName) { User user = api.getUser(uuid); if (user != null) { + // Remove last server + user.clearMatching(n -> n.isMeta() && n.getPermission().contains("meta.last-server")); + + // Add current server as last server Node node = api.getNodeFactory().newBuilder("meta.last-server." + serverName).build(); user.setPermission(node); api.getUserManager().saveUser(user);