Fixed description, fixed previous server not being removed from luckperms

This commit is contained in:
Bastien 2019-08-13 08:52:48 +02:00
parent c10c8ace2a
commit f3bd368cbf
5 changed files with 19 additions and 9 deletions

View File

@ -5,7 +5,7 @@ plugins {
} }
group = "com.actualplayer" group = "com.actualplayer"
version = "1.0" version = "1.1"
description = "A way for the user to login to the server he last connected to." description = "A way for the user to login to the server he last connected to."
repositories { repositories {
@ -31,16 +31,13 @@ dependencies {
compileOnly("com.velocitypowered:velocity-api:1.0.3-SNAPSHOT") compileOnly("com.velocitypowered:velocity-api:1.0.3-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:1.0.3-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:1.0.3-SNAPSHOT")
implementation("org.spongepowered:configurate-yaml:3.6") { implementation("org.yaml:snakeyaml:1.18")
exclude(group = "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.guava", module = "guava")
}
testImplementation("junit", "junit", "4.12") testImplementation("junit", "junit", "4.12")
} }
blossom { blossom {
replaceToken("@ID@", name.toLowerCase()) replaceToken("@ID@", name.replace(" ", "").toLowerCase())
replaceToken("@NAME@", name) replaceToken("@NAME@", name)
replaceToken("@VERSION@", version) replaceToken("@VERSION@", version)
replaceToken("@DESCRIPTION@", description) replaceToken("@DESCRIPTION@", description)

View File

@ -1,2 +1,2 @@
rootProject.name = 'rememberme' rootProject.name = 'Remember Me'

View File

@ -18,7 +18,7 @@ import org.slf4j.Logger;
import java.nio.file.Path; 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 { public class RememberMe {
@Getter @Getter

View File

@ -5,7 +5,17 @@ import java.util.concurrent.CompletableFuture;
public interface IRememberMeHandler { 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<String> getLastServerName(UUID uuid); CompletableFuture<String> 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); void setLastServerName(UUID uuid, String serverName);
} }

View File

@ -20,7 +20,6 @@ public class LuckPermsHandler implements IRememberMeHandler {
this.api = api; this.api = api;
} }
@Override @Override
public CompletableFuture<String> getLastServerName(UUID uuid) { public CompletableFuture<String> getLastServerName(UUID uuid) {
UserManager userManager = api.getUserManager(); UserManager userManager = api.getUserManager();
@ -43,6 +42,10 @@ public class LuckPermsHandler implements IRememberMeHandler {
public void setLastServerName(UUID uuid, String serverName) { public void setLastServerName(UUID uuid, String serverName) {
User user = api.getUser(uuid); User user = api.getUser(uuid);
if (user != null) { 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(); Node node = api.getNodeFactory().newBuilder("meta.last-server." + serverName).build();
user.setPermission(node); user.setPermission(node);
api.getUserManager().saveUser(user); api.getUserManager().saveUser(user);