This commit is contained in:
kirillsaint 2023-07-03 15:01:51 +06:00
parent 26db9bb0d4
commit adc547e61a
12 changed files with 90 additions and 9 deletions

View File

@ -12,6 +12,8 @@ import net.silentclient.client.event.EventManager;
import net.silentclient.client.event.EventTarget;
import net.silentclient.client.event.impl.ClientTickEvent;
import net.silentclient.client.event.impl.ConnectToServerEvent;
import net.silentclient.client.event.impl.ServerLeaveEvent;
import net.silentclient.client.event.impl.SingleplayerJoinEvent;
import net.silentclient.client.gui.GuiError;
import net.silentclient.client.gui.clickgui.ClickGUI;
import net.silentclient.client.gui.font.SilentFontRenderer;
@ -404,7 +406,25 @@ public class Client {
playersCount = 0;
nextPing = 10;
this.updateUserInformation();
silentSocket.getSocket().emit("update_information", (Minecraft.getMinecraft().getCurrentServerData() != null ? Minecraft.getMinecraft().getCurrentServerData().serverIP : ""));
silentSocket.getSocket().emit("update_information", event.getIp());
}
@EventTarget
public void onServerDisconnect(ServerLeaveEvent event) {
ping = 0;
playersCount = 0;
nextPing = 10;
this.updateUserInformation();
silentSocket.getSocket().emit("update_information", "");
}
@EventTarget
public void onServerDisconnect(SingleplayerJoinEvent event) {
ping = 0;
playersCount = 0;
nextPing = 10;
this.updateUserInformation();
silentSocket.getSocket().emit("update_information", "");
}
// Instances

View File

