1
0
minecraft-tweaks-2a03/src/main/java/party/_2a03/mc/mixin/MixinGameModeCommand.java

25 lines
1.0 KiB
Java
Raw Normal View History

2020-01-07 10:53:42 -05:00
package party._2a03.mc.mixin;
2022-01-29 20:18:37 -05:00
import java.util.Collection;
import com.mojang.brigadier.context.CommandContext;
2020-01-07 10:53:42 -05:00
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.command.GameModeCommand;
import net.minecraft.server.network.ServerPlayerEntity;
2022-06-11 23:58:16 -04:00
import net.minecraft.text.Text;
2020-01-07 10:53:42 -05:00
import net.minecraft.world.GameMode;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
2022-01-29 20:18:37 -05:00
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
2020-01-07 10:53:42 -05:00
@Mixin(GameModeCommand.class)
public class MixinGameModeCommand {
2022-01-29 20:18:37 -05:00
@Inject(method = "execute", at = @At("HEAD"))
private static void OnExecute(CommandContext<ServerCommandSource> context, Collection<ServerPlayerEntity> targets, GameMode gameMode, CallbackInfoReturnable cir) {
2020-01-07 10:53:42 -05:00
if (gameMode == GameMode.CREATIVE) {
2022-06-11 23:58:16 -04:00
context.getSource().sendFeedback(Text.of("<Server> Creative mode? What are you, a cheater?"), false);
2020-01-07 10:53:42 -05:00
}
return;
}
}