mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 21:15:53 +08:00
[Feat] AltManager
This commit is contained in:
1 parent
96269c2fec
commit
a7cdf23a39
11 files changed
+573
No files matched your search
@@ -26,9 +26,21 @@ dependencies {
|
|||||||
implementation("org.ow2.asm:asm:9.8")
|
implementation("org.ow2.asm:asm:9.8")
|
||||||
// Source: https://mvnrepository.com/artifact/org.greenrobot/eventbus
|
// Source: https://mvnrepository.com/artifact/org.greenrobot/eventbus
|
||||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||||
|
// Source: https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||||
|
implementation 'com.google.code.gson:gson:2.13.2'
|
||||||
|
|
||||||
|
// for Alt
|
||||||
|
// Source: https://mvnrepository.com/artifact/net.raphimc/MinecraftAuth
|
||||||
|
implementation 'net.raphimc:MinecraftAuth:5.0.0'
|
||||||
|
// Source: https://mvnrepository.com/artifact/net.lenni0451.commons/gson
|
||||||
|
implementation 'net.lenni0451.commons:gson:1.9.2'
|
||||||
|
// Source: https://mvnrepository.com/artifact/net.lenni0451.commons/httpclient
|
||||||
|
implementation 'net.lenni0451.commons:httpclient:1.9.2'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate 'org.objectweb.asm', 'cn.xiaozhou233.asm9'
|
relocate 'org.objectweb.asm', 'cn.xiaozhou233.asm9'
|
||||||
|
relocate 'com.google.gson', "cn.xiaozhou233.gson"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.xiaozhou233.orangex;
|
package cn.xiaozhou233.orangex;
|
||||||
|
|
||||||
|
import cn.xiaozhou233.orangex.alts.AltManager;
|
||||||
import cn.xiaozhou233.orangex.font.FontManager;
|
import cn.xiaozhou233.orangex.font.FontManager;
|
||||||
import cn.xiaozhou233.orangex.mixin.MixinManager;
|
import cn.xiaozhou233.orangex.mixin.MixinManager;
|
||||||
import cn.xiaozhou233.orangex.module.ModuleManager;
|
import cn.xiaozhou233.orangex.module.ModuleManager;
|
||||||
@@ -8,8 +9,11 @@ import lombok.Getter;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class OrangeX {
|
public class OrangeX {
|
||||||
|
@Getter
|
||||||
|
private static File orangeXDir = new File(System.getProperty("user.home") + "/.orangex");
|
||||||
private static OrangeX instance;
|
private static OrangeX instance;
|
||||||
@Getter
|
@Getter
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
@@ -18,6 +22,8 @@ public class OrangeX {
|
|||||||
private static FontManager fontManager;
|
private static FontManager fontManager;
|
||||||
@Getter
|
@Getter
|
||||||
private final NoticeManager noticeManager;
|
private final NoticeManager noticeManager;
|
||||||
|
@Getter
|
||||||
|
private final AltManager altManager;
|
||||||
|
|
||||||
public OrangeX() {
|
public OrangeX() {
|
||||||
this.eventBus = EventBus.builder()
|
this.eventBus = EventBus.builder()
|
||||||
@@ -32,6 +38,11 @@ public class OrangeX {
|
|||||||
|
|
||||||
// Notice Manager
|
// Notice Manager
|
||||||
this.noticeManager = new NoticeManager(this.eventBus);
|
this.noticeManager = new NoticeManager(this.eventBus);
|
||||||
|
|
||||||
|
// Alt Manager
|
||||||
|
this.altManager = new AltManager();
|
||||||
|
|
||||||
|
eventBus.register(altManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package cn.xiaozhou233.orangex.alts;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter @Setter
|
||||||
|
public class Alt {
|
||||||
|
private String name;
|
||||||
|
private UUID uuid;
|
||||||
|
private String accessToken;
|
||||||
|
private long expireTimeMs;
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package cn.xiaozhou233.orangex.alts;
|
||||||
|
|
||||||
|
import cn.xiaozhou233.orangex.OrangeX;
|
||||||
|
import cn.xiaozhou233.orangex.utils.BrowserUtil;
|
||||||
|
import cn.xiaozhou233.orangex.utils.ClipboardUtil;
|
||||||
|
import net.lenni0451.commons.httpclient.HttpClient;
|
||||||
|
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||||
|
import net.raphimc.minecraftauth.java.JavaAuthManager;
|
||||||
|
import net.raphimc.minecraftauth.msa.model.MsaDeviceCode;
|
||||||
|
import net.raphimc.minecraftauth.msa.service.impl.DeviceCodeMsaAuthService;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class AltLoginThread extends Thread {
|
||||||
|
|
||||||
|
private String status = "NONE";
|
||||||
|
private final Consumer<String> statusConsumer;
|
||||||
|
|
||||||
|
public AltLoginThread(Consumer<String> statusConsumer) {
|
||||||
|
super("Alt Login Thread");
|
||||||
|
this.statusConsumer = statusConsumer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
if (statusConsumer != null) {
|
||||||
|
statusConsumer.accept(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
HttpClient httpClient = MinecraftAuth.createHttpClient();
|
||||||
|
setStatus("Created HttpClient");
|
||||||
|
|
||||||
|
JavaAuthManager.Builder authManagerBuilder = JavaAuthManager.create(httpClient);
|
||||||
|
setStatus("Created AuthManagerBuilder");
|
||||||
|
|
||||||
|
JavaAuthManager authManager = authManagerBuilder.login(DeviceCodeMsaAuthService::new, new Consumer<MsaDeviceCode>() {
|
||||||
|
@Override
|
||||||
|
public void accept(MsaDeviceCode deviceCode) {
|
||||||
|
System.out.println("Go to " + deviceCode.getVerificationUri());
|
||||||
|
BrowserUtil.openUrl(deviceCode.getDirectVerificationUri());
|
||||||
|
System.out.println("Enter code " + deviceCode.getUserCode());
|
||||||
|
ClipboardUtil.copyToClipboard(deviceCode.getUserCode());
|
||||||
|
|
||||||
|
setStatus("Waiting Login... code: " + deviceCode.getUserCode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
String username = authManager.getMinecraftProfile().getUpToDate().getName();
|
||||||
|
UUID uuid = authManager.getMinecraftProfile().getUpToDate().getId();
|
||||||
|
String accessToken = authManager.getMinecraftToken().getUpToDate().getToken();
|
||||||
|
long expireTimeMs = authManager.getMinecraftToken().getUpToDate().getExpireTimeMs();
|
||||||
|
|
||||||
|
Alt alt = new Alt(username, uuid, accessToken, expireTimeMs);
|
||||||
|
OrangeX.getInstance().getAltManager().addAlt(alt);
|
||||||
|
setStatus("Login Success!");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
setStatus("Login Failed: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package cn.xiaozhou233.orangex.alts;
|
||||||
|
|
||||||
|
import cn.xiaozhou233.orangex.OrangeX;
|
||||||
|
import cn.xiaozhou233.orangex.event.impl.EventTick;
|
||||||
|
import cn.xiaozhou233.orangex.ui.altmanager.GUIAltManager;
|
||||||
|
import cn.xiaozhou233.orangex.utils.SessionUtil;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiMultiplayer;
|
||||||
|
import net.minecraft.util.Session;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AltManager {
|
||||||
|
private Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
@Getter
|
||||||
|
private List<Alt> alts = new ArrayList<>();
|
||||||
|
private File file;
|
||||||
|
public AltManager() {
|
||||||
|
file = new File(OrangeX.getOrangeXDir(), "alts.json");
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onTick(EventTick event) {
|
||||||
|
// Return when key is not pressed
|
||||||
|
if (!Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Return when not in multiplayer menu
|
||||||
|
if (!(mc.currentScreen instanceof GuiMultiplayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Right SHIFT + Multiplayer Menu -> Display Alt List
|
||||||
|
mc.displayGuiScreen(new GUIAltManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAlt(Alt alt) {
|
||||||
|
alts.add(alt);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAlt(String name) {
|
||||||
|
alts.removeIf(alt -> alt.getName().equals(name));
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAlt(Alt alt) {
|
||||||
|
alts.remove(alt);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Alt get(int index) {
|
||||||
|
return alts.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return alts.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
try {
|
||||||
|
if (!file.getParentFile().exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
String json = gson.toJson(alts);
|
||||||
|
|
||||||
|
try (FileWriter writer = new FileWriter(file)) {
|
||||||
|
writer.write(json);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
try {
|
||||||
|
if (!file.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Type listType = new TypeToken<List<Alt>>() {}.getType();
|
||||||
|
|
||||||
|
try (FileReader reader = new FileReader(file)) {
|
||||||
|
List<Alt> loaded = gson.fromJson(reader, listType);
|
||||||
|
if (loaded != null) {
|
||||||
|
alts = loaded;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void login(Alt alt) {
|
||||||
|
Session session = new Session(
|
||||||
|
alt.getName(),
|
||||||
|
alt.getUuid().toString(),
|
||||||
|
alt.getAccessToken(),
|
||||||
|
"mojang"
|
||||||
|
);
|
||||||
|
SessionUtil.setSession(session);
|
||||||
|
System.out.println("Logging in as " + alt.getName());
|
||||||
|
System.out.println("UUID: " + alt.getUuid());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package cn.xiaozhou233.orangex.ui.altmanager;
|
||||||
|
|
||||||
|
import cn.xiaozhou233.orangex.OrangeX;
|
||||||
|
import cn.xiaozhou233.orangex.alts.Alt;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class GUIAddCracked extends GuiScreen {
|
||||||
|
|
||||||
|
private GuiTextField nameField;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
this.buttonList.clear();
|
||||||
|
|
||||||
|
nameField = new GuiTextField(0, fontRendererObj, this.width / 2 - 100, this.height / 2 - 10, 200, 20);
|
||||||
|
nameField.setMaxStringLength(32);
|
||||||
|
|
||||||
|
this.buttonList.add(new GuiButton(1, this.width / 2 - 50, this.height / 2 + 20, 100, 20, "Save"));
|
||||||
|
this.buttonList.add(new GuiButton(0, this.width / 2 - 50, this.height / 2 + 45, 100, 20, "Back"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
switch (button.id) {
|
||||||
|
case 1:
|
||||||
|
save();
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
mc.displayGuiScreen(new GUIAltManager());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
|
String name = nameField.getText().trim();
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
Alt alt = new Alt(
|
||||||
|
name,
|
||||||
|
UUID.randomUUID(),
|
||||||
|
"",
|
||||||
|
0L
|
||||||
|
);
|
||||||
|
OrangeX.getInstance().getAltManager().addAlt(alt);
|
||||||
|
mc.displayGuiScreen(new GUIAltManager());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen() {
|
||||||
|
super.updateScreen();
|
||||||
|
nameField.updateCursorCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||||
|
nameField.textboxKeyTyped(typedChar, keyCode);
|
||||||
|
|
||||||
|
if (keyCode == 28) {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.keyTyped(typedChar, keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
nameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
drawDefaultBackground();
|
||||||
|
drawCenteredString(fontRendererObj, "Add Cracked", width / 2, height / 2 - 30, 0xFFFFFF);
|
||||||
|
|
||||||
|
nameField.drawTextBox();
|
||||||
|
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesGuiPauseGame() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package cn.xiaozhou233.orangex.ui.altmanager;
|
||||||
|
|
||||||
|
import cn.xiaozhou233.orangex.alts.AltLoginThread;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class GUIAddMicrosoft extends GuiScreen {
|
||||||
|
|
||||||
|
private AltLoginThread loginThread;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
this.buttonList.clear();
|
||||||
|
|
||||||
|
this.buttonList.add(new GuiButton(1, this.width / 2 - 50, this.height / 2 + 20, 100, 20, "Start Login"));
|
||||||
|
this.buttonList.add(new GuiButton(0, this.width / 2 - 50, this.height / 2 + 45, 100, 20, "Back"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
switch (button.id) {
|
||||||
|
case 1:
|
||||||
|
if (loginThread == null || !loginThread.isAlive()) {
|
||||||
|
loginThread = new AltLoginThread(null);
|
||||||
|
loginThread.start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
mc.displayGuiScreen(new GUIAltManager());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen() {
|
||||||
|
super.updateScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
drawDefaultBackground();
|
||||||
|
|
||||||
|
drawCenteredString(fontRendererObj, "Add Microsoft", width / 2, height / 2 - 40, 0xFFFFFF);
|
||||||
|
|
||||||
|
String status = "NONE";
|
||||||
|
if (loginThread != null) {
|
||||||
|
status = loginThread.getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCenteredString(fontRendererObj, "Status: " + status, width / 2, height / 2 - 10, 0xFFFFFF);
|
||||||
|
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesGuiPauseGame() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
package cn.xiaozhou233.orangex.ui.altmanager;
|
||||||
|
|
||||||
|
import cn.xiaozhou233.orangex.OrangeX;
|
||||||
|
import cn.xiaozhou233.orangex.alts.Alt;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GUIAltManager extends GuiScreen {
|
||||||
|
|
||||||
|
private int selectedIndex = -1;
|
||||||
|
private int scroll = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
this.buttonList.clear();
|
||||||
|
|
||||||
|
// Add
|
||||||
|
this.buttonList.add(new GuiButton(1, this.width - 110, 10, 100, 20, "Add Cracked"));
|
||||||
|
this.buttonList.add(new GuiButton(2, this.width - 110, 35, 100, 20, "Add Microsoft"));
|
||||||
|
|
||||||
|
// Back
|
||||||
|
this.buttonList.add(new GuiButton(3, 10, this.height - 30, 60, 20, "Back"));
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
this.buttonList.add(new GuiButton(5, 80, this.height - 30, 60, 20, "Delete"));
|
||||||
|
|
||||||
|
// Login
|
||||||
|
this.buttonList.add(new GuiButton(4, this.width - 70, this.height - 30, 60, 20, "Login"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
switch (button.id) {
|
||||||
|
case 1:
|
||||||
|
mc.displayGuiScreen(new GUIAddCracked());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
mc.displayGuiScreen(new GUIAddMicrosoft());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mc.displayGuiScreen(null);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (selectedIndex >= 0) {
|
||||||
|
Alt alt = OrangeX.getInstance().getAltManager().getAlts().get(selectedIndex);
|
||||||
|
OrangeX.getInstance().getAltManager().login(alt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (selectedIndex >= 0) {
|
||||||
|
Alt alt = OrangeX.getInstance().getAltManager().getAlts().get(selectedIndex);
|
||||||
|
OrangeX.getInstance().getAltManager().removeAlt(alt);
|
||||||
|
selectedIndex = -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
|
||||||
|
drawCenteredString(this.fontRendererObj, "Alt Manager", this.width / 2, 10, Color.WHITE.getRGB());
|
||||||
|
|
||||||
|
mc.fontRendererObj.drawString(
|
||||||
|
"Current Account: §a" + Minecraft.getMinecraft().getSession().getUsername(),
|
||||||
|
10, 30, Color.WHITE.getRGB()
|
||||||
|
);
|
||||||
|
|
||||||
|
List<Alt> alts = OrangeX.getInstance().getAltManager().getAlts();
|
||||||
|
|
||||||
|
int startX = 10;
|
||||||
|
int startY = 60;
|
||||||
|
int listWidth = this.width - 20;
|
||||||
|
int listHeight = this.height - 110;
|
||||||
|
int lineHeight = 20;
|
||||||
|
|
||||||
|
// Draw list background
|
||||||
|
drawRect(startX - 2, startY - 2, startX + listWidth + 2, startY + listHeight + 2, 0x55000000);
|
||||||
|
|
||||||
|
// Scroll
|
||||||
|
int wheel = Mouse.getDWheel();
|
||||||
|
if (wheel != 0) {
|
||||||
|
if (wheel > 0) scroll -= 20;
|
||||||
|
else scroll += 20;
|
||||||
|
}
|
||||||
|
if (scroll < 0) scroll = 0;
|
||||||
|
if (scroll > Math.max(0, alts.size() * lineHeight - listHeight)) {
|
||||||
|
scroll = Math.max(0, alts.size() * lineHeight - listHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render alts
|
||||||
|
for (int i = 0; i < alts.size(); i++) {
|
||||||
|
int y = startY + i * lineHeight - scroll;
|
||||||
|
|
||||||
|
if (y < startY - lineHeight || y > startY + listHeight) continue;
|
||||||
|
|
||||||
|
if (i == selectedIndex) {
|
||||||
|
drawRect(startX, y, startX + listWidth, y + lineHeight, 0x55FFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
mc.fontRendererObj.drawString(alts.get(i).getName(), startX + 5, y + 6, Color.WHITE.getRGB());
|
||||||
|
|
||||||
|
// Click select
|
||||||
|
if (mouseX >= startX && mouseX <= startX + listWidth &&
|
||||||
|
mouseY >= y && mouseY <= y + lineHeight &&
|
||||||
|
Mouse.isButtonDown(0)) {
|
||||||
|
selectedIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesGuiPauseGame() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.xiaozhou233.orangex.utils;
|
||||||
|
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
public class BrowserUtil {
|
||||||
|
|
||||||
|
public static void openUrl(String url) {
|
||||||
|
try {
|
||||||
|
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||||
|
Desktop.getDesktop().browse(new URI(url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
try {
|
||||||
|
if (os.contains("win")) {
|
||||||
|
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
|
||||||
|
} else if (os.contains("mac")) {
|
||||||
|
Runtime.getRuntime().exec("open " + url);
|
||||||
|
} else if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
|
||||||
|
Runtime.getRuntime().exec("xdg-open " + url);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package cn.xiaozhou233.orangex.utils;
|
||||||
|
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
|
public class ClipboardUtil {
|
||||||
|
|
||||||
|
public static void copyToClipboard(String text) {
|
||||||
|
StringSelection selection = new StringSelection(text);
|
||||||
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
clipboard.setContents(selection, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package cn.xiaozhou233.orangex.utils;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.Session;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class SessionUtil {
|
||||||
|
public static boolean setSession(Session session) {
|
||||||
|
try {
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
Field sessionField = Minecraft.class.getDeclaredField("session");
|
||||||
|
sessionField.setAccessible(true);
|
||||||
|
sessionField.set(mc, session);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user