Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ Currently the default value is not configurable, as this was made for a specific

### Regular Commands

| Command | Description |
|----------------------------|---------------------------------------------------------------------------------------------|
| `/clan` | Base command. |
| `/clan help [pageName]` | Shows a help menu page (defaults to this page if pageName isn't chosen). |
| `/clan create <clanName>` | Creates a clan if it doesn't already exist, the name is allowed, and you are not in a clan. |
| `/clan info <clanName>` | Shows info about a certain clan. If blank, attempts to use your clan. |
| `/clan invites` | Views your current clan invites in a neat list to accept/decline. |
| `/clan accept <clanName>` | Alternative to clicking in chat to accept an invite. |
| `/clan decline <clanName>` | Alternative to clicking in chat to decline an invite. |
| `/clan join <clanName>` | Joins a clan if it is open to joins. |
| `/clan leave` | Leaves your current clan. If you are the leader with no other members, disbands the clan. |
| Command | Description |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| `/clan` | Base command. |
| `/clan help [pageName]` | Shows a help menu page (defaults to this page if pageName isn't chosen). |
| `/clan create <clanName>` | Creates a clan if it doesn't already exist, the name is allowed, and you are not in a clan. |
| `/clan info [name\|player] <clanName\|playerName>` | Shows info about a certain clan. If blank, attempts to use your clan. |
| `/clan invites` | Views your current clan invites in a neat list to accept/decline. |
| `/clan accept <clanName>` | Alternative to clicking in chat to accept an invite. |
| `/clan decline <clanName>` | Alternative to clicking in chat to decline an invite. |
| `/clan join <clanName>` | Joins a clan if it is open to joins. |
| `/clan leave` | Leaves your current clan. If you are the leader with no other members, disbands the clan. |

### Clan Officer Commands - Restricted to Officers and Above

Expand All @@ -55,7 +55,7 @@ Currently the default value is not configurable, as this was made for a specific
| `/clan demote <playerName>` | Demotes a player to Member rank. |
| `/clan disband [confirm]` | Deletes a clan (if confirmed). |
| `/clan set color <colorName/hexCode>` | Changes the color code of your clan. |
| `/clan set access <open\|invite_only\|toggle>` | Changes your clan’s access state. |
| `/clan set access [open\|invite_only\|toggle]` | Changes your clan’s access state. |
| `/clan set name <newClanName>` | Changes the name of your clan if allowed and available. |
| `/clan transfer <playerName>` | Transfers clan ownership to a member. |

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mnfu/clantag/commands/AdminCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private int executeRename(CommandContext<ServerCommandSource> context) {
return 0;
}
if (newClanName.length() < 3 || newClanName.length() > 16) {
context.getSource().sendMessage(Text.literal("Warning: Your proposed new clan name will override length defaults!").formatted(Formatting.YELLOW));
context.getSource().sendMessage(Text.literal("Warning: Proposed new clan name will override length limits!").formatted(Formatting.YELLOW));
}

boolean clanRenamed = clanManager.changeName(oldClanName, newClanName);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mnfu/clantag/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MutableText buildGeneralMessage () {
message.append(Text.literal("[ General Commands ]").formatted(Formatting.WHITE)).append("\n");
message.append(Text.literal("/clan help [pageName]").formatted(Formatting.YELLOW)).append(" - Shows a help menu page (defaults to this page if [pageName] isn't chosen)").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan create <clanName>").formatted(Formatting.YELLOW)).append(" - Creates a clan if it doesn't already exist").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan info <clanName>").formatted(Formatting.YELLOW)).append(" - Shows info about a clan, and if <clanName> is blank, it shows your clan").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan info [name|player] <clanName|playerName>").formatted(Formatting.YELLOW)).append(" - Shows info about a clan, defaults to your clan if no arguments given").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan invites").formatted(Formatting.YELLOW)).append(" - Displays your current clan invites to accept/decline").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan accept <clanName>").formatted(Formatting.YELLOW)).append(" - Accepts a clan invite").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan decline <clanName>").formatted(Formatting.YELLOW)).append(" - Declines a clan invite").formatted(Formatting.GRAY).append("\n");
Expand Down Expand Up @@ -85,7 +85,7 @@ public MutableText buildManageMessage () {
message.append(Text.literal("/clan demote <playerName>").formatted(Formatting.YELLOW)).append(" - Demotes a player in the clan rank hierarchy").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan disband [confirm]").formatted(Formatting.YELLOW)).append(" - Facilitates the deletion of your clan").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan set color <colorName|hexCode>").formatted(Formatting.YELLOW)).append(" - Sets your clan color (supports \"WHITE\" or #FFFFFF or FFFFFF formats)").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan set access <open|invite_only|toggle>").formatted(Formatting.YELLOW)).append(" - Sets your clan access to open or invite only").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan set access [open|invite_only|toggle]").formatted(Formatting.YELLOW)).append(" - Sets your clan access to open or invite only").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan set name <newClanName>").formatted(Formatting.YELLOW)).append(" - Sets your clan name to <newClanName> if it is available").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("/clan transfer <playerName>").formatted(Formatting.YELLOW)).append(" - Transfers clan ownership to <playerName>").formatted(Formatting.GRAY).append("\n");
message.append(Text.literal("[General Help Page]")
Expand Down
53 changes: 45 additions & 8 deletions src/main/java/mnfu/clantag/commands/InfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import static mnfu.clantag.commands.CommandUtils.getPlayerName;
import static mnfu.clantag.commands.CommandUtils.getUuid;

public class InfoCommand {
private final ClanManager clanManager;
Expand All @@ -31,14 +33,27 @@ public InfoCommand(ClanManager clanManager) {
public LiteralArgumentBuilder<ServerCommandSource> build() {
return CommandManager.literal("info")
.executes(this::executeForSelf)
.then(CommandManager.argument("clanName", StringArgumentType.greedyString())
.suggests((context, builder) -> {
for (String canonicalName : clanManager.getAllClansCanonicalNames()) {
builder.suggest(canonicalName);
}
return builder.buildFuture();
})
.executes(this::executeForClanName));
.then(CommandManager.literal("name")
.then(CommandManager.argument("clanName", StringArgumentType.greedyString())
.suggests((context, builder) -> {
for (String canonicalName : clanManager.getAllClansCanonicalNames()) {
builder.suggest(canonicalName);
}
return builder.buildFuture();
})
.executes(this::executeForClanName)
)
)
.then(CommandManager.literal("player")
.then(CommandManager.argument("playerName", StringArgumentType.word())
.suggests((context, builder) -> {
Collection<String> onlinePlayers = context.getSource().getPlayerNames();
onlinePlayers.forEach(builder::suggest);
return builder.buildFuture();
})
.executes(this::executeForPlayer)
)
);
}

private int executeForSelf(CommandContext<ServerCommandSource> context) {
Expand Down Expand Up @@ -72,6 +87,28 @@ private int executeForClanName(CommandContext<ServerCommandSource> context) {
return 1;
}

private int executeForPlayer(CommandContext<ServerCommandSource> context) {
String playerName = StringArgumentType.getString(context, "playerName");

getUuid(context, playerName).thenAccept(optUuid -> {
UUID playerUuid = optUuid.orElse(null);
if (playerUuid == null) {
context.getSource().sendError(Text.literal("Player not found!"));
return;
}

Clan clan = clanManager.getPlayerClan(playerUuid);
if (clan == null) {
context.getSource().sendError(Text.literal("This player is not in a clan."));
return;
}

displayClanInfo(context, clan);
});

return 1;
}

private void displayClanInfo(CommandContext<ServerCommandSource> context, Clan clan) {
MutableText message = Text.empty();
TextColor clanColor = TextColor.parse(clan.hexColor()).getOrThrow();
Expand Down
Loading
Loading