|
1 | 1 | package dev.ithundxr.railwaystweaks.commands;
|
2 | 2 |
|
3 | 3 | import com.mojang.brigadier.Command;
|
| 4 | +import com.mojang.brigadier.arguments.StringArgumentType; |
4 | 5 | import com.mojang.brigadier.builder.ArgumentBuilder;
|
5 | 6 | import com.mojang.brigadier.context.CommandContext;
|
6 | 7 | import com.simibubi.create.Create;
|
7 | 8 | import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
|
8 | 9 | import dev.ithundxr.railwaystweaks.RailwaysTweaks;
|
9 | 10 | import dev.ithundxr.railwaystweaks.mixin.compat.tconstruct.SimpleChannelAccessor;
|
| 11 | +import dev.ithundxr.railwaystweaks.utils.UUIDFinder; |
10 | 12 | import me.pepperbell.simplenetworking.C2SPacket;
|
11 | 13 | import me.pepperbell.simplenetworking.S2CPacket;
|
12 | 14 | import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
@@ -40,10 +42,18 @@ public static void init() {
|
40 | 42 | .executes(ctx -> avgMSPT(ctx.getSource())));
|
41 | 43 | });
|
42 | 44 |
|
| 45 | + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { |
| 46 | + dispatcher.register(literal("uuid") |
| 47 | + .then(Commands.argument("player_name", StringArgumentType.string()) |
| 48 | + .executes(RailwaysTweaksCommands::getPlayerUUID) |
| 49 | + ) |
| 50 | + ); |
| 51 | + }); |
| 52 | + |
43 | 53 | CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
44 | 54 | dispatcher.register(literal("railwaystweaks")
|
45 | 55 | .then(
|
46 |
| - literal("opac-party") |
| 56 | + literal("opac-party") |
47 | 57 | .then(Commands.argument("player_uuid", UuidArgument.uuid())
|
48 | 58 | .executes(RailwaysTweaksCommands::getPlayerPartyName)
|
49 | 59 | )
|
@@ -132,11 +142,23 @@ private static int getPlayerPartyName(CommandContext<CommandSourceStack> ctx) {
|
132 | 142 | IServerPartyAPI partyAPI = api.getPartyManager().getPartyByMember(uuid);
|
133 | 143 |
|
134 | 144 | if (partyAPI != null) {
|
135 |
| - ctx.getSource().sendSuccess(() -> Component.literal(partyAPI.getDefaultName() + "\n" + partyAPI.getId()), true); |
| 145 | + ctx.getSource().sendSuccess(() -> Component.literal(partyAPI.getDefaultName() + "\n" + partyAPI.getId()), false); |
136 | 146 | return 0;
|
137 | 147 | } else {
|
138 | 148 | ctx.getSource().sendFailure(Component.literal("Failed to get a party uuid from this player"));
|
139 | 149 | return 1;
|
140 | 150 | }
|
141 | 151 | }
|
| 152 | + |
| 153 | + private static int getPlayerUUID(CommandContext<CommandSourceStack> ctx) { |
| 154 | + String name = StringArgumentType.getString(ctx, "player_name"); |
| 155 | + |
| 156 | + if (name != null) { |
| 157 | + UUIDFinder.findUuid(name, (uuid) -> { |
| 158 | + if (uuid != null) |
| 159 | + ctx.getSource().sendSuccess(() -> Component.literal(uuid.toString()), false); |
| 160 | + }); |
| 161 | + } |
| 162 | + return 0; |
| 163 | + } |
142 | 164 | }
|
0 commit comments