Skip to content

Commit

Permalink
Fix Options.chatClear
Browse files Browse the repository at this point in the history
  • Loading branch information
MystWraith committed Dec 20, 2023
1 parent b5d2f79 commit a39cc95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ModMenuIntergrationImpl() {
public void saveConfig() {
Pickaxe.LOGGER.info("Saving config");

((Function<Boolean, Boolean>)Options.getInstance().chatClear).apply(false); // Result is ignored
Options.getInstance().chatClear.apply(false); // Result is ignored

try {
File file = new File(configPath);
Expand Down Expand Up @@ -190,7 +190,7 @@ public void createTimerConfig(YetAnotherConfigLib.@NotNull Builder builder) {
)
.build()
)

.group(OptionGroup.createBuilder()
.name(Text.literal("Moon Door Timer"))
.option(Option.<Boolean>createBuilder()
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/tech/showierdata/pickaxe/config/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.function.Function;

public class Options {
public boolean enabled = true;
Expand All @@ -28,7 +29,7 @@ public class Options {
public final MsgStackConfig msgStackConfig;
public final MDTConfig mdtConfig;

public Object chatClear;
public Function<Boolean, Void> chatClear;

static Options INSTANCE;

Expand Down
13 changes: 4 additions & 9 deletions src/main/java/tech/showierdata/pickaxe/mixin/ChatHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,10 @@ public void optionUpdateClear(MinecraftClient client, CallbackInfo info) {
* Wanted to do void but can't return void for some reason
* Instead I return a "success" boolean
*/
Options.getInstance().chatClear = new Function<Boolean,Boolean>() {
public Boolean apply(Boolean clearHistory) {
try {
clear(clearHistory);
return true;
}
catch (Error ignored) {
return false;
}
Options.getInstance().chatClear = new Function<Boolean, Void>() {
public Void apply(Boolean clearHistory) {
clear(clearHistory);
return null;
}
};
}
Expand Down

0 comments on commit a39cc95

Please sign in to comment.