Password Hiding

This commit is contained in:
PeytonPlayz595 2024-04-19 23:22:54 -04:00
parent 086a2b9860
commit 1c3bdd9624
10 changed files with 119917 additions and 119830 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -264,6 +264,7 @@ public class GameSettings {
public boolean ofSwampColors = true;
public boolean ofSmoothBiomes = true;
public boolean ofCustomColors = true;
public boolean hidePassword = true;
public GameSettings(Minecraft mcIn) {
this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem,
@ -892,6 +893,10 @@ public class GameSettings {
this.mc.renderGlobal.loadRenderers();
}
if (parOptions == GameSettings.Options.HIDE_PASSWORD) {
hidePassword =! hidePassword;
}
this.saveOptions();
}
@ -1012,6 +1017,8 @@ public class GameSettings {
return this.ofSmoothBiomes;
case CUSTOM_COLORS:
return this.ofCustomColors;
case HIDE_PASSWORD:
return hidePassword;
default:
return false;
}
@ -1289,7 +1296,9 @@ public class GameSettings {
return this.ofSmoothBiomes ? s + Lang.getOn() : s + Lang.getOff();
} else if (parOptions == GameSettings.Options.CUSTOM_COLORS) {
return this.ofCustomColors ? s + Lang.getOn() : s + Lang.getOff();
} else {
} else if (parOptions == GameSettings.Options.HIDE_PASSWORD) {
return hidePassword ? s + "ON" : s + "OFF";
} else {
return s;
}
}
@ -1856,6 +1865,10 @@ public class GameSettings {
this.ofCustomColors = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("hidePassword") && astring.length >= 2) {
hidePassword = Boolean.valueOf(astring[1]).booleanValue();
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
for (SoundCategory soundcategory : SoundCategory._VALUES) {
@ -2033,6 +2046,7 @@ public class GameSettings {
printwriter.println("ofSwampColors:" + this.ofSwampColors);
printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes);
printwriter.println("ofCustomColors:" + this.ofCustomColors);
printwriter.println("hidePassword:" + hidePassword);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -2240,7 +2254,8 @@ public class GameSettings {
CUSTOM_ITEMS("Custom Items", false, false),
SWAMP_COLORS("Swamp Colors", false, false),
SMOOTH_BIOMES("Smooth Biomes", false, false),
CUSTOM_COLORS("Custom Colors", false, false);
CUSTOM_COLORS("Custom Colors", false, false),
HIDE_PASSWORD("Hide Password", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;

View File

@ -324,6 +324,10 @@ public class Config {
return gameSettings.ofCustomColors;
}
public static boolean isPasswordHidden() {
return gameSettings.hidePassword;
}
public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) {
return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_);
}

View File

@ -9,7 +9,7 @@ import net.minecraft.client.settings.GameSettings;
public class GuiShadow extends GuiScreen {
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.TOGGLE_SPRINT, GameSettings.Options.CHUNK_BORDERS};
private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.TOGGLE_SPRINT, GameSettings.Options.CHUNK_BORDERS, GameSettings.Options.HIDE_PASSWORD};
private GuiScreen parentScreen;
protected String title;

View File

@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
import net.PeytonPlayz585.shadow.Config;
import net.lax1dude.eaglercraft.v1_8.Keyboard;
import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -289,6 +290,9 @@ public class GuiChat extends GuiScreen {
public void drawScreen(int i, int j, float f) {
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.inputField.drawTextBox();
if (this.inputField.isTypingPassword && Config.isPasswordHidden()) {
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

@ -5,6 +5,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.PeytonPlayz585.shadow.Config;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.minecraft.client.renderer.Tessellator;
@ -69,6 +70,8 @@ public class GuiTextField extends Gui {
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;
this.fontRendererInstance = fontrendererObj;
@ -462,9 +465,45 @@ public class GuiTextField extends Gui {
}
if (s.length() > 0) {
String s1 = flag ? s.substring(0, j) : s;
j1 = this.fontRendererInstance.drawStringWithShadow(s1, (float) l, (float) i1, i);
}
String s1 = flag ? s.substring(0, j) : s;
String s2 = s1;
if(Config.isPasswordHidden()) {
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);
}
boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength();
int k1 = j1;

View File

@ -266,6 +266,7 @@ public class GameSettings extends ModData {
public boolean ofSwampColors = true;
public boolean ofSmoothBiomes = true;
public boolean ofCustomColors = true;
public boolean hidePassword = true;
public GameSettings(Minecraft mcIn) {
this.keyBindings = (KeyBinding[]) ArrayUtils.addAll(new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem,
@ -1056,6 +1057,10 @@ public class GameSettings extends ModData {
this.mc.renderGlobal.loadRenderers();
}
if (parOptions == GameSettings.Options.HIDE_PASSWORD) {
hidePassword =! hidePassword;
}
this.saveOptions();
}
@ -1453,7 +1458,9 @@ public class GameSettings extends ModData {
return this.ofSmoothBiomes ? s + Lang.getOn() : s + Lang.getOff();
} else if (parOptions == GameSettings.Options.CUSTOM_COLORS) {
return this.ofCustomColors ? s + Lang.getOn() : s + Lang.getOff();
} else {
} else if (parOptions == GameSettings.Options.HIDE_PASSWORD) {
return hidePassword ? s + "ON" : s + "OFF";
} else {
return s;
}
}
@ -2020,6 +2027,10 @@ public class GameSettings extends ModData {
this.ofCustomColors = Boolean.valueOf(astring[1]).booleanValue();
}
if (astring[0].equals("hidePassword") && astring.length >= 2) {
hidePassword = Boolean.valueOf(astring[1]).booleanValue();
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
for (SoundCategory soundcategory : SoundCategory._VALUES) {
@ -2197,6 +2208,7 @@ public class GameSettings extends ModData {
printwriter.println("ofSwampColors:" + this.ofSwampColors);
printwriter.println("ofSmoothBiomes:" + this.ofSmoothBiomes);
printwriter.println("ofCustomColors:" + this.ofCustomColors);
printwriter.println("hidePassword:" + hidePassword);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -2404,7 +2416,8 @@ public class GameSettings extends ModData {
CUSTOM_ITEMS("Custom Items", false, false),
SWAMP_COLORS("Swamp Colors", false, false),
SMOOTH_BIOMES("Smooth Biomes", false, false),
CUSTOM_COLORS("Custom Colors", false, false);
CUSTOM_COLORS("Custom Colors", false, false),
HIDE_PASSWORD("Hide Password", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;