fix password hiding

This commit is contained in:
ParadoxGitHub 2023-03-11 17:42:41 -05:00
parent c501b8899d
commit 9f853cf993
3 changed files with 48 additions and 3 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ desktopRuntime/hs_err_*
desktopRuntime/crash-reports/* desktopRuntime/crash-reports/*
desktopRuntime/options.txt desktopRuntime/options.txt
desktopRuntime/_eagstorage* desktopRuntime/_eagstorage*
/.metadata/

View File

@ -284,6 +284,9 @@ public class GuiChat extends GuiScreen {
GlUtils.startTranslate(0, 29 - (int) animation.getValue()); GlUtils.startTranslate(0, 29 - (int) animation.getValue());
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE); drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.inputField.drawTextBox(); this.inputField.drawTextBox();
if (this.inputField.isTypingPassword)
this.mc.fontRendererObj.drawStringWithShadow("Password Hidden", 2, this.height - 25, 16770425);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY()); IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) { if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) {

View File

@ -67,6 +67,8 @@ public class GuiTextField extends Gui {
private GuiPageButtonList.GuiResponder field_175210_x; private GuiPageButtonList.GuiResponder field_175210_x;
private Predicate<String> field_175209_y = Predicates.alwaysTrue(); private Predicate<String> field_175209_y = Predicates.alwaysTrue();
public boolean isTypingPassword = false;
public GuiTextField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height) { public GuiTextField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height) {
this.id = componentId; this.id = componentId;
this.fontRendererInstance = fontrendererObj; this.fontRendererInstance = fontrendererObj;
@ -451,9 +453,48 @@ public class GuiTextField extends Gui {
k = s.length(); k = s.length();
} }
if (s.length() > 0) { if (s.length() > 0) {
String s1 = flag ? s.substring(0, j) : s;
String s2 = s1.startsWith("/login ") ? "/login *" : s1.startsWith("/l ") ? "/l *" : s1; String s1 = flag ? s.substring(0, j) : s;
String s2 = s1;
if (s1.startsWith("/l ") || s1.startsWith("/login ") || s1.startsWith("/log ")) {
s2 = "";
String password = "";
// password isnt sent anywhere, its just used for counting how many "*" you need for hiding the password.
if (s1.startsWith("/l ")) {
s2 = s1.substring(0, 3);
password = s1.substring(3);
}
if (s1.startsWith("/login ")) {
s2 = s1.substring(0, 7);
password = s1.substring(7);
}
if (s1.startsWith("/log ")) {
s2 = s1.substring(0, 5);
password = s1.substring(7);
}
if (password.length() > 0) {
isTypingPassword = true;
for (int n = 0; n < password.length(); n++) {
s2 += "*";
}
}
}
else {
isTypingPassword = false;
}
j1 = this.fontRendererInstance.drawStringWithShadow(s2, (float) l, (float) i1, i); j1 = this.fontRendererInstance.drawStringWithShadow(s2, (float) l, (float) i1, i);
} }