Added AltManager, Added GuiAltManager
This commit is contained in:
parent
a2e8ba70ff
commit
d16368b1c7
|
@ -75,6 +75,8 @@ public final class Seppuku {
|
|||
|
||||
private CameraManager cameraManager;
|
||||
|
||||
private AltManager altManager;
|
||||
|
||||
/**
|
||||
* The initialization point of the client
|
||||
* this is called post launch
|
||||
|
@ -99,6 +101,7 @@ public final class Seppuku {
|
|||
this.moduleManager = new ModuleManager();
|
||||
this.commandManager = new CommandManager();
|
||||
this.cameraManager = new CameraManager();
|
||||
this.altManager = new AltManager();
|
||||
this.hudManager = new HudManager();
|
||||
this.hudEditor = new GuiHudEditor();
|
||||
this.seppukuMainMenu = new GuiSeppukuMainMenu();
|
||||
|
@ -157,6 +160,7 @@ public final class Seppuku {
|
|||
this.hudEditor.unload();
|
||||
this.seppukuMainMenu.unload();
|
||||
this.cameraManager.unload();
|
||||
this.altManager.unload();
|
||||
|
||||
this.getEventManager().dispatchEvent(new EventUnload());
|
||||
|
||||
|
@ -369,4 +373,10 @@ public final class Seppuku {
|
|||
return this.cameraManager;
|
||||
}
|
||||
|
||||
public AltManager getAltManager() {
|
||||
if (this.altManager == null) {
|
||||
this.altManager = new AltManager();
|
||||
}
|
||||
return this.altManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package me.rigamortis.seppuku.api.gui.menu;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public class AltData {
|
||||
|
||||
private final String email;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final boolean premium;
|
||||
|
||||
public AltData(String email, String username, String password) {
|
||||
this.email = email;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.premium = true;
|
||||
}
|
||||
|
||||
public AltData(String username, String password) {
|
||||
this.email = "";
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.premium = true;
|
||||
}
|
||||
|
||||
public AltData(String username) {
|
||||
this.email = "";
|
||||
this.username = username;
|
||||
this.password = "";
|
||||
this.premium = false;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public boolean isPremium() {
|
||||
return this.premium;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package me.rigamortis.seppuku.api.gui.menu;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.impl.gui.menu.GuiAltManager;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public final class GuiAddAlt extends GuiScreen {
|
||||
|
||||
private GuiTextField usernameField;
|
||||
private GuiTextField emailField;
|
||||
private GuiPasswordField passwordField;
|
||||
private final GuiAltManager parent;
|
||||
|
||||
public GuiAddAlt(GuiAltManager parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
this.buttonList.clear();
|
||||
this.emailField = new GuiTextField(2, this.fontRenderer, this.width / 2 - 100, 56, 200, 20);
|
||||
this.usernameField = new GuiTextField(3, this.fontRenderer, this.width / 2 - 100, 96, 200, 20);
|
||||
this.passwordField = new GuiPasswordField(4, this.fontRenderer, this.width / 2 - 100, 136, 200, 20);
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, "Add"));
|
||||
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96 + 36, "Back"));
|
||||
this.usernameField.setMaxStringLength(64);
|
||||
this.passwordField.setMaxStringLength(64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow("Email", (this.width / 2.0f - 100), 56 - mc.fontRenderer.FONT_HEIGHT - 1, 0xFFAAAAAA);
|
||||
mc.fontRenderer.drawStringWithShadow("Username", (this.width / 2.0f - 100), 96.0F - mc.fontRenderer.FONT_HEIGHT - 1, 0xFFAAAAAA);
|
||||
mc.fontRenderer.drawStringWithShadow("Password", (this.width / 2.0f - 100), 136.0F - mc.fontRenderer.FONT_HEIGHT - 1, 0xFFAAAAAA);
|
||||
this.emailField.drawTextBox();
|
||||
this.usernameField.drawTextBox();
|
||||
this.passwordField.drawTextBox();
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
|
||||
final boolean emailFieldEmpty = this.emailField.getText().trim().isEmpty();
|
||||
final boolean usernameFieldEmpty = this.usernameField.getText().trim().isEmpty();
|
||||
final boolean passwordFieldEmpty = this.passwordField.getText().trim().isEmpty();
|
||||
|
||||
switch (button.id) {
|
||||
case 0:
|
||||
if (!emailFieldEmpty && !usernameFieldEmpty && !passwordFieldEmpty) {
|
||||
final AltData premiumAlt = new AltData(this.emailField.getText().trim(), this.usernameField.getText().trim(), this.passwordField.getText().trim());
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(premiumAlt);
|
||||
}
|
||||
if (emailFieldEmpty && !usernameFieldEmpty && passwordFieldEmpty) {
|
||||
final AltData offlineAlt = new AltData(this.usernameField.getText().trim());
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(offlineAlt);
|
||||
}
|
||||
if (emailFieldEmpty && !usernameFieldEmpty && !passwordFieldEmpty) {
|
||||
final AltData semiPremiumAlt = new AltData(this.usernameField.getText().trim(), this.passwordField.getText().trim());
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(semiPremiumAlt);
|
||||
}
|
||||
mc.displayGuiScreen(this.parent);
|
||||
break;
|
||||
case 1:
|
||||
mc.displayGuiScreen(this.parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
this.emailField.textboxKeyTyped(typedChar, keyCode);
|
||||
this.usernameField.textboxKeyTyped(typedChar, keyCode);
|
||||
this.passwordField.textboxKeyTyped(typedChar, keyCode);
|
||||
|
||||
if (typedChar == '\r') {
|
||||
this.actionPerformed(this.buttonList.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.emailField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.usernameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.passwordField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package me.rigamortis.seppuku.api.gui.menu;
|
||||
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.gui.GuiListExtended;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public class GuiEntryAlt implements GuiListExtended.IGuiListEntry {
|
||||
|
||||
private GuiListAlt parent;
|
||||
private ResourceLocation resourceLocation;
|
||||
private final AltData alt;
|
||||
|
||||
public GuiEntryAlt(GuiListAlt parent, AltData alt) {
|
||||
this.parent = parent;
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePosition(int i, int i1, int i2, float v) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean mouseOver, float v) {
|
||||
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(this.alt.getUsername(), x + 22, y + 2, 0xFFFFFFFF);
|
||||
|
||||
if (this.alt.isPremium()) {
|
||||
String password = this.alt.getPassword().replaceAll("(?s).", "*");
|
||||
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(password, x + 22, y + 2 + Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT, 0xFFAAAAAA);
|
||||
}
|
||||
|
||||
if (this.resourceLocation == null) {
|
||||
this.resourceLocation = AbstractClientPlayer.getLocationSkin(this.alt.getUsername());
|
||||
this.getDownloadImageSkin(this.resourceLocation, this.alt.getUsername());
|
||||
} else {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
|
||||
GlStateManager.enableTexture2D();
|
||||
RenderUtil.drawTexture(x, y, 20, 20, 0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(int slotIndex, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) {
|
||||
this.parent.setSelected(slotIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
|
||||
}
|
||||
|
||||
private ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
|
||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
textureManager.getTexture(resourceLocationIn);
|
||||
ThreadDownloadImageData textureObject = new ThreadDownloadImageData(null, String.format("https://minotar.net/avatar/%s/64.png", StringUtils.stripControlCodes(username)), DefaultPlayerSkin.getDefaultSkin(AbstractClientPlayer.getOfflineUUID(username)), new ImageBufferDownload());
|
||||
textureManager.loadTexture(resourceLocationIn, textureObject);
|
||||
return textureObject;
|
||||
}
|
||||
|
||||
public AltData getAlt() {
|
||||
return this.alt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package me.rigamortis.seppuku.api.gui.menu;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import me.rigamortis.seppuku.api.util.AuthUtil;
|
||||
import me.rigamortis.seppuku.impl.gui.menu.GuiAltManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiListExtended;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public final class GuiListAlt extends GuiListExtended {
|
||||
|
||||
private final List<GuiEntryAlt> entries = new ArrayList<>();
|
||||
private int selected = -1;
|
||||
|
||||
public GuiListAlt(Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn) {
|
||||
super(mcIn, widthIn, heightIn, topIn, bottomIn, 24);
|
||||
}
|
||||
|
||||
public void login(final GuiAltManager guiAltManager) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final GuiEntryAlt guiEntryAlt = GuiListAlt.this.getSelected();
|
||||
String status = "Logging in...";
|
||||
|
||||
if (guiEntryAlt != null) {
|
||||
if (guiEntryAlt.getAlt().getEmail().isEmpty()) {
|
||||
if (guiEntryAlt.getAlt().isPremium()) {
|
||||
status = AuthUtil.loginPassword(guiEntryAlt.getAlt().getUsername(), guiEntryAlt.getAlt().getPassword());
|
||||
} else {
|
||||
AuthUtil.loginPasswordOffline(guiEntryAlt.getAlt().getUsername());
|
||||
status = "Success (offline account)";
|
||||
}
|
||||
} else {
|
||||
status = AuthUtil.loginPassword(guiEntryAlt.getAlt().getEmail(), guiEntryAlt.getAlt().getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
guiAltManager.setStatus(ChatFormatting.GRAY + status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setAlts(List<AltData> alts) {
|
||||
this.selected = -1;
|
||||
this.entries.clear();
|
||||
|
||||
for (AltData alt : alts) {
|
||||
this.entries.add(new GuiEntryAlt(this, alt));
|
||||
}
|
||||
}
|
||||
|
||||
public GuiEntryAlt getListEntry(int index) {
|
||||
return this.entries.get(index);
|
||||
}
|
||||
|
||||
protected boolean isSelected(int index) {
|
||||
return (index == this.selected);
|
||||
}
|
||||
|
||||
public void setSelected(int index) {
|
||||
this.selected = index;
|
||||
}
|
||||
|
||||
public boolean hasSelected() {
|
||||
return (this.selected >= 0 && this.selected < this.entries.size());
|
||||
}
|
||||
|
||||
public GuiEntryAlt getSelected() {
|
||||
return this.hasSelected() ? this.entries.get(this.selected) : null;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.entries.size();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,551 @@
|
|||
package me.rigamortis.seppuku.api.gui.menu;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiPageButtonList.GuiResponder;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.GlStateManager.LogicOp;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
/**
|
||||
* @author Mojang
|
||||
* @author noil
|
||||
*/
|
||||
public class GuiPasswordField extends Gui {
|
||||
|
||||
private final int id;
|
||||
private final FontRenderer fontRenderer;
|
||||
public int x;
|
||||
public int y;
|
||||
public int width;
|
||||
public int height;
|
||||
private String text = "";
|
||||
private int maxStringLength = 32;
|
||||
private int cursorCounter;
|
||||
private boolean enableBackgroundDrawing = true;
|
||||
private boolean canLoseFocus = true;
|
||||
private boolean isFocused;
|
||||
private boolean isEnabled = true;
|
||||
private int lineScrollOffset;
|
||||
private int cursorPosition;
|
||||
private int selectionEnd;
|
||||
private int enabledColor = 14737632;
|
||||
private int disabledColor = 7368816;
|
||||
private boolean visible = true;
|
||||
private GuiResponder guiResponder;
|
||||
private Predicate<String> validator = Predicates.alwaysTrue();
|
||||
|
||||
public GuiPasswordField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height) {
|
||||
this.id = componentId;
|
||||
this.fontRenderer = fontrendererObj;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = par5Width;
|
||||
this.height = par6Height;
|
||||
}
|
||||
|
||||
public void setGuiResponder(GuiResponder guiResponderIn) {
|
||||
this.guiResponder = guiResponderIn;
|
||||
}
|
||||
|
||||
public void updateCursorCounter() {
|
||||
++this.cursorCounter;
|
||||
}
|
||||
|
||||
public void setText(String textIn) {
|
||||
if (this.validator.apply(textIn)) {
|
||||
if (textIn.length() > this.maxStringLength) {
|
||||
this.text = textIn.substring(0, this.maxStringLength);
|
||||
} else {
|
||||
this.text = textIn;
|
||||
}
|
||||
|
||||
this.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public String getSelectedText() {
|
||||
int i = Math.min(this.cursorPosition, this.selectionEnd);
|
||||
int j = Math.max(this.cursorPosition, this.selectionEnd);
|
||||
return this.text.substring(i, j);
|
||||
}
|
||||
|
||||
public void setValidator(Predicate<String> theValidator) {
|
||||
this.validator = theValidator;
|
||||
}
|
||||
|
||||
public void writeText(String textToWrite) {
|
||||
String s = "";
|
||||
String s1 = ChatAllowedCharacters.filterAllowedCharacters(textToWrite);
|
||||
int i = Math.min(this.cursorPosition, this.selectionEnd);
|
||||
int j = Math.max(this.cursorPosition, this.selectionEnd);
|
||||
int k = this.maxStringLength - this.text.length() - (i - j);
|
||||
if (!this.text.isEmpty()) {
|
||||
s = s + this.text.substring(0, i);
|
||||
}
|
||||
|
||||
int l;
|
||||
if (k < s1.length()) {
|
||||
s = s + s1.substring(0, k);
|
||||
l = k;
|
||||
} else {
|
||||
s = s + s1;
|
||||
l = s1.length();
|
||||
}
|
||||
|
||||
if (!this.text.isEmpty() && j < this.text.length()) {
|
||||
s = s + this.text.substring(j);
|
||||
}
|
||||
|
||||
if (this.validator.apply(s)) {
|
||||
this.text = s;
|
||||
this.moveCursorBy(i - this.selectionEnd + l);
|
||||
this.setResponderEntryValue(this.id, this.text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setResponderEntryValue(int idIn, String textIn) {
|
||||
if (this.guiResponder != null) {
|
||||
this.guiResponder.setEntryValue(idIn, textIn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteWords(int num) {
|
||||
if (!this.text.isEmpty()) {
|
||||
if (this.selectionEnd != this.cursorPosition) {
|
||||
this.writeText("");
|
||||
} else {
|
||||
this.deleteFromCursor(this.getNthWordFromCursor(num) - this.cursorPosition);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteFromCursor(int num) {
|
||||
if (!this.text.isEmpty()) {
|
||||
if (this.selectionEnd != this.cursorPosition) {
|
||||
this.writeText("");
|
||||
} else {
|
||||
boolean flag = num < 0;
|
||||
int i = flag ? this.cursorPosition + num : this.cursorPosition;
|
||||
int j = flag ? this.cursorPosition : this.cursorPosition + num;
|
||||
String s = "";
|
||||
if (i >= 0) {
|
||||
s = this.text.substring(0, i);
|
||||
}
|
||||
|
||||
if (j < this.text.length()) {
|
||||
s = s + this.text.substring(j);
|
||||
}
|
||||
|
||||
if (this.validator.apply(s)) {
|
||||
this.text = s;
|
||||
if (flag) {
|
||||
this.moveCursorBy(num);
|
||||
}
|
||||
|
||||
this.setResponderEntryValue(this.id, this.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getNthWordFromCursor(int numWords) {
|
||||
return this.getNthWordFromPos(numWords, this.getCursorPosition());
|
||||
}
|
||||
|
||||
public int getNthWordFromPos(int n, int pos) {
|
||||
return this.getNthWordFromPosWS(n, pos, true);
|
||||
}
|
||||
|
||||
public int getNthWordFromPosWS(int n, int pos, boolean skipWs) {
|
||||
int i = pos;
|
||||
boolean flag = n < 0;
|
||||
int j = Math.abs(n);
|
||||
|
||||
for(int k = 0; k < j; ++k) {
|
||||
if (!flag) {
|
||||
int l = this.text.length();
|
||||
i = this.text.indexOf(32, i);
|
||||
if (i == -1) {
|
||||
i = l;
|
||||
} else {
|
||||
while(skipWs && i < l && this.text.charAt(i) == ' ') {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while(skipWs && i > 0 && this.text.charAt(i - 1) == ' ') {
|
||||
--i;
|
||||
}
|
||||
|
||||
while(i > 0 && this.text.charAt(i - 1) != ' ') {
|
||||
--i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public void moveCursorBy(int num) {
|
||||
this.setCursorPosition(this.selectionEnd + num);
|
||||
}
|
||||
|
||||
public void setCursorPosition(int pos) {
|
||||
this.cursorPosition = pos;
|
||||
int i = this.text.length();
|
||||
this.cursorPosition = MathHelper.clamp(this.cursorPosition, 0, i);
|
||||
this.setSelectionPos(this.cursorPosition);
|
||||
}
|
||||
|
||||
public void setCursorPositionZero() {
|
||||
this.setCursorPosition(0);
|
||||
}
|
||||
|
||||
public void setCursorPositionEnd() {
|
||||
this.setCursorPosition(this.text.length());
|
||||
}
|
||||
|
||||
public boolean textboxKeyTyped(char typedChar, int keyCode) {
|
||||
if (!this.isFocused) {
|
||||
return false;
|
||||
} else if (GuiScreen.isKeyComboCtrlA(keyCode)) {
|
||||
this.setCursorPositionEnd();
|
||||
this.setSelectionPos(0);
|
||||
return true;
|
||||
} else if (GuiScreen.isKeyComboCtrlC(keyCode)) {
|
||||
GuiScreen.setClipboardString(this.getSelectedText());
|
||||
return true;
|
||||
} else if (GuiScreen.isKeyComboCtrlV(keyCode)) {
|
||||
if (this.isEnabled) {
|
||||
this.writeText(GuiScreen.getClipboardString());
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (GuiScreen.isKeyComboCtrlX(keyCode)) {
|
||||
GuiScreen.setClipboardString(this.getSelectedText());
|
||||
if (this.isEnabled) {
|
||||
this.writeText("");
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
switch(keyCode) {
|
||||
case 14:
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
if (this.isEnabled) {
|
||||
this.deleteWords(-1);
|
||||
}
|
||||
} else if (this.isEnabled) {
|
||||
this.deleteFromCursor(-1);
|
||||
}
|
||||
|
||||
return true;
|
||||
case 199:
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
this.setSelectionPos(0);
|
||||
} else {
|
||||
this.setCursorPositionZero();
|
||||
}
|
||||
|
||||
return true;
|
||||
case 203:
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
|
||||
} else {
|
||||
this.setSelectionPos(this.getSelectionEnd() - 1);
|
||||
}
|
||||
} else if (GuiScreen.isCtrlKeyDown()) {
|
||||
this.setCursorPosition(this.getNthWordFromCursor(-1));
|
||||
} else {
|
||||
this.moveCursorBy(-1);
|
||||
}
|
||||
|
||||
return true;
|
||||
case 205:
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
|
||||
} else {
|
||||
this.setSelectionPos(this.getSelectionEnd() + 1);
|
||||
}
|
||||
} else if (GuiScreen.isCtrlKeyDown()) {
|
||||
this.setCursorPosition(this.getNthWordFromCursor(1));
|
||||
} else {
|
||||
this.moveCursorBy(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
case 207:
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
this.setSelectionPos(this.text.length());
|
||||
} else {
|
||||
this.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
return true;
|
||||
case 211:
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
if (this.isEnabled) {
|
||||
this.deleteWords(1);
|
||||
}
|
||||
} else if (this.isEnabled) {
|
||||
this.deleteFromCursor(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
if (ChatAllowedCharacters.isAllowedCharacter(typedChar)) {
|
||||
if (this.isEnabled) {
|
||||
this.writeText(Character.toString(typedChar));
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
boolean flag = mouseX >= this.x && mouseX < this.x + this.width && mouseY >= this.y && mouseY < this.y + this.height;
|
||||
if (this.canLoseFocus) {
|
||||
this.setFocused(flag);
|
||||
}
|
||||
|
||||
if (this.isFocused && flag && mouseButton == 0) {
|
||||
int i = mouseX - this.x;
|
||||
if (this.enableBackgroundDrawing) {
|
||||
i -= 4;
|
||||
}
|
||||
|
||||
String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
|
||||
this.setCursorPosition(this.fontRenderer.trimStringToWidth(s, i).length() + this.lineScrollOffset);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTextBox() {
|
||||
if (this.getVisible()) {
|
||||
if (this.getEnableBackgroundDrawing()) {
|
||||
drawRect(this.x - 1, this.y - 1, this.x + this.width + 1, this.y + this.height + 1, -6250336);
|
||||
drawRect(this.x, this.y, this.x + this.width, this.y + this.height, -16777216);
|
||||
}
|
||||
|
||||
int i = this.isEnabled ? this.enabledColor : this.disabledColor;
|
||||
int j = this.cursorPosition - this.lineScrollOffset;
|
||||
int k = this.selectionEnd - this.lineScrollOffset;
|
||||
String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
|
||||
boolean flag = j >= 0 && j <= s.length();
|
||||
boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag;
|
||||
int l = this.enableBackgroundDrawing ? this.x + 4 : this.x;
|
||||
int i1 = this.enableBackgroundDrawing ? this.y + (this.height - 8) / 2 : this.y;
|
||||
int j1 = l;
|
||||
if (k > s.length()) {
|
||||
k = s.length();
|
||||
}
|
||||
|
||||
if (!s.isEmpty()) {
|
||||
String s1 = flag ? s.substring(0, j) : s;
|
||||
j1 = this.fontRenderer.drawStringWithShadow(s1.replaceAll("(?s).", "*"), (float)l, (float)i1, i);
|
||||
}
|
||||
|
||||
boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength();
|
||||
int k1 = j1;
|
||||
if (!flag) {
|
||||
k1 = j > 0 ? l + this.width : l;
|
||||
} else if (flag2) {
|
||||
k1 = j1 - 1;
|
||||
--j1;
|
||||
}
|
||||
|
||||
if (!s.isEmpty() && flag && j < s.length()) {
|
||||
j1 = this.fontRenderer.drawStringWithShadow(s.substring(j), (float)j1, (float)i1, i);
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
if (flag2) {
|
||||
Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT, -3092272);
|
||||
} else {
|
||||
this.fontRenderer.drawStringWithShadow("_", (float)k1, (float)i1, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (k != j) {
|
||||
int l1 = l + this.fontRenderer.getStringWidth(s.substring(0, k));
|
||||
this.drawSelectionBox(k1, i1 - 1, l1 - 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void drawSelectionBox(int startX, int startY, int endX, int endY) {
|
||||
int j;
|
||||
if (startX < endX) {
|
||||
j = startX;
|
||||
startX = endX;
|
||||
endX = j;
|
||||
}
|
||||
|
||||
if (startY < endY) {
|
||||
j = startY;
|
||||
startY = endY;
|
||||
endY = j;
|
||||
}
|
||||
|
||||
if (endX > this.x + this.width) {
|
||||
endX = this.x + this.width;
|
||||
}
|
||||
|
||||
if (startX > this.x + this.width) {
|
||||
startX = this.x + this.width;
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableColorLogic();
|
||||
GlStateManager.colorLogicOp(LogicOp.OR_REVERSE);
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||
bufferbuilder.pos((double)startX, (double)endY, 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)endX, (double)endY, 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)endX, (double)startY, 0.0D).endVertex();
|
||||
bufferbuilder.pos((double)startX, (double)startY, 0.0D).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.disableColorLogic();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public void setMaxStringLength(int length) {
|
||||
this.maxStringLength = length;
|
||||
if (this.text.length() > length) {
|
||||
this.text = this.text.substring(0, length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getMaxStringLength() {
|
||||
return this.maxStringLength;
|
||||
}
|
||||
|
||||
public int getCursorPosition() {
|
||||
return this.cursorPosition;
|
||||
}
|
||||
|
||||
public boolean getEnableBackgroundDrawing() {
|
||||
return this.enableBackgroundDrawing;
|
||||
}
|
||||
|
||||
public void setEnableBackgroundDrawing(boolean enableBackgroundDrawingIn) {
|
||||
this.enableBackgroundDrawing = enableBackgroundDrawingIn;
|
||||
}
|
||||
|
||||
public void setTextColor(int color) {
|
||||
this.enabledColor = color;
|
||||
}
|
||||
|
||||
public void setDisabledTextColour(int color) {
|
||||
this.disabledColor = color;
|
||||
}
|
||||
|
||||
public void setFocused(boolean isFocusedIn) {
|
||||
if (isFocusedIn && !this.isFocused) {
|
||||
this.cursorCounter = 0;
|
||||
}
|
||||
|
||||
this.isFocused = isFocusedIn;
|
||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
||||
Minecraft.getMinecraft().currentScreen.setFocused(isFocusedIn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isFocused() {
|
||||
return this.isFocused;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.isEnabled = enabled;
|
||||
}
|
||||
|
||||
public int getSelectionEnd() {
|
||||
return this.selectionEnd;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width;
|
||||
}
|
||||
|
||||
public void setSelectionPos(int position) {
|
||||
int i = this.text.length();
|
||||
if (position > i) {
|
||||
position = i;
|
||||
}
|
||||
|
||||
if (position < 0) {
|
||||
position = 0;
|
||||
}
|
||||
|
||||
this.selectionEnd = position;
|
||||
if (this.fontRenderer != null) {
|
||||
if (this.lineScrollOffset > i) {
|
||||
this.lineScrollOffset = i;
|
||||
}
|
||||
|
||||
int j = this.getWidth();
|
||||
String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), j);
|
||||
int k = s.length() + this.lineScrollOffset;
|
||||
if (position == this.lineScrollOffset) {
|
||||
this.lineScrollOffset -= this.fontRenderer.trimStringToWidth(this.text, j, true).length();
|
||||
}
|
||||
|
||||
if (position > k) {
|
||||
this.lineScrollOffset += position - k;
|
||||
} else if (position <= this.lineScrollOffset) {
|
||||
this.lineScrollOffset -= this.lineScrollOffset - position;
|
||||
}
|
||||
|
||||
this.lineScrollOffset = MathHelper.clamp(this.lineScrollOffset, 0, i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setCanLoseFocus(boolean canLoseFocusIn) {
|
||||
this.canLoseFocus = canLoseFocusIn;
|
||||
}
|
||||
|
||||
public boolean getVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
public void setVisible(boolean isVisible) {
|
||||
this.visible = isVisible;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package me.rigamortis.seppuku.impl.gui.menu;
|
||||
package me.rigamortis.seppuku.api.gui.menu;
|
||||
|
||||
import me.rigamortis.seppuku.api.util.RenderUtil;
|
||||
import net.minecraft.client.Minecraft;
|
|
@ -0,0 +1,54 @@
|
|||
package me.rigamortis.seppuku.api.util;
|
||||
|
||||
import com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Session;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
/**
|
||||
* @author Seth
|
||||
*/
|
||||
public final class AuthUtil {
|
||||
|
||||
public AuthUtil(final String name, final String password, boolean online) {
|
||||
if (online) {
|
||||
if (name != null && password != null) {
|
||||
(new Thread() {
|
||||
public void run() {
|
||||
AuthUtil.loginPassword(name, password);
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
System.out.println("Username and/or password is incorrect.");
|
||||
}
|
||||
} else {
|
||||
loginPasswordOffline(name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loginPasswordOffline(String username) {
|
||||
Minecraft.getMinecraft().session = new Session(username, username, username, "MOJANG");
|
||||
}
|
||||
|
||||
public static String loginPassword(String username, String password) {
|
||||
if (username == null || username.length() <= 0 || password == null || password.length() <= 0)
|
||||
return "Error";
|
||||
YggdrasilAuthenticationService a = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
|
||||
YggdrasilUserAuthentication b = (YggdrasilUserAuthentication)a.createUserAuthentication(Agent.MINECRAFT);
|
||||
b.setUsername(username);
|
||||
b.setPassword(password);
|
||||
try {
|
||||
b.logIn();
|
||||
Minecraft.getMinecraft()
|
||||
.session = new Session(b.getSelectedProfile().getName(), b.getSelectedProfile().getId().toString(), b.getAuthenticatedToken(), "MOJANG");
|
||||
} catch (AuthenticationException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
return "Success";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package me.rigamortis.seppuku.impl.config;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.config.Configurable;
|
||||
import me.rigamortis.seppuku.api.gui.menu.AltData;
|
||||
import me.rigamortis.seppuku.api.util.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public final class AltConfig extends Configurable {
|
||||
|
||||
public AltConfig(File dir) {
|
||||
super(FileUtil.createJsonFile(dir, "Alts"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
this.getJsonObject().entrySet().forEach(entry -> {
|
||||
final String username = entry.getKey();
|
||||
|
||||
String email = "";
|
||||
String password = "";
|
||||
JsonArray jsonArray = entry.getValue().getAsJsonArray();
|
||||
|
||||
if (jsonArray != null) {
|
||||
if (jsonArray.size() > 0) {
|
||||
if (jsonArray.get(0).isJsonNull()) {
|
||||
email = "";
|
||||
} else {
|
||||
email = jsonArray.get(0).getAsString();
|
||||
}
|
||||
if (jsonArray.get(1).isJsonNull()) {
|
||||
password = "";
|
||||
} else {
|
||||
password = jsonArray.get(1).getAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!email.equals("") && !password.equals(""))
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(new AltData(email, username, password));
|
||||
else if (email.equals("") && !password.equals(""))
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(new AltData(username, password));
|
||||
else
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(new AltData(username));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSave() {
|
||||
JsonObject altListJsonObject = new JsonObject();
|
||||
Seppuku.INSTANCE.getAltManager().getAlts().forEach(alt -> {
|
||||
JsonArray array = new JsonArray();
|
||||
array.add(alt.getEmail());
|
||||
array.add(alt.getPassword());
|
||||
altListJsonObject.add(alt.getUsername(), array);
|
||||
});
|
||||
this.saveJsonObjectToFile(altListJsonObject);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
package me.rigamortis.seppuku.impl.gui.menu;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.gui.menu.AltData;
|
||||
import me.rigamortis.seppuku.api.gui.menu.GuiAddAlt;
|
||||
import me.rigamortis.seppuku.api.gui.menu.GuiListAlt;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @author noil
|
||||
*/
|
||||
public final class GuiAltManager extends GuiScreen implements GuiYesNoCallback {
|
||||
|
||||
private final GuiScreen parent;
|
||||
private GuiListAlt guiListAlt;
|
||||
private GuiButton login;
|
||||
private GuiButton remove;
|
||||
private String status = "Idle";
|
||||
|
||||
public GuiAltManager(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
this.guiListAlt = new GuiListAlt(this.mc, this.width, this.height, 32, this.height - 64, 36);
|
||||
this.updateAlts();
|
||||
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 60 - 2, this.height - 54, 60, 20, "Add"));
|
||||
this.buttonList.add(this.remove = new GuiButton(1, this.width / 2 + 2, this.height - 54, 60, 20, "Remove"));
|
||||
this.buttonList.add(this.login = new GuiButton(2, this.width / 2 + 2, this.height - 30, 60, 20, "Login"));
|
||||
this.buttonList.add(new GuiButton(3, this.width / 2 + 40 + 4 + 20, this.height - 30, 20, 20, "..."));
|
||||
this.buttonList.add(new GuiButton(4, this.width / 2 - 60 - 2, this.height - 30, 60, 20, "Back"));
|
||||
|
||||
this.login.enabled = this.guiListAlt.hasSelected();
|
||||
this.remove.enabled = this.guiListAlt.hasSelected();
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
this.guiListAlt.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
this.mc.fontRenderer.drawStringWithShadow(mc.getSession().getUsername(), 2.0F, 2.0F, 0xFFAAAAAA);
|
||||
this.mc.fontRenderer.drawStringWithShadow(this.status, (this.width - this.mc.fontRenderer.getStringWidth(this.status) - 2), 2.0F, 0xFFAAAAAA);
|
||||
final String accounts = Seppuku.INSTANCE.getAltManager().getAlts().size() + " " + ((Seppuku.INSTANCE.getAltManager().getAlts().size() == 1) ? "Account" : "Accounts");
|
||||
this.mc.fontRenderer.drawStringWithShadow(accounts, (this.width - this.mc.fontRenderer.getStringWidth(accounts) - 2), (2 + this.mc.fontRenderer.FONT_HEIGHT), 0xFFAAAAAA);
|
||||
|
||||
this.login.enabled = this.guiListAlt.hasSelected();
|
||||
this.remove.enabled = this.guiListAlt.hasSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void actionPerformed(GuiButton button) throws IOException {
|
||||
GuiAddAlt guiAddAlt;
|
||||
super.actionPerformed(button);
|
||||
switch (button.id) {
|
||||
case 0:
|
||||
guiAddAlt = new GuiAddAlt(this);
|
||||
mc.displayGuiScreen(guiAddAlt);
|
||||
break;
|
||||
case 1:
|
||||
if (this.guiListAlt.hasSelected() && this.guiListAlt.getSelected() != null) {
|
||||
mc.displayGuiScreen((GuiScreen) new GuiYesNo(this, "Remove account '" + this.guiListAlt.getSelected().getAlt().getUsername() + "'?", "", "Yes", "No", 0));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.guiListAlt.hasSelected()) {
|
||||
this.guiListAlt.login(this);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
this.importAccounts();
|
||||
break;
|
||||
case 4:
|
||||
mc.displayGuiScreen(this.parent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
|
||||
if (keyCode == 28 || keyCode == 205) { // ENTER
|
||||
this.guiListAlt.login(this);
|
||||
}
|
||||
|
||||
if (keyCode == 211) { // DEL
|
||||
if (this.guiListAlt.getSelected() != null) {
|
||||
Seppuku.INSTANCE.getAltManager().getAlts().remove(this.guiListAlt.getSelected().getAlt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean result, int id) {
|
||||
super.confirmClicked(result, id);
|
||||
if (result && id == 0) {
|
||||
if (this.guiListAlt.getSelected() != null) {
|
||||
Seppuku.INSTANCE.getAltManager().removeAlt(this.guiListAlt.getSelected().getAlt());
|
||||
}
|
||||
this.updateAlts();
|
||||
}
|
||||
this.mc.displayGuiScreen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.guiListAlt.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
this.guiListAlt.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
super.handleMouseInput();
|
||||
this.guiListAlt.handleMouseInput();
|
||||
}
|
||||
|
||||
private void updateAlts() {
|
||||
this.guiListAlt.setAlts(Seppuku.INSTANCE.getAltManager().getAlts());
|
||||
}
|
||||
|
||||
private void importAccounts() {
|
||||
final JFileChooser chooser = new JFileChooser();
|
||||
chooser.setVisible(true);
|
||||
chooser.setSize(500, 500);
|
||||
chooser.setAcceptAllFileFilterUsed(false);
|
||||
chooser.setFileFilter(new FileNameExtensionFilter("File", "txt"));
|
||||
final JFrame frame = new JFrame("Import");
|
||||
chooser.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("ApproveSelection") && chooser.getSelectedFile() != null) {
|
||||
try {
|
||||
Scanner scanner = new Scanner(new FileReader(chooser.getSelectedFile()));
|
||||
scanner.useDelimiter("\n");
|
||||
while (scanner.hasNext()) {
|
||||
String[] split = scanner.next().trim().split(":");
|
||||
Seppuku.INSTANCE.getAltManager().addAlt(new AltData(split[0], split[1]));
|
||||
GuiAltManager.this.updateAlts();
|
||||
}
|
||||
scanner.close();
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
frame.setVisible(false);
|
||||
frame.dispose();
|
||||
}
|
||||
if (e.getActionCommand().equals("CancelSelection")) {
|
||||
frame.setVisible(false);
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
frame.setAlwaysOnTop(true);
|
||||
frame.add(chooser);
|
||||
frame.setVisible(true);
|
||||
frame.setSize(800, 600);
|
||||
}
|
||||
|
||||
public GuiScreen getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public GuiListAlt getGuiListAlt() {
|
||||
return guiListAlt;
|
||||
}
|
||||
|
||||
public void setGuiListAlt(GuiListAlt guiListAlt) {
|
||||
this.guiListAlt = guiListAlt;
|
||||
}
|
||||
|
||||
public GuiButton getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(GuiButton login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public GuiButton getRemove() {
|
||||
return remove;
|
||||
}
|
||||
|
||||
public void setRemove(GuiButton remove) {
|
||||
this.remove = remove;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.gui.menu;
|
|||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.event.minecraft.EventDisplayGui;
|
||||
import me.rigamortis.seppuku.api.gui.menu.MainMenuButton;
|
||||
import me.rigamortis.seppuku.api.texture.Texture;
|
||||
import me.rigamortis.seppuku.impl.fml.SeppukuMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -95,6 +96,15 @@ public final class GuiSeppukuMainMenu extends GuiScreen {
|
|||
|
||||
height += 20;
|
||||
|
||||
this.alts = new MainMenuButton(res.getScaledWidth() / 2.0f - 70, height, "Alts") {
|
||||
@Override
|
||||
public void action() {
|
||||
mc.displayGuiScreen(new GuiAltManager(menu));
|
||||
}
|
||||
};
|
||||
|
||||
height += 20;
|
||||
|
||||
this.donate = new MainMenuButton(res.getScaledWidth() / 2.0f - 70, height, 69, 18, ChatFormatting.YELLOW + "Donate") {
|
||||
@Override
|
||||
public void action() {
|
||||
|
@ -123,15 +133,6 @@ public final class GuiSeppukuMainMenu extends GuiScreen {
|
|||
|
||||
height += 20;
|
||||
|
||||
/*this.alts = new MainMenuButton(res.getScaledWidth() / 2.0f - 70, height, "Alts") {
|
||||
@Override
|
||||
public void action() {
|
||||
//TODO
|
||||
}
|
||||
};
|
||||
|
||||
height += 20;*/
|
||||
|
||||
this.quit = new MainMenuButton(res.getScaledWidth() / 2.0f - 70, height, "Quit") {
|
||||
@Override
|
||||
public void action() {
|
||||
|
@ -213,7 +214,7 @@ public final class GuiSeppukuMainMenu extends GuiScreen {
|
|||
this.mods.render(mouseX, mouseY, partialTicks);
|
||||
this.donate.render(mouseX, mouseY, partialTicks);
|
||||
this.hudEditor.render(mouseX, mouseY, partialTicks);
|
||||
//this.alts.render(mouseX, mouseY, partialTicks);
|
||||
this.alts.render(mouseX, mouseY, partialTicks);
|
||||
this.quit.render(mouseX, mouseY, partialTicks);
|
||||
this.disable.render(mouseX, mouseY, partialTicks);
|
||||
this.language.render(mouseX, mouseY, partialTicks);
|
||||
|
@ -232,7 +233,7 @@ public final class GuiSeppukuMainMenu extends GuiScreen {
|
|||
this.mods.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.donate.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.hudEditor.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
//this.alts.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.alts.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.quit.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.disable.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.language.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
@ -249,7 +250,7 @@ public final class GuiSeppukuMainMenu extends GuiScreen {
|
|||
this.mods.mouseRelease(mouseX, mouseY, state);
|
||||
this.donate.mouseRelease(mouseX, mouseY, state);
|
||||
this.hudEditor.mouseRelease(mouseX, mouseY, state);
|
||||
//this.alts.mouseRelease(mouseX, mouseY, state);
|
||||
this.alts.mouseRelease(mouseX, mouseY, state);
|
||||
this.quit.mouseRelease(mouseX, mouseY, state);
|
||||
this.disable.mouseRelease(mouseX, mouseY, state);
|
||||
this.language.mouseRelease(mouseX, mouseY, state);
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package me.rigamortis.seppuku.impl.management;
|
||||
|
||||
import me.rigamortis.seppuku.api.gui.menu.AltData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AltManager {
|
||||
|
||||
private final List<AltData> alts = new ArrayList<>();
|
||||
|
||||
public AltManager() {
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
public void addAlt(AltData alt) {
|
||||
if (!this.alts.contains(alt))
|
||||
this.alts.add(alt);
|
||||
}
|
||||
|
||||
public void removeAlt(AltData alt) {
|
||||
this.alts.remove(alt);
|
||||
}
|
||||
|
||||
public void removeAlt(String username) {
|
||||
this.alts.removeIf(alt -> alt.getUsername().equalsIgnoreCase(username));
|
||||
}
|
||||
|
||||
public List<AltData> getAlts() {
|
||||
return this.alts;
|
||||
}
|
||||
}
|
|
@ -64,6 +64,7 @@ public final class ConfigManager {
|
|||
this.configurableList.add(new WorldConfig(configDir));
|
||||
this.configurableList.add(new IgnoreConfig(configDir));
|
||||
this.configurableList.add(new AutoIgnoreConfig(configDir));
|
||||
this.configurableList.add(new AltConfig(configDir));
|
||||
|
||||
if (this.firstLaunch) {
|
||||
this.saveAll();
|
||||
|
|
Loading…
Reference in New Issue