Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the partial speaking disabled by default; Fix mod crashing on loading wrong config.json; #77

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static POIConfigMap buildDefault() {
m4.setDelay(100);
m1.setLockingConfigMap(m4);

m1.poiMarkingConfigMap = (POIMarkingConfigMap.buildDefault());
m1.setPoiMarkingConfigMap(POIMarkingConfigMap.buildDefault());

return m1;
}
Expand Down Expand Up @@ -84,5 +84,13 @@ public POILockingConfigMap getLockingConfigMap() {
public void setLockingConfigMap(POILockingConfigMap poiLockingConfigMap) {
this.poiLockingConfigMap = poiLockingConfigMap;
}

public POIMarkingConfigMap getPoiMarkingConfigMap() {
return poiMarkingConfigMap;
}

public void setPoiMarkingConfigMap(POIMarkingConfigMap poiMarkingConfigMap) {
this.poiMarkingConfigMap = poiMarkingConfigMap;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class RCPartialSpeakingConfigMap {

public static RCPartialSpeakingConfigMap buildDefault() {
RCPartialSpeakingConfigMap m = new RCPartialSpeakingConfigMap();
m.enabled = true;
m.enabled = false;
m.partialSpeakingWhitelistMode = true;
m.partialSpeakingFuzzyMode = true;
m.partialSpeakingTargets = List.of("slab", "planks", "block", "stone", "sign");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.khanshoaib3.minecraft_access.features;

import com.github.khanshoaib3.minecraft_access.MainClass;
import com.github.khanshoaib3.minecraft_access.config.Config;
import com.github.khanshoaib3.minecraft_access.config.config_maps.RCPartialSpeakingConfigMap;
import com.github.khanshoaib3.minecraft_access.config.config_maps.ReadCrosshairConfigMap;
import com.github.khanshoaib3.minecraft_access.utils.PlayerPositionUtils;
Expand Down Expand Up @@ -91,7 +92,11 @@ public void update() {
}

private void loadConfigurations() {
ReadCrosshairConfigMap rcMap = ReadCrosshairConfigMap.getInstance();
// It is best to get the config map from instance of Config class rather than directly from
// the ReadCrosshairConfigMap class because in the case of an error in the config.json,
// while it does get reset to default but the mod crashes as well. So to avoid the mod from crashing,
// use the instance of Config class to get instances of other config maps.
ReadCrosshairConfigMap rcMap = Config.getInstance().getConfigMap().getReadCrosshairConfigMap();
RCPartialSpeakingConfigMap rcpMap = rcMap.getPartialSpeakingConfigMap();

this.speakSide = rcMap.isSpeakSide();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.khanshoaib3.minecraft_access.features.point_of_interest;

import com.github.khanshoaib3.minecraft_access.MainClass;
import com.github.khanshoaib3.minecraft_access.config.config_maps.POIMarkingConfigMap;
import com.github.khanshoaib3.minecraft_access.config.Config;
import com.github.khanshoaib3.minecraft_access.utils.KeyBindingsHandler;
import com.github.khanshoaib3.minecraft_access.utils.KeyUtils;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -38,7 +38,7 @@ public static POIMarking getInstance() {
* if this feature is enabled.
*/
public void update() {
if (POIMarkingConfigMap.getInstance().isEnabled()) {
if (Config.getInstance().getConfigMap().getPoiConfigMap().getPoiMarkingConfigMap().isEnabled()) {
boolean controlPressed = Screen.hasControlDown();
boolean AltPressed = Screen.hasAltDown();
boolean lockingKeyPressed = KeyUtils.isAnyPressed(KeyBindingsHandler.getInstance().lockingHandlerKey);
Expand Down