SilentDisconnect

This commit is contained in:
ThebestkillerTBK
2022-10-20 21:48:30 +08:00
parent 981fa4c37d
commit 7b4412227b
4 changed files with 60 additions and 3 deletions

View File

@@ -81,13 +81,14 @@ public class MeteorRejectsAddon extends MeteorAddon {
commands.add(new ClearChatCommand());
commands.add(new GhostCommand());
commands.add(new GiveCommand());
commands.add(new SaveSkinCommand());
commands.add(new SeedCommand());
commands.add(new HeadsCommand());
commands.add(new KickCommand());
// commands.add(new LocateCommand()); I wish it was that simple -_-
commands.add(new ServerCommand());
commands.add(new PanicCommand());
commands.add(new ReconnectCommand());
commands.add(new ServerCommand());
commands.add(new SaveSkinCommand());
commands.add(new SeedCommand());
commands.add(new SetBlockCommand());
commands.add(new SetVelocityCommand());
commands.add(new TeleportCommand());

View File

@@ -0,0 +1,31 @@
package anticope.rejects.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.misc.AutoReconnect;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.command.CommandSource;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public class ReconnectCommand extends Command {
public ReconnectCommand() {
super("reconnect", "Reconnects server.");
}
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
mc.world.disconnect();
AutoReconnect autoReconnect = Modules.get().get(AutoReconnect.class);
ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), MinecraftClient.getInstance(),
ServerAddress.parse(autoReconnect.lastServerInfo.address), autoReconnect.lastServerInfo);
return SINGLE_SUCCESS;
});
}
}

View File

@@ -2,15 +2,21 @@ package anticope.rejects.mixin;
import anticope.rejects.events.ChunkPosDataEvent;
import anticope.rejects.events.PlayerRespawnEvent;
import anticope.rejects.modules.SilentDisconnect;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static meteordevelopment.meteorclient.MeteorClient.mc;
@Mixin(ClientPlayNetworkHandler.class)
public class ClientPlayNetworkHandlerMixin {
@@ -25,4 +31,13 @@ public class ClientPlayNetworkHandlerMixin {
public void onPlayerRespawn(PlayerRespawnS2CPacket packet, CallbackInfo ci) {
MeteorClient.EVENT_BUS.post(PlayerRespawnEvent.get());
}
@Inject(method = "onDisconnected", at = @At("HEAD"), cancellable = true)
private void onDisconnected(Text reason, CallbackInfo info) {
if (Modules.get().isActive(SilentDisconnect.class) && mc.world != null && mc.player != null) {
ChatUtils.info(Text.translatable("disconnect.lost").getString() + ":");
ChatUtils.sendMsg(reason);
info.cancel();
}
}
}

View File

@@ -0,0 +1,10 @@
package anticope.rejects.modules;
import anticope.rejects.MeteorRejectsAddon;
import meteordevelopment.meteorclient.systems.modules.Module;
public class SilentDisconnect extends Module {
public SilentDisconnect() {
super(MeteorRejectsAddon.CATEGORY, "silent-disconnect", "Won't show a disconnect screen when you disconnects.");
}
}