Skip to content

Commit

Permalink
Update to malilib boolean toggle message changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maruohon committed Apr 1, 2022
1 parent d1d8822 commit f71d457
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/main/java/fi/dy/masa/minihud/config/ConfigCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import fi.dy.masa.malilib.config.option.BooleanConfig;
import fi.dy.masa.malilib.config.option.BaseGenericConfig;
import fi.dy.masa.malilib.input.callback.AdjustableValueHotkeyCallback;
import fi.dy.masa.malilib.listener.EventListener;
import fi.dy.masa.malilib.overlay.message.MessageHelpers;
import fi.dy.masa.malilib.overlay.message.MessageUtils;
import fi.dy.masa.malilib.render.overlay.OverlayRendererContainer;
import fi.dy.masa.malilib.util.EntityUtils;
import fi.dy.masa.malilib.util.StringUtils;
import fi.dy.masa.malilib.util.data.BooleanStorage;
import fi.dy.masa.minihud.data.DataStorage;
import fi.dy.masa.minihud.feature.Actions;
import fi.dy.masa.minihud.network.CarpetPubsubPacketHandler;
Expand Down Expand Up @@ -89,7 +90,8 @@ private static void onChunkUnloadBucketOverlayEnabled()
Configs.Internal.CHUNK_UNLOAD_BUCKET_OVERLAY_Y.setDoubleValue(pos.y - 2);
}

private static String getSpawnChunksMessage(BooleanConfig config)
private static<CFG extends BaseGenericConfig<?> & BooleanStorage>
String getSpawnChunksMessage(CFG config)
{
if (config.getBooleanValue())
{
Expand All @@ -103,7 +105,8 @@ private static String getSpawnChunksMessage(BooleanConfig config)
return MessageHelpers.getBooleanConfigToggleMessage(config, null);
}

private static String getSpawnableChunksMessage(BooleanConfig config)
private static <CFG extends BaseGenericConfig<?> & BooleanStorage>
String getSpawnableChunksMessage(CFG config)
{
if (config.getBooleanValue())
{
Expand All @@ -118,7 +121,8 @@ private static String getSpawnableChunksMessage(BooleanConfig config)
return MessageHelpers.getBooleanConfigToggleMessage(config, null);
}

private static String getRandomTicksMessage(BooleanConfig config)
private static <CFG extends BaseGenericConfig<?> & BooleanStorage>
String getRandomTicksMessage(CFG config)
{
if (config.getBooleanValue())
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fi/dy/masa/minihud/config/InfoLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public enum InfoLine implements ConfigInfo
this.toggleHotkey.setNameTranslationKey(nameKey);
this.toggleHotkey.setPrettyNameTranslationKey(nameKey);
this.toggleHotkey.setCommentTranslationKey(commentKey);
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback(this.toggleStatus));
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback<>(this.toggleStatus));
}

public void addValueChangeListener(EventListener listener)
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/fi/dy/masa/minihud/config/RendererToggle.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList;
Expand All @@ -13,6 +12,7 @@
import fi.dy.masa.malilib.input.KeyBindSettings;
import fi.dy.masa.malilib.input.callback.ToggleBooleanWithMessageKeyCallback;
import fi.dy.masa.malilib.listener.EventListener;
import fi.dy.masa.malilib.overlay.message.MessageHelpers.BooleanConfigMessageFactory;
import fi.dy.masa.malilib.util.data.ModInfo;
import fi.dy.masa.minihud.Reference;

Expand Down Expand Up @@ -72,7 +72,7 @@ public enum RendererToggle implements ConfigInfo
this.toggleHotkey.setPrettyNameTranslationKey(nameKey);
this.toggleHotkey.setCommentTranslationKey(commentKey);

this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback(this.booleanConfig));
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback<>(this.booleanConfig));
}

public boolean isRendererEnabled()
Expand All @@ -90,9 +90,9 @@ public void addEnableListener(EventListener listener)
this.booleanConfig.addEnableListener(listener);
}

public void setToggleMessageFactory(@Nullable Function<BooleanConfig, String> messageFactory)
public void setToggleMessageFactory(@Nullable BooleanConfigMessageFactory messageFactory)
{
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback(this.booleanConfig, messageFactory));
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback<>(this.booleanConfig, messageFactory));
}

public BooleanConfig getBooleanConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public enum StructureToggle implements ConfigInfo

this.toggleHotkey.setNameTranslationKey(nameKey);
this.toggleHotkey.setCommentTranslationKey(commentKey);
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback(this.toggleStatus));
this.toggleHotkey.getKeyBind().setCallback(new ToggleBooleanWithMessageKeyCallback<>(this.toggleStatus));
this.toggleStatus.addValueChangeListener(DataStorage.getInstance().getStructureStorage()::requestStructureDataUpdates);
}

Expand Down

0 comments on commit f71d457

Please sign in to comment.