Skip to content

Commit 48bb44b

Browse files
committed
fix build + add helper method
1 parent e7b9659 commit 48bb44b

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

modules/hud/api/hud.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public abstract class org/polyfrost/oneconfig/api/hud/v1/Hud : org/polyfrost/one
2222
public final fun setHidden (Z)V
2323
public abstract fun title ()Ljava/lang/String;
2424
public abstract fun update ()Z
25+
protected final fun updateAndRecalculate ()V
2526
public fun updateFrequency ()J
2627
protected final fun updateWhenChanged (Ljava/lang/String;)V
2728
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,17 @@ abstract class Hud<T : Drawable> : Cloneable, Config("null", null, "null", null)
233233
open fun initialize() {}
234234

235235
/**
236-
* shorthand for [adding a callback][addCallback] on the given property that just calls [update].
236+
* shorthand for [adding a callback][addCallback] on the given property that just calls [updateAndRecalculate].
237237
*/
238238
protected fun updateWhenChanged(optionName: String) {
239-
if (isReal) addCallback(optionName) {
240-
if (update()) get()._parent?.recalculate()
241-
}
239+
if (isReal) addCallback(optionName, this::updateAndRecalculate)
242240
else LOGGER.warn("attempted to add callback to {}'s option '{}', but it is not real. no action has been taken.", title(), optionName)
243241
}
244242

243+
protected fun updateAndRecalculate() {
244+
if (update()) get()._parent?.recalculate()
245+
}
246+
245247
/**
246248
* Update your HUD element.
247249
* Get the instance of your HUD element by calling [get] or [hud].

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ abstract class TextHud(
132132
if (isReal) {
133133
addCallback("template") {
134134
_formatter = null
135-
if (update()) get()._parent?.recalculate()
135+
updateAndRecalculate()
136136
}
137137
}
138138
}

modules/utils/api/utils.api

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,7 @@ public final class org/polyfrost/oneconfig/utils/v1/Deprecator {
150150
}
151151

152152
public final class org/polyfrost/oneconfig/utils/v1/IOUtils {
153-
public static fun copyImageToClipboard (Ljava/awt/Image;)V
154-
public static fun copyStringToClipboard (Ljava/lang/String;)V
155153
public static fun getFileChecksum (Ljava/nio/file/Path;)Ljava/lang/String;
156-
public static fun getImageFromClipboard ()Ljava/awt/Image;
157-
public static fun getStringFromClipboard ()Ljava/lang/String;
158154
}
159155

160156
public final class org/polyfrost/oneconfig/utils/v1/JsonUtils {

0 commit comments

Comments
 (0)