|
|
@ -63,10 +63,13 @@ public class CommandEntity |
|
|
|
if(entity == null && result == null) |
|
|
|
if(entity == null && result == null) |
|
|
|
throw new CommandAnswerException("{_LR}I don't know such name!"); |
|
|
|
throw new CommandAnswerException("{_LR}I don't know such name!"); |
|
|
|
if(args[1] == null) |
|
|
|
if(args[1] == null) |
|
|
|
args[1] = "help"; |
|
|
|
args[1] = "info"; |
|
|
|
final String targetName = args[0]; |
|
|
|
final String targetName = args[0]; |
|
|
|
switch(args[1].toLowerCase()) |
|
|
|
switch(args[1].toLowerCase()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
case "info": |
|
|
|
|
|
|
|
if(entity != null) |
|
|
|
|
|
|
|
throw new CommandAnswerException(showEntityDetails(entity)); |
|
|
|
case "help": |
|
|
|
case "help": |
|
|
|
throw new CommandAnswerException(getHelpForType(type)); |
|
|
|
throw new CommandAnswerException(getHelpForType(type)); |
|
|
|
case "prefix": |
|
|
|
case "prefix": |
|
|
@ -144,7 +147,7 @@ public class CommandEntity |
|
|
|
answer.add("There are following known groups in database:"); |
|
|
|
answer.add("There are following known groups in database:"); |
|
|
|
for(RowEntity group : groups) |
|
|
|
for(RowEntity group : groups) |
|
|
|
{ |
|
|
|
{ |
|
|
|
final String details = detailsAboutEntity(group); |
|
|
|
final String details = showEntityDetails(group); |
|
|
|
if(details != null) |
|
|
|
if(details != null) |
|
|
|
answer.add(details); |
|
|
|
answer.add(details); |
|
|
|
} |
|
|
|
} |
|
|
@ -157,102 +160,109 @@ public class CommandEntity |
|
|
|
answer.add("There are following known users in database:"); |
|
|
|
answer.add("There are following known users in database:"); |
|
|
|
for(RowEntity user : users) |
|
|
|
for(RowEntity user : users) |
|
|
|
{ |
|
|
|
{ |
|
|
|
final String details = detailsAboutEntity(user); |
|
|
|
final String details = showEntityDetails(user); |
|
|
|
if(details != null) |
|
|
|
if(details != null) |
|
|
|
answer.add(details); |
|
|
|
answer.add(details); |
|
|
|
} |
|
|
|
} |
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
} |
|
|
|
} |
|
|
|
private String detailsAboutEntity(RowEntity entity) |
|
|
|
private String showEntityDetails(RowEntity entity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
String name = entity.entity; |
|
|
|
final String name = entity.entity; |
|
|
|
if("".equals(name)) |
|
|
|
if("".equals(name)) |
|
|
|
// return null;
|
|
|
|
return null; |
|
|
|
name = "<WTF?!?>"; |
|
|
|
|
|
|
|
final StringBuilder sb = new StringBuilder(); |
|
|
|
final StringBuilder sb = new StringBuilder(); |
|
|
|
if(entity.splittedId != null) |
|
|
|
if(entity.splittedId != null) |
|
|
|
sb.append("{_WH}").append(entity.splittedId).append(" "); |
|
|
|
sb.append("{_WH}").append(entity.splittedId).append(" "); |
|
|
|
sb.append("{_YL}").append(name); |
|
|
|
sb.append("{_YL}").append(name); |
|
|
|
if(entity.prefix != null && !"".equals(entity.prefix)) |
|
|
|
final boolean isPrefix = entity.prefix != null && !"".equals(entity.prefix); |
|
|
|
sb.append("{_LS}, prefix \"").append(entity.prefix).append("{_LS}\""); |
|
|
|
final boolean isSuffix = entity.suffix != null && !"".equals(entity.suffix); |
|
|
|
if(entity.suffix != null && !"".equals(entity.suffix)) |
|
|
|
if(isPrefix || isSuffix) |
|
|
|
sb.append("{_LS}, suffix \"").append(entity.suffix).append("{_LS}\""); |
|
|
|
sb |
|
|
|
|
|
|
|
.append("{_R} {_LS}[\'") |
|
|
|
|
|
|
|
.append(isPrefix ? entity.prefix : "") |
|
|
|
|
|
|
|
.append("{_LS}\', \'") |
|
|
|
|
|
|
|
.append(isSuffix ? entity.suffix : "") |
|
|
|
|
|
|
|
.append("{_LS}\']"); |
|
|
|
if(entity.lifetime != null) |
|
|
|
if(entity.lifetime != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
final String lifetime = entity.lifetime.toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).replace("T", " "); |
|
|
|
final String lifetime = entity.lifetime |
|
|
|
|
|
|
|
.toLocalDateTime() |
|
|
|
|
|
|
|
.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) |
|
|
|
|
|
|
|
.replace("T", " "); |
|
|
|
sb.append("{_R} {_YL}").append(lifetime); |
|
|
|
sb.append("{_R} {_YL}").append(lifetime); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(entity.permissions != null && entity.permissions.length > 0) |
|
|
|
|
|
|
|
sb.append(String.format("{_R} {_LC}%d{_DC}p", entity.permissions.length)); |
|
|
|
|
|
|
|
if(entity.inheritance != null && entity.inheritance.length > 0) |
|
|
|
|
|
|
|
sb.append(String.format("{_R} {_LC}%d{_DC}i", entity.inheritance.length)); |
|
|
|
return sb.toString(); |
|
|
|
return sb.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
private void viewEntityPrefix(RowEntity entity) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Own prefix for " + (entity.entityType == EntityType.GROUP ? "group" : "user") |
|
|
|
|
|
|
|
+ " {_YL}" + entity.entity + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + (entity.prefix != null ? entity.prefix : "") + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void viewEntitySuffix(RowEntity entity) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Own suffix for " + (entity.entityType == EntityType.GROUP ? "group" : "user") |
|
|
|
|
|
|
|
+ " {_YL}" + entity.entity + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + (entity.suffix != null ? entity.suffix : "") + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void viewCalculatedPrefix(ResolutionResult result, String user) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(Matchers.isCorrectDashlessUUID(user)) |
|
|
|
|
|
|
|
user = Matchers.uuidAddDashes(user); |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Calculated prefix for user {_YL}" + user + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + result.getPrefix() + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void viewCalculatedSuffix(ResolutionResult result, String user) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(Matchers.isCorrectDashlessUUID(user)) |
|
|
|
|
|
|
|
user = Matchers.uuidAddDashes(user); |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Calculated suffix for user {_YL}" + user + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + result.getSuffix() + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void showEntityPermissions(RowEntity entity) throws CommandAnswerException |
|
|
|
private void showEntityPermissions(RowEntity entity) throws CommandAnswerException |
|
|
|
{ |
|
|
|
{ |
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
final String typeName = entity.entityType.name().toLowerCase(); |
|
|
|
final String typeName = entity.entityType.name().toLowerCase(); |
|
|
|
answer.add("Explicit permissions for " + typeName + " {_YL}" + entity.entity + "{_LS}:"); |
|
|
|
answer.add("Explicit permissions for " + typeName + " {_YL}" + entity.entity + "{_LS}:"); |
|
|
|
for(RowPermission permission : entity.permissions) |
|
|
|
for(RowPermission permission : entity.permissions) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final String details = showPermissionDetails(permission); |
|
|
|
|
|
|
|
if(details != null) |
|
|
|
|
|
|
|
answer.add(details); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private String showPermissionDetails(RowPermission row) |
|
|
|
{ |
|
|
|
{ |
|
|
|
final StringBuilder sb = new StringBuilder(); |
|
|
|
final StringBuilder sb = new StringBuilder(); |
|
|
|
sb.append("{_WH}").append(permission.splittedId); |
|
|
|
sb.append("{_WH}").append(row.splittedId); |
|
|
|
sb.append(permission.value ? " {_LG}" : " {_LR}").append(permission.permission); |
|
|
|
sb.append(row.value ? " {_LG}" : " {_LR}").append(row.permission); |
|
|
|
if(permission.destination != null) |
|
|
|
if(row.destination != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
final String destination = permission.destination.toString(); |
|
|
|
final String destination = row.destination.toString(); |
|
|
|
if(!"".equals(destination)) |
|
|
|
if(!"".equals(destination)) |
|
|
|
sb.append("{_R} {_LC}{_U}").append(destination); |
|
|
|
sb.append("{_R} {_LC}{_U}").append(destination); |
|
|
|
} |
|
|
|
} |
|
|
|
if(permission.expirience > 0) |
|
|
|
if(row.expirience > 0) |
|
|
|
sb.append("{_R} {_LB}").append(permission.expirience).append(" LVLs"); |
|
|
|
sb.append("{_R} {_LB}").append(row.expirience).append(" LVLs"); |
|
|
|
if(permission.lifetime != null) |
|
|
|
if(row.lifetime != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
final String lifetime = permission.lifetime.toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).replace("T", " "); |
|
|
|
final String lifetime = row.lifetime.toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).replace("T", " "); |
|
|
|
sb.append("{_R} {_YL}").append(lifetime); |
|
|
|
sb.append("{_R} {_YL}").append(lifetime); |
|
|
|
} |
|
|
|
} |
|
|
|
answer.add(sb.toString()); |
|
|
|
return sb.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
private void showEntityParents(RowEntity entity) throws CommandAnswerException |
|
|
|
private void showEntityParents(RowEntity entity) throws CommandAnswerException |
|
|
|
{ |
|
|
|
{ |
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
answer.add("Parent groups for " + entity.entityType.name().toLowerCase() + " {_YL}" + entity.entity + "{_LS}:"); |
|
|
|
answer.add("Explicit parent groups for " + entity.entityType.name().toLowerCase() + " {_YL}" + entity.entity + "{_LS}:"); |
|
|
|
for(RowInheritance parent : entity.inheritance) |
|
|
|
for(RowInheritance parent : entity.inheritance) |
|
|
|
answer.add("{_WH}" + parent.splittedId + " {_LG}" + parent.getParentWithInstance()); |
|
|
|
{ |
|
|
|
|
|
|
|
final String details = showInheritanceDetails(parent); |
|
|
|
|
|
|
|
if(details != null) |
|
|
|
|
|
|
|
answer.add(details); |
|
|
|
|
|
|
|
} |
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String showInheritanceDetails(RowInheritance row) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
|
|
sb.append("{_WH}").append(row.splittedId).append(" {_LG}").append(row.getParentWithInstance()); |
|
|
|
|
|
|
|
sb.append(String.format("{_R} {_DG}({_LG}%d{_DG})", row.priority)); |
|
|
|
|
|
|
|
if(row.destination != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final String destination = row.destination.toString(); |
|
|
|
|
|
|
|
if(!"".equals(destination)) |
|
|
|
|
|
|
|
sb.append("{_R} {_LC}{_U}").append(destination); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(row.expirience > 0) |
|
|
|
|
|
|
|
sb.append("{_R} {_LB}").append(row.expirience).append(" LVLs"); |
|
|
|
|
|
|
|
if(row.lifetime != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final String lifetime = row.lifetime.toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).replace("T", " "); |
|
|
|
|
|
|
|
sb.append("{_R} {_YL}").append(lifetime); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return sb.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
private void listFinalPlayerPermissions(ResolutionResult result, String user) throws CommandAnswerException |
|
|
|
private void listFinalPlayerPermissions(ResolutionResult result, String user) throws CommandAnswerException |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(Matchers.isCorrectDashlessUUID(user)) |
|
|
|
if(Matchers.isCorrectDashlessUUID(user)) |
|
|
@ -273,6 +283,40 @@ public class CommandEntity |
|
|
|
answer.add("{_LG}" + group); |
|
|
|
answer.add("{_LG}" + group); |
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void viewEntityPrefix(RowEntity entity) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Own prefix for " + (entity.entityType == EntityType.GROUP ? "group" : "user") |
|
|
|
|
|
|
|
+ " {_YL}" + entity.entity + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + (entity.prefix != null ? entity.prefix : "") + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void viewEntitySuffix(RowEntity entity) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Own suffix for " + (entity.entityType == EntityType.GROUP ? "group" : "user") |
|
|
|
|
|
|
|
+ " {_YL}" + entity.entity + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + (entity.suffix != null ? entity.suffix : "") + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void viewCalculatedPrefix(ResolutionResult result, String user) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(Matchers.isCorrectDashlessUUID(user)) |
|
|
|
|
|
|
|
user = Matchers.uuidAddDashes(user); |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Calculated prefix for user {_YL}" + user + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + result.getPrefix() + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void viewCalculatedSuffix(ResolutionResult result, String user) throws CommandAnswerException |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(Matchers.isCorrectDashlessUUID(user)) |
|
|
|
|
|
|
|
user = Matchers.uuidAddDashes(user); |
|
|
|
|
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
|
|
|
|
answer.add("Calculated suffix for user {_YL}" + user + "{_LS} is:"); |
|
|
|
|
|
|
|
answer.add("{_R}\"" + result.getSuffix() + "{_R}\""); |
|
|
|
|
|
|
|
throw new CommandAnswerException(answer); |
|
|
|
|
|
|
|
} |
|
|
|
private void addGroup(ResolutionResult result, String user, String parent, String destination, Integer seconds) throws CommandAnswerException |
|
|
|
private void addGroup(ResolutionResult result, String user, String parent, String destination, Integer seconds) throws CommandAnswerException |
|
|
|
{ |
|
|
|
{ |
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|
final ArrayList<String> answer = new ArrayList<>(); |
|
|
|