Skip to content

Commit 87cd314

Browse files
committed
Code tweaks
1 parent 461888c commit 87cd314

3 files changed

Lines changed: 14 additions & 39 deletions

File tree

glass-config-api-v3/src/main/java/net/modificationstation/stationapi/api/config/ConfigFactoryProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package net.modificationstation.stationapi.api.config;
22

33
import com.google.common.collect.ImmutableMap;
4-
import net.modificationstation.stationapi.impl.config.NonFunction;
54
import net.modificationstation.stationapi.impl.config.object.ConfigEntryHandler;
65
import uk.co.benjiweber.expressions.function.SeptFunction;
7-
import uk.co.benjiweber.expressions.function.SexFunction;
86

97
import java.lang.reflect.*;
108
import java.util.function.*;

glass-config-api-v3/src/main/java/net/modificationstation/stationapi/impl/config/screen/widget/ExtensibleTextFieldWidget.java

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.modificationstation.stationapi.impl.config.screen.widget;
22

3+
import lombok.Getter;
4+
import lombok.Setter;
35
import net.minecraft.client.font.TextRenderer;
46
import net.minecraft.client.gui.DrawContext;
57
import net.minecraft.client.render.Tessellator;
@@ -8,7 +10,6 @@
810
import net.modificationstation.stationapi.api.config.HasToolTip;
911
import org.lwjgl.input.Keyboard;
1012
import org.lwjgl.opengl.GL11;
11-
import uk.co.benjiweber.expressions.tuple.BiTuple;
1213

1314
import java.awt.*;
1415
import java.util.List;
@@ -26,17 +27,17 @@ public class ExtensibleTextFieldWidget extends DrawContext implements HasDrawabl
2627
private int y;
2728
private int width;
2829
private int height;
29-
private String text = "";
30-
private int maxLength = 32;
30+
@Getter private String text = "";
31+
@Getter private int maxLength = 32;
3132
private int focusedTicks;
3233
private boolean shouldDrawBackground = true;
33-
private boolean enabled = true;
34+
@Getter @Setter private boolean enabled = true;
3435
private boolean selected = false;
3536
@SuppressWarnings("FieldMayBeFinal")
3637
private boolean focusable = true;
3738
private int cursorPosition = 0;
38-
private int cursorMax = 0;
39-
private int cursorMin = 0;
39+
@Getter private int cursorMax = 0;
40+
@Getter private int cursorMin = 0;
4041
public int selectedTextColour = 14737632;
4142
public int deselectedTextColour = 7368816;
4243
public int errorBorderColour = CharacterUtils.getIntFromColour(new Color(200, 50, 50));
@@ -74,10 +75,6 @@ public void setText(String string) {
7475
this.onTextChanged();
7576
}
7677

77-
public String getText() {
78-
return this.text;
79-
}
80-
8178
public String getSelectedText() {
8279
int var1 = Math.min(this.cursorMax, this.cursorMin);
8380
int var2 = Math.max(this.cursorMax, this.cursorMin);
@@ -90,7 +87,7 @@ public void addText(String string) {
9087
int var4 = Math.min(this.cursorMax, this.cursorMin);
9188
int var5 = Math.max(this.cursorMax, this.cursorMin);
9289
int var6 = this.maxLength - this.text.length() - (var4 - this.cursorMin);
93-
if (this.text.length() > 0) {
90+
if (!this.text.isEmpty()) {
9491
var2 = var2 + this.text.substring(0, var4);
9592
}
9693

@@ -103,7 +100,7 @@ public void addText(String string) {
103100
var8 = var3.length();
104101
}
105102

106-
if (this.text.length() > 0 && var5 < this.text.length()) {
103+
if (!this.text.isEmpty() && var5 < this.text.length()) {
107104
var2 = var2 + this.text.substring(var5);
108105
}
109106

@@ -112,7 +109,7 @@ public void addText(String string) {
112109
}
113110

114111
public void method_729(int i) {
115-
if (this.text.length() != 0) {
112+
if (!this.text.isEmpty()) {
116113
if (this.cursorMin != this.cursorMax) {
117114
this.addText("");
118115
} else {
@@ -122,7 +119,7 @@ public void method_729(int i) {
122119
}
123120

124121
public void method_735(int i) {
125-
if (this.text.length() != 0) {
122+
if (!this.text.isEmpty()) {
126123
if (this.cursorMin != this.cursorMax) {
127124
this.addText("");
128125
} else {
@@ -365,7 +362,7 @@ public void draw(int mouseX, int mouseY) {
365362
var3 = var4.length();
366363
}
367364

368-
if (var4.length() > 0) {
365+
if (!var4.isEmpty()) {
369366
String firstString = var5 ? var4.substring(0, var2) : var4;
370367
this.textRenderer.drawWithShadow(firstString, firstStringPos, textY, var1);
371368
secondStringPos += textRenderer.getWidth(firstString);
@@ -380,7 +377,7 @@ public void draw(int mouseX, int mouseY) {
380377
selectStart = --secondStringPos;
381378
}
382379

383-
if (var4.length() > 0 && var5 && var2 < var4.length()) {
380+
if (!var4.isEmpty() && var5 && var2 < var4.length()) {
384381
this.textRenderer.drawWithShadow(var4.substring(var2), secondStringPos, textY, var1);
385382
}
386383

@@ -436,14 +433,6 @@ public void setMaxLength(int i) {
436433

437434
}
438435

439-
public int getMaxLength() {
440-
return this.maxLength;
441-
}
442-
443-
public int getCursorMax() {
444-
return this.cursorMax;
445-
}
446-
447436
public boolean shouldDrawBackground() {
448437
return this.shouldDrawBackground;
449438
}
@@ -466,10 +455,6 @@ public boolean isSelected() {
466455
return this.selected;
467456
}
468457

469-
public int getCursorMin() {
470-
return this.cursorMin;
471-
}
472-
473458
public int getBackgroundOffset() {
474459
return this.shouldDrawBackground() ? this.width - 8 : this.width;
475460
}
@@ -514,14 +499,6 @@ public void updateCursorPosition(int newCursorPos) {
514499

515500
}
516501

517-
public void setEnabled(boolean flag) {
518-
this.enabled = flag;
519-
}
520-
521-
public boolean isEnabled() {
522-
return enabled;
523-
}
524-
525502
public void setValidator(Function<String, List<String>> contentsValidator) {
526503
this.contentsValidator = contentsValidator;
527504
}

src/test/java/net/modificationstation/sltest/gcapi/ExampleConfigCategoryTwo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ public class ExampleConfigCategoryTwo {
2020
public Float[] aFList = new Float[0];
2121

2222
@ConfigEntry(name = "A FIXED LIST?!", maxLength = 10, maxArrayLength = 3, minArrayLength = 3)
23-
public Integer[] aFIList = new Integer[0];
23+
public Integer[] aFIList = new Integer[] {8, 4, 1};
2424
}

0 commit comments

Comments
 (0)