|
33 | 33 | import net.draycia.carbon.common.command.Commander;
|
34 | 34 | import net.draycia.carbon.common.command.ParserFactory;
|
35 | 35 | import net.draycia.carbon.common.command.PlayerCommander;
|
| 36 | +import net.draycia.carbon.common.command.argument.CarbonPlayerParser; |
36 | 37 | import net.draycia.carbon.common.config.ConfigManager;
|
37 | 38 | import net.draycia.carbon.common.messages.CarbonMessages;
|
38 | 39 | import net.draycia.carbon.common.messages.Option;
|
39 | 40 | import net.draycia.carbon.common.messages.TagPermissions;
|
40 | 41 | import net.draycia.carbon.common.users.NetworkUsers;
|
41 | 42 | import net.draycia.carbon.common.users.PartyInvites;
|
42 | 43 | import net.draycia.carbon.common.users.UserManagerInternal;
|
| 44 | +import net.draycia.carbon.common.util.CloudUtils; |
43 | 45 | import net.draycia.carbon.common.util.Pagination;
|
44 | 46 | import net.draycia.carbon.common.util.PaginationHelper;
|
45 | 47 | import net.kyori.adventure.key.Key;
|
@@ -199,20 +201,31 @@ private void createParty(final CommandContext<PlayerCommander> ctx) {
|
199 | 201 | private void invitePlayer(final CommandContext<PlayerCommander> ctx) {
|
200 | 202 | final CarbonPlayer player = ctx.sender().carbonPlayer();
|
201 | 203 | final CarbonPlayer recipient = ctx.get("player");
|
| 204 | + |
| 205 | + final @Nullable String recipientInputString = ctx.parsingContext("player").consumedInput(); |
| 206 | + if (!this.network.online(recipient) || !player.awareOf(recipient) && !player.hasPermission("carbon.whisper.vanished")) { |
| 207 | + final var exception = new CarbonPlayerParser.ParseException(recipientInputString, this.messages); |
| 208 | + this.messages.errorCommandArgumentParsing(player, CloudUtils.message(exception)); |
| 209 | + return; |
| 210 | + } |
| 211 | + |
202 | 212 | if (recipient.uuid().equals(player.uuid())) {
|
203 | 213 | this.messages.cannotInviteSelf(player);
|
204 | 214 | return;
|
205 | 215 | }
|
| 216 | + |
206 | 217 | final @Nullable Party party = player.party().join();
|
207 | 218 | if (party == null) {
|
208 | 219 | this.messages.mustBeInParty(player);
|
209 | 220 | return;
|
210 | 221 | }
|
| 222 | + |
211 | 223 | final @Nullable Party recipientParty = recipient.party().join();
|
212 | 224 | if (recipientParty != null && recipientParty.id().equals(party.id())) {
|
213 | 225 | this.messages.alreadyInParty(player, recipient.displayName());
|
214 | 226 | return;
|
215 | 227 | }
|
| 228 | + |
216 | 229 | this.partyInvites.sendInvite(player.uuid(), recipient.uuid(), party.id());
|
217 | 230 | this.messages.receivedPartyInvite(recipient, player.displayName(), player.username(), party.name());
|
218 | 231 | this.messages.sentPartyInvite(player, recipient.displayName(), party.name());
|
|
0 commit comments