1414import net .minecraft .server .MinecraftServer ;
1515import net .minecraft .server .command .ServerCommandSource ;
1616import net .minecraft .server .network .ServerPlayerEntity ;
17+ import net .minecraft .world .GameMode ;
1718
1819import java .util .HashMap ;
1920import java .util .Map ;
@@ -91,11 +92,20 @@ private static int teleport(CommandContext<ServerCommandSource> context) {
9192 if ((server .getPlayerManager ().isOperator (context .getSource ().getPlayer ().getGameProfile ()))) {
9293 executeTp (commandSourcePlayerName , context , server );
9394 } else {
94- Messenger .m (context .getSource (), "r You have no permission to teleport to fake player.You aren't op." );
95+ if (OptCarpetSettings .allowSpectatorTpToAnyPlayer && context .getSource ().getPlayer ().interactionManager .getGameMode ().equals (GameMode .SPECTATOR )){
96+ executeTp (commandSourcePlayerName , context , server );
97+ } else {
98+ Messenger .m (context .getSource (), "r You have no permission to teleport to fake player.You aren't op." );
99+ }
95100 }
96101 }
97- case OptCarpetSettings .FALSE ->
102+ case OptCarpetSettings .FALSE -> {
103+ if (OptCarpetSettings .allowSpectatorTpToAnyPlayer && context .getSource ().getPlayer ().interactionManager .getGameMode ().equals (GameMode .SPECTATOR )){
104+ executeTp (commandSourcePlayerName , context , server );
105+ } else {
98106 Messenger .m (context .getSource (), "r Anybody can't teleport to fake player." );
107+ }
108+ }
99109 }
100110
101111 } else {
@@ -107,11 +117,20 @@ private static int teleport(CommandContext<ServerCommandSource> context) {
107117 if ((server .getPlayerManager ().isOperator (context .getSource ().getPlayer ().getGameProfile ()))) {
108118 server .getCommandManager ().getDispatcher ().execute (server .getCommandManager ().getDispatcher ().parse ("tp " + commandSourcePlayerName + " " + target , server .getCommandSource ()));
109119 } else {
110- Messenger .m (context .getSource (), "r You have no permission to teleport to real player.You aren't op." );
120+ if (OptCarpetSettings .allowSpectatorTpToAnyPlayer && context .getSource ().getPlayer ().interactionManager .getGameMode ().equals (GameMode .SPECTATOR )){
121+ executeTp (commandSourcePlayerName , context , server );
122+ } else {
123+ Messenger .m (context .getSource (), "r You have no permission to teleport to real player.You aren't op." );
124+ }
111125 }
112126 }
113- case OptCarpetSettings .FALSE ->
114- Messenger .m (context .getSource (), "r Anybody can't teleport to real player." );
127+ case OptCarpetSettings .FALSE -> {
128+ if (OptCarpetSettings .allowSpectatorTpToAnyPlayer && context .getSource ().getPlayer ().interactionManager .getGameMode ().equals (GameMode .SPECTATOR )){
129+ executeTp (commandSourcePlayerName , context , server );
130+ } else {
131+ Messenger .m (context .getSource (), "r Anybody can't teleport to real player." );
132+ }
133+ }
115134 }
116135
117136 }
0 commit comments