@ -82,6 +82,7 @@ public final class ConfigManager {
}
public void updateConfigs() {
Client.logger.info("Updating Config List");
this.configs = Stream.of(Client.getInstance().dir.listFiles())
.filter(file -> !file.isDirectory())
.map(File::getName)
@ -98,6 +99,7 @@ public final class ConfigManager {
}
public void loadConfig(String name) {
Client.logger.info("Loading Config: " + name);
try(PrintWriter writer = new PrintWriter(this.settingsFile)) {
writer.println("config:" + name);
} catch (Exception err) {
@ -123,21 +125,23 @@ public final class ConfigManager {
}
public String newConfig(String name, boolean clone) {
Client.logger.info("Creating Config: " + name);
File testConfig = new File(Client.getInstance().dir, name);
if(testConfig.exists()) {
Client.logger.info("Creating Config Error: Config already exists.");
return "Config already exists.";
} else {
try {
testConfig.createNewFile();
} catch (IOException e) {
e.printStackTrace();
Client.logger.catching(e);
return "Error: " + e.getMessage();
}
}
try(PrintWriter writer = new PrintWriter(this.settingsFile)) {
writer.println("config:" + name);
} catch (Exception err) {
err.printStackTrace();
Client.logger.catching(err);
return "Error: " + err.getMessage();
}
configFile = testConfig;
@ -269,6 +273,7 @@ public final class ConfigManager {
}
public void save() {
Client.logger.info("Saving Config: " + this.configFile.getName());
try(PrintWriter writer = new PrintWriter(this.configFile)) {
for(Mod m : Client.getInstance().getModInstances().getMods()) {
writer.println("MOD:" + m.getName() + ":" + m.isToggled());

View File

@ -3,5 +3,14 @@ package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class ConnectToServerEvent extends Event {
private final String ip;
public ConnectToServerEvent(String ip) {
this.ip = ip;
}
public String getIp() {
return ip;
}
}

View File

@ -0,0 +1,6 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class ServerLeaveEvent extends Event {
}

View File

@ -0,0 +1,6 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class SingleplayerJoinEvent extends Event {
}

View File

@ -59,6 +59,7 @@ public class GuiConnecting extends GuiScreen
private void connectServerData(final ServerData serverData)
{
logger.info("Connecting to " + serverData.serverIP);
(new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet())
{
public void run()
@ -89,7 +90,7 @@ public class GuiConnecting extends GuiScreen
GuiConnecting.this.networkManager.setNetHandler(new NetHandlerLoginClient(GuiConnecting.this.networkManager, GuiConnecting.this.mc, GuiConnecting.this.previousGuiScreen));
GuiConnecting.this.networkManager.sendPacket(new C00Handshake(47, ip, port, EnumConnectionState.LOGIN));
GuiConnecting.this.networkManager.sendPacket(new C00PacketLoginStart(GuiConnecting.this.mc.getSession().getProfile()));
new ConnectToServerEvent().call();
new ConnectToServerEvent(serverData.serverIP).call();
}
catch (UnknownHostException unknownhostexception)
{
@ -153,7 +154,7 @@ public class GuiConnecting extends GuiScreen
GuiConnecting.this.networkManager.setNetHandler(new NetHandlerLoginClient(GuiConnecting.this.networkManager, GuiConnecting.this.mc, GuiConnecting.this.previousGuiScreen));
GuiConnecting.this.networkManager.sendPacket(new C00Handshake(47, ip, port, EnumConnectionState.LOGIN));
GuiConnecting.this.networkManager.sendPacket(new C00PacketLoginStart(GuiConnecting.this.mc.getSession().getProfile()));
new ConnectToServerEvent().call();
new ConnectToServerEvent(ip).call();
}
catch (UnknownHostException unknownhostexception)
{

View File

@ -14,6 +14,7 @@ import net.silentclient.client.Client;
import net.silentclient.client.admin.AdminRender;
import net.silentclient.client.cosmetics.Cosmetics;
import net.silentclient.client.cosmetics.gui.CosmeticsGui;
import net.silentclient.client.event.impl.ServerLeaveEvent;
import net.silentclient.client.gui.elements.IconButton;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.GuiMultiplayerInGame;
@ -97,6 +98,7 @@ public class GuiIngameMenu extends GuiScreen
{
this.mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu()));
}
new ServerLeaveEvent().call();
case 2:
case 3:

View File

@ -0,0 +1,21 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.IChatComponent;
import net.silentclient.client.event.impl.ServerLeaveEvent;
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;
@Mixin(GuiDisconnected.class)
public class GuiDisconnectedMixin {
@Inject(method = "<init>", at = @At("RETURN"))
private void init(GuiScreen screen,
String reasonLocalizationKey,
IChatComponent chatComp,
CallbackInfo ci) {
new ServerLeaveEvent().call();
}
}

View File

@ -14,7 +14,7 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ScreenShotHelper;
import net.minecraft.world.WorldSettings;
import net.silentclient.client.Client;
import net.silentclient.client.event.impl.*;
import net.silentclient.client.gui.GuiNews;
@ -113,6 +113,9 @@ public abstract class MinecraftMixin {
@Inject(method = "displayGuiScreen", at = @At("RETURN"), cancellable = true)
public void displayGuiScreenInject(GuiScreen guiScreenIn, CallbackInfo ci) {
if(guiScreenIn != null) {
Client.logger.info("Opening menu: " + guiScreenIn.getClass().toString());
}
if(Client.backgroundPanorama == null) {
Client.backgroundPanorama = new BackgroundPanorama(Minecraft.getMinecraft());
}
@ -260,4 +263,9 @@ public abstract class MinecraftMixin {
public void cancelChatMessage(GuiNewChat instance, IChatComponent chatComponent) {
}
@Inject(method = "launchIntegratedServer", at = @At("HEAD"))
public void event(String folderName, String worldName, WorldSettings worldSettingsIn, CallbackInfo ci) {
new SingleplayerJoinEvent().call();
}
}

View File

@ -1,5 +1,6 @@
package net.silentclient.client.mods.hypixel;
import net.silentclient.client.Client;
import net.silentclient.client.event.EventTarget;
import net.silentclient.client.event.impl.ClientTickEvent;
import net.silentclient.client.mods.Mod;
@ -36,6 +37,7 @@ public class AutoTipMod extends Mod {
public void onTick(ClientTickEvent event) {
if(Server.isHypixel()) {
if(timer.delay(1200000)) {
Client.logger.info("Attempting to tip: all");
mc.thePlayer.sendChatMessage("/tip all");
timer.reset();
}

View File

@ -11,12 +11,12 @@ import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.utils.types.PlayerResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.WeakHashMap;
public class Players {
public static final Map<String, PlayerResponse.Account> playersCache = new HashMap<>();
public static final Map<String, PlayerResponse.Account> playersCache = new WeakHashMap<>();
public static void reload() {
// playersCache.clear();

View File

@ -109,6 +109,7 @@
"mixins.ServerListMixin",
"mixins.EntityPacketsMixin",
"mixins.ScreenShotHelperMixin",
"mixins.RenderTNTPrimedMixin"
"mixins.RenderTNTPrimedMixin",
"mixins.GuiDisconnectedMixin"
]
}