(fix) quickplay bug

This commit is contained in:
kirillsaint 2024-06-04 13:42:43 +06:00
parent 7169eaf437
commit 08188bf9e5

View File

@ -4,6 +4,7 @@ import com.google.common.reflect.TypeToken;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.event.EventTarget; import net.silentclient.client.event.EventTarget;
import net.silentclient.client.event.impl.ConnectToServerEvent;
import net.silentclient.client.event.impl.KeyEvent; import net.silentclient.client.event.impl.KeyEvent;
import net.silentclient.client.gui.quickplay.QuickplayGui; import net.silentclient.client.gui.quickplay.QuickplayGui;
import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.Mod;
@ -68,7 +69,8 @@ public class QuickPlayMod extends Mod {
public void updateHashMap() { public void updateHashMap() {
HashMap<Integer, Setting> map = new HashMap<>(); HashMap<Integer, Setting> map = new HashMap<>();
for(Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(this)) { for(Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(this)) {
if (setting.isKeybind()) { String[] args = setting.getName().split("&");
if (((args[1].equals("Hypixel") && Server.isHypixel()) || (args[1].equals("RuHypixel") && Server.isRuHypixel())) && setting.isKeybind()) {
map.put(setting.getKeybind(), setting); map.put(setting.getKeybind(), setting);
} }
} }
@ -76,6 +78,11 @@ public class QuickPlayMod extends Mod {
hashMap = map; hashMap = map;
} }
@EventTarget
public void onServerJoin(ConnectToServerEvent event) {
updateHashMap();
}
@Override @Override
public void onChangeSettingValue(Setting setting) { public void onChangeSettingValue(Setting setting) {
super.onChangeSettingValue(setting); super.onChangeSettingValue(setting);
@ -133,7 +140,7 @@ public class QuickPlayMod extends Mod {
if(setting != null) { if(setting != null) {
if(setting.getName().equals("Open Menu")) { if(setting.getName().equals("Open Menu")) {
// Open Menu // Open Menu
if(setting.isKeyDown() && (Server.isHypixel() || Server.isRuHypixel())) { if(Server.isHypixel() || Server.isRuHypixel()) {
mc.displayGuiScreen(new QuickplayGui()); mc.displayGuiScreen(new QuickplayGui());
} }
} else { } else {
@ -141,13 +148,11 @@ public class QuickPlayMod extends Mod {
return; return;
} }
String[] args = setting.getName().split("&"); String[] args = setting.getName().split("&");
if(((args[1].equals("Hypixel") && Server.isHypixel()) || (args[1].equals("RuHypixel") && Server.isRuHypixel())) && setting.isKeyDown()) {
runCommand(args[2]); runCommand(args[2]);
} }
} }
} }
} }
}
@Override @Override
public void onEnable() { public void onEnable() {