Cleanup remaining (un)setPermission methods

This commit is contained in:
Luck 2017-03-25 11:04:25 +00:00
parent 1137e476dd
commit 671e2adc32
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
15 changed files with 85 additions and 119 deletions

View File

@ -32,6 +32,7 @@ import me.lucko.luckperms.api.caching.PermissionData;
import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.bukkit.LPBukkitPlugin;
import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.Group;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
@ -92,9 +93,9 @@ public class VaultPermissionHook extends Permission {
return CompletableFuture.runAsync(() -> { return CompletableFuture.runAsync(() -> {
try { try {
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) { if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
holder.setPermission(permission, true, getServer(), world); holder.setPermission(NodeFactory.make(permission, true, getServer(), world));
} else { } else {
holder.setPermission(permission, true, getServer()); holder.setPermission(NodeFactory.make(permission, true, getServer()));
} }
save(holder); save(holder);
@ -113,9 +114,9 @@ public class VaultPermissionHook extends Permission {
return CompletableFuture.runAsync(() -> { return CompletableFuture.runAsync(() -> {
try { try {
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) { if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
holder.unsetPermission(permission, getServer(), world); holder.unsetPermission(NodeFactory.make(permission, getServer(), world));
} else { } else {
holder.unsetPermission(permission, getServer()); holder.unsetPermission(NodeFactory.make(permission, getServer()));
} }
save(holder); save(holder);

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.api.LocalizedNode;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.PermissionHolder; import me.lucko.luckperms.api.PermissionHolder;
import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.utils.ExtractedContexts; import me.lucko.luckperms.common.utils.ExtractedContexts;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.exceptions.ObjectLacksException;
@ -175,32 +176,32 @@ public class PermissionHolderDelegate implements PermissionHolder {
@Override @Override
public void setPermission(@NonNull String node, @NonNull boolean value) throws ObjectAlreadyHasException { public void setPermission(@NonNull String node, @NonNull boolean value) throws ObjectAlreadyHasException {
master.setPermission(node, value); master.setPermission(NodeFactory.make(node, value));
} }
@Override @Override
public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server) throws ObjectAlreadyHasException { public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server) throws ObjectAlreadyHasException {
master.setPermission(node, value, server); master.setPermission(NodeFactory.make(node, value, server));
} }
@Override @Override
public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException { public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException {
master.setPermission(node, value, server, world); master.setPermission(NodeFactory.make(node, value, server, world));
} }
@Override @Override
public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull long expireAt) throws ObjectAlreadyHasException { public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull long expireAt) throws ObjectAlreadyHasException {
master.setPermission(node, value, checkTime(expireAt)); master.setPermission(NodeFactory.make(node, value, checkTime(expireAt)));
} }
@Override @Override
public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException { public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException {
master.setPermission(node, value, server, checkTime(expireAt)); master.setPermission(NodeFactory.make(node, value, server, checkTime(expireAt)));
} }
@Override @Override
public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException { public void setPermission(@NonNull String node, @NonNull boolean value, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException {
master.setPermission(node, value, server, world, checkTime(expireAt)); master.setPermission(NodeFactory.make(node, value, server, world, checkTime(expireAt)));
} }
@Override @Override
@ -215,32 +216,32 @@ public class PermissionHolderDelegate implements PermissionHolder {
@Override @Override
public void unsetPermission(@NonNull String node, @NonNull boolean temporary) throws ObjectLacksException { public void unsetPermission(@NonNull String node, @NonNull boolean temporary) throws ObjectLacksException {
master.unsetPermission(node, temporary); master.unsetPermission(NodeFactory.make(node, temporary));
} }
@Override @Override
public void unsetPermission(@NonNull String node) throws ObjectLacksException { public void unsetPermission(@NonNull String node) throws ObjectLacksException {
master.unsetPermission(node); master.unsetPermission(NodeFactory.make(node));
} }
@Override @Override
public void unsetPermission(@NonNull String node, @NonNull String server) throws ObjectLacksException { public void unsetPermission(@NonNull String node, @NonNull String server) throws ObjectLacksException {
master.unsetPermission(node, server); master.unsetPermission(NodeFactory.make(node, server));
} }
@Override @Override
public void unsetPermission(@NonNull String node, @NonNull String server, @NonNull String world) throws ObjectLacksException { public void unsetPermission(@NonNull String node, @NonNull String server, @NonNull String world) throws ObjectLacksException {
master.unsetPermission(node, server, world); master.unsetPermission(NodeFactory.make(node, server, world));
} }
@Override @Override
public void unsetPermission(@NonNull String node, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException { public void unsetPermission(@NonNull String node, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException {
master.unsetPermission(node, server, temporary); master.unsetPermission(NodeFactory.make(node, server, temporary));
} }
@Override @Override
public void unsetPermission(@NonNull String node, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException { public void unsetPermission(@NonNull String node, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException {
master.unsetPermission(node, server, world, temporary); master.unsetPermission(NodeFactory.make(node, server, world, temporary));
} }
@Override @Override

View File

@ -32,6 +32,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -66,15 +67,15 @@ public class MetaAddPrefix extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.setPermission(node, true); holder.setPermission(NodeFactory.make(node, true));
Message.ADDPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority); Message.ADDPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
break; break;
case SERVER: case SERVER:
holder.setPermission(node, true, server); holder.setPermission(NodeFactory.make(node, true, server));
Message.ADDPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server); Message.ADDPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.setPermission(node, true, server, world); holder.setPermission(NodeFactory.make(node, true, server, world));
Message.ADDPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world); Message.ADDPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
break; break;
} }

View File

@ -32,6 +32,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -66,15 +67,15 @@ public class MetaAddSuffix extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.setPermission(node, true); holder.setPermission(NodeFactory.make(node, true));
Message.ADDSUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority); Message.ADDSUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
break; break;
case SERVER: case SERVER:
holder.setPermission(node, true, server); holder.setPermission(NodeFactory.make(node, true, server));
Message.ADDSUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server); Message.ADDSUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.setPermission(node, true, server, world); holder.setPermission(NodeFactory.make(node, true, server, world));
Message.ADDSUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world); Message.ADDSUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
break; break;
} }

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -100,15 +101,15 @@ public class MetaRemovePrefix extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission(node); holder.unsetPermission(NodeFactory.make(node));
Message.REMOVEPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority); Message.REMOVEPREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
break; break;
case SERVER: case SERVER:
holder.unsetPermission(node, server); holder.unsetPermission(NodeFactory.make(node, server));
Message.REMOVEPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server); Message.REMOVEPREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission(node, server, world); holder.unsetPermission(NodeFactory.make(node, server, world));
Message.REMOVEPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world); Message.REMOVEPREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
break; break;
} }

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -100,15 +101,15 @@ public class MetaRemoveSuffix extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission(node); holder.unsetPermission(NodeFactory.make(node));
Message.REMOVESUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority); Message.REMOVESUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
break; break;
case SERVER: case SERVER:
holder.unsetPermission(node, server); holder.unsetPermission(NodeFactory.make(node, server));
Message.REMOVESUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server); Message.REMOVESUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission(node, server, world); holder.unsetPermission(NodeFactory.make(node, server, world));
Message.REMOVESUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world); Message.REMOVESUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
break; break;
} }

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -100,15 +101,15 @@ public class MetaRemoveTempPrefix extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission(node, true); holder.unsetPermission(NodeFactory.make(node, true));
Message.REMOVE_TEMP_PREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority); Message.REMOVE_TEMP_PREFIX_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority);
break; break;
case SERVER: case SERVER:
holder.unsetPermission(node, server, true); holder.unsetPermission(NodeFactory.make(node, server, true));
Message.REMOVE_TEMP_PREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server); Message.REMOVE_TEMP_PREFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission(node, server, world, true); holder.unsetPermission(NodeFactory.make(node, server, world, true));
Message.REMOVE_TEMP_PREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world); Message.REMOVE_TEMP_PREFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), prefix, priority, server, world);
break; break;
} }

