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() {
|
private Subcommand databaseCommand() {
|
||||||
return CommandWithSubcommands.builder()
|
return CommandWithSubcommands.builder()
|
||||||
.aliases("database", "db")
|
.aliases("db", "database")
|
||||||
.requirePermission("plan.data.base")
|
.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")
|
.description("Manage Plan database")
|
||||||
.colorScheme(colors)
|
.colorScheme(colors)
|
||||||
.subcommand(backupCommand())
|
.subcommand(backupCommand())
|
||||||
|
@ -170,14 +170,14 @@ public class DatabaseCommands {
|
|||||||
if (sender.supportsChatEvents()) {
|
if (sender.supportsChatEvents()) {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getType().getName() + " with data in " + backupDBFile.toPath()).newLine()
|
.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(" ")
|
||||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||||
.send();
|
.send();
|
||||||
} else {
|
} else {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getType().getName() + " with data in " + backupDBFile.toPath()).newLine()
|
.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(" ")
|
||||||
.addPart("§c/" + mainCommand + " cancel")
|
.addPart("§c/" + mainCommand + " cancel")
|
||||||
.send();
|
.send();
|
||||||
@ -222,14 +222,14 @@ public class DatabaseCommands {
|
|||||||
if (sender.supportsChatEvents()) {
|
if (sender.supportsChatEvents()) {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getName() + " with data in " + fromDB.getName()).newLine()
|
.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(" ")
|
||||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||||
.send();
|
.send();
|
||||||
} else {
|
} else {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to overwrite data in Plan " + toDB.getName() + " with data in " + fromDB.getName()).newLine()
|
.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(" ")
|
||||||
.addPart("§c/" + mainCommand + " cancel")
|
.addPart("§c/" + mainCommand + " cancel")
|
||||||
.send();
|
.send();
|
||||||
@ -277,14 +277,14 @@ public class DatabaseCommands {
|
|||||||
if (sender.supportsChatEvents()) {
|
if (sender.supportsChatEvents()) {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to remove all Plan-data in " + fromDB.getName()).newLine()
|
.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(" ")
|
||||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||||
.send();
|
.send();
|
||||||
} else {
|
} else {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to remove all Plan-data in " + fromDB.getName()).newLine()
|
.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(" ")
|
||||||
.addPart("§c/" + mainCommand + " cancel")
|
.addPart("§c/" + mainCommand + " cancel")
|
||||||
.send();
|
.send();
|
||||||
@ -334,14 +334,14 @@ public class DatabaseCommands {
|
|||||||
if (sender.supportsChatEvents()) {
|
if (sender.supportsChatEvents()) {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to remove data of " + playerUUID + " from " + database.getType().getName()).newLine()
|
.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(" ")
|
||||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||||
.send();
|
.send();
|
||||||
} else {
|
} else {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to remove data of " + playerUUID + " from " + database.getType().getName()).newLine()
|
.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(" ")
|
||||||
.addPart("§c/" + mainCommand + " cancel")
|
.addPart("§c/" + mainCommand + " cancel")
|
||||||
.send();
|
.send();
|
||||||
|
@ -78,11 +78,10 @@ public class LinkCommands {
|
|||||||
|
|
||||||
MessageBuilder linkTo(MessageBuilder builder, CMDSender sender, String address) {
|
MessageBuilder linkTo(MessageBuilder builder, CMDSender sender, String address) {
|
||||||
if (sender.supportsChatEvents()) {
|
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 {
|
} else {
|
||||||
builder.addPart(colors.getTertiaryColor() + address);
|
return builder.addPart(colors.getTertiaryColor() + address);
|
||||||
}
|
}
|
||||||
return builder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,14 +200,14 @@ public class RegistrationCommands {
|
|||||||
if (sender.supportsChatEvents()) {
|
if (sender.supportsChatEvents()) {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine()
|
.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(" ")
|
||||||
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel")
|
.addPart("§4§l[\u2718]").command("/" + mainCommand + " cancel").hover("Cancel")
|
||||||
.send();
|
.send();
|
||||||
} else {
|
} else {
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart(colors.getMainColor() + "You are about to unregister '" + presentUser.getUsername() + "' linked to " + presentUser.getLinkedTo()).newLine()
|
.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(" ")
|
||||||
.addPart("§c/" + mainCommand + " cancel")
|
.addPart("§c/" + mainCommand + " cancel")
|
||||||
.send();
|
.send();
|
||||||
|
@ -45,11 +45,11 @@ public class CommandWithSubcommands extends Subcommand {
|
|||||||
public void onHelp(CMDSender sender, Arguments arguments) {
|
public void onHelp(CMDSender sender, Arguments arguments) {
|
||||||
List<Subcommand> hasPermissionFor = subcommands.stream().filter(sender::hasAllPermissionsFor).collect(Collectors.toList());
|
List<Subcommand> hasPermissionFor = subcommands.stream().filter(sender::hasAllPermissionsFor).collect(Collectors.toList());
|
||||||
sender.buildMessage()
|
sender.buildMessage()
|
||||||
.addPart("Header")
|
.addPart("Header" /*TODO*/)
|
||||||
.newLine().newLine()
|
.newLine().newLine()
|
||||||
.apply(new HelpFormatter(sender, colors, getPrimaryAlias(), hasPermissionFor)::addSubcommands)
|
.apply(new HelpFormatter(sender, colors, getPrimaryAlias(), hasPermissionFor)::addSubcommands)
|
||||||
.newLine().newLine()
|
.newLine().newLine()
|
||||||
.addPart("Footer")
|
.addPart("Footer" /*TODO*/)
|
||||||
.send();
|
.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,37 +47,50 @@ public class HelpFormatter {
|
|||||||
.filter(cmd -> cmd.getDescription() != null)
|
.filter(cmd -> cmd.getDescription() != null)
|
||||||
.map(cmd ->
|
.map(cmd ->
|
||||||
m + mainCommand + " " + cmd.getPrimaryAlias() +
|
m + mainCommand + " " + cmd.getPrimaryAlias() +
|
||||||
(sender.getPlayerName().isPresent() ? "" : " " + cmd.getArgumentsAsString()) + "--" +
|
(sender.supportsChatEvents() ? "" : " " + cmd.getArgumentsAsString()) + "***" +
|
||||||
s + cmd.getDescription() + "\n"
|
s + cmd.getDescription() + "\n"
|
||||||
).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
|
).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
|
||||||
.toString();
|
.toString();
|
||||||
List<String[]> table = sender.getFormatter().tableAsParts(asString, "--");
|
List<String[]> table = sender.getFormatter().tableAsParts(asString, "***");
|
||||||
|
|
||||||
for (int i = 0; i < table.size(); i++) {
|
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);
|
String[] row = table.get(i);
|
||||||
toReturn = toReturn.addPart(row[0])
|
|
||||||
.hover(argumentsAndAliases(subcommand.getArguments(), subcommand.getAliases()))
|
if (sender.isPlayer()) {
|
||||||
.addPart(row[1])
|
toReturn = toReturn.addPart(m + "/");
|
||||||
.hover(subcommand.getInDepthDescription())
|
}
|
||||||
.newLine();
|
|
||||||
|
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;
|
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<>();
|
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) {
|
for (Subcommand.ArgumentDescriptor descriptor : descriptors) {
|
||||||
if (descriptor.isRequired()) {
|
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 {
|
} 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;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user