mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 13:45:20 +01:00
Convert promote / demote commands to use new context system, update en locale with latest changes
This commit is contained in:
parent
0504e904a2
commit
37b940f3a5
@ -42,16 +42,17 @@ server-invalid-entry: "Server names can only contain alphanumeric characters."
|
|||||||
use-inherit-command: "Use the 'parent add' and 'parent remove' commands instead of specifying the node."
|
use-inherit-command: "Use the 'parent add' and 'parent remove' commands instead of specifying the node."
|
||||||
verbose-invalid-filter: "&cInvalid verbose filter: &f{0}"
|
verbose-invalid-filter: "&cInvalid verbose filter: &f{0}"
|
||||||
verbose-on: "&bVerbose checking output set to &aTRUE &bfor all permissions."
|
verbose-on: "&bVerbose checking output set to &aTRUE &bfor all permissions."
|
||||||
verbose-on-query: "&bVerbose checking output set to &aTRUE &bfor permissions matching the following filters: &f{0}"
|
verbose-on-query: "&bVerbose checking output set to &aTRUE &bfor permissions matching filter: &f{0}"
|
||||||
verbose-off: "&bVerbose checking output set to &cFALSE&b."
|
verbose-off: "&bVerbose checking output set to &cFALSE&b."
|
||||||
verbose-recording-on: "&bVerbose recording set to &aTRUE &bfor all permissions."
|
verbose-recording-on: "&bVerbose recording set to &aTRUE &bfor all permissions."
|
||||||
verbose-recording-on-query: "&bVerbose recording set to &aTRUE &bfor permissions matching the following filters: &f{0}"
|
verbose-recording-on-query: "&bVerbose recording set to &aTRUE &bfor permissions matching filter: &f{0}"
|
||||||
verbose-recording-upload-start: "&bVerbose recording was disabled. Uploading results..."
|
verbose-recording-upload-start: "&bVerbose recording was disabled. Uploading results..."
|
||||||
verbose-recording-url: "&aVerbose results URL:"
|
verbose-recording-url: "&aVerbose results URL:"
|
||||||
tree-upload-start: "&bGenerating permission tree..."
|
tree-upload-start: "&bGenerating permission tree..."
|
||||||
tree-empty: "&aUnable to generate tree. No results were found."
|
tree-empty: "&aUnable to generate tree. No results were found."
|
||||||
tree-url: "&aPermission Tree URL:"
|
tree-url: "&aPermission Tree URL:"
|
||||||
search-searching: "&aSearching for users and groups with &b{0}&a..."
|
search-searching: "&aSearching for users and groups with &b{0}&a..."
|
||||||
|
search-searching-members: "&aSearching for users and groups who inherit from &b{0}&a..."
|
||||||
search-result: "&aFound &b{0}&a entries from &b{1}&a users and &b{2}&a groups."
|
search-result: "&aFound &b{0}&a entries from &b{1}&a users and &b{2}&a groups."
|
||||||
search-showing-users: "&bShowing user entries:"
|
search-showing-users: "&bShowing user entries:"
|
||||||
search-showing-groups: "&bShowing group entries:"
|
search-showing-groups: "&bShowing group entries:"
|
||||||
@ -189,6 +190,15 @@ set-meta-success: "&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &
|
|||||||
set-meta-temp-success: "&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a for a duration of &b{3}&a in context {4}&a."
|
set-meta-temp-success: "&aSet meta value for key &f\"{0}&f\"&a to &f\"{1}&f\"&a for &b{2}&a for a duration of &b{3}&a in context {4}&a."
|
||||||
unset-meta-success: "&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a."
|
unset-meta-success: "&aUnset meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a."
|
||||||
unset-meta-temp-success: "&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a."
|
unset-meta-temp-success: "&aUnset temporary meta value with key &f\"{0}&f\"&a for &b{1}&a in context {2}&a."
|
||||||
|
bulk-update-invalid-data-type: "Invalid type. Was expecting 'all', 'users' or 'groups'."
|
||||||
|
bulk-update-invalid-constraint: "Invalid constraint &4{0}&c. Constraints should be in the format '&f<field> <comparison operator> <value>&c'."
|
||||||
|
bulk-update-invalid-comparison: "Invalid comparison operator '&4{0}&c'. Expected one of the following: &f== != ~~ ~!"
|
||||||
|
bulk-update-queued: "&aBulk update operation was queued. &7(&f{0}&7)"
|
||||||
|
bulk-update-confirm: "&aRun &b/{0} bulkupdate confirm {1} &ato execute the update."
|
||||||
|
bulk-update-unknown-id: "&aOperation with id &b{0}&a does not exist or has expired."
|
||||||
|
bulk-update-starting: "&aRunning bulk update."
|
||||||
|
bulk-update-success: "&bBulk update completed successfully."
|
||||||
|
bulk-update-failure: "&cBulk update failed. Check the console for errors."
|
||||||
bulk-change-type-error: "Invalid type. Was expecting 'server' or 'world'."
|
bulk-change-type-error: "Invalid type. Was expecting 'server' or 'world'."
|
||||||
bulk-change-success: "&aApplied bulk change successfully. {0} records were changed."
|
bulk-change-success: "&aApplied bulk change successfully. {0} records were changed."
|
||||||
user-info-general: >
|
user-info-general: >
|
||||||
@ -217,19 +227,13 @@ user-primarygroup-warn-option: "&cWarning: The primary group calculation method
|
|||||||
user-primarygroup-error-alreadyhas: "The user already has this group set as their primary group."
|
user-primarygroup-error-alreadyhas: "The user already has this group set as their primary group."
|
||||||
user-primarygroup-error-notmember: "&b{0}&a was not already a member of &b{1}&a, adding them now."
|
user-primarygroup-error-notmember: "&b{0}&a was not already a member of &b{1}&a, adding them now."
|
||||||
user-track-error-not-contain-group: "The user specified isn't already in any groups on this track."
|
user-track-error-not-contain-group: "The user specified isn't already in any groups on this track."
|
||||||
user-track-added-to-first: "&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a."
|
user-track-added-to-first: "&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a in context {2}&a."
|
||||||
user-track-added-to-first-server: "&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a, on server &b{2}&a."
|
user-promote-success: "&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a in context {3}&a."
|
||||||
user-track-added-to-first-server-world: "&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a, on server &b{2}&a, world &b{3}&a."
|
|
||||||
user-promote-success: "&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a."
|
|
||||||
user-promote-success-server: "&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a."
|
|
||||||
user-promote-success-server-world: "&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a, world &b{4}&a."
|
|
||||||
user-promote-error-endoftrack: "The end of track &4{0}&c was reached. Unable to promote user."
|
user-promote-error-endoftrack: "The end of track &4{0}&c was reached. Unable to promote user."
|
||||||
user-promote-error-malformed: >
|
user-promote-error-malformed: >
|
||||||
{PREFIX}The next group on the track, {0}, no longer exists. Unable to promote user.\n
|
{PREFIX}The next group on the track, {0}, no longer exists. Unable to promote user.\n
|
||||||
{PREFIX}Either create the group, or remove it from the track and try again.
|
{PREFIX}Either create the group, or remove it from the track and try again.
|
||||||
user-demote-success: "&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a."
|
user-demote-success: "&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a in context {3}&a."
|
||||||
user-demote-success-server: "&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a."
|
|
||||||
user-demote-success-server-world: "&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a, world &b{4}&a."
|
|
||||||
user-demote-endoftrack: "The end of track &4{0}&c was reached, so &4{1}&c was removed from &4{2}&c."
|
user-demote-endoftrack: "The end of track &4{0}&c was reached, so &4{1}&c was removed from &4{2}&c."
|
||||||
user-demote-error-malformed: >
|
user-demote-error-malformed: >
|
||||||
{PREFIX}The previous group on the track, {0}, no longer exists. Unable to demote user.\n
|
{PREFIX}The previous group on the track, {0}, no longer exists. Unable to demote user.\n
|
||||||
|
@ -22,16 +22,14 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands.impl.user;
|
package me.lucko.luckperms.common.commands.impl.user;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.Arg;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||||
import me.lucko.luckperms.common.commands.utils.ContextHelper;
|
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
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;
|
||||||
@ -45,18 +43,16 @@ import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class UserDemote extends SubCommand<User> {
|
public class UserDemote extends SubCommand<User> {
|
||||||
public UserDemote() {
|
public UserDemote() {
|
||||||
super("demote", "Demotes the user down a track", Permission.USER_DEMOTE, Predicates.notInRange(1, 3),
|
super("demote", "Demotes the user down a track", Permission.USER_DEMOTE, Predicates.is(0),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("track", true, "the track to demote the user down"),
|
Arg.create("track", true, "the track to demote the user down"),
|
||||||
Arg.create("server", false, "the server to promote on"),
|
Arg.create("context...", false, "the contexts to demote the user in")
|
||||||
Arg.create("world", false, "the world to promote on")
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -85,32 +81,20 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String server = ArgumentUtils.handleServer(1, args);
|
MutableContextSet context = ArgumentUtils.handleContext(1, args);
|
||||||
String world = ArgumentUtils.handleWorld(2, args);
|
boolean silent = false;
|
||||||
|
|
||||||
|
if (args.contains("-s")) {
|
||||||
|
args.remove("-s");
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Load applicable groups
|
// Load applicable groups
|
||||||
Set<Node> nodes = new HashSet<>();
|
Set<Node> nodes = user.getNodes().values().stream()
|
||||||
for (Node node : user.getNodes().values()) {
|
.filter(Node::isGroupNode)
|
||||||
if (!node.isGroupNode()) {
|
.filter(Node::getValue)
|
||||||
continue;
|
.filter(node -> node.getFullContexts().makeImmutable().equals(context.makeImmutable()))
|
||||||
}
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (!node.getValue()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = node.getServer().orElse(null);
|
|
||||||
if (!Objects.equal(s, server)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String w = node.getWorld().orElse(null);
|
|
||||||
if (!Objects.equal(w, world)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.removeIf(g -> !track.containsGroup(g.getGroupName()));
|
nodes.removeIf(g -> !track.containsGroup(g.getGroupName()));
|
||||||
|
|
||||||
@ -161,28 +145,21 @@ public class UserDemote extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.unsetPermission(oldNode);
|
user.unsetPermission(oldNode);
|
||||||
user.setPermission(NodeFactory.newBuilder("group." + previousGroup.getName()).setServer(server).setWorld(world).build());
|
user.setPermission(NodeFactory.newBuilder("group." + previousGroup.getName()).withExtraContext(context).build());
|
||||||
|
|
||||||
if (server == null && world == null && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(old)) {
|
if (context.isEmpty() && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(old)) {
|
||||||
user.getPrimaryGroup().setStoredValue(previousGroup.getName());
|
user.getPrimaryGroup().setStoredValue(previousGroup.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ContextHelper.determine(server, world)) {
|
Message.USER_DEMOTE_SUCCESS.send(sender, track.getName(), old, previousGroup.getDisplayName(), Util.contextSetToString(context));
|
||||||
case NONE:
|
if (!silent) {
|
||||||
Message.USER_DEMOTE_SUCCESS.send(sender, track.getName(), old, previousGroup.getDisplayName());
|
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), previousGroup.getDisplayName(), old, true));
|
||||||
break;
|
|
||||||
case SERVER:
|
|
||||||
Message.USER_DEMOTE_SUCCESS_SERVER.send(sender, track.getName(), old, previousGroup.getDisplayName(), server);
|
|
||||||
break;
|
|
||||||
case SERVER_AND_WORLD:
|
|
||||||
Message.USER_DEMOTE_SUCCESS_SERVER_WORLD.send(sender, track.getName(), old, previousGroup.getDisplayName(), server, world);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), previousGroup.getDisplayName(), old, true));
|
|
||||||
LogEntry.build().actor(sender).acted(user)
|
LogEntry.build().actor(sender).acted(user)
|
||||||
.action("demote " + args.stream().collect(Collectors.joining(" ")))
|
.action("demote " + args.stream().collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserDemote(user, track, old, previousGroup.getName());
|
plugin.getApiProvider().getEventFactory().handleUserDemote(user, track, old, previousGroup.getName());
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
@ -22,16 +22,14 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.commands.impl.user;
|
package me.lucko.luckperms.common.commands.impl.user;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.common.commands.Arg;
|
import me.lucko.luckperms.common.commands.Arg;
|
||||||
import me.lucko.luckperms.common.commands.CommandException;
|
import me.lucko.luckperms.common.commands.CommandException;
|
||||||
import me.lucko.luckperms.common.commands.CommandResult;
|
import me.lucko.luckperms.common.commands.CommandResult;
|
||||||
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||||
import me.lucko.luckperms.common.commands.utils.ContextHelper;
|
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
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;
|
||||||
@ -45,18 +43,16 @@ import me.lucko.luckperms.common.utils.ArgumentChecker;
|
|||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class UserPromote extends SubCommand<User> {
|
public class UserPromote extends SubCommand<User> {
|
||||||
public UserPromote() {
|
public UserPromote() {
|
||||||
super("promote", "Promotes the user up a track", Permission.USER_PROMOTE, Predicates.notInRange(1, 3),
|
super("promote", "Promotes the user up a track", Permission.USER_PROMOTE, Predicates.is(0),
|
||||||
Arg.list(
|
Arg.list(
|
||||||
Arg.create("track", true, "the track to promote the user up"),
|
Arg.create("track", true, "the track to promote the user up"),
|
||||||
Arg.create("server", false, "the server to promote on"),
|
Arg.create("context...", false, "the contexts to promote the user in")
|
||||||
Arg.create("world", false, "the world to promote on")
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -85,32 +81,20 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
String server = ArgumentUtils.handleServer(1, args);
|
MutableContextSet context = ArgumentUtils.handleContext(1, args);
|
||||||
String world = ArgumentUtils.handleWorld(2, args);
|
boolean silent = false;
|
||||||
|
|
||||||
|
if (args.contains("-s")) {
|
||||||
|
args.remove("-s");
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Load applicable groups
|
// Load applicable groups
|
||||||
Set<Node> nodes = new HashSet<>();
|
Set<Node> nodes = user.getNodes().values().stream()
|
||||||
for (Node node : user.getNodes().values()) {
|
.filter(Node::isGroupNode)
|
||||||
if (!node.isGroupNode()) {
|
.filter(Node::getValue)
|
||||||
continue;
|
.filter(node -> node.getFullContexts().makeImmutable().equals(context.makeImmutable()))
|
||||||
}
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (!node.getValue()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = node.getServer().orElse(null);
|
|
||||||
if (!Objects.equal(s, server)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String w = node.getWorld().orElse(null);
|
|
||||||
if (!Objects.equal(w, world)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.removeIf(g -> !track.containsGroup(g.getGroupName()));
|
nodes.removeIf(g -> !track.containsGroup(g.getGroupName()));
|
||||||
|
|
||||||
@ -123,26 +107,14 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
return CommandResult.LOADING_ERROR;
|
return CommandResult.LOADING_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setPermission(NodeFactory.newBuilder("group." + first).setServer(server).setWorld(world).build());
|
user.setPermission(NodeFactory.newBuilder("group." + first).withExtraContext(context).build());
|
||||||
|
|
||||||
switch (ContextHelper.determine(server, world)) {
|
|
||||||
case NONE:
|
|
||||||
Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getName(), first);
|
|
||||||
break;
|
|
||||||
case SERVER:
|
|
||||||
Message.USER_TRACK_ADDED_TO_FIRST_SERVER.send(sender, user.getName(), first, server);
|
|
||||||
break;
|
|
||||||
case SERVER_AND_WORLD:
|
|
||||||
Message.USER_TRACK_ADDED_TO_FIRST_SERVER_WORLD.send(sender, user.getName(), first, server, world);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getName(), first, Util.contextSetToString(context));
|
||||||
LogEntry.build().actor(sender).acted(user)
|
LogEntry.build().actor(sender).acted(user)
|
||||||
.action("promote " + args.stream().collect(Collectors.joining(" ")))
|
.action("promote " + args.stream().collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
save(user, sender, plugin);
|
save(user, sender, plugin);
|
||||||
plugin.getApiProvider().getEventFactory().handleUserPromote(user, track, null, first);
|
plugin.getApiProvider().getEventFactory().handleUserPromote(user, track, null, first);
|
||||||
|
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,25 +150,17 @@ public class UserPromote extends SubCommand<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.unsetPermission(oldNode);
|
user.unsetPermission(oldNode);
|
||||||
user.setPermission(NodeFactory.newBuilder("group." + nextGroup.getName()).setServer(server).setWorld(world).build());
|
user.setPermission(NodeFactory.newBuilder("group." + nextGroup.getName()).withExtraContext(context).build());
|
||||||
|
|
||||||
if (server == null && world == null && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(old)) {
|
if (context.isEmpty() && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(old)) {
|
||||||
user.getPrimaryGroup().setStoredValue(nextGroup.getName());
|
user.getPrimaryGroup().setStoredValue(nextGroup.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ContextHelper.determine(server, world)) {
|
Message.USER_PROMOTE_SUCCESS.send(sender, track.getName(), old, nextGroup.getDisplayName(), Util.contextSetToString(context));
|
||||||
case NONE:
|
if (!silent) {
|
||||||
Message.USER_PROMOTE_SUCCESS.send(sender, track.getName(), old, nextGroup.getDisplayName());
|
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), old, nextGroup.getDisplayName(), false));
|
||||||
break;
|
|
||||||
case SERVER:
|
|
||||||
Message.USER_PROMOTE_SUCCESS_SERVER.send(sender, track.getName(), old, nextGroup.getDisplayName(), server);
|
|
||||||
break;
|
|
||||||
case SERVER_AND_WORLD:
|
|
||||||
Message.USER_PROMOTE_SUCCESS_SERVER_WORLD.send(sender, track.getName(), old, nextGroup.getDisplayName(), server, world);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Message.EMPTY.send(sender, Util.listToArrowSep(track.getGroups(), old, nextGroup.getDisplayName(), false));
|
|
||||||
LogEntry.build().actor(sender).acted(user)
|
LogEntry.build().actor(sender).acted(user)
|
||||||
.action("promote " + args.stream().collect(Collectors.joining(" ")))
|
.action("promote " + args.stream().collect(Collectors.joining(" ")))
|
||||||
.build().submit(plugin, sender);
|
.build().submit(plugin, sender);
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.common.commands.utils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility used to help in commands that take arguments for different contexts
|
|
||||||
*/
|
|
||||||
public class ContextHelper {
|
|
||||||
|
|
||||||
public static CommandContext determine(String server, String world) {
|
|
||||||
return server == null ? CommandContext.NONE : (world == null ? CommandContext.SERVER : CommandContext.SERVER_AND_WORLD);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CommandContext {
|
|
||||||
NONE, SERVER, SERVER_AND_WORLD
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -307,21 +307,17 @@ public enum Message {
|
|||||||
USER_PRIMARYGROUP_ERROR_ALREADYHAS("The user already has this group set as their primary group.", true),
|
USER_PRIMARYGROUP_ERROR_ALREADYHAS("The user already has this group set as their primary group.", true),
|
||||||
USER_PRIMARYGROUP_ERROR_NOTMEMBER("&b{0}&a was not already a member of &b{1}&a, adding them now.", true),
|
USER_PRIMARYGROUP_ERROR_NOTMEMBER("&b{0}&a was not already a member of &b{1}&a, adding them now.", true),
|
||||||
USER_TRACK_ERROR_NOT_CONTAIN_GROUP("The user specified isn't already in any groups on this track.", true),
|
USER_TRACK_ERROR_NOT_CONTAIN_GROUP("The user specified isn't already in any groups on this track.", true),
|
||||||
USER_TRACK_ADDED_TO_FIRST("&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a.", true),
|
|
||||||
USER_TRACK_ADDED_TO_FIRST_SERVER("&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a, on server &b{2}&a.", true),
|
USER_TRACK_ADDED_TO_FIRST("&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a in context {2}&a.", true),
|
||||||
USER_TRACK_ADDED_TO_FIRST_SERVER_WORLD("&b{0}&a isn't in any groups on this track, so they were added to the first group, &b{1}&a, on server &b{2}&a, world &b{3}&a.", true),
|
USER_PROMOTE_SUCCESS("&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a in context {3}&a.", true),
|
||||||
USER_PROMOTE_SUCCESS("&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a.", true),
|
|
||||||
USER_PROMOTE_SUCCESS_SERVER("&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a.", true),
|
|
||||||
USER_PROMOTE_SUCCESS_SERVER_WORLD("&aPromoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a, world &b{4}&a.", true),
|
|
||||||
USER_PROMOTE_ERROR_ENDOFTRACK("The end of track &4{0}&c was reached. Unable to promote user.", true),
|
USER_PROMOTE_ERROR_ENDOFTRACK("The end of track &4{0}&c was reached. Unable to promote user.", true),
|
||||||
USER_PROMOTE_ERROR_MALFORMED(
|
USER_PROMOTE_ERROR_MALFORMED(
|
||||||
"{PREFIX}The next group on the track, {0}, no longer exists. Unable to promote user." + "\n" +
|
"{PREFIX}The next group on the track, {0}, no longer exists. Unable to promote user." + "\n" +
|
||||||
"{PREFIX}Either create the group, or remove it from the track and try again.",
|
"{PREFIX}Either create the group, or remove it from the track and try again.",
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
USER_DEMOTE_SUCCESS("&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a.", true),
|
USER_DEMOTE_SUCCESS("&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a in context {3}&a.", true),
|
||||||
USER_DEMOTE_SUCCESS_SERVER("&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a.", true),
|
|
||||||
USER_DEMOTE_SUCCESS_SERVER_WORLD("&aDemoting user along track &b{0}&a from &b{1}&a to &b{2}&a on server &b{3}&a, world &b{4}&a.", true),
|
|
||||||
USER_DEMOTE_ENDOFTRACK("The end of track &4{0}&c was reached, so &4{1}&c was removed from &4{2}&c.", true),
|
USER_DEMOTE_ENDOFTRACK("The end of track &4{0}&c was reached, so &4{1}&c was removed from &4{2}&c.", true),
|
||||||
USER_DEMOTE_ERROR_MALFORMED(
|
USER_DEMOTE_ERROR_MALFORMED(
|
||||||
"{PREFIX}The previous group on the track, {0}, no longer exists. Unable to demote user." + "\n" +
|
"{PREFIX}The previous group on the track, {0}, no longer exists. Unable to demote user." + "\n" +
|
||||||
|
@ -63,7 +63,7 @@ import java.util.stream.Collectors;
|
|||||||
public abstract class FlatfileBacking extends AbstractBacking {
|
public abstract class FlatfileBacking extends AbstractBacking {
|
||||||
private static final String LOG_FORMAT = "%s(%s): [%s] %s(%s) --> %s";
|
private static final String LOG_FORMAT = "%s(%s): [%s] %s(%s) --> %s";
|
||||||
|
|
||||||
private final Logger actionLogger = Logger.getLogger("lp_actions");
|
private final Logger actionLogger = Logger.getLogger("luckperms_actions");
|
||||||
private Map<String, String> uuidCache = new ConcurrentHashMap<>();
|
private Map<String, String> uuidCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final File pluginDir;
|
private final File pluginDir;
|
||||||
|
Loading…
Reference in New Issue
Block a user