View File

@ -33,6 +33,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -100,15 +101,15 @@ public class MetaRemoveTempSuffix extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission(node, true); holder.unsetPermission(NodeFactory.make(node, true));
Message.REMOVE_TEMP_SUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority); Message.REMOVE_TEMP_SUFFIX_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority);
break; break;
case SERVER: case SERVER:
holder.unsetPermission(node, server, true); holder.unsetPermission(NodeFactory.make(node, server, true));
Message.REMOVE_TEMP_SUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server); Message.REMOVE_TEMP_SUFFIX_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission(node, server, world, true); holder.unsetPermission(NodeFactory.make(node, server, world, true));
Message.REMOVE_TEMP_SUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world); Message.REMOVE_TEMP_SUFFIX_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), suffix, priority, server, world);
break; break;
} }

View File

@ -32,6 +32,7 @@ import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.core.model.User; import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
@ -81,15 +82,15 @@ public class ParentRemove extends SharedSubCommand {
try { try {
switch (context) { switch (context) {
case NONE: case NONE:
holder.unsetPermission("group." + groupName); holder.unsetPermission(NodeFactory.make("group." + groupName));
Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName); Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName);
break; break;
case SERVER: case SERVER:
holder.unsetPermission("group." + groupName, server); holder.unsetPermission(NodeFactory.make("group." + groupName, server));
Message.UNSET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server); Message.UNSET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission("group." + groupName, server, world); holder.unsetPermission(NodeFactory.make("group." + groupName, server, world));
Message.UNSET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world); Message.UNSET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world);
break; break;
} }

