Move all messages to one class
This commit is contained in:
parent
2413f0f379
commit
f803082b15
@ -12,6 +12,7 @@ import me.lucko.luckperms.commands.misc.InfoCommand;
|
||||
import me.lucko.luckperms.commands.misc.SyncCommand;
|
||||
import me.lucko.luckperms.commands.user.UserMainCommand;
|
||||
import me.lucko.luckperms.commands.user.subcommands.*;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -105,7 +106,7 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
private void sendCommandUsage(Sender sender) {
|
||||
Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6.");
|
||||
Messages.INFO_BRIEF.send(sender, plugin.getVersion());
|
||||
|
||||
mainCommands.stream()
|
||||
.filter(c -> c.canUse(sender))
|
||||
|
@ -3,6 +3,7 @@ package me.lucko.luckperms.commands;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -33,7 +34,7 @@ public abstract class MainCommand {
|
||||
}
|
||||
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
|
||||
Messages.COMMAND_NO_PERMISSION.send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.lucko.luckperms.commands;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.lucko.luckperms.commands.group;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -21,13 +25,13 @@ public class CreateGroupCommand extends MainCommand {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (success) {
|
||||
Util.sendPluginMessage(sender, "That group already exists!");
|
||||
Messages.GROUP_ALREADY_EXISTS.send(sender);
|
||||
} else {
|
||||
plugin.getDatastore().createAndLoadGroup(groupName, success1 -> {
|
||||
if (!success1) {
|
||||
Util.sendPluginMessage(sender, "There was an error whilst creating the group.");
|
||||
Messages.CREATE_GROUP_ERROR.send(sender);
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "&b" + groupName + "&a was successfully created.");
|
||||
Messages.CREATE_GROUP_SUCCESS.send(sender, groupName);
|
||||
plugin.runUpdateTask();
|
||||
}
|
||||
});
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.lucko.luckperms.commands.group;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -22,24 +26,24 @@ public class DeleteGroupCommand extends MainCommand {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (groupName.equalsIgnoreCase(plugin.getConfiguration().getDefaultGroupName())) {
|
||||
Util.sendPluginMessage(sender, "You cannot delete the default group.");
|
||||
Messages.DELETE_GROUP_ERROR_DEFAULT.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, "That group does not exist!");
|
||||
Messages.GROUP_DOES_NOT_EXIST.send(sender);
|
||||
} else {
|
||||
|
||||
Group group = plugin.getGroupManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
Util.sendPluginMessage(sender, "An unexpected error occurred. Group not loaded.");
|
||||
Messages.GROUP_LOAD_ERROR.send(sender);
|
||||
} else {
|
||||
plugin.getDatastore().deleteGroup(group, success1 -> {
|
||||
if (!success1) {
|
||||
Util.sendPluginMessage(sender, "There was an error whilst deleting the group.");
|
||||
Messages.DELETE_GROUP_ERROR.send(sender);
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "&b" + groupName + "&a was successfully deleted.");
|
||||
Messages.DELETE_GROUP_SUCCESS.send(sender, groupName);
|
||||
plugin.runUpdateTask();
|
||||
}
|
||||
});
|
||||
|
@ -4,7 +4,7 @@ import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -29,13 +29,13 @@ public class GroupMainCommand extends MainCommand {
|
||||
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.");
|
||||
Messages.COMMAND_NOT_RECOGNISED.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final GroupSubCommand sub = o.get();
|
||||
if (!sub.isAuthorized(sender)) {
|
||||
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
|
||||
Messages.COMMAND_NO_PERMISSION.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -47,13 +47,13 @@ public class GroupMainCommand extends MainCommand {
|
||||
final String groupName = args.get(0).toLowerCase();
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, "&eGroup could not be found.");
|
||||
Messages.GROUP_NOT_FOUND.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
Util.sendPluginMessage(sender, "&eGroup could not be found.");
|
||||
Messages.GROUP_NOT_FOUND.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,9 +19,9 @@ public abstract class GroupSubCommand extends SubCommand {
|
||||
protected void saveGroup(Group group, Sender sender, LuckPermsPlugin plugin) {
|
||||
plugin.getDatastore().saveGroup(group, success -> {
|
||||
if (success) {
|
||||
Util.sendPluginMessage(sender, "&7(Group data was saved to the datastore)");
|
||||
Messages.GROUP_SAVE_SUCCESS.send(sender);
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "There was an error whilst saving the group.");
|
||||
Messages.GROUP_SAVE_ERROR.send(sender);
|
||||
}
|
||||
|
||||
plugin.runUpdateTask();
|
||||
|
@ -1,7 +1,12 @@
|
||||
package me.lucko.luckperms.commands.group;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -15,10 +20,9 @@ public class ListGroupsCommand extends MainCommand {
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
plugin.getDatastore().loadAllGroups(success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, "Unable to load all groups.");
|
||||
Messages.GROUPS_LOAD_ERROR.send(sender);
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "&aGroups: " +
|
||||
Util.listToCommaSep(new ArrayList<>(plugin.getGroupManager().getGroups().keySet())));
|
||||
Messages.GROUPS_LIST.send(sender, Util.listToCommaSep(new ArrayList<>(plugin.getGroupManager().getGroups().keySet())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
@ -17,7 +17,7 @@ public class GroupClearCommand extends GroupSubCommand {
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
|
||||
group.clearNodes();
|
||||
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a's permissions were cleared.");
|
||||
Messages.CLEAR_SUCCESS.send(sender, group.getName());
|
||||
|
||||
saveGroup(group, sender, plugin);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,11 +16,7 @@ public class GroupInfoCommand extends GroupSubCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
|
||||
sender.sendMessage(Util.color(
|
||||
Util.PREFIX + "&d-> &eGroup: &6" + group.getName() + "\n" +
|
||||
Util.PREFIX + "&d-> &ePermissions: &6" + group.getNodes().keySet().size() + "\n" +
|
||||
Util.PREFIX + "&d-> &bUse &a/perms group " + group.getName() + " listnodes &bto see all permissions."
|
||||
));
|
||||
Messages.GROUP_INFO.send(sender, group.getName(), group.getNodes().keySet().size(), group.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,11 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
import java.util.List;
|
||||
@ -17,8 +18,7 @@ public class GroupListNodesCommand extends GroupSubCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, Group group, List<String> args) {
|
||||
Util.sendPluginMessage(sender, "&e" + group.getName() + "'s Nodes:");
|
||||
sender.sendMessage(Util.color(Util.nodesToString(group.getNodes())));
|
||||
Messages.LISTNODES.send(sender, group.getName(), Util.nodesToString(group.getNodes()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
@ -22,23 +22,21 @@ public class GroupSetInheritCommand extends GroupSubCommand {
|
||||
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, groupName + " does not exist!");
|
||||
Messages.GROUP_LOAD_ERROR.send(sender);
|
||||
} else {
|
||||
try {
|
||||
if (args.size() == 2) {
|
||||
final String server = args.get(1).toLowerCase();
|
||||
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.");
|
||||
Messages.GROUP_SETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server);
|
||||
} else {
|
||||
group.setPermission("group." + groupName, true);
|
||||
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a now inherits permissions from &b" +
|
||||
groupName + "&a.");
|
||||
Messages.GROUP_SETINHERIT_SUCCESS.send(sender, group.getName(), groupName);
|
||||
}
|
||||
|
||||
saveGroup(group, sender, plugin);
|
||||
} catch (ObjectAlreadyHasException e) {
|
||||
Util.sendPluginMessage(sender, group.getName() + " already inherits '" + groupName + "'.");
|
||||
Messages.GROUP_ALREADY_INHERITS.send(sender, group.getName(), groupName);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
@ -27,7 +27,7 @@ public class GroupSetPermissionCommand extends GroupSubCommand {
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
Util.sendPluginMessage(sender, "Use the inherit command instead of specifying the node.");
|
||||
Messages.GROUP_USE_INHERIT.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,16 +42,15 @@ public class GroupSetPermissionCommand extends GroupSubCommand {
|
||||
if (args.size() == 3) {
|
||||
final String server = args.get(2).toLowerCase();
|
||||
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.");
|
||||
Messages.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, group.getName(), server);
|
||||
} else {
|
||||
group.setPermission(node, b);
|
||||
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + group.getName() + "&a.");
|
||||
Messages.SETPERMISSION_SUCCESS.send(sender, node, bool, group.getName());
|
||||
}
|
||||
|
||||
saveGroup(group, sender, plugin);
|
||||
} catch (ObjectAlreadyHasException e) {
|
||||
Util.sendPluginMessage(sender, group.getName() + " already has this permission!");
|
||||
Messages.ALREADY_HASPERMISSION.send(sender, group.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
@ -26,7 +26,7 @@ public class GroupUnSetPermissionCommand extends GroupSubCommand {
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
Util.sendPluginMessage(sender, "Use the unsetinherit command instead of specifying the node.");
|
||||
Messages.GROUP_USE_UNINHERIT.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,16 +34,15 @@ public class GroupUnSetPermissionCommand extends GroupSubCommand {
|
||||
if (args.size() == 2) {
|
||||
final String server = args.get(1).toLowerCase();
|
||||
group.unsetPermission(node, server);
|
||||
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + group.getName() + "&a on server &b" +
|
||||
server + "&a.");
|
||||
Messages.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, group.getName(), server);
|
||||
} else {
|
||||
group.unsetPermission(node);
|
||||
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + group.getName() + "&a.");
|
||||
Messages.UNSETPERMISSION_SUCCESS.send(sender, node, group.getName());
|
||||
}
|
||||
|
||||
saveGroup(group, sender, plugin);
|
||||
} catch (ObjectLacksPermissionException e) {
|
||||
Util.sendPluginMessage(sender, "That group does not have this permission set.");
|
||||
Messages.DOES_NOT_HAVEPERMISSION.send(sender, group.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.group.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.group.GroupSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
|
||||
@ -24,17 +24,15 @@ public class GroupUnsetInheritCommand extends GroupSubCommand {
|
||||
if (args.size() == 2) {
|
||||
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.");
|
||||
Messages.GROUP_UNSETINHERIT_SERVER_SUCCESS.send(sender, group.getName(), groupName, server);
|
||||
} else {
|
||||
group.unsetPermission("group." + groupName);
|
||||
Util.sendPluginMessage(sender, "&b" + group.getName() + "&a no longer inherits permissions from &b" +
|
||||
groupName + "&a.");
|
||||
Messages.GROUP_UNSETINHERIT_SUCCESS.send(sender, group.getName(), groupName);
|
||||
}
|
||||
|
||||
saveGroup(group, sender, plugin);
|
||||
} catch (ObjectLacksPermissionException e) {
|
||||
Util.sendPluginMessage(sender, "That group does not inherit '" + groupName + "'.");
|
||||
Messages.GROUP_DOES_NOT_INHERIT.send(sender, group.getName(), groupName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.lucko.luckperms.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -13,10 +17,9 @@ public class DebugCommand extends MainCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
Util.sendPluginMessage(sender, "&d&l> &dDebug Info");
|
||||
Util.sendPluginMessage(sender, "&eOnline Players: &6" + plugin.getPlayerCount());
|
||||
Util.sendPluginMessage(sender, "&eLoaded Users: &6" + plugin.getUserManager().getUsers().size());
|
||||
Util.sendPluginMessage(sender, "&eLoaded Groups: &6" + plugin.getGroupManager().getGroups().size());
|
||||
Messages.DEBUG.send(sender, plugin.getPlayerCount(), plugin.getUserManager().getUsers().size(),
|
||||
plugin.getGroupManager().getGroups().size()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.lucko.luckperms.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -13,9 +17,7 @@ public class InfoCommand extends MainCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
Util.sendPluginMessage(sender, "&6Running &bLuckPerms " + plugin.getVersion() + "&6.");
|
||||
Util.sendPluginMessage(sender, "&eAuthor: &6Luck");
|
||||
Util.sendPluginMessage(sender, "&eStorage Method: &6" + plugin.getDatastore().getName());
|
||||
Messages.INFO.send(sender, plugin.getVersion(), plugin.getDatastore().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.lucko.luckperms.commands.misc;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.*;
|
||||
import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -13,7 +17,7 @@ public class SyncCommand extends MainCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
Util.sendPluginMessage(sender, "&bRunning update task for all online users.");
|
||||
Messages.UPDATE_TASK_RUN.send(sender);
|
||||
plugin.runUpdateTask();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import me.lucko.luckperms.commands.MainCommand;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -30,13 +31,13 @@ public class UserMainCommand extends MainCommand{
|
||||
Optional<UserSubCommand> o = subCommands.stream().filter(s -> s.getName().equalsIgnoreCase(args.get(1))).limit(1).findAny();
|
||||
|
||||
if (!o.isPresent()) {
|
||||
Util.sendPluginMessage(sender, "Command not recognised.");
|
||||
Messages.COMMAND_NOT_RECOGNISED.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
final UserSubCommand sub = o.get();
|
||||
if (!sub.isAuthorized(sender)) {
|
||||
Util.sendPluginMessage(sender, "You do not have permission to use this command!");
|
||||
Messages.COMMAND_NO_PERMISSION.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -54,11 +55,11 @@ public class UserMainCommand extends MainCommand{
|
||||
}
|
||||
|
||||
if (user.length() <= 16) {
|
||||
Util.sendPluginMessage(sender, "&7(Attempting UUID lookup, since you specified a user)");
|
||||
Messages.USER_ATTEMPTING_LOOKUP.send(sender);
|
||||
|
||||
plugin.getDatastore().getUUID(user, uuid -> {
|
||||
if (uuid == null) {
|
||||
Util.sendPluginMessage(sender, "&eUser could not be found.");
|
||||
Messages.USER_NOT_FOUND.send(sender);
|
||||
return;
|
||||
}
|
||||
runSub(plugin, sender, uuid, sub, strippedArgs);
|
||||
@ -66,19 +67,19 @@ public class UserMainCommand extends MainCommand{
|
||||
return;
|
||||
}
|
||||
|
||||
Util.sendPluginMessage(sender, "&d" + user + "&c is not a valid username/uuid.");
|
||||
Messages.USER_INVALID_ENTRY.send(sender, user);
|
||||
}
|
||||
|
||||
private void runSub(LuckPermsPlugin plugin, Sender sender, UUID uuid, UserSubCommand command, List<String> strippedArgs) {
|
||||
plugin.getDatastore().loadUser(uuid, success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, "&eUser could not be found.");
|
||||
Messages.USER_NOT_FOUND.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
User user = plugin.getUserManager().getUser(uuid);
|
||||
if (user == null) {
|
||||
Util.sendPluginMessage(sender, "&eUser could not be found.");
|
||||
Messages.USER_NOT_FOUND.send(sender);
|
||||
}
|
||||
|
||||
if (command.isArgLengthInvalid(strippedArgs.size())) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.SubCommand;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -21,9 +21,9 @@ public abstract class UserSubCommand extends SubCommand {
|
||||
|
||||
plugin.getDatastore().saveUser(user, success -> {
|
||||
if (success) {
|
||||
Util.sendPluginMessage(sender, "&7(User data was saved to the datastore)");
|
||||
Messages.USER_SAVE_SUCCESS.send(sender);
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "There was an error whilst saving the user.");
|
||||
Messages.USER_SAVE_ERROR.send(sender);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.users.User;
|
||||
@ -22,11 +22,11 @@ public class UserAddGroupCommand extends UserSubCommand {
|
||||
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, groupName + " does not exist!");
|
||||
Messages.GROUP_DOES_NOT_EXIST.send(sender);
|
||||
} else {
|
||||
Group group = plugin.getGroupManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
Util.sendPluginMessage(sender, "That group does not exist!");
|
||||
Messages.GROUP_DOES_NOT_EXIST.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,17 +34,15 @@ public class UserAddGroupCommand extends UserSubCommand {
|
||||
if (args.size() == 2) {
|
||||
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.");
|
||||
Messages.USER_ADDGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
|
||||
} else {
|
||||
user.addGroup(group);
|
||||
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a successfully added to group &b" +
|
||||
groupName + "&a.");
|
||||
Messages.USER_ADDGROUP_SUCCESS.send(sender, user.getName(), groupName);
|
||||
}
|
||||
|
||||
saveUser(user, sender, plugin);
|
||||
} catch (ObjectAlreadyHasException e) {
|
||||
Util.sendPluginMessage(sender, "The user is already a member of that group.");
|
||||
Messages.USER_ALREADY_MEMBER_OF.send(sender, user.getName(), group.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -18,7 +18,7 @@ public class UserClearCommand extends UserSubCommand {
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
user.clearNodes();
|
||||
plugin.getUserManager().giveDefaults(user);
|
||||
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a's permissions were cleared.");
|
||||
Messages.CLEAR_SUCCESS.send(sender, user.getName());
|
||||
|
||||
saveUser(user, sender, plugin);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,7 +16,7 @@ public class UserGetUUIDCommand extends UserSubCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
Util.sendPluginMessage(sender, "&bThe UUID of &e" + user.getName() + "&b is &e" + user.getUuid().toString() + "&b.");
|
||||
Messages.USER_GETUUID.send(sender, user.getName(), user.getUuid().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,10 +1,11 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,15 +17,10 @@ public class UserInfoCommand extends UserSubCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
sender.sendMessage(Util.color(
|
||||
Util.PREFIX + "&d-> &eUser: &6" + user.getName() + "\n" +
|
||||
Util.PREFIX + "&d-> &eUUID: &6" + user.getUuid() + "\n" +
|
||||
Util.PREFIX + "&d-> &eStatus: " + plugin.getPlayerStatus(user.getUuid()) + "\n" +
|
||||
Util.PREFIX + "&d-> &eGroups: &6" + Util.listToCommaSep(user.getGroupNames()) + "\n" +
|
||||
Util.PREFIX + "&d-> &ePrimary Group: &6" + user.getPrimaryGroup() + "\n" +
|
||||
Util.PREFIX + "&d-> &ePermissions: &6" + (user.getNodes().keySet().size() - user.getGroupNames().size()) + "\n" +
|
||||
Util.PREFIX + "&d-> &bUse &a/perms user " + user.getName() + " listnodes &bto see all permissions."
|
||||
));
|
||||
Messages.USER_INFO.send(sender, user.getName(), user.getUuid(), plugin.getPlayerStatus(user.getUuid()),
|
||||
Util.listToCommaSep(user.getGroupNames()), user.getPrimaryGroup(),
|
||||
(user.getNodes().keySet().size() - user.getGroupNames().size()), user.getName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,11 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,8 +17,7 @@ public class UserListNodesCommand extends UserSubCommand {
|
||||
|
||||
@Override
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
Util.sendPluginMessage(sender, "&e" + user.getName() + "'s Nodes:");
|
||||
sender.sendMessage(Util.color(Util.nodesToString(user.getNodes())));
|
||||
Messages.LISTNODES.send(sender, user.getName(), Util.nodesToString(user.getNodes()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,12 +1,11 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
import java.util.List;
|
||||
@ -20,40 +19,26 @@ public class UserRemoveGroupCommand extends UserSubCommand {
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
plugin.getDatastore().loadGroup(groupName, success -> {
|
||||
if (!success) {
|
||||
Util.sendPluginMessage(sender, groupName + " does not exist!");
|
||||
if ((args.size() == 1 || (args.size() == 2 && args.get(1).equalsIgnoreCase("global")))
|
||||
&& user.getPrimaryGroup().equalsIgnoreCase(groupName)) {
|
||||
Messages.USER_REMOVEGROUP_ERROR_PRIMARY.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.size() == 2) {
|
||||
final String server = args.get(1).toLowerCase();
|
||||
user.unsetPermission("group." + groupName, server);
|
||||
Messages.USER_REMOVEGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server);
|
||||
} else {
|
||||
Group group = plugin.getGroupManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
Util.sendPluginMessage(sender, "That group does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.size() == 2) {
|
||||
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) {
|
||||
Util.sendPluginMessage(sender, "The user is not a member of that group.");
|
||||
}
|
||||
user.unsetPermission("group." + groupName);
|
||||
Messages.USER_REMOVEGROUP_SUCCESS.send(sender, user.getName(), groupName);
|
||||
}
|
||||
});
|
||||
|
||||
saveUser(user, sender, plugin);
|
||||
} catch (ObjectLacksPermissionException e) {
|
||||
Messages.USER_NOT_MEMBER_OF.send(sender, user.getName(), groupName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
@ -27,7 +27,7 @@ public class UserSetPermissionCommand extends UserSubCommand {
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
Util.sendPluginMessage(sender, "Use the addgroup command instead of specifying the node.");
|
||||
Messages.USER_USE_ADDGROUP.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,16 +42,15 @@ public class UserSetPermissionCommand extends UserSubCommand {
|
||||
if (args.size() == 3) {
|
||||
final String server = args.get(2).toLowerCase();
|
||||
user.setPermission(node, b, server);
|
||||
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + user.getName() +
|
||||
"&a on server &b" + server + "&a.");
|
||||
Messages.SETPERMISSION_SERVER_SUCCESS.send(sender, node, bool, user.getName(), server);
|
||||
} else {
|
||||
user.setPermission(node, b);
|
||||
Util.sendPluginMessage(sender, "&aSet &b" + node + "&a to " + bool + " for &b" + user.getName() + "&a.");
|
||||
Messages.SETPERMISSION_SUCCESS.send(sender, node, bool, user.getName());
|
||||
}
|
||||
|
||||
saveUser(user, sender, plugin);
|
||||
} catch (ObjectAlreadyHasException e) {
|
||||
Util.sendPluginMessage(sender, "That user already has this permission!");
|
||||
Messages.ALREADY_HASPERMISSION.send(sender, user.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
@ -20,22 +20,22 @@ public class UserSetPrimaryGroupCommand extends UserSubCommand {
|
||||
protected void execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args) {
|
||||
Group group = plugin.getGroupManager().getGroup(args.get(0).toLowerCase());
|
||||
if (group == null) {
|
||||
Util.sendPluginMessage(sender, "That group does not exist!");
|
||||
Messages.GROUP_DOES_NOT_EXIST.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.getPrimaryGroup().equalsIgnoreCase(group.getName())) {
|
||||
Util.sendPluginMessage(sender, "The user already has this group set as their primary group.");
|
||||
Messages.USER_PRIMARYGROUP_ERROR_ALREADYHAS.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.isInGroup(group)) {
|
||||
Util.sendPluginMessage(sender, "The user must be a member of the group first! Use &4/perms user <user> addgroup <group>");
|
||||
Messages.USER_PRIMARYGROUP_ERROR_NOTMEMBER.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setPrimaryGroup(group.getName());
|
||||
Util.sendPluginMessage(sender, "&b" + user.getName() + "&a's primary group was set to &b" + group.getName() + "&a.");
|
||||
Messages.USER_PRIMARYGROUP_SUCCESS.send(sender, user.getName(), group.getName());
|
||||
|
||||
saveUser(user, sender, plugin);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.lucko.luckperms.commands.user.subcommands;
|
||||
|
||||
import me.lucko.luckperms.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.commands.Permission;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
import me.lucko.luckperms.commands.user.UserSubCommand;
|
||||
import me.lucko.luckperms.constants.Messages;
|
||||
import me.lucko.luckperms.constants.Permission;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.users.User;
|
||||
|
||||
@ -26,7 +26,7 @@ public class UserUnSetPermissionCommand extends UserSubCommand {
|
||||
}
|
||||
|
||||
if (node.matches("group\\..*")) {
|
||||
Util.sendPluginMessage(sender, "Use the removegroup command instead of specifying the node.");
|
||||
Messages.USER_USE_REMOVEGROUP.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,16 +34,15 @@ public class UserUnSetPermissionCommand extends UserSubCommand {
|
||||
if (args.size() == 2) {
|
||||
final String server = args.get(1).toLowerCase();
|
||||
user.unsetPermission(node, server);
|
||||
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + user.getName() + "&a on server &b" +
|
||||
server + "&a.");
|
||||
Messages.UNSETPERMISSION_SERVER_SUCCESS.send(sender, node, user.getName(), server);
|
||||
} else {
|
||||
user.unsetPermission(node);
|
||||
Util.sendPluginMessage(sender, "&aUnset &b" + node + "&a for &b" + user.getName() + "&a.");
|
||||
Messages.UNSETPERMISSION_SUCCESS.send(sender, node, user.getName());
|
||||
}
|
||||
|
||||
saveUser(user, sender, plugin);
|
||||
} catch (ObjectLacksPermissionException e) {
|
||||
Util.sendPluginMessage(sender, "That user does not have this permission set.");
|
||||
Messages.DOES_NOT_HAVEPERMISSION.send(sender, user.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
123
common/src/main/java/me/lucko/luckperms/constants/Messages.java
Normal file
123
common/src/main/java/me/lucko/luckperms/constants/Messages.java
Normal file
@ -0,0 +1,123 @@
|
||||
package me.lucko.luckperms.constants;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@AllArgsConstructor
|
||||
public enum Messages {
|
||||
|
||||
PREFIX("&7&l[&b&lL&a&lP&7&l] &c", false),
|
||||
|
||||
COMMAND_NOT_RECOGNISED("Command not recognised.", true),
|
||||
COMMAND_NO_PERMISSION("You do not have permission to use this command!", true),
|
||||
INFO_BRIEF("&6Running &bLuckPerms %s&6.", true),
|
||||
|
||||
|
||||
ALREADY_HASPERMISSION("%s already has this permission!", true),
|
||||
DOES_NOT_HAVEPERMISSION("%s does not have this permission set.", true),
|
||||
|
||||
USER_NOT_FOUND("&eUser could not be found.", true),
|
||||
USER_SAVE_SUCCESS("&7(User data was saved to the datastore)", true),
|
||||
USER_SAVE_ERROR("There was an error whilst saving the user.", true),
|
||||
USER_ALREADY_MEMBER_OF("%s is already a member of '%s'.", true),
|
||||
USER_NOT_MEMBER_OF("%s is not a member of '%s'.", true),
|
||||
USER_USE_ADDGROUP("Use the addgroup command instead of specifying the node.", true),
|
||||
USER_USE_REMOVEGROUP("Use the removegroup command instead of specifying the node.", true),
|
||||
|
||||
GROUP_NOT_FOUND("&eGroup could not be found.", true),
|
||||
GROUP_SAVE_SUCCESS("&7(Group data was saved to the datastore)", true),
|
||||
GROUP_SAVE_ERROR("There was an error whilst saving the group.", true),
|
||||
GROUP_ALREADY_INHERITS("%s already inherits '%s'.", true),
|
||||
GROUP_DOES_NOT_INHERIT("%s does not inherit '%s'.", true),
|
||||
GROUP_USE_INHERIT("Use the setinherit command instead of specifying the node.", true),
|
||||
GROUP_USE_UNINHERIT("Use the unsetinherit command instead of specifying the node.", true),
|
||||
|
||||
|
||||
USER_ATTEMPTING_LOOKUP("&7(Attempting UUID lookup, since you specified a user)", true),
|
||||
USER_INVALID_ENTRY("&d%s&c is not a valid username/uuid.", true),
|
||||
|
||||
GROUP_ALREADY_EXISTS("That group already exists!", true),
|
||||
GROUP_DOES_NOT_EXIST("That group does not exist!", true),
|
||||
|
||||
GROUP_LOAD_ERROR("An unexpected error occurred. Group not loaded.", true),
|
||||
GROUPS_LOAD_ERROR("An unexpected error occurred. Unable to load all groups.", true),
|
||||
|
||||
|
||||
UPDATE_TASK_RUN("&bRunning update task for all online users.", true),
|
||||
INFO(
|
||||
PREFIX + "&6Running &bLuckPerms %s&6." + "\n" +
|
||||
PREFIX + "&eAuthor: &6Luck" + "\n" +
|
||||
PREFIX + "&eStorage Method: &6%s",
|
||||
false
|
||||
),
|
||||
DEBUG(
|
||||
PREFIX + "&d&l> &dDebug Info" + "\n" +
|
||||
PREFIX + "&eOnline Players: &6%s" + "\n" +
|
||||
PREFIX + "&eLoaded Users: &6%s" + "\n" +
|
||||
PREFIX + "&eLoaded Groups: &6%s",
|
||||
false
|
||||
),
|
||||
|
||||
CREATE_GROUP_ERROR("There was an error whilst creating the group.", true),
|
||||
CREATE_GROUP_SUCCESS("&b%s&a was successfully created.", true),
|
||||
DELETE_GROUP_ERROR("There was an error whilst deleting the group.", true),
|
||||
DELETE_GROUP_ERROR_DEFAULT("You cannot delete the default group.", true),
|
||||
DELETE_GROUP_SUCCESS("&b%s&a was successfully deleted.", true),
|
||||
GROUPS_LIST("&aGroups: %s", true),
|
||||
|
||||
LISTNODES("&e%s's Nodes:" + "\n" + "%s", true),
|
||||
SETPERMISSION_SUCCESS("&aSet &b%s&a to &b%s&a for &b%s&a.", true),
|
||||
SETPERMISSION_SERVER_SUCCESS("&aSet &b%s&a to &b%s&a for &b%s&a on server &b%s&a.", true),
|
||||
UNSETPERMISSION_SUCCESS("&aUnset &b%s&a for &b%s&a.", true),
|
||||
UNSETPERMISSION_SERVER_SUCCESS("&aUnset &b%s&a for &b%s&a on server &b%$s&a.", true),
|
||||
CLEAR_SUCCESS("&b%s&a's permissions were cleared.", true),
|
||||
|
||||
USER_INFO(
|
||||
PREFIX + "&d-> &eUser: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &eUUID: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &eStatus: %s" + "\n" +
|
||||
PREFIX + "&d-> &eGroups: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &ePrimary Group: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &ePermissions: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &bUse &a/perms user %s listnodes &bto see all permissions.",
|
||||
false
|
||||
),
|
||||
USER_GETUUID("&bThe UUID of &e%s&b is &e%s&b.", true),
|
||||
USER_ADDGROUP_SUCCESS("&b%s&a successfully added to group &b%s&a.", true),
|
||||
USER_ADDGROUP_SERVER_SUCCESS("&b%s&a successfully added to group &b%s&a on server &b%s&a.", true),
|
||||
USER_REMOVEGROUP_SUCCESS("&b%s&a was removed from group &b%s&a.", true),
|
||||
USER_REMOVEGROUP_SERVER_SUCCESS("&b%s&a was removed from group &b%s&a on server &b%s&a.", true),
|
||||
USER_REMOVEGROUP_ERROR_PRIMARY("You cannot remove a user from their primary group.", true),
|
||||
USER_PRIMARYGROUP_SUCCESS("&b%s&a's primary group was set to &b%s&a.", true),
|
||||
USER_PRIMARYGROUP_ERROR_ALREADYHAS("The user already has this group set as their primary group.", true),
|
||||
USER_PRIMARYGROUP_ERROR_NOTMEMBER("The user must be a member of the group first! Use &4/perms user <user> addgroup <group>", true),
|
||||
|
||||
GROUP_INFO(
|
||||
PREFIX + "&d-> &eGroup: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &ePermissions: &6%s" + "\n" +
|
||||
PREFIX + "&d-> &bUse &a/perms group %s listnodes &bto see all permissions.",
|
||||
false
|
||||
),
|
||||
GROUP_SETINHERIT_SUCCESS("&b%s&a now inherits permissions from &b%s&a.", true),
|
||||
GROUP_SETINHERIT_SERVER_SUCCESS("&b%s&a now inherits permissions from &b%s&a on server &b%s&a.", true),
|
||||
GROUP_UNSETINHERIT_SUCCESS("&b%s&a no longer inherits permissions from &b%s&a.", true),
|
||||
GROUP_UNSETINHERIT_SERVER_SUCCESS("&b%s&a no longer inherits permissions from &b%s&a on server &b%s&a.", true);
|
||||
|
||||
private String message;
|
||||
private boolean showPrefix;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void send(Sender sender, Object... objects) {
|
||||
if (showPrefix) {
|
||||
sender.sendMessage(Util.color(PREFIX + String.format(message, objects)));
|
||||
} else {
|
||||
sender.sendMessage(Util.color(String.format(message, objects)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package me.lucko.luckperms.commands;
|
||||
package me.lucko.luckperms.constants;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@AllArgsConstructor
|
||||
public enum Permission {
|
||||
|
Loading…
Reference in New Issue
Block a user