Browse Source

Generify BaseListEntry to use the "curiously recurring template" pattern

This allows it to specify the types of the input functions in terms of the inheriting class (eventually). The `self()` method is a type-safe `this`, since `this` doesn't know that it should be the same type as the `SELF` parameter.

This ultimately cleans up a lot of ugly casting and prevents some simple mistakes when accessing the entry from inside a function argument.
Mitchell Skaggs 5 years ago
parent
commit
0ae3872741

+ 44 - 36
src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java

@@ -21,8 +21,14 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Supplier;
 
-public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipListEntry<List<T>> {
-    
+/**
+ * @param <T>    the configuration object type
+ * @param <C>    the cell type
+ * @param <SELF> the "curiously recurring template pattern" type parameter
+ * @implNote See <a href="https://stackoverflow.com/questions/7354740/is-there-a-way-to-refer-to-the-current-type-with-a-type-variable">Is there a way to refer to the current type with a type variable?</href> on Stack Overflow.
+ */
+public abstract class BaseListEntry<T, C extends BaseListCell, SELF extends BaseListEntry<T, C, SELF>> extends TooltipListEntry<List<T>> {
+
     protected static final Identifier CONFIG_TEX = new Identifier("cloth-config2", "textures/gui/cloth_config.png");
     protected final List<C> cells;
     protected final List<Element> widgets;
@@ -30,16 +36,16 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
     protected Consumer<List<T>> saveConsumer;
     protected ListLabelWidget labelWidget;
     protected AbstractButtonWidget resetWidget;
-    protected Function<BaseListEntry, C> createNewInstance;
+    protected Function<SELF, C> createNewInstance;
     protected Supplier<List<T>> defaultValue;
     protected String addTooltip = I18n.translate("text.cloth-config.list.add"), removeTooltip = I18n.translate("text.cloth-config.list.remove");
-    
+
     @Deprecated
-    public BaseListEntry(String fieldName, Supplier<Optional<String[]>> tooltipSupplier, Supplier<List<T>> defaultValue, Function<BaseListEntry, C> createNewInstance, Consumer<List<T>> saveConsumer, String resetButtonKey) {
+    public BaseListEntry(String fieldName, Supplier<Optional<String[]>> tooltipSupplier, Supplier<List<T>> defaultValue, Function<SELF, C> createNewInstance, Consumer<List<T>> saveConsumer, String resetButtonKey) {
         this(fieldName, tooltipSupplier, defaultValue, createNewInstance, saveConsumer, resetButtonKey, false);
     }
-    
-    public BaseListEntry(String fieldName, Supplier<Optional<String[]>> tooltipSupplier, Supplier<List<T>> defaultValue, Function<BaseListEntry, C> createNewInstance, Consumer<List<T>> saveConsumer, String resetButtonKey, boolean requiresRestart) {
+
+    public BaseListEntry(String fieldName, Supplier<Optional<String[]>> tooltipSupplier, Supplier<List<T>> defaultValue, Function<SELF, C> createNewInstance, Consumer<List<T>> saveConsumer, String resetButtonKey, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, requiresRestart);
         this.cells = Lists.newArrayList();
         this.labelWidget = new ListLabelWidget();
@@ -56,62 +62,64 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
         this.createNewInstance = createNewInstance;
         this.defaultValue = defaultValue;
     }
-    
+
+    public abstract SELF self();
+
     public boolean isDeleteButtonEnabled() {
         return true;
     }
-    
+
     protected abstract C getFromValue(T value);
-    
-    public Function<BaseListEntry, C> getCreateNewInstance() {
+
+    public Function<SELF, C> getCreateNewInstance() {
         return createNewInstance;
     }
-    
-    public void setCreateNewInstance(Function<BaseListEntry, C> createNewInstance) {
+
+    public void setCreateNewInstance(Function<SELF, C> createNewInstance) {
         this.createNewInstance = createNewInstance;
     }
-    
+
     public String getAddTooltip() {
         return addTooltip;
     }
-    
+
     public void setAddTooltip(String addTooltip) {
         this.addTooltip = addTooltip;
     }
-    
+
     public String getRemoveTooltip() {
         return removeTooltip;
     }
-    
+
     public void setRemoveTooltip(String removeTooltip) {
         this.removeTooltip = removeTooltip;
     }
-    
+
     @Override
     public Optional<List<T>> getDefaultValue() {
         return Optional.ofNullable(defaultValue.get());
     }
-    
+
     @Override
     public int getItemHeight() {
         if (expended) {
             int i = 24;
-            for(BaseListCell entry : cells)
+            for (BaseListCell entry : cells)
                 i += entry.getCellHeight();
             return i;
         }
         return 24;
     }
-    
+
     @Override
     public List<? extends Element> children() {
         return widgets;
     }
-    
+
     @Override
     public Optional<String> getError() {
         String error = null;
-        for(BaseListCell entry : cells)
+        for (BaseListCell entry : cells)
             if (entry.getConfigError().isPresent()) {
                 if (error != null)
                     return Optional.ofNullable(I18n.translate("text.cloth-config.multi_error"));
@@ -119,13 +127,13 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
             }
         return Optional.ofNullable(error);
     }
-    
+
     @Override
     public void save() {
         if (saveConsumer != null)
             saveConsumer.accept(getValue());
     }
-    
+
     @Override
     public boolean isMouseInside(int mouseX, int mouseY, int x, int y, int entryWidth, int entryHeight) {
         labelWidget.rectangle.x = x - 15;
@@ -134,15 +142,15 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
         labelWidget.rectangle.height = 24;
         return labelWidget.rectangle.contains(mouseX, mouseY) && getParent().isMouseOver(mouseX, mouseY) && !resetWidget.isMouseOver(mouseX, mouseY);
     }
-    
+
     protected boolean isInsideCreateNew(double mouseX, double mouseY) {
         return mouseX >= labelWidget.rectangle.x + 12 && mouseY >= labelWidget.rectangle.y + 3 && mouseX <= labelWidget.rectangle.x + 12 + 11 && mouseY <= labelWidget.rectangle.y + 3 + 11;
     }
-    
+
     protected boolean isInsideDelete(double mouseX, double mouseY) {
         return isDeleteButtonEnabled() && mouseX >= labelWidget.rectangle.x + 25 && mouseY >= labelWidget.rectangle.y + 3 && mouseX <= labelWidget.rectangle.x + 25 + 11 && mouseY <= labelWidget.rectangle.y + 3 + 11;
     }
-    
+
     public Optional<String[]> getTooltip(int mouseX, int mouseY) {
         if (addTooltip != null && isInsideCreateNew(mouseX, mouseY))
             return Optional.of(new String[]{addTooltip});
@@ -152,7 +160,7 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
             return getTooltipSupplier().get();
         return Optional.empty();
     }
-    
+
     @Override
     public void render(int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
         labelWidget.rectangle.x = x - 19;
@@ -181,20 +189,20 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
         MinecraftClient.getInstance().textRenderer.drawWithShadow(I18n.translate(getFieldName()), isDeleteButtonEnabled() ? x + 24 : x + 24 - 9, y + 5, labelWidget.rectangle.contains(mouseX, mouseY) && !resetWidget.isMouseOver(mouseX, mouseY) && !insideDelete && !insideCreateNew ? 0xffe6fe16 : getPreferredTextColor());
         if (expended) {
             int yy = y + 24;
-            for(BaseListCell cell : cells) {
+            for (BaseListCell cell : cells) {
                 cell.render(-1, yy, x + 14, entryWidth - 14, cell.getCellHeight(), mouseX, mouseY, getParent().getFocused() != null && getParent().getFocused().equals(this) && getFocused() != null && getFocused().equals(cell), delta);
                 yy += cell.getCellHeight();
             }
         }
     }
-    
+
     public boolean insertInFront() {
         return true;
     }
-    
+
     public class ListLabelWidget implements Element {
         protected Rectangle rectangle = new Rectangle();
-        
+
         @Override
         public boolean mouseClicked(double double_1, double double_2, int int_1) {
             if (resetWidget.isMouseOver(double_1, double_2)) {
@@ -203,10 +211,10 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
                 expended = true;
                 C cell;
                 if (insertInFront()) {
-                    cells.add(0, cell = createNewInstance.apply(BaseListEntry.this));
+                    cells.add(0, cell = createNewInstance.apply(BaseListEntry.this.self()));
                     widgets.add(0, cell);
                 } else {
-                    cells.add(cell = createNewInstance.apply(BaseListEntry.this));
+                    cells.add(cell = createNewInstance.apply(BaseListEntry.this.self()));
                     widgets.add(cell);
                 }
                 getScreen().setEdited(true, isRequiresRestart());
@@ -229,5 +237,5 @@ public abstract class BaseListEntry<T, C extends BaseListCell> extends TooltipLi
             return false;
         }
     }
-    
+
 }

+ 14 - 9
src/main/java/me/shedaniel/clothconfig2/gui/entries/DoubleListListEntry.java

@@ -13,16 +13,16 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-public class DoubleListListEntry extends BaseListEntry<Double, DoubleListListEntry.DoubleListCell> {
-    
+public class DoubleListListEntry extends BaseListEntry<Double, DoubleListListEntry.DoubleListCell, DoubleListListEntry> {
+
     private double minimum, maximum;
     private Function<Double, Optional<String>> cellErrorSupplier;
-    
+
     @Deprecated
     public DoubleListListEntry(String fieldName, List<Double> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, String resetButtonKey) {
         this(fieldName, value, defaultExpended, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
-    
+
     @Deprecated
     public DoubleListListEntry(String fieldName, List<Double> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Double>> saveConsumer, Supplier<List<Double>> defaultValue, String resetButtonKey, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, defaultValue, baseListEntry -> new DoubleListCell(0d, (DoubleListListEntry) baseListEntry), saveConsumer, resetButtonKey, requiresRestart);
@@ -46,24 +46,29 @@ public class DoubleListListEntry extends BaseListEntry<Double, DoubleListListEnt
     public List<Double> getValue() {
         return cells.stream().map(DoubleListCell::getValue).collect(Collectors.toList());
     }
-    
+
     public DoubleListListEntry setMaximum(Double maximum) {
         this.maximum = maximum;
         return this;
     }
-    
+
     public DoubleListListEntry setMinimum(Double minimum) {
         this.minimum = minimum;
         return this;
     }
-    
+
+    @Override
+    public DoubleListListEntry self() {
+        return this;
+    }
+
     @Override
     protected DoubleListCell getFromValue(Double value) {
         return new DoubleListCell(value, this);
     }
-    
+
     public static class DoubleListCell extends BaseListCell {
-        
+
         private Function<String, String> stripCharacters = s -> {
             StringBuilder stringBuilder_1 = new StringBuilder();
             char[] var2 = s.toCharArray();

+ 31 - 26
src/main/java/me/shedaniel/clothconfig2/gui/entries/FloatListListEntry.java

@@ -13,72 +13,77 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.FloatListCell> {
-    
+public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.FloatListCell, FloatListListEntry> {
+
     private float minimum, maximum;
     private Function<Float, Optional<String>> cellErrorSupplier;
-    
+
     @Deprecated
     public FloatListListEntry(String fieldName, List<Float> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, String resetButtonKey) {
         this(fieldName, value, defaultExpended, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
-    
+
     @Deprecated
     public FloatListListEntry(String fieldName, List<Float> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Float>> saveConsumer, Supplier<List<Float>> defaultValue, String resetButtonKey, boolean requiresRestart) {
-        super(fieldName, tooltipSupplier, defaultValue, baseListEntry -> new FloatListCell(0, (FloatListListEntry) baseListEntry), saveConsumer, resetButtonKey, requiresRestart);
+        super(fieldName, tooltipSupplier, defaultValue, floatListListEntry -> new FloatListCell(0, floatListListEntry), saveConsumer, resetButtonKey, requiresRestart);
         this.minimum = -Float.MAX_VALUE;
         this.maximum = Float.MAX_VALUE;
-        for(float f : value)
+        for (float f : value)
             cells.add(new FloatListCell(f, this));
         this.widgets.addAll(cells);
         expended = defaultExpended;
     }
-    
+
     public Function<Float, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public void setCellErrorSupplier(Function<Float, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
     }
-    
+
     @Override
     public List<Float> getValue() {
         return cells.stream().map(FloatListCell::getValue).collect(Collectors.toList());
     }
-    
+
     public FloatListListEntry setMaximum(float maximum) {
         this.maximum = maximum;
         return this;
     }
-    
+
     public FloatListListEntry setMinimum(float minimum) {
         this.minimum = minimum;
         return this;
     }
-    
+
+    @Override
+    public FloatListListEntry self() {
+        return this;
+    }
+
     @Override
     protected FloatListCell getFromValue(Float value) {
         return new FloatListCell(value, this);
     }
-    
+
     public static class FloatListCell extends BaseListCell {
-        
+
         private Function<String, String> stripCharacters = s -> {
             StringBuilder stringBuilder_1 = new StringBuilder();
             char[] var2 = s.toCharArray();
             int var3 = var2.length;
-            
-            for(int var4 = 0; var4 < var3; ++var4)
+
+            for (int var4 = 0; var4 < var3; ++var4)
                 if (Character.isDigit(var2[var4]) || var2[var4] == '-' || var2[var4] == '.')
                     stringBuilder_1.append(var2[var4]);
-            
+
             return stringBuilder_1.toString();
         };
         private TextFieldWidget widget;
         private boolean isSelected;
         private FloatListListEntry listListEntry;
-        
+
         public FloatListCell(float value, FloatListListEntry listListEntry) {
             this.listListEntry = listListEntry;
             this.setErrorSupplier(() -> listListEntry.cellErrorSupplier == null ? Optional.empty() : listListEntry.getCellErrorSupplier().apply(getValue()));
@@ -91,7 +96,7 @@ public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.
                     super.render(int_1, int_2, float_1);
                     setFocused(f);
                 }
-                
+
                 @Override
                 public void write(String string_1) {
                     super.write(stripCharacters.apply(string_1));
@@ -105,7 +110,7 @@ public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.
                     listListEntry.getScreen().setEdited(true, listListEntry.isRequiresRestart());
             });
         }
-        
+
         public float getValue() {
             try {
                 return Float.valueOf(widget.getText());
@@ -113,7 +118,7 @@ public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.
                 return 0f;
             }
         }
-        
+
         @Override
         public Optional<String> getError() {
             try {
@@ -127,12 +132,12 @@ public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.
             }
             return Optional.empty();
         }
-        
+
         @Override
         public int getCellHeight() {
             return 20;
         }
-        
+
         @Override
         public void render(int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             widget.setWidth(entryWidth - 12);
@@ -144,12 +149,12 @@ public class FloatListListEntry extends BaseListEntry<Float, FloatListListEntry.
             if (isSelected && listListEntry.isEditable())
                 fill(x, y + 12, x + entryWidth - 12, y + 13, getConfigError().isPresent() ? 0xffff5555 : 0xffe0e0e0);
         }
-        
+
         @Override
         public List<? extends Element> children() {
             return Collections.singletonList(widget);
         }
-        
+
     }
-    
+
 }

+ 31 - 26
src/main/java/me/shedaniel/clothconfig2/gui/entries/IntegerListListEntry.java

@@ -13,72 +13,77 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListListEntry.IntegerListCell> {
-    
+public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListListEntry.IntegerListCell, IntegerListListEntry> {
+
     private int minimum, maximum;
     private Function<Integer, Optional<String>> cellErrorSupplier;
-    
+
     @Deprecated
     public IntegerListListEntry(String fieldName, List<Integer> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, String resetButtonKey) {
         this(fieldName, value, defaultExpended, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
-    
+
     @Deprecated
     public IntegerListListEntry(String fieldName, List<Integer> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Integer>> saveConsumer, Supplier<List<Integer>> defaultValue, String resetButtonKey, boolean requiresRestart) {
-        super(fieldName, tooltipSupplier, defaultValue, baseListEntry -> new IntegerListCell(0, (IntegerListListEntry) baseListEntry), saveConsumer, resetButtonKey, requiresRestart);
+        super(fieldName, tooltipSupplier, defaultValue, integerListListEntry -> new IntegerListCell(0, integerListListEntry), saveConsumer, resetButtonKey, requiresRestart);
         this.minimum = -Integer.MAX_VALUE;
         this.maximum = Integer.MAX_VALUE;
-        for(int integer : value)
+        for (int integer : value)
             cells.add(new IntegerListCell(integer, this));
         this.widgets.addAll(cells);
         expended = defaultExpended;
     }
-    
+
     public Function<Integer, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public void setCellErrorSupplier(Function<Integer, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
     }
-    
+
     @Override
     public List<Integer> getValue() {
         return cells.stream().map(IntegerListCell::getValue).collect(Collectors.toList());
     }
-    
+
     public IntegerListListEntry setMaximum(int maximum) {
         this.maximum = maximum;
         return this;
     }
-    
+
     public IntegerListListEntry setMinimum(int minimum) {
         this.minimum = minimum;
         return this;
     }
-    
+
+    @Override
+    public IntegerListListEntry self() {
+        return this;
+    }
+
     @Override
     protected IntegerListCell getFromValue(Integer value) {
         return new IntegerListCell(value, this);
     }
-    
+
     public static class IntegerListCell extends BaseListCell {
-        
+
         private Function<String, String> stripCharacters = s -> {
             StringBuilder stringBuilder_1 = new StringBuilder();
             char[] var2 = s.toCharArray();
             int var3 = var2.length;
-            
-            for(int var4 = 0; var4 < var3; ++var4)
+
+            for (int var4 = 0; var4 < var3; ++var4)
                 if (Character.isDigit(var2[var4]) || var2[var4] == '-')
                     stringBuilder_1.append(var2[var4]);
-            
+
             return stringBuilder_1.toString();
         };
         private TextFieldWidget widget;
         private boolean isSelected;
         private IntegerListListEntry listListEntry;
-        
+
         public IntegerListCell(int value, IntegerListListEntry listListEntry) {
             this.listListEntry = listListEntry;
             this.setErrorSupplier(() -> listListEntry.cellErrorSupplier == null ? Optional.empty() : listListEntry.getCellErrorSupplier().apply(getValue()));
@@ -91,7 +96,7 @@ public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListList
                     super.render(int_1, int_2, float_1);
                     setFocused(f);
                 }
-                
+
                 @Override
                 public void write(String string_1) {
                     super.write(stripCharacters.apply(string_1));
@@ -105,7 +110,7 @@ public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListList
                     listListEntry.getScreen().setEdited(true, listListEntry.isRequiresRestart());
             });
         }
-        
+
         public int getValue() {
             try {
                 return Integer.valueOf(widget.getText());
@@ -113,7 +118,7 @@ public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListList
                 return 0;
             }
         }
-        
+
         @Override
         public Optional<String> getError() {
             try {
@@ -127,12 +132,12 @@ public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListList
             }
             return Optional.empty();
         }
-        
+
         @Override
         public int getCellHeight() {
             return 20;
         }
-        
+
         @Override
         public void render(int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             widget.setWidth(entryWidth - 12);
@@ -144,12 +149,12 @@ public class IntegerListListEntry extends BaseListEntry<Integer, IntegerListList
             if (isSelected && listListEntry.isEditable())
                 fill(x, y + 12, x + entryWidth - 12, y + 13, getConfigError().isPresent() ? 0xffff5555 : 0xffe0e0e0);
         }
-        
+
         @Override
         public List<? extends Element> children() {
             return Collections.singletonList(widget);
         }
-        
+
     }
-    
+
 }

+ 30 - 25
src/main/java/me/shedaniel/clothconfig2/gui/entries/LongListListEntry.java

@@ -13,72 +13,77 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.LongListCell> {
-    
+public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.LongListCell, LongListListEntry> {
+
     private long minimum, maximum;
     private Function<Long, Optional<String>> cellErrorSupplier;
-    
+
     @Deprecated
     public LongListListEntry(String fieldName, List<Long> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, String resetButtonKey) {
         this(fieldName, value, defaultExpended, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
-    
+
     @Deprecated
     public LongListListEntry(String fieldName, List<Long> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<Long>> saveConsumer, Supplier<List<Long>> defaultValue, String resetButtonKey, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, defaultValue, baseListEntry -> new LongListCell(0, (LongListListEntry) baseListEntry), saveConsumer, resetButtonKey, requiresRestart);
         this.minimum = -Long.MAX_VALUE;
         this.maximum = Long.MAX_VALUE;
-        for(long l : value)
+        for (long l : value)
             cells.add(new LongListCell(l, this));
         this.widgets.addAll(cells);
         expended = defaultExpended;
     }
-    
+
     public Function<Long, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public void setCellErrorSupplier(Function<Long, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
     }
-    
+
     @Override
     public List<Long> getValue() {
         return cells.stream().map(LongListCell::getValue).collect(Collectors.toList());
     }
-    
+
     public LongListListEntry setMaximum(long maximum) {
         this.maximum = maximum;
         return this;
     }
-    
+
     public LongListListEntry setMinimum(long minimum) {
         this.minimum = minimum;
         return this;
     }
-    
+
+    @Override
+    public LongListListEntry self() {
+        return this;
+    }
+
     @Override
     protected LongListCell getFromValue(Long value) {
         return new LongListCell(value, this);
     }
-    
+
     public static class LongListCell extends BaseListCell {
-        
+
         private Function<String, String> stripCharacters = s -> {
             StringBuilder stringBuilder_1 = new StringBuilder();
             char[] var2 = s.toCharArray();
             int var3 = var2.length;
-            
-            for(int var4 = 0; var4 < var3; ++var4)
+
+            for (int var4 = 0; var4 < var3; ++var4)
                 if (Character.isDigit(var2[var4]) || var2[var4] == '-')
                     stringBuilder_1.append(var2[var4]);
-            
+
             return stringBuilder_1.toString();
         };
         private TextFieldWidget widget;
         private boolean isSelected;
         private LongListListEntry listListEntry;
-        
+
         public LongListCell(long value, LongListListEntry listListEntry) {
             this.listListEntry = listListEntry;
             this.setErrorSupplier(() -> listListEntry.cellErrorSupplier == null ? Optional.empty() : listListEntry.getCellErrorSupplier().apply(getValue()));
@@ -91,7 +96,7 @@ public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.Lon
                     super.render(int_1, int_2, float_1);
                     setFocused(f);
                 }
-                
+
                 @Override
                 public void write(String string_1) {
                     super.write(stripCharacters.apply(string_1));
@@ -105,7 +110,7 @@ public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.Lon
                     listListEntry.getScreen().setEdited(true, listListEntry.isRequiresRestart());
             });
         }
-        
+
         public long getValue() {
             try {
                 return Long.valueOf(widget.getText());
@@ -113,7 +118,7 @@ public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.Lon
                 return 0;
             }
         }
-        
+
         @Override
         public Optional<String> getError() {
             try {
@@ -127,12 +132,12 @@ public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.Lon
             }
             return Optional.empty();
         }
-        
+
         @Override
         public int getCellHeight() {
             return 20;
         }
-        
+
         @Override
         public void render(int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             widget.setWidth(entryWidth - 12);
@@ -144,12 +149,12 @@ public class LongListListEntry extends BaseListEntry<Long, LongListListEntry.Lon
             if (isSelected && listListEntry.isEditable())
                 fill(x, y + 12, x + entryWidth - 12, y + 13, getConfigError().isPresent() ? 0xffff5555 : 0xffe0e0e0);
         }
-        
+
         @Override
         public List<? extends Element> children() {
             return Collections.singletonList(widget);
         }
-        
+
     }
-    
+
 }

+ 23 - 18
src/main/java/me/shedaniel/clothconfig2/gui/entries/StringListListEntry.java

@@ -12,48 +12,53 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-public class StringListListEntry extends BaseListEntry<String, StringListListEntry.StringListCell> {
-    
+public class StringListListEntry extends BaseListEntry<String, StringListListEntry.StringListCell, StringListListEntry> {
+
     private Function<String, Optional<String>> cellErrorSupplier;
-    
+
     @Deprecated
     public StringListListEntry(String fieldName, List<String> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, String resetButtonKey) {
         this(fieldName, value, defaultExpended, tooltipSupplier, saveConsumer, defaultValue, resetButtonKey, false);
     }
-    
+
     @Deprecated
     public StringListListEntry(String fieldName, List<String> value, boolean defaultExpended, Supplier<Optional<String[]>> tooltipSupplier, Consumer<List<String>> saveConsumer, Supplier<List<String>> defaultValue, String resetButtonKey, boolean requiresRestart) {
         super(fieldName, tooltipSupplier, defaultValue, baseListEntry -> new StringListCell("", (StringListListEntry) baseListEntry), saveConsumer, resetButtonKey, requiresRestart);
-        for(String str : value)
+        for (String str : value)
             cells.add(new StringListCell(str, this));
         this.widgets.addAll(cells);
         expended = defaultExpended;
     }
-    
+
     public Function<String, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public void setCellErrorSupplier(Function<String, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
     }
-    
+
     @Override
     public List<String> getValue() {
         return cells.stream().map(cell -> cell.widget.getText()).collect(Collectors.toList());
     }
-    
+
+    @Override
+    public StringListListEntry self() {
+        return this;
+    }
+
     @Override
     protected StringListCell getFromValue(String value) {
         return new StringListCell(value, this);
     }
-    
+
     public static class StringListCell extends BaseListCell {
-        
+
         private TextFieldWidget widget;
         private boolean isSelected;
         private StringListListEntry listListEntry;
-        
+
         public StringListCell(String value, StringListListEntry listListEntry) {
             this.listListEntry = listListEntry;
             this.setErrorSupplier(() -> listListEntry.cellErrorSupplier == null ? Optional.empty() : listListEntry.getCellErrorSupplier().apply(widget.getText()));
@@ -75,17 +80,17 @@ public class StringListListEntry extends BaseListEntry<String, StringListListEnt
                     listListEntry.getScreen().setEdited(true, listListEntry.isRequiresRestart());
             });
         }
-        
+
         @Override
         public Optional<String> getError() {
             return Optional.empty();
         }
-        
+
         @Override
         public int getCellHeight() {
             return 20;
         }
-        
+
         @Override
         public void render(int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) {
             widget.setWidth(entryWidth - 12);
@@ -97,12 +102,12 @@ public class StringListListEntry extends BaseListEntry<String, StringListListEnt
             if (isSelected && listListEntry.isEditable())
                 fill(x, y + 12, x + entryWidth - 12, y + 13, getConfigError().isPresent() ? 0xffff5555 : 0xffe0e0e0);
         }
-        
+
         @Override
         public List<? extends Element> children() {
             return Collections.singletonList(widget);
         }
-        
+
     }
-    
+
 }

+ 8 - 7
src/main/java/me/shedaniel/clothconfig2/impl/builders/DoubleListBuilder.java

@@ -1,9 +1,9 @@
 package me.shedaniel.clothconfig2.impl.builders;
 
-import me.shedaniel.clothconfig2.gui.entries.BaseListEntry;
 import me.shedaniel.clothconfig2.gui.entries.DoubleListListEntry;
 import net.minecraft.client.resource.language.I18n;
 
+import javax.annotation.Nonnull;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -18,7 +18,7 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
     private List<Double> value;
     private boolean expended = false;
     private Double min = null, max = null;
-    private Function<BaseListEntry, DoubleListListEntry.DoubleListCell> createNewInstance;
+    private Function<DoubleListListEntry, DoubleListListEntry.DoubleListCell> createNewInstance;
     private String addTooltip = I18n.translate("text.cloth-config.list.add"), removeTooltip = I18n.translate("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
@@ -65,8 +65,8 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
         requireRestart(true);
         return this;
     }
-    
-    public DoubleListBuilder setCreateNewInstance(Function<BaseListEntry, DoubleListListEntry.DoubleListCell> createNewInstance) {
+
+    public DoubleListBuilder setCreateNewInstance(Function<DoubleListListEntry, DoubleListListEntry.DoubleListCell> createNewInstance) {
         this.createNewInstance = createNewInstance;
         return this;
     }
@@ -130,7 +130,8 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }
-    
+
+    @Nonnull
     @Override
     public DoubleListListEntry build() {
         DoubleListListEntry entry = new DoubleListListEntry(getFieldNameKey(), value, expended, null, saveConsumer, defaultValue, getResetButtonKey(), isRequireRestart()) {
@@ -138,7 +139,7 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
             public boolean isDeleteButtonEnabled() {
                 return deleteButtonEnabled;
             }
-            
+
             @Override
             public boolean insertInFront() {
                 return insertInFront;
@@ -159,4 +160,4 @@ public class DoubleListBuilder extends FieldBuilder<List<Double>, DoubleListList
         return entry;
     }
     
-}
+}

+ 31 - 30
src/main/java/me/shedaniel/clothconfig2/impl/builders/FloatListBuilder.java

@@ -1,9 +1,9 @@
 package me.shedaniel.clothconfig2.impl.builders;
 
-import me.shedaniel.clothconfig2.gui.entries.BaseListEntry;
 import me.shedaniel.clothconfig2.gui.entries.FloatListListEntry;
 import net.minecraft.client.resource.language.I18n;
 
+import javax.annotation.Nonnull;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -11,126 +11,127 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 
 public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEntry> {
-    
+
     protected Function<Float, Optional<String>> cellErrorSupplier;
     private Consumer<List<Float>> saveConsumer = null;
     private Function<List<Float>, Optional<String[]>> tooltipSupplier = list -> Optional.empty();
     private List<Float> value;
     private boolean expended = false;
     private Float min = null, max = null;
-    private Function<BaseListEntry, FloatListListEntry.FloatListCell> createNewInstance;
+    private Function<FloatListListEntry, FloatListListEntry.FloatListCell> createNewInstance;
     private String addTooltip = I18n.translate("text.cloth-config.list.add"), removeTooltip = I18n.translate("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
-    
+
     public FloatListBuilder(String resetButtonKey, String fieldNameKey, List<Float> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
-    
+
     public Function<Float, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public FloatListBuilder setCellErrorSupplier(Function<Float, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
-    
+
     public FloatListBuilder setDeleteButtonEnabled(boolean deleteButtonEnabled) {
         this.deleteButtonEnabled = deleteButtonEnabled;
         return this;
     }
-    
+
     public FloatListBuilder setErrorSupplier(Function<List<Float>, Optional<String>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
-    
+
     public FloatListBuilder setInsertInFront(boolean insertInFront) {
         this.insertInFront = insertInFront;
         return this;
     }
-    
+
     public FloatListBuilder setAddButtonTooltip(String addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
-    
+
     public FloatListBuilder setRemoveButtonTooltip(String removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
-    
+
     public FloatListBuilder requireRestart() {
         requireRestart(true);
         return this;
     }
-    
-    public FloatListBuilder setCreateNewInstance(Function<BaseListEntry, FloatListListEntry.FloatListCell> createNewInstance) {
+
+    public FloatListBuilder setCreateNewInstance(Function<FloatListListEntry, FloatListListEntry.FloatListCell> createNewInstance) {
         this.createNewInstance = createNewInstance;
         return this;
     }
-    
+
     public FloatListBuilder setExpended(boolean expended) {
         this.expended = expended;
         return this;
     }
-    
+
     public FloatListBuilder setSaveConsumer(Consumer<List<Float>> saveConsumer) {
         this.saveConsumer = saveConsumer;
         return this;
     }
-    
+
     public FloatListBuilder setDefaultValue(Supplier<List<Float>> defaultValue) {
         this.defaultValue = defaultValue;
         return this;
     }
-    
+
     public FloatListBuilder setMin(float min) {
         this.min = min;
         return this;
     }
-    
+
     public FloatListBuilder setMax(float max) {
         this.max = max;
         return this;
     }
-    
+
     public FloatListBuilder removeMin() {
         this.min = null;
         return this;
     }
-    
+
     public FloatListBuilder removeMax() {
         this.max = null;
         return this;
     }
-    
+
     public FloatListBuilder setDefaultValue(List<Float> defaultValue) {
         this.defaultValue = () -> defaultValue;
         return this;
     }
-    
+
     public FloatListBuilder setTooltipSupplier(Supplier<Optional<String[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
-    
+
     public FloatListBuilder setTooltipSupplier(Function<List<Float>, Optional<String[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
-    
+
     public FloatListBuilder setTooltip(Optional<String[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
-    
+
     public FloatListBuilder setTooltip(String... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }
-    
+
+    @Nonnull
     @Override
     public FloatListListEntry build() {
         FloatListListEntry entry = new FloatListListEntry(getFieldNameKey(), value, expended, null, saveConsumer, defaultValue, getResetButtonKey(), isRequireRestart()) {
@@ -138,7 +139,7 @@ public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEnt
             public boolean isDeleteButtonEnabled() {
                 return deleteButtonEnabled;
             }
-            
+
             @Override
             public boolean insertInFront() {
                 return insertInFront;
@@ -158,5 +159,5 @@ public class FloatListBuilder extends FieldBuilder<List<Float>, FloatListListEnt
             entry.setErrorSupplier(() -> errorSupplier.apply(entry.getValue()));
         return entry;
     }
-    
-}
+
+}

+ 31 - 30
src/main/java/me/shedaniel/clothconfig2/impl/builders/IntListBuilder.java

@@ -1,9 +1,9 @@
 package me.shedaniel.clothconfig2.impl.builders;
 
-import me.shedaniel.clothconfig2.gui.entries.BaseListEntry;
 import me.shedaniel.clothconfig2.gui.entries.IntegerListListEntry;
 import net.minecraft.client.resource.language.I18n;
 
+import javax.annotation.Nonnull;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -11,126 +11,127 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 
 public class IntListBuilder extends FieldBuilder<List<Integer>, IntegerListListEntry> {
-    
+
     protected Function<Integer, Optional<String>> cellErrorSupplier;
     private Consumer<List<Integer>> saveConsumer = null;
     private Function<List<Integer>, Optional<String[]>> tooltipSupplier = list -> Optional.empty();
     private List<Integer> value;
     private boolean expended = false;
     private Integer min = null, max = null;
-    private Function<BaseListEntry, IntegerListListEntry.IntegerListCell> createNewInstance;
+    private Function<IntegerListListEntry, IntegerListListEntry.IntegerListCell> createNewInstance;
     private String addTooltip = I18n.translate("text.cloth-config.list.add"), removeTooltip = I18n.translate("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
-    
+
     public IntListBuilder(String resetButtonKey, String fieldNameKey, List<Integer> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
-    
+
     public Function<Integer, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public IntListBuilder setCellErrorSupplier(Function<Integer, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
-    
+
     public IntListBuilder setErrorSupplier(Function<List<Integer>, Optional<String>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
-    
+
     public IntListBuilder setDeleteButtonEnabled(boolean deleteButtonEnabled) {
         this.deleteButtonEnabled = deleteButtonEnabled;
         return this;
     }
-    
+
     public IntListBuilder setInsertInFront(boolean insertInFront) {
         this.insertInFront = insertInFront;
         return this;
     }
-    
+
     public IntListBuilder setAddButtonTooltip(String addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
-    
+
     public IntListBuilder setRemoveButtonTooltip(String removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
-    
+
     public IntListBuilder requireRestart() {
         requireRestart(true);
         return this;
     }
-    
-    public IntListBuilder setCreateNewInstance(Function<BaseListEntry, IntegerListListEntry.IntegerListCell> createNewInstance) {
+
+    public IntListBuilder setCreateNewInstance(Function<IntegerListListEntry, IntegerListListEntry.IntegerListCell> createNewInstance) {
         this.createNewInstance = createNewInstance;
         return this;
     }
-    
+
     public IntListBuilder setExpended(boolean expended) {
         this.expended = expended;
         return this;
     }
-    
+
     public IntListBuilder setSaveConsumer(Consumer<List<Integer>> saveConsumer) {
         this.saveConsumer = saveConsumer;
         return this;
     }
-    
+
     public IntListBuilder setDefaultValue(Supplier<List<Integer>> defaultValue) {
         this.defaultValue = defaultValue;
         return this;
     }
-    
+
     public IntListBuilder setMin(int min) {
         this.min = min;
         return this;
     }
-    
+
     public IntListBuilder setMax(int max) {
         this.max = max;
         return this;
     }
-    
+
     public IntListBuilder removeMin() {
         this.min = null;
         return this;
     }
-    
+
     public IntListBuilder removeMax() {
         this.max = null;
         return this;
     }
-    
+
     public IntListBuilder setDefaultValue(List<Integer> defaultValue) {
         this.defaultValue = () -> defaultValue;
         return this;
     }
-    
+
     public IntListBuilder setTooltipSupplier(Function<List<Integer>, Optional<String[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
-    
+
     public IntListBuilder setTooltipSupplier(Supplier<Optional<String[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
-    
+
     public IntListBuilder setTooltip(Optional<String[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
-    
+
     public IntListBuilder setTooltip(String... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }
-    
+
+    @Nonnull
     @Override
     public IntegerListListEntry build() {
         IntegerListListEntry entry = new IntegerListListEntry(getFieldNameKey(), value, expended, null, saveConsumer, defaultValue, getResetButtonKey(), isRequireRestart()) {
@@ -138,7 +139,7 @@ public class IntListBuilder extends FieldBuilder<List<Integer>, IntegerListListE
             public boolean isDeleteButtonEnabled() {
                 return deleteButtonEnabled;
             }
-            
+
             @Override
             public boolean insertInFront() {
                 return insertInFront;
@@ -158,5 +159,5 @@ public class IntListBuilder extends FieldBuilder<List<Integer>, IntegerListListE
             entry.setErrorSupplier(() -> errorSupplier.apply(entry.getValue()));
         return entry;
     }
-    
-}
+
+}

+ 8 - 7
src/main/java/me/shedaniel/clothconfig2/impl/builders/LongListBuilder.java

@@ -1,9 +1,9 @@
 package me.shedaniel.clothconfig2.impl.builders;
 
-import me.shedaniel.clothconfig2.gui.entries.BaseListEntry;
 import me.shedaniel.clothconfig2.gui.entries.LongListListEntry;
 import net.minecraft.client.resource.language.I18n;
 
+import javax.annotation.Nonnull;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Consumer;
@@ -18,7 +18,7 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
     private List<Long> value;
     private boolean expended = false;
     private Long min = null, max = null;
-    private Function<BaseListEntry, LongListListEntry.LongListCell> createNewInstance;
+    private Function<LongListListEntry, LongListListEntry.LongListCell> createNewInstance;
     private String addTooltip = I18n.translate("text.cloth-config.list.add"), removeTooltip = I18n.translate("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
     
@@ -65,8 +65,8 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
         requireRestart(true);
         return this;
     }
-    
-    public LongListBuilder setCreateNewInstance(Function<BaseListEntry, LongListListEntry.LongListCell> createNewInstance) {
+
+    public LongListBuilder setCreateNewInstance(Function<LongListListEntry, LongListListEntry.LongListCell> createNewInstance) {
         this.createNewInstance = createNewInstance;
         return this;
     }
@@ -130,7 +130,8 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }
-    
+
+    @Nonnull
     @Override
     public LongListListEntry build() {
         LongListListEntry entry = new LongListListEntry(getFieldNameKey(), value, expended, null, saveConsumer, defaultValue, getResetButtonKey(), isRequireRestart()) {
@@ -138,7 +139,7 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
             public boolean isDeleteButtonEnabled() {
                 return deleteButtonEnabled;
             }
-            
+
             @Override
             public boolean insertInFront() {
                 return insertInFront;
@@ -159,4 +160,4 @@ public class LongListBuilder extends FieldBuilder<List<Long>, LongListListEntry>
         return entry;
     }
     
-}
+}

+ 24 - 25
src/main/java/me/shedaniel/clothconfig2/impl/builders/StringListBuilder.java

@@ -1,6 +1,5 @@
 package me.shedaniel.clothconfig2.impl.builders;
 
-import me.shedaniel.clothconfig2.gui.entries.BaseListEntry;
 import me.shedaniel.clothconfig2.gui.entries.StringListListEntry;
 import net.minecraft.client.resource.language.I18n;
 
@@ -11,105 +10,105 @@ import java.util.function.Function;
 import java.util.function.Supplier;
 
 public class StringListBuilder extends FieldBuilder<List<String>, StringListListEntry> {
-    
+
     private Function<String, Optional<String>> cellErrorSupplier;
     private Consumer<List<String>> saveConsumer = null;
     private Function<List<String>, Optional<String[]>> tooltipSupplier = list -> Optional.empty();
     private List<String> value;
     private boolean expended = false;
-    private Function<BaseListEntry, StringListListEntry.StringListCell> createNewInstance;
+    private Function<StringListListEntry, StringListListEntry.StringListCell> createNewInstance;
     private String addTooltip = I18n.translate("text.cloth-config.list.add"), removeTooltip = I18n.translate("text.cloth-config.list.remove");
     private boolean deleteButtonEnabled = true, insertInFront = true;
-    
+
     public StringListBuilder(String resetButtonKey, String fieldNameKey, List<String> value) {
         super(resetButtonKey, fieldNameKey);
         this.value = value;
     }
-    
+
     public Function<String, Optional<String>> getCellErrorSupplier() {
         return cellErrorSupplier;
     }
-    
+
     public StringListBuilder setCellErrorSupplier(Function<String, Optional<String>> cellErrorSupplier) {
         this.cellErrorSupplier = cellErrorSupplier;
         return this;
     }
-    
+
     public StringListBuilder setErrorSupplier(Function<List<String>, Optional<String>> errorSupplier) {
         this.errorSupplier = errorSupplier;
         return this;
     }
-    
+
     public StringListBuilder setDeleteButtonEnabled(boolean deleteButtonEnabled) {
         this.deleteButtonEnabled = deleteButtonEnabled;
         return this;
     }
-    
+
     public StringListBuilder setInsertInFront(boolean insertInFront) {
         this.insertInFront = insertInFront;
         return this;
     }
-    
+
     public StringListBuilder setAddButtonTooltip(String addTooltip) {
         this.addTooltip = addTooltip;
         return this;
     }
-    
+
     public StringListBuilder setRemoveButtonTooltip(String removeTooltip) {
         this.removeTooltip = removeTooltip;
         return this;
     }
-    
+
     public StringListBuilder requireRestart() {
         requireRestart(true);
         return this;
     }
-    
-    public StringListBuilder setCreateNewInstance(Function<BaseListEntry, StringListListEntry.StringListCell> createNewInstance) {
+
+    public StringListBuilder setCreateNewInstance(Function<StringListListEntry, StringListListEntry.StringListCell> createNewInstance) {
         this.createNewInstance = createNewInstance;
         return this;
     }
-    
+
     public StringListBuilder setExpended(boolean expended) {
         this.expended = expended;
         return this;
     }
-    
+
     public StringListBuilder setSaveConsumer(Consumer<List<String>> saveConsumer) {
         this.saveConsumer = saveConsumer;
         return this;
     }
-    
+
     public StringListBuilder setDefaultValue(Supplier<List<String>> defaultValue) {
         this.defaultValue = defaultValue;
         return this;
     }
-    
+
     public StringListBuilder setDefaultValue(List<String> defaultValue) {
         this.defaultValue = () -> defaultValue;
         return this;
     }
-    
+
     public StringListBuilder setTooltipSupplier(Supplier<Optional<String[]>> tooltipSupplier) {
         this.tooltipSupplier = list -> tooltipSupplier.get();
         return this;
     }
-    
+
     public StringListBuilder setTooltipSupplier(Function<List<String>, Optional<String[]>> tooltipSupplier) {
         this.tooltipSupplier = tooltipSupplier;
         return this;
     }
-    
+
     public StringListBuilder setTooltip(Optional<String[]> tooltip) {
         this.tooltipSupplier = list -> tooltip;
         return this;
     }
-    
+
     public StringListBuilder setTooltip(String... tooltip) {
         this.tooltipSupplier = list -> Optional.ofNullable(tooltip);
         return this;
     }
-    
+
     @Override
     public StringListListEntry build() {
         StringListListEntry entry = new StringListListEntry(getFieldNameKey(), value, expended, null, saveConsumer, defaultValue, getResetButtonKey(), isRequireRestart());
@@ -123,5 +122,5 @@ public class StringListBuilder extends FieldBuilder<List<String>, StringListList
             entry.setErrorSupplier(() -> errorSupplier.apply(entry.getValue()));
         return entry;
     }
-    
-}
+
+}