View File

@ -31,6 +31,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -63,15 +64,15 @@ public class ParentRemoveTemp extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission("group." + groupName, true); holder.unsetPermission(NodeFactory.make("group." + groupName, true));
Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName); Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName);
break; break;
case SERVER: case SERVER:
holder.unsetPermission("group." + groupName, server, true); holder.unsetPermission(NodeFactory.make("group." + groupName, server, true));
Message.UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server); Message.UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission("group." + groupName, server, world, true); holder.unsetPermission(NodeFactory.make("group." + groupName, server, world, true));
Message.UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world); Message.UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world);
break; break;
} }

View File

@ -31,6 +31,7 @@ import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
import me.lucko.luckperms.common.commands.utils.ContextHelper; import me.lucko.luckperms.common.commands.utils.ContextHelper;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.constants.Permission;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.core.model.PermissionHolder; import me.lucko.luckperms.common.core.model.PermissionHolder;
import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.data.LogEntry;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
@ -67,15 +68,15 @@ public class PermissionSet extends SharedSubCommand {
try { try {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.setPermission(node, b); holder.setPermission(NodeFactory.make(node, b));
Message.SETPERMISSION_SUCCESS.send(sender, node, b, holder.getFriendlyName()); Message.SETPERMISSION_SUCCESS.send(sender, node, b, holder.getFriendlyName());
break; break;
case SERVER: case SERVER:
holder.setPermission(node, b, server); holder.setPermission(NodeFactory.make(node, b, server));
Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server); Message.SETPERMISSION_SERVER_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.setPermission(node, b, server, world); holder.setPermission(NodeFactory.make(node, b, server, world));
Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server, world); Message.SETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, b, holder.getFriendlyName(), server, world);
break; break;
} }

View File

@ -80,15 +80,15 @@ public class PermissionUnset extends SharedSubCommand {
// standard unset // standard unset
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission(node); holder.unsetPermission(NodeFactory.make(node));
Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName()); Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName());
break; break;
case SERVER: case SERVER:
holder.unsetPermission(node, server); holder.unsetPermission(NodeFactory.make(node, server));
Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server); Message.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission(node, server, world); holder.unsetPermission(NodeFactory.make(node, server, world));
Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world); Message.UNSETPERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world);
break; break;
} }

View File

