add: team info
This commit is contained in:
parent
4210826715
commit
cbc3552d15
1 changed files with 31 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
package rip.iwakura.civil.commands;
|
package rip.iwakura.civil.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
|
|
||||||
|
@ -188,12 +189,42 @@ public class Team {
|
||||||
})));
|
})));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// List team info.
|
||||||
|
private LiteralArgumentBuilder<CommandSourceStack> getTeamInfo() {
|
||||||
|
return Commands.literal("info")
|
||||||
|
.then(
|
||||||
|
Commands.argument("team", new TeamArgument(database))
|
||||||
|
.executes(ctx -> {
|
||||||
|
try {
|
||||||
|
CivilTeam civilTeam = ctx.getArgument("team", CivilTeam.class);
|
||||||
|
CommandSender sender = ctx.getSource().getSender();
|
||||||
|
|
||||||
|
String finalMessage = String.format(
|
||||||
|
"<green>Team: <white>%s\n<green>Prefix: <white>%s\n<green>Players:<white>",
|
||||||
|
civilTeam.getName(), civilTeam.getPrefix());
|
||||||
|
|
||||||
|
List<CivilPlayer> members = database.getAllPlayers(civilTeam);
|
||||||
|
|
||||||
|
for (CivilPlayer member : members)
|
||||||
|
finalMessage += " " + member.getName();
|
||||||
|
|
||||||
|
sender.sendMessage(MiniMessage.miniMessage().deserialize(finalMessage));
|
||||||
|
|
||||||
|
return Command.SINGLE_SUCCESS;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
public LiteralCommandNode<CommandSourceStack> getCommand() {
|
public LiteralCommandNode<CommandSourceStack> getCommand() {
|
||||||
return Commands.literal("team")
|
return Commands.literal("team")
|
||||||
.then(createTeam())
|
.then(createTeam())
|
||||||
.then(joinTeam())
|
.then(joinTeam())
|
||||||
.then(teamChat())
|
.then(teamChat())
|
||||||
.then(homeCommand())
|
.then(homeCommand())
|
||||||
|
.then(getTeamInfo())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue