Huge cleanup

This commit is contained in:
Luck 2016-06-29 15:35:57 +01:00
parent 0e449cdd7a
commit 84335afacd
43 changed files with 351 additions and 378 deletions

View File

@ -6,6 +6,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.lang.ref.WeakReference;
import java.util.Arrays; import java.util.Arrays;
class CommandManagerBukkit extends CommandManager implements CommandExecutor { class CommandManagerBukkit extends CommandManager implements CommandExecutor {
@ -15,15 +16,20 @@ class CommandManagerBukkit extends CommandManager implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
final WeakReference<CommandSender> cs = new WeakReference<>(sender);
return onCommand(new Sender() { return onCommand(new Sender() {
@Override @Override
public void sendMessage(String s) { public void sendMessage(String s) {
sender.sendMessage(s); CommandSender c = cs.get();
if (c != null) {
c.sendMessage(s);
}
} }
@Override @Override
public boolean hasPermission(String node) { public boolean hasPermission(String node) {
return sender.hasPermission(node); CommandSender c = cs.get();
return c != null && c.hasPermission(node);
} }
}, Arrays.asList(args)); }, Arrays.asList(args));
} }

View File

@ -123,8 +123,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
@Override @Override
public String getPlayerStatus(UUID uuid) { public String getPlayerStatus(UUID uuid) {
if (getServer().getPlayer(uuid) != null) return "&aOnline"; return getServer().getPlayer(uuid) != null ? "&aOnline" : "&cOffline";
return "&cOffline";
} }
@Override @Override

View File

@ -40,15 +40,11 @@ public class BukkitUser extends User {
} }
// Clear existing permissions // Clear existing permissions
for (String p : attachment.getPermissions().keySet()) { attachment.getPermissions().keySet().stream().forEach(p -> attachment.setPermission(p, false));
attachment.setPermission(p, false);
}
// Re-add all defined permissions for the user // Re-add all defined permissions for the user
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), null); Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), null);
for (String node : local.keySet()) { local.entrySet().stream().forEach(e -> attachment.setPermission(e.getKey(), e.getValue()));
attachment.setPermission(node, local.get(node));
}
}); });
} }
} }

View File

@ -54,8 +54,6 @@ public class BukkitUserManager extends UserManager {
@Override @Override
public void updateAllUsers() { public void updateAllUsers() {
for (Player p : plugin.getServer().getOnlinePlayers()) { plugin.getServer().getOnlinePlayers().stream().map(Player::getUniqueId).forEach(u -> plugin.getDatastore().loadUser(u));
plugin.getDatastore().loadUser(p.getUniqueId());
}
} }
} }

View File

@ -77,8 +77,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
@Override @Override
public String getPlayerStatus(UUID uuid) { public String getPlayerStatus(UUID uuid) {
if (getProxy().getPlayer(uuid) != null) return "&aOnline"; return getProxy().getPlayer(uuid) != null ? "&aOnline" : "&cOffline";
return "&cOffline";
} }
@Override @Override

View File

@ -6,6 +6,7 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
import java.lang.ref.WeakReference;
import java.util.Arrays; import java.util.Arrays;
class MainCommand extends Command { class MainCommand extends Command {
@ -19,15 +20,20 @@ class MainCommand extends Command {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
final WeakReference<CommandSender> cs = new WeakReference<>(sender);
manager.onCommand(new Sender() { manager.onCommand(new Sender() {
@Override @Override
public void sendMessage(String s) { public void sendMessage(String s) {
sender.sendMessage(new TextComponent(s)); final CommandSender c = cs.get();
if (c != null) {
c.sendMessage(new TextComponent(s));
}
} }
@Override @Override
public boolean hasPermission(String node) { public boolean hasPermission(String node) {
return sender.hasPermission(node); final CommandSender c = cs.get();
return c != null && c.hasPermission(node);
} }
}, Arrays.asList(args)); }, Arrays.asList(args));
} }

View File

@ -29,14 +29,10 @@ public class BungeeUser extends User {
// Clear existing permissions // Clear existing permissions
Collection<String> perms = new ArrayList<>(player.getPermissions()); Collection<String> perms = new ArrayList<>(player.getPermissions());
for (String p : perms) { perms.stream().forEach(p -> player.setPermission(p, false));
player.setPermission(p, false);
}
// Re-add all defined permissions for the user // Re-add all defined permissions for the user
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), null); Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), null);
for (String node : local.keySet()) { local.entrySet().stream().forEach(e -> player.setPermission(e.getKey(), e.getValue()));
player.setPermission(node, local.get(node));
}
} }
} }

View File

@ -41,8 +41,6 @@ public class BungeeUserManager extends UserManager {
@Override @Override
public void updateAllUsers() { public void updateAllUsers() {
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) { plugin.getProxy().getPlayers().stream().map(ProxiedPlayer::getUniqueId).forEach(u -> plugin.getDatastore().loadUser(u));
plugin.getDatastore().loadUser(p.getUniqueId());
}
} }
} }

View File

@ -15,6 +15,7 @@ import me.lucko.luckperms.commands.user.subcommands.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
public class CommandManager { public class CommandManager {
@ -66,25 +67,20 @@ public class CommandManager {
*/ */
public boolean onCommand(Sender sender, List<String> args) { public boolean onCommand(Sender sender, List<String> args) {
if (args.size() == 0) { if (args.size() == 0) {
Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6."); sendCommandUsage(sender);
return true;
mainCommands.stream()
.filter(c -> c.canUse(sender))
.forEach(c -> Util.sendPluginMessage(sender, "&e-> &d" + c.getUsage()));
} else {
String c = args.get(0);
MainCommand main = null;
for (MainCommand mainCommand : mainCommands) {
if (mainCommand.getName().equalsIgnoreCase(c)) {
main = mainCommand;
break;
}
} }
if (main == null) { Optional<MainCommand> o = mainCommands.stream().filter(m -> m.getName().equalsIgnoreCase(args.get(0))).limit(1).findAny();
Util.sendPluginMessage(sender, "Command not recognised.");
if (!o.isPresent()) {
sendCommandUsage(sender);
return true;
}
final MainCommand main = o.get();
if (!main.canUse(sender)) {
sendCommandUsage(sender);
return true; return true;
} }
@ -99,7 +95,6 @@ public class CommandManager {
} }
main.execute(plugin, sender, new ArrayList<>(args.subList(1, args.size()))); main.execute(plugin, sender, new ArrayList<>(args.subList(1, args.size())));
}
return true; return true;
} }
@ -109,4 +104,11 @@ public class CommandManager {
mainCommands.add(command); mainCommands.add(command);
} }
private void sendCommandUsage(Sender sender) {
Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6.");
mainCommands.stream()
.filter(c -> c.canUse(sender))
.forEach(c -> Util.sendPluginMessage(sender, "&e-> &d" + c.getUsage()));
}
} }

