1919
2020import org .mvplugins .multiverse .core .command .MVCommandIssuer ;
2121import org .mvplugins .multiverse .core .command .context .issueraware .PlayerArrayValue ;
22+ import org .mvplugins .multiverse .core .command .flag .CommandFlag ;
23+ import org .mvplugins .multiverse .core .command .flag .CommandFlagsManager ;
2224import org .mvplugins .multiverse .core .command .flag .ParsedCommandFlags ;
25+ import org .mvplugins .multiverse .core .command .flags .PageFilterFlags ;
2326import org .mvplugins .multiverse .core .command .flags .UnsafeFlags ;
2427import org .mvplugins .multiverse .core .config .CoreConfig ;
2528import org .mvplugins .multiverse .core .destination .DestinationInstance ;
@@ -35,14 +38,14 @@ final class TeleportCommand extends CoreCommand {
3538 private final CoreConfig config ;
3639 private final CorePermissionsChecker permissionsChecker ;
3740 private final AsyncSafetyTeleporter safetyTeleporter ;
38- private final UnsafeFlags flags ;
41+ private final Flags flags ;
3942
4043 @ Inject
4144 TeleportCommand (
4245 @ NotNull CoreConfig config ,
4346 @ NotNull CorePermissionsChecker permissionsChecker ,
4447 @ NotNull AsyncSafetyTeleporter safetyTeleporter ,
45- @ NotNull UnsafeFlags flags
48+ @ NotNull Flags flags
4649 ) {
4750 this .config = config ;
4851 this .permissionsChecker = permissionsChecker ;
@@ -54,14 +57,14 @@ final class TeleportCommand extends CoreCommand {
5457 @ Subcommand ("teleport|tp" )
5558 @ CommandPermission ("@mvteleport" )
5659 @ CommandCompletion ("@playersarray:checkPermissions=@mvteleportother|@destinations:byIssuerForArg=arg1 "
57- + "@destinations:notByIssuerForArg=arg1|@flags:byIssuerForArg=arg1,groupName=" + UnsafeFlags .NAME + " "
58- + "@flags:notByIssuerForArg=arg1,groupName=" + UnsafeFlags .NAME )
60+ + "@destinations:notByIssuerForArg=arg1|@flags:byIssuerForArg=arg1,groupName=" + Flags .NAME + " "
61+ + "@flags:notByIssuerForArg=arg1,groupName=" + Flags .NAME )
5962 @ Syntax ("[player] <destination> [--unsafe]" )
6063 @ Description ("{@@mv-core.teleport.description}" )
6164 void onTeleportCommand (
6265 MVCommandIssuer issuer ,
6366
64- @ Flags ("resolve=issuerAware" )
67+ @ co . aikar . commands . annotation . Flags ("resolve=issuerAware" )
6568 @ Syntax ("[player]" )
6669 @ Description ("{@@mv-core.teleport.player.description}" )
6770 PlayerArrayValue playersValue ,
@@ -103,16 +106,21 @@ private void teleportSinglePlayer(MVCommandIssuer issuer, Player player,
103106 .checkSafety (!parsedFlags .hasFlag (flags .unsafe ) && destination .checkTeleportSafety ())
104107 .passengerMode (config .getPassengerMode ())
105108 .teleportSingle (player )
106- .onSuccess (() -> issuer .sendInfo (MVCorei18n .TELEPORT_SUCCESS ,
107- Replace .PLAYER .with (getYouOrName (issuer , player )),
108- Replace .DESTINATION .with (destination .getDisplayMessage ())))
109+ .onSuccess (() -> {
110+ if (parsedFlags .hasFlag (flags .silent )) {
111+ return ;
112+ }
113+ issuer .sendInfo (MVCorei18n .TELEPORT_SUCCESS ,
114+ Replace .PLAYER .with (getYouOrName (issuer , player )),
115+ Replace .DESTINATION .with (destination .getDisplayMessage ()));
116+ })
109117 .onFailureCount (reasonsCountMap -> {
110118 for (var entry : reasonsCountMap .entrySet ()) {
111119 Logging .finer ("Failed to teleport %s players to %s: %s" ,
112120 entry .getValue (), destination , entry .getKey ());
113121 issuer .sendError (MVCorei18n .TELEPORT_FAILED ,
114122 Replace .PLAYER .with (player .getName ()),
115- Replace .DESTINATION .with (destination .toString ()),
123+ Replace .DESTINATION .with (destination .getDisplayMessage ()),
116124 Replace .REASON .with (Message .of (entry .getKey ())));
117125 }
118126 });
@@ -136,18 +144,38 @@ private void teleportMultiplePlayers(MVCommandIssuer issuer, Player[] players,
136144 .checkSafety (!parsedFlags .hasFlag (flags .unsafe ) && destination .checkTeleportSafety ())
137145 .passengerMode (config .getPassengerMode ())
138146 .teleport (List .of (players ))
139- .onSuccessCount (successCount -> issuer .sendInfo (MVCorei18n .TELEPORT_SUCCESS ,
140- Replace .PLAYER .with (successCount + " players" ),
141- Replace .DESTINATION .with (destination .getDisplayMessage ())))
147+ .onSuccessCount (successCount -> {
148+ if (parsedFlags .hasFlag (flags .silent )) {
149+ return ;
150+ }
151+ issuer .sendInfo (MVCorei18n .TELEPORT_SUCCESS ,
152+ Replace .PLAYER .with (successCount + " players" ),
153+ Replace .DESTINATION .with (destination .getDisplayMessage ()));
154+ })
142155 .onFailureCount (reasonsCountMap -> {
143156 for (var entry : reasonsCountMap .entrySet ()) {
144157 Logging .finer ("Failed to teleport %s players to %s: %s" ,
145158 entry .getValue (), destination , entry .getKey ());
146159 issuer .sendError (MVCorei18n .TELEPORT_FAILED ,
147160 Replace .PLAYER .with (entry .getValue () + " players" ),
148- Replace .DESTINATION .with (destination .toString ()),
161+ Replace .DESTINATION .with (destination .getDisplayMessage ()),
149162 Replace .REASON .with (Message .of (entry .getKey ())));
150163 }
151164 });
152165 }
166+
167+ @ Service
168+ private static final class Flags extends UnsafeFlags {
169+
170+ private static final String NAME = "mvteleport" ;
171+
172+ @ Inject
173+ private Flags (@ NotNull CommandFlagsManager flagsManager ) {
174+ super (NAME , flagsManager );
175+ }
176+
177+ private final CommandFlag silent = flag (CommandFlag .builder ("--silent" )
178+ .addAlias ("-s" )
179+ .build ());
180+ }
153181}
0 commit comments