Fix clear command not resetting primary group
This commit is contained in:
parent
e5e1333769
commit
d4c335e33e
@ -10,6 +10,7 @@ public class BukkitUserManager extends UserManager {
|
|||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
public BukkitUserManager(LPBukkitPlugin plugin) {
|
public BukkitUserManager(LPBukkitPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ public class BungeeUserManager extends UserManager {
|
|||||||
private final LPBungeePlugin plugin;
|
private final LPBungeePlugin plugin;
|
||||||
|
|
||||||
public BungeeUserManager(LPBungeePlugin plugin) {
|
public BungeeUserManager(LPBungeePlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class UserClearCommand extends UserSubCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||||
user.clearNodes();
|
user.clearNodes();
|
||||||
user.getNodes().put(plugin.getConfiguration().getDefaultGroupNode(), true);
|
plugin.getUserManager().giveDefaults(user);
|
||||||
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a's permissions were cleared.");
|
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a's permissions were cleared.");
|
||||||
|
|
||||||
saveUser(user, sender, plugin);
|
saveUser(user, sender, plugin);
|
||||||
|
@ -4,7 +4,6 @@ import com.google.gson.stream.JsonReader;
|
|||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import me.lucko.luckperms.LuckPermsPlugin;
|
import me.lucko.luckperms.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.data.Datastore;
|
import me.lucko.luckperms.data.Datastore;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|
||||||
import me.lucko.luckperms.groups.Group;
|
import me.lucko.luckperms.groups.Group;
|
||||||
import me.lucko.luckperms.users.User;
|
import me.lucko.luckperms.users.User;
|
||||||
|
|
||||||
@ -130,11 +129,7 @@ public class FlatfileDatastore extends Datastore {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the new user with default values
|
plugin.getUserManager().giveDefaults(user);
|
||||||
try {
|
|
||||||
user.setPermission(plugin.getConfiguration().getDefaultGroupNode(), true);
|
|
||||||
} catch (ObjectAlreadyHasException ignored) {}
|
|
||||||
user.setPrimaryGroup(plugin.getConfiguration().getDefaultGroupName());
|
|
||||||
|
|
||||||
boolean success = doWrite(userFile, writer -> {
|
boolean success = doWrite(userFile, writer -> {
|
||||||
writer.beginObject();
|
writer.beginObject();
|
||||||
|
@ -6,7 +6,6 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lucko.luckperms.LuckPermsPlugin;
|
import me.lucko.luckperms.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.data.Datastore;
|
import me.lucko.luckperms.data.Datastore;
|
||||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
|
||||||
import me.lucko.luckperms.groups.Group;
|
import me.lucko.luckperms.groups.Group;
|
||||||
import me.lucko.luckperms.groups.GroupManager;
|
import me.lucko.luckperms.groups.GroupManager;
|
||||||
import me.lucko.luckperms.users.User;
|
import me.lucko.luckperms.users.User;
|
||||||
@ -165,12 +164,7 @@ abstract class SQLDatastore extends Datastore {
|
|||||||
boolean onResult(ResultSet resultSet) throws SQLException {
|
boolean onResult(ResultSet resultSet) throws SQLException {
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
if (!resultSet.next()) {
|
if (!resultSet.next()) {
|
||||||
|
plugin.getUserManager().giveDefaults(user);
|
||||||
// Setup the new user with default values
|
|
||||||
try {
|
|
||||||
user.setPermission(plugin.getConfiguration().getDefaultGroupNode(), true);
|
|
||||||
} catch (ObjectAlreadyHasException ignored) {}
|
|
||||||
user.setPrimaryGroup(plugin.getConfiguration().getDefaultGroupName());
|
|
||||||
|
|
||||||
success = runQuery(new QueryPS(USER_INSERT) {
|
success = runQuery(new QueryPS(USER_INSERT) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package me.lucko.luckperms.users;
|
package me.lucko.luckperms.users;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import me.lucko.luckperms.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.data.Datastore;
|
import me.lucko.luckperms.data.Datastore;
|
||||||
|
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
public abstract class UserManager {
|
public abstract class UserManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,6 +17,15 @@ public abstract class UserManager {
|
|||||||
@Getter
|
@Getter
|
||||||
private final Map<UUID, User> users = new ConcurrentHashMap<>();
|
private final Map<UUID, User> users = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to main plugin instance
|
||||||
|
*/
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
|
public UserManager(LuckPermsPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a user object by UUID
|
* Get a user object by UUID
|
||||||
* @param uuid The uuid to search by
|
* @param uuid The uuid to search by
|
||||||
@ -80,6 +89,18 @@ public abstract class UserManager {
|
|||||||
datastore.saveUser(user, success -> {});
|
datastore.saveUser(user, success -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a user to the default group
|
||||||
|
* @param user the user to give to
|
||||||
|
*/
|
||||||
|
public void giveDefaults(User user) {
|
||||||
|
// Setup the new user with default values
|
||||||
|
try {
|
||||||
|
user.setPermission(plugin.getConfiguration().getDefaultGroupNode(), true);
|
||||||
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
user.setPrimaryGroup(plugin.getConfiguration().getDefaultGroupName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if a user is loaded or not
|
* Check to see if a user is loaded or not
|
||||||
* @param uuid the UUID of the user
|
* @param uuid the UUID of the user
|
||||||
|
Loading…
Reference in New Issue
Block a user