Merge pull request #30 from squareblob/dev

Split long permission descriptions over multiple lines
This commit is contained in:
Maxopoly
2020-07-28 05:57:29 +02:00
committed by GitHub
2 changed files with 13 additions and 5 deletions

View File

@@ -138,9 +138,17 @@ public class PermissionManageGUI extends AbstractGroupGUI {
ItemAPI.setDisplayName(is, perm.getName());
String desc = perm.getDescription();
if (desc != null) {
ItemAPI.addLore(is, ChatColor.GREEN + desc);
final int MAX_CHARS = 35;
String[] words = desc.split(" ");
StringBuilder line = new StringBuilder();
for (int i = 0; i < words.length; i++) {
line.append(words[i]).append(" ");
if (line.length() >= MAX_CHARS || i == words.length - 1){
ItemAPI.addLore(is, ChatColor.GREEN + line.toString().trim());
line = new StringBuilder();
}
}
}
if (pType == PlayerType.NOT_BLACKLISTED && !perm.getCanBeBlacklisted()) {
canEdit = false;

View File

@@ -95,17 +95,17 @@ public class PermissionType {
//allows adding/removing members
registerPermission("MEMBERS", new ArrayList<>(modAndAbove), "Allows inviting new members and removing existing members");
//allows blacklisting/unblacklisting players and viewing the blacklist
registerPermission("BLACKLIST", new ArrayList<>(modAndAbove), "Allows viewing this group's blacklist, adding players to the blacklist "
registerPermission("BLACKLIST", new ArrayList<>(modAndAbove), "Allows viewing this groups blacklist, adding players to the blacklist "
+ "and removing players from the blacklist");
//allows adding/removing mods
registerPermission("MODS", new ArrayList<>(adminAndAbove), "Allows inviting new mods and removing existing mods");
//allows adding/modifying a password for the group
registerPermission("PASSWORD", new ArrayList<>(adminAndAbove), "Allows viewing this groups password and changing or removing it");
//allows to list the permissions for each permission group
registerPermission("LIST_PERMS", new ArrayList<>(adminAndAbove), "Allows viewing how permission for this group are set up");
registerPermission("LIST_PERMS", new ArrayList<>(adminAndAbove), "Allows viewing how permissions for this group are set up");
//allows to see general group stats
registerPermission("GROUPSTATS", new ArrayList<>(adminAndAbove), "Gives access to various group statistics such as member "
+ "counts by permission type, who owns the group etc.");
+ "counts by permission type, who owns the group etc");
//allows to add/remove admins
registerPermission("ADMINS", new ArrayList<>(owner), "Allows inviting new admins and removing existing admins");
//allows to add/remove owners