mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-19 09:05:26 +01:00
Some fixes to how things look
This commit is contained in:
parent
a52e467e01
commit
33fb2c3011
@ -272,9 +272,9 @@ public class PlanCommand {
|
||||
|
||||
private Subcommand databaseCommand() {
|
||||
return CommandWithSubcommands.builder()
|
||||
.aliases("database", "db")
|
||||
.aliases("db", "database")
|
||||
.requirePermission("plan.data.base")
|
||||
.optionalArgument("[subcommand]", "Use the command without subcommand to see help.")
|
||||
.optionalArgument("subcommand", "Use the command without subcommand to see help.")
|
||||
.description("Manage Plan database")
|
||||
.colorScheme(colors)
|
||||
.subcommand(backupCommand())
|
||||
|
@ -170,14 +170,14 @@ public class DatabaseCommands {
|
||||
if (sender.supportsChatEvents()) {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getType().getName() + " with data in " + backupDBFile.toPath()).newLine()
|
||||
.addPart("Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept")
|
||||
.addPart(" ")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||
.send();
|
||||
} else {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getType().getName() + " with data in " + backupDBFile.toPath()).newLine()
|
||||
.addPart("Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(" ")
|
||||
.addPart("§c/" + mainCommand + " cancel")
|
||||
.send();
|
||||
@ -222,14 +222,14 @@ public class DatabaseCommands {
|
||||
if (sender.supportsChatEvents()) {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getName() + " with data in " + fromDB.getName()).newLine()
|
||||
.addPart("Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept")
|
||||
.addPart(" ")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||
.send();
|
||||
} else {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getName() + " with data in " + fromDB.getName()).newLine()
|
||||
.addPart("Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(" ")
|
||||
.addPart("§c/" + mainCommand + " cancel")
|
||||
.send();
|
||||
@ -277,14 +277,14 @@ public class DatabaseCommands {
|
||||
if (sender.supportsChatEvents()) {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to remove all Plan-data in " + fromDB.getName()).newLine()
|
||||
.addPart("Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept")
|
||||
.addPart(" ")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||
.send();
|
||||
} else {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to remove all Plan-data in " + fromDB.getName()).newLine()
|
||||
.addPart("Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(" ")
|
||||
.addPart("§c/" + mainCommand + " cancel")
|
||||
.send();
|
||||
@ -334,14 +334,14 @@ public class DatabaseCommands {
|
||||
if (sender.supportsChatEvents()) {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to remove data of " + playerUUID + " from " + database.getType().getName()).newLine()
|
||||
.addPart("Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept")
|
||||
.addPart(" ")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||
.send();
|
||||
} else {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to remove data of " + playerUUID + " from " + database.getType().getName()).newLine()
|
||||
.addPart("Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(" ")
|
||||
.addPart("§c/" + mainCommand + " cancel")
|
||||
.send();
|
||||
|
@ -78,11 +78,10 @@ public class LinkCommands {
|
||||
|
||||
MessageBuilder linkTo(MessageBuilder builder, CMDSender sender, String address) {
|
||||
if (sender.supportsChatEvents()) {
|
||||
builder.addPart(colors.getTertiaryColor() + "§l[Link]").link(address).hover(address);
|
||||
return builder.addPart(colors.getTertiaryColor() + "§l[Link]").link(address).hover(address);
|
||||
} else {
|
||||
builder.addPart(colors.getTertiaryColor() + address);
|
||||
return builder.addPart(colors.getTertiaryColor() + address);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,14 +200,14 @@ public class RegistrationCommands {
|
||||
if (sender.supportsChatEvents()) {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine()
|
||||
.addPart("Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§2§l[\u2714]").command("/" + mainCommand + " accept").hover("Accept")
|
||||
.addPart(" ")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||
.send();
|
||||
} else {
|
||||
sender.buildMessage()
|
||||
.addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine()
|
||||
.addPart("Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(colors.getTertiaryColor() + "Confirm: ").addPart("§a/" + mainCommand + " accept")
|
||||
.addPart(" ")
|
||||
.addPart("§c/" + mainCommand + " cancel")
|
||||
.send();
|
||||
|
@ -45,11 +45,11 @@ public class CommandWithSubcommands extends Subcommand {
|
||||
public void onHelp(CMDSender sender, Arguments arguments) {
|
||||
List<Subcommand> hasPermissionFor = subcommands.stream().filter(sender::hasAllPermissionsFor).collect(Collectors.toList());
|
||||
sender.buildMessage()
|
||||
.addPart("Header")
|
||||
.addPart("Header" /*TODO*/)
|
||||
.newLine().newLine()
|
||||
.apply(new HelpFormatter(sender, colors, getPrimaryAlias(), hasPermissionFor)::addSubcommands)
|
||||
.newLine().newLine()
|
||||
.addPart("Footer")
|
||||
.addPart("Footer" /*TODO*/)
|
||||
.send();
|
||||
}
|
||||
|
||||
|
@ -47,37 +47,50 @@ public class HelpFormatter {
|
||||
.filter(cmd -> cmd.getDescription() != null)
|
||||
.map(cmd ->
|
||||
m + mainCommand + " " + cmd.getPrimaryAlias() +
|
||||
(sender.getPlayerName().isPresent() ? "" : " " + cmd.getArgumentsAsString()) + "--" +
|
||||
(sender.supportsChatEvents() ? "" : " " + cmd.getArgumentsAsString()) + "***" +
|
||||
s + cmd.getDescription() + "\n"
|
||||
).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
|
||||
.toString();
|
||||
List<String[]> table = sender.getFormatter().tableAsParts(asString, "--");
|
||||
List<String[]> table = sender.getFormatter().tableAsParts(asString, "***");
|
||||
|
||||
for (int i = 0; i < table.size(); i++) {
|
||||
Subcommand subcommand = subcommands.get(i);
|
||||
Subcommand cmd = subcommands.get(i);
|
||||
if (cmd.getDescription() == null) continue;
|
||||
|
||||
String[] row = table.get(i);
|
||||
toReturn = toReturn.addPart(row[0])
|
||||
.hover(argumentsAndAliases(subcommand.getArguments(), subcommand.getAliases()))
|
||||
.addPart(row[1])
|
||||
.hover(subcommand.getInDepthDescription())
|
||||
.newLine();
|
||||
|
||||
if (sender.isPlayer()) {
|
||||
toReturn = toReturn.addPart(m + "/");
|
||||
}
|
||||
|
||||
if (sender.supportsChatEvents()) {
|
||||
toReturn = toReturn.addPart(row[0])
|
||||
.hover(argumentsAndAliases(cmd, cmd.getArguments(), cmd.getAliases()))
|
||||
.addPart(row[1])
|
||||
.hover(cmd.getInDepthDescription())
|
||||
.newLine();
|
||||
} else {
|
||||
toReturn = toReturn.addPart(row[0])
|
||||
.addPart(row[1])
|
||||
.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private List<String> argumentsAndAliases(List<Subcommand.ArgumentDescriptor> descriptors, Set<String> aliases) {
|
||||
private List<String> argumentsAndAliases(Subcommand subcommand, List<Subcommand.ArgumentDescriptor> descriptors, Set<String> aliases) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
lines.add(colors.getTertiaryColor() + "Arguments:");
|
||||
lines.add(colors.getMainColor() + subcommand.getPrimaryAlias() + colors.getTertiaryColor() + " Arguments:" + (descriptors.isEmpty() ? " none" : ""));
|
||||
for (Subcommand.ArgumentDescriptor descriptor : descriptors) {
|
||||
if (descriptor.isRequired()) {
|
||||
lines.add(" " + colors.getMainColor() + "§l<" + descriptor.getName() + ">§r " + colors.getSecondaryColor() + descriptor.getDescription());
|
||||
lines.add(colors.getMainColor() + "§l<" + descriptor.getName() + ">§r " + colors.getSecondaryColor() + descriptor.getDescription());
|
||||
} else {
|
||||
lines.add(" " + colors.getMainColor() + "[" + descriptor.getName() + "] " + colors.getSecondaryColor() + descriptor.getDescription());
|
||||
lines.add(colors.getMainColor() + "[" + descriptor.getName() + "] " + colors.getSecondaryColor() + descriptor.getDescription());
|
||||
}
|
||||
}
|
||||
lines.add(colors.getTertiaryColor() + "Aliases:" + new TextStringBuilder().appendWithSeparators(aliases, " | ").toString());
|
||||
lines.add("");
|
||||
lines.add(colors.getTertiaryColor() + "Aliases: " + new TextStringBuilder().appendWithSeparators(aliases, ", ").toString());
|
||||
return lines;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user