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

3
.gitignore vendored
View File

@ -12,4 +12,5 @@ desktopRuntime/eclipseProject/bin*
desktopRuntime/hs_err_*
desktopRuntime/crash-reports/*
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());
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
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);
IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) {

View File

@ -66,6 +66,8 @@ public class GuiTextField extends Gui {
private boolean visible = true;
private GuiPageButtonList.GuiResponder field_175210_x;
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) {
this.id = componentId;
@ -450,10 +452,49 @@ public class GuiTextField extends Gui {
if (k > s.length()) {
k = s.length();
}
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);
}