@ -79,15 +79,15 @@ public class PermissionUnsetTemp extends SharedSubCommand {
} else { } else {
switch (ContextHelper.determine(server, world)) { switch (ContextHelper.determine(server, world)) {
case NONE: case NONE:
holder.unsetPermission(node, true); holder.unsetPermission(NodeFactory.make(node, true));
Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName()); Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName());
break; break;
case SERVER: case SERVER:
holder.unsetPermission(node, server, true); holder.unsetPermission(NodeFactory.make(node, server, true));
Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server); Message.UNSET_TEMP_PERMISSION_SERVER_SUCCESS.send(sender, node, holder.getFriendlyName(), server);
break; break;
case SERVER_AND_WORLD: case SERVER_AND_WORLD:
holder.unsetPermission(node, server, world, true); holder.unsetPermission(NodeFactory.make(node, server, world, true));
Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world); Message.UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS.send(sender, node, holder.getFriendlyName(), server, world);
break; break;
} }

View File

@ -704,6 +704,10 @@ public abstract class PermissionHolder {
* @return a tristate * @return a tristate
*/ */
public Tristate hasPermission(Node node, boolean checkTransient) { public Tristate hasPermission(Node node, boolean checkTransient) {
if (node.isGroupNode() && node.getGroupName().equalsIgnoreCase(getObjectName())) {
return Tristate.TRUE;
}
return getAlmostEquals(node, checkTransient).map(Node::getTristate).orElse(Tristate.UNDEFINED); return getAlmostEquals(node, checkTransient).map(Node::getTristate).orElse(Tristate.UNDEFINED);
} }
@ -918,30 +922,6 @@ public abstract class PermissionHolder {
} catch (ObjectAlreadyHasException ignored) {} } catch (ObjectAlreadyHasException ignored) {}
} }
public void setPermission(String node, boolean value) throws ObjectAlreadyHasException {
setPermission(NodeFactory.make(node, value));
}
public void setPermission(String node, boolean value, String server) throws ObjectAlreadyHasException {
setPermission(NodeFactory.make(node, value, server));
}
public void setPermission(String node, boolean value, String server, String world) throws ObjectAlreadyHasException {
setPermission(NodeFactory.make(node, value, server, world));
}
public void setPermission(String node, boolean value, long expireAt) throws ObjectAlreadyHasException {
setPermission(NodeFactory.make(node, value, expireAt));
}
public void setPermission(String node, boolean value, String server, long expireAt) throws ObjectAlreadyHasException {
setPermission(NodeFactory.make(node, value, server, expireAt));
}
public void setPermission(String node, boolean value, String server, String world, long expireAt) throws ObjectAlreadyHasException {
setPermission(NodeFactory.make(node, value, server, world, expireAt));
}
/** /**
* Unsets a permission node * Unsets a permission node
* *
@ -1021,30 +1001,6 @@ public abstract class PermissionHolder {
} catch (ObjectLacksException ignored) {} } catch (ObjectLacksException ignored) {}
} }
public void unsetPermission(String node, boolean temporary) throws ObjectLacksException {
unsetPermission(NodeFactory.make(node, temporary));
}
public void unsetPermission(String node) throws ObjectLacksException {
unsetPermission(NodeFactory.make(node));
}
public void unsetPermission(String node, String server) throws ObjectLacksException {
unsetPermission(NodeFactory.make(node, server));
}
public void unsetPermission(String node, String server, String world) throws ObjectLacksException {
unsetPermission(NodeFactory.make(node, server, world));
}
public void unsetPermission(String node, String server, boolean temporary) throws ObjectLacksException {
unsetPermission(NodeFactory.make(node, server, temporary));
}
public void unsetPermission(String node, String server, String world, boolean temporary) throws ObjectLacksException {
unsetPermission(NodeFactory.make(node, server, world, temporary));
}
public boolean inheritsGroup(Group group) { public boolean inheritsGroup(Group group) {
return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission("group." + group.getName(), true); return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission("group." + group.getName(), true);
} }
@ -1062,7 +1018,7 @@ public abstract class PermissionHolder {
throw new ObjectAlreadyHasException(); throw new ObjectAlreadyHasException();
} }
setPermission("group." + group.getName(), true); setPermission(NodeFactory.make("group." + group.getName(), true));
} }
public void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException {
@ -1070,7 +1026,7 @@ public abstract class PermissionHolder {
throw new ObjectAlreadyHasException(); throw new ObjectAlreadyHasException();
} }
setPermission("group." + group.getName(), true, server); setPermission(NodeFactory.make("group." + group.getName(), true, server));
} }
public void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException {
@ -1078,7 +1034,7 @@ public abstract class PermissionHolder {
throw new ObjectAlreadyHasException(); throw new ObjectAlreadyHasException();
} }
setPermission("group." + group.getName(), true, server, world); setPermission(NodeFactory.make("group." + group.getName(), true, server, world));
} }
public void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException {
@ -1086,7 +1042,7 @@ public abstract class PermissionHolder {
throw new ObjectAlreadyHasException(); throw new ObjectAlreadyHasException();
} }
setPermission("group." + group.getName(), true, expireAt); setPermission(NodeFactory.make("group." + group.getName(), true, expireAt));
} }
public void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException {
@ -1094,7 +1050,7 @@ public abstract class PermissionHolder {
throw new ObjectAlreadyHasException(); throw new ObjectAlreadyHasException();
} }
setPermission("group." + group.getName(), true, server, expireAt); setPermission(NodeFactory.make("group." + group.getName(), true, server, expireAt));
} }
public void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException { public void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException {
@ -1102,31 +1058,31 @@ public abstract class PermissionHolder {
throw new ObjectAlreadyHasException(); throw new ObjectAlreadyHasException();
} }
setPermission("group." + group.getName(), true, server, world, expireAt); setPermission(NodeFactory.make("group." + group.getName(), true, server, world, expireAt));
} }
public void unsetInheritGroup(Group group) throws ObjectLacksException { public void unsetInheritGroup(Group group) throws ObjectLacksException {
unsetPermission("group." + group.getName()); unsetPermission(NodeFactory.make("group." + group.getName()));
} }
public void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException { public void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException {
unsetPermission("group." + group.getName(), temporary); unsetPermission(NodeFactory.make("group." + group.getName(), temporary));
} }
public void unsetInheritGroup(Group group, String server) throws ObjectLacksException { public void unsetInheritGroup(Group group, String server) throws ObjectLacksException {
unsetPermission("group." + group.getName(), server); unsetPermission(NodeFactory.make("group." + group.getName(), server));
} }
public void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException { public void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException {
unsetPermission("group." + group.getName(), server, world); unsetPermission(NodeFactory.make("group." + group.getName(), server, world));
} }
public void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException { public void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException {
unsetPermission("group." + group.getName(), server, temporary); unsetPermission(NodeFactory.make("group." + group.getName(), server, temporary));
} }
public void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException { public void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException {
unsetPermission("group." + group.getName(), server, world, temporary); unsetPermission(NodeFactory.make("group." + group.getName(), server, world, temporary));
} }
/** /**
@ -1424,12 +1380,4 @@ public abstract class PermissionHolder {
.map(Node::getGroupName) .map(Node::getGroupName)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public static Map<String, Boolean> exportToLegacy(Iterable<Node> nodes) {
Map<String, Boolean> m = new HashMap<>();
for (Node node : nodes) {
m.put(node.toSerializedNode(), node.getValue());
}
return m;
}
} }

View File

@ -51,6 +51,7 @@ import org.bson.Document;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -60,8 +61,6 @@ import java.util.concurrent.Callable;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLegacy;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class MongoDBBacking extends AbstractBacking { public class MongoDBBacking extends AbstractBacking {
@ -644,4 +643,12 @@ public class MongoDBBacking extends AbstractBacking {
return null; return null;
}, null); }, null);
} }
public static Map<String, Boolean> exportToLegacy(Iterable<Node> nodes) {
Map<String, Boolean> m = new HashMap<>();
for (Node node : nodes) {
m.put(node.toSerializedNode(), node.getValue());
}
return m;
}
} }