Skip to content

Commit 75b2d5f

Browse files
committed
fix some issues (maybe)
1 parent 11ad5d1 commit 75b2d5f

File tree

3 files changed

+18
-0
lines changed
  • modules
    • config-impl/src/main/java/org/polyfrost/oneconfig/api/config/v1
    • hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1

3 files changed

+18
-0
lines changed

modules/config-impl/src/main/java/org/polyfrost/oneconfig/api/config/v1/Config.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.polyfrost.oneconfig.api.config.v1.annotations.Include;
3434
import org.polyfrost.polyui.data.PolyImage;
3535

36+
import java.nio.file.Files;
3637
import java.nio.file.Path;
3738
import java.util.ArrayList;
3839
import java.util.Arrays;
@@ -214,6 +215,15 @@ protected void loadFrom(Path p) {
214215
tree.overwrite(in, false);
215216
}
216217

218+
protected void loadFromAndDelete(Path p) {
219+
try {
220+
loadFrom(p);
221+
Files.deleteIfExists(p);
222+
} catch (Exception e) {
223+
ConfigManager.LOGGER.error("An unknown error occurred", e);
224+
}
225+
}
226+
217227

218228
protected Property<?> getProperty(String option) {
219229
if (tree == null) initialize(false);

modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/Hud.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ abstract class Hud<T : Drawable>(id: String, title: String, val category: Catego
313313
}
314314

315315
protected fun updateAndRecalculate() {
316+
if (it == null) {
317+
LOGGER.warn("attempted to updateAndRecalculate on {} but it doesn't exist yet (method called to early, or have you checked isReal?) - it will be ignored. if you need this to run, call get() first.", id)
318+
return
319+
}
316320
if (update()) getBackground()?.recalculate(false)
317321
}
318322

modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/LegacyHud.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ abstract class LegacyHud(id: String, title: String, category: Category) : Hud<Dr
5353
abstract var width: Float
5454
abstract var height: Float
5555

56+
init {
57+
get()
58+
}
59+
5660
/**
5761
* Support for complex hybrid legacy HUDs with PolyUI children is currently experimental. Please report any issues you find.
5862
*/

0 commit comments

Comments
 (0)