Skip to content

Commit

Permalink
Bugfix for github.com//issues/6 and add gradle configs (#7)
Browse files Browse the repository at this point in the history
* Add missing World params in HardcoreSpawnUtils mixins

* Update README.md

* Add gradle config/jar and update dev instructions.

* Readme typo.

* Fix issue where maximum radius <1000 would crash

Validation of config settings during initial load now only happens after all settings have been loaded, not once after each setting. Behavior using the in-game command is unchanged.

github.com//issues/6
  • Loading branch information
dddoss authored Jan 2, 2025
1 parent da17aeb commit 6b0fb8b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ run
BTW_dev
custom_mappings
dev_run
gradle
release

# BTW Files
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Want to be able to change HC Spawn mechanics? Want to disable lightning fires? This addon is for you!

Currently updated for BTW CE 2.1.4. Compatibility with is untested and not guaranteed.

[Download](https://github.com/BTW-Community/Tweaker/releases/latest)

## Installation
Expand Down Expand Up @@ -69,3 +71,14 @@ lightningFire=true
```

</details>

## Dev Instructions

For 2.1.4 mod dev, you'll need to obtain the BTW-sources. See https://github.com/BTW-Community/BTW-gradle for
instructions; the source should be copied to `./src/btw`. Gradle version must be <8 (version 7.2 is configured in
`gradle-wrapper.properties`).

There is a known issue with this dev environment causing the error `Caused by: java.io.IOException: The account being
accessed does not support http. for
http://resources.download.minecraft.net/99/991b421dfd401f115241601b2b373140a8d78572`. As a workaround, you may need
to manually copy assets from an existing minecraft jar.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ minecraft_version = 1.5.2
yarn_mappings = 1.5.2+build.202201092137
loader_version = 1.0.0

mod_version = 1.4.1
mod_version = 1.4.2
maven_group = issame
archives_base_name = tweaker
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 14 additions & 11 deletions src/main/java/issame/tweaker/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Config {
private static Map<String, Boolean> configBooleans = getDefaultBooleans();

public static void loadConfig(Map<String, String> configProperties) {
configProperties.forEach(Config::putValue);
configProperties.forEach((k, v) -> putValue(k, v, false));
}

public static void resetConfig() {
Expand All @@ -26,6 +26,7 @@ public static void resetConfig() {
configBooleans = getDefaultBooleans();

loadConfig(tweaker.loadConfigProperties());
verifyConfig();
}

private static void verifyConfig() {
Expand Down Expand Up @@ -167,25 +168,27 @@ public static Boolean getBoolean(String key) {

// === Putters ===

public static void putValue(String key, String value) {
public static void putValue(String key, String value, boolean validate) {
if (configDoubles.containsKey(key)) {
putType(configDoubles, key, parseDouble(value));
putType(configDoubles, key, parseDouble(value), validate);
} else if (configIntegers.containsKey(key)) {
putType(configIntegers, key, parseInteger(value));
putType(configIntegers, key, parseInteger(value), validate);
} else if (configBooleans.containsKey(key)) {
putType(configBooleans, key, parseBoolean(value));
putType(configBooleans, key, parseBoolean(value), validate);
} else {
throw new CommandNotFoundException("Could not find command " + key);
}
}

private static <T> void putType(Map<String, T> configType, String key, T value) {
private static <T> void putType(Map<String, T> configType, String key, T value, boolean validate) {
T prevValue = configType.put(key, value);
try {
verifyConfig();
} catch (CommandException e) {
configType.put(key, prevValue);
throw e;
if (validate) {
try {
verifyConfig();
} catch (CommandException e) {
configType.put(key, prevValue);
throw e;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/issame/tweaker/TweakerCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void processCommand(ICommandSender commandSender, String key) {
}

private void processCommand(ICommandSender commandSender, String key, String value) {
Config.putValue(key, value);
Config.putValue(key, value, true);
notifyAdmins(commandSender, key + " set to " + value, key, value);
}
}

0 comments on commit 6b0fb8b

Please sign in to comment.