diff --git a/src/main/java/dev/ithundxr/railwaystweaks/mixin/ServerStatusPacketListenerImplMixin.java b/src/main/java/dev/ithundxr/railwaystweaks/mixin/ServerStatusPacketListenerImplMixin.java new file mode 100644 index 0000000..00fb0fa --- /dev/null +++ b/src/main/java/dev/ithundxr/railwaystweaks/mixin/ServerStatusPacketListenerImplMixin.java @@ -0,0 +1,45 @@ +package dev.ithundxr.railwaystweaks.mixin; + +import com.mojang.authlib.GameProfile; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.status.ServerStatus; +import net.minecraft.server.network.ServerStatusPacketListenerImpl; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Mixin(ServerStatusPacketListenerImpl.class) +public class ServerStatusPacketListenerImplMixin { + @Shadow @Mutable @Final private ServerStatus status; + + @Inject(method = "", at = @At("TAIL")) + private void railwaysTweaks$noSpying(ServerStatus status, Connection connection, CallbackInfo ci) { + List names = List.of("Stop", "Trying", "To", "Spy"); + List profiles = new ArrayList<>(); + + for (String name : names) { + profiles.add(new GameProfile(UUID.randomUUID(), name)); + } + + Optional players = Optional.of(new ServerStatus.Players( + 1, 1, profiles + )); + + this.status = new ServerStatus( + status.description(), + players, + status.version(), + status.favicon(), + status.enforcesSecureChat() + ); + } +} diff --git a/src/main/resources/railwaystweaks.mixins.json b/src/main/resources/railwaystweaks.mixins.json index 45cb0ee..faedc61 100644 --- a/src/main/resources/railwaystweaks.mixins.json +++ b/src/main/resources/railwaystweaks.mixins.json @@ -4,7 +4,8 @@ "package": "dev.ithundxr.railwaystweaks.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "LivingEntityMixin" + "LivingEntityMixin", + "ServerStatusPacketListenerImplMixin" ], "client": [ "client.HttpTextureMixin",