View File

@ -1,32 +1,29 @@
package me.lucko.luckperms.commands; package me.lucko.luckperms.commands;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Getter
@AllArgsConstructor
public abstract class MainCommand { public abstract class MainCommand {
@Getter
private final String name; private final String name;
@Getter
private final String usage; private final String usage;
@Getter
private final int requiredArgsLength; private final int requiredArgsLength;
protected MainCommand(String name, String usage, int requiredArgsLength) {
this.name = name;
this.usage = usage;
this.requiredArgsLength = requiredArgsLength;
}
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, List<String> args); protected abstract void execute(LuckPermsPlugin plugin, Sender sender, List<String> args);
public abstract List<? extends SubCommand> getSubCommands(); public abstract List<? extends SubCommand> getSubCommands();
protected void sendUsage(Sender sender) { protected void sendUsage(Sender sender) {
if (getSubCommands().isEmpty()) {
Util.sendPluginMessage(sender, "&e-> &d" + getUsage());
return;
}
List<SubCommand> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList()); List<SubCommand> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList());
if (subs.size() > 0) { if (subs.size() > 0) {
Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:"); Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:");
@ -41,11 +38,6 @@ public abstract class MainCommand {
} }
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
for (SubCommand sc : getSubCommands()) { return getSubCommands().stream().filter(sc -> sc.isAuthorized(sender)).count() != 0;
if (sc.isAuthorized(sender)) {
return true;
}
}
return false;
} }
} }

View File

@ -0,0 +1,65 @@
package me.lucko.luckperms.commands;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
public enum Permission {
SYNC("sync", null),
INFO("info", null),
DEBUG("debug", null),
CREATE_GROUP("creategroup", null),
DELETE_GROUP("deletegroup", null),
LIST_GROUPS("listgroups", null),
USER_INFO("info", PermissionGroup.USER),
USER_GETUUID("getuuid", PermissionGroup.USER),
USER_LISTNODES("listnodes", PermissionGroup.USER),
USER_HASPERMISSION("haspermission", PermissionGroup.USER),
USER_SETPERMISSION("setpermission", PermissionGroup.USER),
USER_UNSETPERMISSION("unsetpermission", PermissionGroup.USER),
USER_ADDGROUP("addgroup", PermissionGroup.USER),
USER_REMOVEGROUP("removegroup", PermissionGroup.USER),
USER_SETPRIMARYGROUP("setprimarygroup", PermissionGroup.USER),
USER_CLEAR("clear", PermissionGroup.USER),
GROUP_INFO("info", PermissionGroup.GROUP),
GROUP_LISTNODES("listnodes", PermissionGroup.GROUP),
GROUP_HASPERMISSION("haspermission", PermissionGroup.GROUP),
GROUP_SETPERMISSION("setpermission", PermissionGroup.GROUP),
GROUP_UNSETPERMISSION("unsetpermission", PermissionGroup.GROUP),
GROUP_SETINHERIT("setinherit", PermissionGroup.GROUP),
GROUP_UNSETINHERIT("unsetinherit", PermissionGroup.GROUP),
GROUP_CLEAR("clear", PermissionGroup.GROUP);
private String node;
private PermissionGroup group;
public boolean isAuthorized(Sender sender) {
if (sender.hasPermission("luckperms.*")) {
return true;
}
if (group != null) {
return group.isAuthorized(sender) || sender.hasPermission("luckperms." + group.getNode() + "." + node);
}
return sender.hasPermission("luckperms." + node);
}
@Getter
@AllArgsConstructor
private enum PermissionGroup {
USER("user"),
GROUP("group");
private String node;
private boolean isAuthorized(Sender sender) {
return sender.hasPermission("luckperms." + node + ".*");
}
}
}

View File

@ -1,30 +1,18 @@
package me.lucko.luckperms.commands; package me.lucko.luckperms.commands;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@Getter
@AllArgsConstructor
public abstract class SubCommand { public abstract class SubCommand {
@Getter
private final String name; private final String name;
@Getter
private final String description; private final String description;
@Getter
private final String usage; private final String usage;
private final Permission permission;
@Getter
private final String permission;
protected SubCommand(String name, String description, String usage, String permission) {
this.name = name;
this.description = description;
this.usage = usage;
this.permission = permission;
}
public boolean isAuthorized(Sender sender) { public boolean isAuthorized(Sender sender) {
return sender.hasPermission(permission) || sender.hasPermission("luckperms.*"); return permission.isAuthorized(sender);
} }
public void sendUsage(Sender sender) { public void sendUsage(Sender sender) {

View File

@ -42,11 +42,7 @@ public class Util {
if (strings.isEmpty()) return "&6None"; if (strings.isEmpty()) return "&6None";
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
strings.stream().forEach(s -> sb.append("&6").append(s).append("&7, "));
for (String s : strings) {
sb.append("&6").append(s).append("&7, ");
}
return sb.delete(sb.length() - 2, sb.length()).toString(); return sb.delete(sb.length() - 2, sb.length()).toString();
} }
@ -55,11 +51,11 @@ public class Util {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String node : nodes.keySet()) { for (Map.Entry<String, Boolean> e : nodes.entrySet()) {
if (nodes.get(node)) { if (e.getValue()) {
sb.append("&a").append(node).append("&7, "); sb.append("&a").append(e.getKey()).append("&7, ");
} else { } else {
sb.append("&c").append(node).append("&7, "); sb.append("&c").append(e.getKey()).append("&7, ");
} }
} }

View File

@ -1,10 +1,7 @@
package me.lucko.luckperms.commands.group; package me.lucko.luckperms.commands.group;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.MainCommand; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,18 +13,12 @@ public class CreateGroupCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (!sender.hasPermission("luckperms.creategroup")) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
if (args.size() == 0) { if (args.size() == 0) {
sendUsage(sender); sendUsage(sender);
return; return;
} }
String groupName = args.get(0).toLowerCase(); String groupName = args.get(0).toLowerCase();
plugin.getDatastore().loadGroup(groupName, success -> { plugin.getDatastore().loadGroup(groupName, success -> {
if (success) { if (success) {
Util.sendPluginMessage(sender, "That group already exists!"); Util.sendPluginMessage(sender, "That group already exists!");
@ -51,6 +42,6 @@ public class CreateGroupCommand extends MainCommand {
@Override @Override
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
return sender.hasPermission("luckperms.creategroup") || sender.hasPermission("luckperms.*"); return Permission.CREATE_GROUP.isAuthorized(sender);
} }
} }

View File

@ -1,10 +1,7 @@
package me.lucko.luckperms.commands.group; package me.lucko.luckperms.commands.group;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.MainCommand; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.groups.Group;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,11 +14,6 @@ public class DeleteGroupCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (!sender.hasPermission("luckperms.deletegroup")) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
if (args.size() == 0) { if (args.size() == 0) {
sendUsage(sender); sendUsage(sender);
return; return;
@ -41,7 +33,7 @@ public class DeleteGroupCommand extends MainCommand {
Group group = plugin.getGroupManager().getGroup(groupName); Group group = plugin.getGroupManager().getGroup(groupName);
if (group == null) { if (group == null) {
Util.sendPluginMessage(sender, "An unexpected error occurred."); Util.sendPluginMessage(sender, "An unexpected error occurred. Group not loaded.");
} else { } else {
plugin.getDatastore().deleteGroup(group, success1 -> { plugin.getDatastore().deleteGroup(group, success1 -> {
if (!success1) { if (!success1) {
@ -63,6 +55,6 @@ public class DeleteGroupCommand extends MainCommand {
@Override @Override
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
return sender.hasPermission("luckperms.deletegroup") || sender.hasPermission("luckperms.*"); return Permission.DELETE_GROUP.isAuthorized(sender);
} }
} }

View File

@ -9,7 +9,7 @@ import me.lucko.luckperms.groups.Group;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.Optional;
public class GroupMainCommand extends MainCommand { public class GroupMainCommand extends MainCommand {
@ -21,48 +21,37 @@ public class GroupMainCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (args.size() <= 1) { if (args.size() < 2) {
sendUsage(sender); sendUsage(sender);
return; return;
} }
Optional<GroupSubCommand> o = subCommands.stream().filter(s -> s.getName().equalsIgnoreCase(args.get(1))).limit(1).findAny();
if (!o.isPresent()) {
Util.sendPluginMessage(sender, "Command not recognised.");
return;
}
final GroupSubCommand sub = o.get();
if (!sub.isAuthorized(sender)) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
List<String> strippedArgs = new ArrayList<>(); List<String> strippedArgs = new ArrayList<>();
if (args.size() > 2) { if (args.size() > 2) {
strippedArgs.addAll(args.subList(2, args.size())); strippedArgs.addAll(args.subList(2, args.size()));
} }
String c = args.get(1); final String groupName = args.get(0).toLowerCase();
GroupSubCommand tempSub = null; plugin.getDatastore().loadGroup(groupName, success -> {
for (GroupSubCommand s : subCommands) {
if (s.getName().equalsIgnoreCase(c)) {
tempSub = s;
break;
}
}
final GroupSubCommand sub = tempSub;
if (sub == null) {
Util.sendPluginMessage(sender, "Command not recognised.");
return;
}
if (!sub.isAuthorized(sender)) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
String g = args.get(0).toLowerCase();
plugin.getDatastore().loadGroup(g, success -> {
if (!success) { if (!success) {
Util.sendPluginMessage(sender, "&eGroup could not be found."); Util.sendPluginMessage(sender, "&eGroup could not be found.");
return; return;
} }
Group group = plugin.getGroupManager().getGroup(g); Group group = plugin.getGroupManager().getGroup(groupName);
if (group == null) { if (group == null) {
Util.sendPluginMessage(sender, "&eGroup could not be found."); Util.sendPluginMessage(sender, "&eGroup could not be found.");
return; return;
@ -86,18 +75,4 @@ public class GroupMainCommand extends MainCommand {
subCommands.add(subCommand); subCommands.add(subCommand);
} }
@Override
protected void sendUsage(Sender sender) {
List<SubCommand> subs = getSubCommands().stream().filter(s -> s.isAuthorized(sender)).collect(Collectors.toList());
if (subs.size() > 0) {
Util.sendPluginMessage(sender, "&e" + getName() + " Sub Commands:");
for (SubCommand s : subs) {
s.sendUsage(sender);
}
} else {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
}
}
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group; package me.lucko.luckperms.commands.group;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
@ -9,17 +10,12 @@ import me.lucko.luckperms.groups.Group;
import java.util.List; import java.util.List;
public abstract class GroupSubCommand extends SubCommand { public abstract class GroupSubCommand extends SubCommand {
protected GroupSubCommand(String name, String description, String usage, String permission) { protected GroupSubCommand(String name, String description, String usage, Permission permission) {
super(name, description, usage, permission); super(name, description, usage, permission);
} }
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args); protected abstract void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args);
@Override
public boolean isAuthorized(Sender sender) {
return sender.hasPermission(getPermission()) || sender.hasPermission("luckperms.group.*") || sender.hasPermission("luckperms.*");
}
protected void saveGroup(Group group, Sender sender, LuckPermsPlugin plugin) { protected void saveGroup(Group group, Sender sender, LuckPermsPlugin plugin) {
plugin.getDatastore().saveGroup(group, success -> { plugin.getDatastore().saveGroup(group, success -> {
if (success) { if (success) {

View File

@ -1,10 +1,7 @@
package me.lucko.luckperms.commands.group; package me.lucko.luckperms.commands.group;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.MainCommand; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,16 +13,12 @@ public class ListGroupsCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (!sender.hasPermission("luckperms.listgroups")) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
plugin.getDatastore().loadAllGroups(success -> { plugin.getDatastore().loadAllGroups(success -> {
if (!success) { if (!success) {
Util.sendPluginMessage(sender, "Unable to load all groups."); Util.sendPluginMessage(sender, "Unable to load all groups.");
} else { } else {
Util.sendPluginMessage(sender, "&aGroups: " + Util.listToCommaSep(new ArrayList<>(plugin.getGroupManager().getGroups().keySet()))); Util.sendPluginMessage(sender, "&aGroups: " +
Util.listToCommaSep(new ArrayList<>(plugin.getGroupManager().getGroups().keySet())));
} }
}); });
} }
@ -37,6 +30,6 @@ public class ListGroupsCommand extends MainCommand {
@Override @Override
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
return sender.hasPermission("luckperms.listgroups") || sender.hasPermission("luckperms.*"); return Permission.LIST_GROUPS.isAuthorized(sender);
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -10,8 +11,7 @@ import java.util.List;
public class GroupClearCommand extends GroupSubCommand { public class GroupClearCommand extends GroupSubCommand {
public GroupClearCommand() { public GroupClearCommand() {
super("clear", "Clears a groups permissions", super("clear", "Clears a groups permissions", "/perms group <group> clear", Permission.GROUP_CLEAR);
"/perms group <group> clear", "luckperms.group.clear");
} }
@Override @Override
@ -24,6 +24,6 @@ public class GroupClearCommand extends GroupSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return true; return false;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -11,13 +12,13 @@ import java.util.List;
public class GroupHasPermCommand extends GroupSubCommand { public class GroupHasPermCommand extends GroupSubCommand {
public GroupHasPermCommand() { public GroupHasPermCommand() {
super("haspermission", "Checks to see if a group has a certain permission node", super("haspermission", "Checks to see if a group has a certain permission node",
"/perms group <group> haspermission <node> [server]", "luckperms.group.haspermission"); "/perms group <group> haspermission <node> [server]", Permission.GROUP_HASPERMISSION);
} }
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
if (args.size() >= 2) { if (args.size() == 2) {
Util.sendBoolean(sender, args.get(0), group.hasPermission(args.get(0), true, args.get(1))); Util.sendBoolean(sender, args.get(0), group.hasPermission(args.get(0), true, args.get(1).toLowerCase()));
} else { } else {
Util.sendBoolean(sender, args.get(0), group.hasPermission(args.get(0), true, "global")); Util.sendBoolean(sender, args.get(0), group.hasPermission(args.get(0), true, "global"));
} }
@ -25,6 +26,6 @@ public class GroupHasPermCommand extends GroupSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1 && argLength != 2;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -10,18 +11,16 @@ import java.util.List;
public class GroupInfoCommand extends GroupSubCommand { public class GroupInfoCommand extends GroupSubCommand {
public GroupInfoCommand() { public GroupInfoCommand() {
super("info", "Gives info about the group", super("info", "Gives info about the group", "/perms group <group> info", Permission.GROUP_INFO);
"/perms group <group> info", "luckperms.group.info");
} }
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
final String prefix = Util.PREFIX; sender.sendMessage(Util.color(
String sb = prefix + "&d-> &eGroup: &6" + group.getName() + "\n" + Util.PREFIX + "&d-> &eGroup: &6" + group.getName() + "\n" +
prefix + "&d-> &ePermissions: &6" + group.getNodes().keySet().size() + "\n" + Util.PREFIX + "&d-> &ePermissions: &6" + group.getNodes().keySet().size() + "\n" +
prefix + "&d-> &bUse &a/perms group " + group.getName() + " listnodes &bto see all permissions."; Util.PREFIX + "&d-> &bUse &a/perms group " + group.getName() + " listnodes &bto see all permissions."
));
sender.sendMessage(Util.color(sb));
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -10,8 +11,8 @@ import java.util.List;
public class GroupListNodesCommand extends GroupSubCommand { public class GroupListNodesCommand extends GroupSubCommand {
public GroupListNodesCommand() { public GroupListNodesCommand() {
super("listnodes", "Lists the permission nodes the group has", super("listnodes", "Lists the permission nodes the group has", "/perms group <group> listnodes",
"/perms group <group> listnodes", "luckperms.group.listnodes"); Permission.GROUP_LISTNODES);
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -12,7 +13,7 @@ import java.util.List;
public class GroupSetInheritCommand extends GroupSubCommand { public class GroupSetInheritCommand extends GroupSubCommand {
public GroupSetInheritCommand() { public GroupSetInheritCommand() {
super("setinherit", "Sets another group for this group to inherit permissions from", super("setinherit", "Sets another group for this group to inherit permissions from",
"/perms group <group> setinherit <group> [server]", "luckperms.group.setinherit"); "/perms group <group> setinherit <group> [server]", Permission.GROUP_SETINHERIT);
} }
@Override @Override
@ -23,16 +24,16 @@ public class GroupSetInheritCommand extends GroupSubCommand {
if (!success) { if (!success) {
Util.sendPluginMessage(sender, groupName + " does not exist!"); Util.sendPluginMessage(sender, groupName + " does not exist!");
} else { } else {
final String node = "group." + groupName;
try { try {
if (args.size() == 2) { if (args.size() == 2) {
final String server = args.get(1).toLowerCase(); final String server = args.get(1).toLowerCase();
group.setPermission(node, true, server); group.setPermission("group." + groupName, true, server);
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a now inherits permissions from &b" + groupName + "&a on server &b" + server + "&a."); Util.sendPluginMessage(sender, "&b" + group.getName() + "&a now inherits permissions from &b" +
groupName + "&a on server &b" + server + "&a.");
} else { } else {
group.setPermission(node, true); group.setPermission("group." + groupName, true);
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a now inherits permissions from &b" + groupName + "&a."); Util.sendPluginMessage(sender, "&b" + group.getName() + "&a now inherits permissions from &b" +
groupName + "&a.");
} }
saveGroup(group, sender, plugin); saveGroup(group, sender, plugin);
@ -45,6 +46,6 @@ public class GroupSetInheritCommand extends GroupSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1 && argLength != 2;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -11,8 +12,8 @@ import java.util.List;
public class GroupSetPermissionCommand extends GroupSubCommand { public class GroupSetPermissionCommand extends GroupSubCommand {
public GroupSetPermissionCommand() { public GroupSetPermissionCommand() {
super("set", "Sets a permission for a group", super("set", "Sets a permission for a group", "/perms group <group> set <node> <true|false> [server]",
"/perms group <group> set <node> <true|false> [server]", "luckperms.group.setpermission"); Permission.GROUP_SETPERMISSION);
} }
@Override @Override
@ -41,7 +42,8 @@ public class GroupSetPermissionCommand extends GroupSubCommand {
if (args.size() == 3) { if (args.size() == 3) {
final String server = args.get(2).toLowerCase(); final String server = args.get(2).toLowerCase();
group.setPermission(node, b, server); group.setPermission(node, b, server);
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + bool + "&a for &b" + group.getName() + "&a on server &b" + server + "&a."); Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + bool + "&a for &b" + group.getName() +
"&a on server &b" + server + "&a.");
} else { } else {
group.setPermission(node, b); group.setPermission(node, b);
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + group.getName() + "&a."); Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + group.getName() + "&a.");
@ -55,6 +57,6 @@ public class GroupSetPermissionCommand extends GroupSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength < 2; return argLength != 2 && argLength != 3;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -12,7 +13,7 @@ import java.util.List;
public class GroupUnSetPermissionCommand extends GroupSubCommand { public class GroupUnSetPermissionCommand extends GroupSubCommand {
public GroupUnSetPermissionCommand() { public GroupUnSetPermissionCommand() {
super("unset", "Unsets a permission for a group", super("unset", "Unsets a permission for a group",
"/perms group <group> unset <node> [server]", "luckperms.group.unsetpermission"); "/perms group <group> unset <node> [server]", Permission.GROUP_UNSETPERMISSION);
} }
@Override @Override
@ -33,7 +34,8 @@ public class GroupUnSetPermissionCommand extends GroupSubCommand {
if (args.size() == 2) { if (args.size() == 2) {
final String server = args.get(1).toLowerCase(); final String server = args.get(1).toLowerCase();
group.unsetPermission(node, server); group.unsetPermission(node, server);
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + group.getName() + "&a on server &b" + server + "&a."); Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + group.getName() + "&a on server &b" +
server + "&a.");
} else { } else {
group.unsetPermission(node); group.unsetPermission(node);
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + group.getName() + "&a."); Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + group.getName() + "&a.");
@ -47,6 +49,6 @@ public class GroupUnSetPermissionCommand extends GroupSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1 && argLength != 2;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.group.subcommands; package me.lucko.luckperms.commands.group.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.group.GroupSubCommand; import me.lucko.luckperms.commands.group.GroupSubCommand;
@ -12,23 +13,25 @@ import java.util.List;
public class GroupUnsetInheritCommand extends GroupSubCommand { public class GroupUnsetInheritCommand extends GroupSubCommand {
public GroupUnsetInheritCommand() { public GroupUnsetInheritCommand() {
super("unsetinherit", "Unsets another group for this group to inherit permissions from", super("unsetinherit", "Unsets another group for this group to inherit permissions from",
"/perms group <group> unsetinherit <group> [server]", "luckperms.group.unsetinherit"); "/perms group <group> unsetinherit <group> [server]", Permission.GROUP_UNSETINHERIT);
} }
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
String groupName = args.get(0).toLowerCase(); String groupName = args.get(0).toLowerCase();
String server; try {
if (args.size() == 2) { if (args.size() == 2) {
server = args.get(1).toLowerCase(); final String server = args.get(1).toLowerCase();
group.unsetPermission("group." + groupName, server);
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a no longer inherits permissions from &b" +
groupName + "&a on server &b" + server + "&a.");
} else { } else {
server = "global"; group.unsetPermission("group." + groupName);
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a no longer inherits permissions from &b" +
groupName + "&a.");
} }
try {
group.unsetPermission("group." + groupName, server);
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a no longer inherits permissions from &b" + groupName + "&a on server &b" + server + "&a.");
saveGroup(group, sender, plugin); saveGroup(group, sender, plugin);
} catch (ObjectLacksPermissionException e) { } catch (ObjectLacksPermissionException e) {
Util.sendPluginMessage(sender, "That group does not inherit '" + groupName + "'."); Util.sendPluginMessage(sender, "That group does not inherit '" + groupName + "'.");
@ -37,6 +40,6 @@ public class GroupUnsetInheritCommand extends GroupSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1 && argLength != 2;
} }
} }

View File

@ -1,10 +1,7 @@
package me.lucko.luckperms.commands.misc; package me.lucko.luckperms.commands.misc;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.MainCommand; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,11 +13,6 @@ public class DebugCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (!sender.hasPermission("luckperms.debug")) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
Util.sendPluginMessage(sender, "&d&l> &dDebug Info"); Util.sendPluginMessage(sender, "&d&l> &dDebug Info");
Util.sendPluginMessage(sender, "&eOnline Players: &6" + plugin.getPlayerCount()); Util.sendPluginMessage(sender, "&eOnline Players: &6" + plugin.getPlayerCount());
Util.sendPluginMessage(sender, "&eLoaded Users: &6" + plugin.getUserManager().getUsers().size()); Util.sendPluginMessage(sender, "&eLoaded Users: &6" + plugin.getUserManager().getUsers().size());
@ -34,6 +26,6 @@ public class DebugCommand extends MainCommand {
@Override @Override
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
return sender.hasPermission("luckperms.debug") || sender.hasPermission("luckperms.*"); return Permission.DEBUG.isAuthorized(sender);
} }
} }

View File

@ -1,10 +1,7 @@
package me.lucko.luckperms.commands.misc; package me.lucko.luckperms.commands.misc;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.MainCommand; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,11 +13,6 @@ public class InfoCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (!sender.hasPermission("luckperms.info")) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6."); Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6.");
Util.sendPluginMessage(sender, "&eAuthor: &6Luck"); Util.sendPluginMessage(sender, "&eAuthor: &6Luck");
Util.sendPluginMessage(sender, "&eStorage Method: &6" + plugin.getDatastore().getName()); Util.sendPluginMessage(sender, "&eStorage Method: &6" + plugin.getDatastore().getName());
@ -33,6 +25,6 @@ public class InfoCommand extends MainCommand {
@Override @Override
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
return sender.hasPermission("luckperms.info") || sender.hasPermission("luckperms.*"); return Permission.INFO.isAuthorized(sender);
} }
} }

View File

@ -1,10 +1,7 @@
package me.lucko.luckperms.commands.misc; package me.lucko.luckperms.commands.misc;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.MainCommand; import me.lucko.luckperms.commands.*;
import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,11 +13,6 @@ public class SyncCommand extends MainCommand {
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (!sender.hasPermission("luckperms.sync")) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return;
}
Util.sendPluginMessage(sender, "&bRunning update task for all online users."); Util.sendPluginMessage(sender, "&bRunning update task for all online users.");
plugin.runUpdateTask(); plugin.runUpdateTask();
} }
@ -32,6 +24,6 @@ public class SyncCommand extends MainCommand {
@Override @Override
protected boolean canUse(Sender sender) { protected boolean canUse(Sender sender) {
return sender.hasPermission("luckperms.sync") || sender.hasPermission("luckperms.*"); return Permission.SYNC.isAuthorized(sender);
} }
} }

View File

@ -9,6 +9,7 @@ import me.lucko.luckperms.users.User;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public class UserMainCommand extends MainCommand{ public class UserMainCommand extends MainCommand{
@ -21,31 +22,19 @@ public class UserMainCommand extends MainCommand{
@Override @Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) { protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
if (args.size() <= 1) { if (args.size() < 2) {
sendUsage(sender); sendUsage(sender);
return; return;
} }
// The first argument is the name of the user, the second is the command Optional<UserSubCommand> o = subCommands.stream().filter(s -> s.getName().equalsIgnoreCase(args.get(1))).limit(1).findAny();
String command = args.get(1);
UserSubCommand tempSub = null;
// Try to identify the command used if (!o.isPresent()) {
for (UserSubCommand s : subCommands) {
if (s.getName().equalsIgnoreCase(command)) {
tempSub = s;
break;
}
}
// The command the sender used
final UserSubCommand sub = tempSub;
if (sub == null) {
Util.sendPluginMessage(sender, "Command not recognised."); Util.sendPluginMessage(sender, "Command not recognised.");
return; return;
} }
final UserSubCommand sub = o.get();
if (!sub.isAuthorized(sender)) { if (!sub.isAuthorized(sender)) {
Util.sendPluginMessage(sender, "You do not have permission to use this command!"); Util.sendPluginMessage(sender, "You do not have permission to use this command!");
return; return;
@ -57,8 +46,7 @@ public class UserMainCommand extends MainCommand{
strippedArgs.addAll(args.subList(2, args.size())); strippedArgs.addAll(args.subList(2, args.size()));
} }
String user = args.get(0); final String user = args.get(0);
UUID u = Util.parseUuid(user); UUID u = Util.parseUuid(user);
if (u != null) { if (u != null) {
runSub(plugin, sender, u, sub, strippedArgs); runSub(plugin, sender, u, sub, strippedArgs);
@ -88,9 +76,8 @@ public class UserMainCommand extends MainCommand{
return; return;
} }
User user1 = plugin.getUserManager().getUser(uuid); User user = plugin.getUserManager().getUser(uuid);
if (user == null) {
if (user1 == null) {
Util.sendPluginMessage(sender, "&eUser could not be found."); Util.sendPluginMessage(sender, "&eUser could not be found.");
} }
@ -99,8 +86,8 @@ public class UserMainCommand extends MainCommand{
return; return;
} }
command.execute(plugin, sender, user1, strippedArgs); command.execute(plugin, sender, user, strippedArgs);
plugin.getUserManager().cleanupUser(user1); plugin.getUserManager().cleanupUser(user);
}); });
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user; package me.lucko.luckperms.commands.user;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.SubCommand; import me.lucko.luckperms.commands.SubCommand;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
@ -9,17 +10,12 @@ import me.lucko.luckperms.users.User;
import java.util.List; import java.util.List;
public abstract class UserSubCommand extends SubCommand { public abstract class UserSubCommand extends SubCommand {
protected UserSubCommand(String name, String description, String usage, String permission) { protected UserSubCommand(String name, String description, String usage, Permission permission) {
super(name, description, usage, permission); super(name, description, usage, permission);
} }
protected abstract void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args); protected abstract void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args);
@Override
public boolean isAuthorized(Sender sender) {
return sender.hasPermission(getPermission()) || sender.hasPermission("luckperms.user.*") || sender.hasPermission("luckperms.*");
}
protected void saveUser(User user, Sender sender, LuckPermsPlugin plugin) { protected void saveUser(User user, Sender sender, LuckPermsPlugin plugin) {
user.refreshPermissions(); user.refreshPermissions();

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -12,34 +13,41 @@ import java.util.List;
public class UserAddGroupCommand extends UserSubCommand { public class UserAddGroupCommand extends UserSubCommand {
public UserAddGroupCommand() { public UserAddGroupCommand() {
super("addgroup", "Adds the user to a group", super("addgroup", "Adds the user to a group", "/perms user <user> addgroup <group> [server]", Permission.USER_ADDGROUP);
"/perms user <user> addgroup <group> [server]", "luckperms.user.addgroup");
} }
@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) {
String group = args.get(0).toLowerCase(); String groupName = args.get(0).toLowerCase();
String server; plugin.getDatastore().loadGroup(groupName, success -> {
if (args.size() != 1) { if (!success) {
server = args.get(1); Util.sendPluginMessage(sender, groupName + " does not exist!");
} else { } else {
server = "global"; Group group = plugin.getGroupManager().getGroup(groupName);
} if (group == null) {
Group group1 = plugin.getGroupManager().getGroup(group);
if (group1 == null) {
Util.sendPluginMessage(sender, "That group does not exist!"); Util.sendPluginMessage(sender, "That group does not exist!");
return; return;
} }
try { try {
user.addGroup(group1, server); if (args.size() == 2) {
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a successfully added to group &b" + group + "&a on the server &b" + server + "&a."); final String server = args.get(1).toLowerCase();
user.addGroup(group, server);
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a successfully added to group &b" +
groupName + "&a on the server &b" + server + "&a.");
} else {
user.addGroup(group);
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a successfully added to group &b" +
groupName + "&a.");
}
saveUser(user, sender, plugin);
} catch (ObjectAlreadyHasException e) { } catch (ObjectAlreadyHasException e) {
Util.sendPluginMessage(sender, "The user is already a member of that group."); Util.sendPluginMessage(sender, "The user is already a member of that group.");
} }
saveUser(user, sender, plugin); }
});
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -10,8 +11,7 @@ import java.util.List;
public class UserClearCommand extends UserSubCommand { public class UserClearCommand extends UserSubCommand {
public UserClearCommand() { public UserClearCommand() {
super("clear", "Clears a users permissions and groups", super("clear", "Clears a users permissions and groups", "/perms user <user> clear", Permission.USER_CLEAR);
"/perms user <user> clear", "luckperms.user.clear");
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -10,7 +11,7 @@ import java.util.List;
public class UserGetUUIDCommand extends UserSubCommand { public class UserGetUUIDCommand extends UserSubCommand {
public UserGetUUIDCommand() { public UserGetUUIDCommand() {
super("getuuid", "Get the UUID of a user", "/perms user <user> getuuid", "luckperms.user.getuuid"); super("getuuid", "Get the UUID of a user", "/perms user <user> getuuid", Permission.USER_GETUUID);
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -11,7 +12,7 @@ import java.util.List;
public class UserHasPermCommand extends UserSubCommand { public class UserHasPermCommand extends UserSubCommand {
public UserHasPermCommand() { public UserHasPermCommand() {
super("haspermission", "Checks to see if a user has a certain permission node", super("haspermission", "Checks to see if a user has a certain permission node",
"/perms user <user> haspermission <node> [server]", "luckperms.user.haspermission"); "/perms user <user> haspermission <node> [server]", Permission.USER_HASPERMISSION);
} }
@Override @Override
@ -25,6 +26,6 @@ public class UserHasPermCommand extends UserSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1 && argLength != 2;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -10,22 +11,20 @@ import java.util.List;
public class UserInfoCommand extends UserSubCommand { public class UserInfoCommand extends UserSubCommand {
public UserInfoCommand() { public UserInfoCommand() {
super("info", "Gives info about the user", super("info", "Gives info about the user", "/perms user <user> info", Permission.USER_INFO);
"/perms user <user> info", "luckperms.user.info");
} }
@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) {
final String prefix = Util.PREFIX; sender.sendMessage(Util.color(
String sb = prefix + "&d-> &eUser: &6" + user.getName() + "\n" + Util.PREFIX + "&d-> &eUser: &6" + user.getName() + "\n" +
prefix + "&d-> &eUUID: &6" + user.getUuid() + "\n" + Util.PREFIX + "&d-> &eUUID: &6" + user.getUuid() + "\n" +
prefix + "&d-> &eStatus: " + plugin.getPlayerStatus(user.getUuid()) + "\n" + Util.PREFIX + "&d-> &eStatus: " + plugin.getPlayerStatus(user.getUuid()) + "\n" +
prefix + "&d-> &eGroups: &6" + Util.listToCommaSep(user.getGroupNames()) + "\n" + Util.PREFIX + "&d-> &eGroups: &6" + Util.listToCommaSep(user.getGroupNames()) + "\n" +
prefix + "&d-> &ePrimary Group: &6" + user.getPrimaryGroup() + "\n" + Util.PREFIX + "&d-> &ePrimary Group: &6" + user.getPrimaryGroup() + "\n" +
prefix + "&d-> &ePermissions: &6" + (user.getNodes().keySet().size() - user.getGroupNames().size()) + "\n" + Util.PREFIX + "&d-> &ePermissions: &6" + (user.getNodes().keySet().size() - user.getGroupNames().size()) + "\n" +
prefix + "&d-> &bUse &a/perms user " + user.getName() + " listnodes &bto see all permissions."; Util.PREFIX + "&d-> &bUse &a/perms user " + user.getName() + " listnodes &bto see all permissions."
));
sender.sendMessage(Util.color(sb));
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -10,8 +11,7 @@ import java.util.List;
public class UserListNodesCommand extends UserSubCommand { public class UserListNodesCommand extends UserSubCommand {
public UserListNodesCommand() { public UserListNodesCommand() {
super("listnodes", "Lists the permission nodes the user has", super("listnodes", "Lists the permission nodes the user has", "/perms user <user> listnodes", Permission.USER_LISTNODES);
"/perms user <user> listnodes", "luckperms.user.listnodes");
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -12,39 +13,47 @@ import java.util.List;
public class UserRemoveGroupCommand extends UserSubCommand { public class UserRemoveGroupCommand extends UserSubCommand {
public UserRemoveGroupCommand() { public UserRemoveGroupCommand() {
super("removegroup", "Removes a user from a group", super("removegroup", "Removes a user from a group", "/perms user <user> removegroup <group> [server]", Permission.USER_REMOVEGROUP);
"/perms user <user> removegroup <group> [server]", "luckperms.user.removegroup");
} }
@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) {
String group = args.get(0).toLowerCase(); String groupName = args.get(0).toLowerCase();
String server; plugin.getDatastore().loadGroup(groupName, success -> {
if (args.size() != 1) { if (!success) {
server = args.get(1); Util.sendPluginMessage(sender, groupName + " does not exist!");
} else { } else {
server = "global"; Group group = plugin.getGroupManager().getGroup(groupName);
} if (group == null) {
Group group1 = plugin.getGroupManager().getGroup(group);
if (group1 == null) {
Util.sendPluginMessage(sender, "That group does not exist!"); Util.sendPluginMessage(sender, "That group does not exist!");
return; return;
} }
if (server.equalsIgnoreCase("global") && user.getPrimaryGroup().equalsIgnoreCase(group1.getName())) { if ((args.size() == 1 || (args.size() == 2 && args.get(1).equalsIgnoreCase("global")))
&& user.getPrimaryGroup().equalsIgnoreCase(group.getName())) {
Util.sendPluginMessage(sender, "You cannot remove a user from their primary group."); Util.sendPluginMessage(sender, "You cannot remove a user from their primary group.");
return; return;
} }
try { try {
user.removeGroup(group1, server); if (args.size() == 2) {
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a was removed from group &b" + group + "&a on server &b" + server + "&a."); final String server = args.get(1).toLowerCase();
user.removeGroup(group, server);
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a was removed from group &b" +
groupName + "&a on server &b" + server + "&a.");
} else {
user.removeGroup(group);
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a was removed from group &b" +
groupName + "&a.");
}
saveUser(user, sender, plugin);
} catch (ObjectLacksPermissionException e) { } catch (ObjectLacksPermissionException e) {
Util.sendPluginMessage(sender, "The user is not a member of that group."); Util.sendPluginMessage(sender, "The user is not a member of that group.");
} }
saveUser(user, sender, plugin); }
});
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -12,7 +13,7 @@ import java.util.List;
public class UserSetPermissionCommand extends UserSubCommand { public class UserSetPermissionCommand extends UserSubCommand {
public UserSetPermissionCommand() { public UserSetPermissionCommand() {
super("set", "Sets a permission for a user", super("set", "Sets a permission for a user",
"/perms user <user> set <node> <true|false> [server]", "luckperms.user.setpermission"); "/perms user <user> set <node> <true|false> [server]", Permission.USER_SETPERMISSION);
} }
@Override @Override
@ -41,20 +42,21 @@ public class UserSetPermissionCommand extends UserSubCommand {
if (args.size() == 3) { if (args.size() == 3) {
final String server = args.get(2).toLowerCase(); final String server = args.get(2).toLowerCase();
user.setPermission(node, b, server); user.setPermission(node, b, server);
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + user.getName() + "&a on server &b" + server + "&a."); Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + user.getName() +
"&a on server &b" + server + "&a.");
} else { } else {
user.setPermission(node, b); user.setPermission(node, b);
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + user.getName() + "&a."); Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + user.getName() + "&a.");
} }
saveUser(user, sender, plugin);
} catch (ObjectAlreadyHasException e) { } catch (ObjectAlreadyHasException e) {
Util.sendPluginMessage(sender, "That user already has this permission!"); Util.sendPluginMessage(sender, "That user already has this permission!");
} }
saveUser(user, sender, plugin);
} }
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength < 2; return argLength != 2 && argLength != 3;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -12,7 +13,7 @@ import java.util.List;
public class UserSetPrimaryGroupCommand extends UserSubCommand { public class UserSetPrimaryGroupCommand extends UserSubCommand {
public UserSetPrimaryGroupCommand() { public UserSetPrimaryGroupCommand() {
super("setprimarygroup", "Sets a users primary group", super("setprimarygroup", "Sets a users primary group",
"/perms user <user> setprimarygroup <group>", "luckperms.user.setprimarygroup"); "/perms user <user> setprimarygroup <group>", Permission.USER_SETPRIMARYGROUP);
} }
@Override @Override
@ -41,6 +42,6 @@ public class UserSetPrimaryGroupCommand extends UserSubCommand {
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1;
} }
} }

View File

@ -1,6 +1,7 @@
package me.lucko.luckperms.commands.user.subcommands; package me.lucko.luckperms.commands.user.subcommands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.commands.Permission;
import me.lucko.luckperms.commands.Sender; import me.lucko.luckperms.commands.Sender;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.commands.user.UserSubCommand; import me.lucko.luckperms.commands.user.UserSubCommand;
@ -12,7 +13,7 @@ import java.util.List;
public class UserUnSetPermissionCommand extends UserSubCommand { public class UserUnSetPermissionCommand extends UserSubCommand {
public UserUnSetPermissionCommand() { public UserUnSetPermissionCommand() {
super("unset", "Unsets a permission for a user", super("unset", "Unsets a permission for a user",
"/perms user <user> unset <node> [server]", "luckperms.user.unsetpermission"); "/perms user <user> unset <node> [server]", Permission.USER_UNSETPERMISSION);
} }
@Override @Override
@ -33,19 +34,21 @@ public class UserUnSetPermissionCommand extends UserSubCommand {
if (args.size() == 2) { if (args.size() == 2) {
final String server = args.get(1).toLowerCase(); final String server = args.get(1).toLowerCase();
user.unsetPermission(node, server); user.unsetPermission(node, server);
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + user.getName() + "&a on server &b" + server + "&a."); Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + user.getName() + "&a on server &b" +
server + "&a.");
} else { } else {
user.unsetPermission(node); user.unsetPermission(node);
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + user.getName() + "&a."); Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + user.getName() + "&a.");
} }
saveUser(user, sender, plugin);
} catch (ObjectLacksPermissionException e) { } catch (ObjectLacksPermissionException e) {
Util.sendPluginMessage(sender, "That user does not have this permission set."); Util.sendPluginMessage(sender, "That user does not have this permission set.");
} }
saveUser(user, sender, plugin);
} }
@Override @Override
public boolean isArgLengthInvalid(int argLength) { public boolean isArgLengthInvalid(int argLength) {
return argLength == 0; return argLength != 1 && argLength != 2;
} }
} }

View File

@ -6,6 +6,7 @@ import me.lucko.luckperms.data.Datastore;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -40,19 +41,15 @@ public abstract class UserManager {
* @param name The name to search by * @param name The name to search by
* @return a {@link User} object if the user is loaded, returns null if the user is not loaded * @return a {@link User} object if the user is loaded, returns null if the user is not loaded
*/ */
@SuppressWarnings("OptionalGetWithoutIsPresent")
public User getUser(String name) { public User getUser(String name) {
User user = null; try {
return users.values().stream().filter(u -> u.getName().equalsIgnoreCase(name)).limit(1).findAny().get();
for (User u : users.values()) { } catch (NoSuchElementException e) {
if (u.getName().equalsIgnoreCase(name)) { return null;
user = u;
break;
} }
} }
return user;
}
/** /**
* Add a user to the {@link #getUsers()} map * Add a user to the {@link #getUsers()} map
* @param user the user to add * @param user the user to add

View File

@ -56,10 +56,7 @@ public abstract class PermissionObject {
*/ */
public boolean hasPermission(String node, Boolean b) { public boolean hasPermission(String node, Boolean b) {
if (node.startsWith("global/")) node = node.replace("global/", ""); if (node.startsWith("global/")) node = node.replace("global/", "");
if (b) { return b ? getNodes().containsKey(node) && getNodes().get(node) : getNodes().containsKey(node) && !getNodes().get(node);
return getNodes().containsKey(node) && getNodes().get(node);
}
return getNodes().containsKey(node) && !getNodes().get(node);
} }
/** /**
@ -108,7 +105,6 @@ public abstract class PermissionObject {
if (!getNodes().containsKey(node)) { if (!getNodes().containsKey(node)) {
throw new ObjectLacksPermissionException(); throw new ObjectLacksPermissionException();
} }
getNodes().remove(node); getNodes().remove(node);
} }