f65b7f176b
* Carpet features
* refactor(config): move up config
* refactor file
diff in file system
* Update Luminol
* move up - stage 1
* Revert "Update Luminol"
This reverts commit 6f02993bfe.
* move up - stage 2
* new carpet features
* upload docs
* stage - pre update
* [ci skip]Update Luminol
only update for dev branch, so skip ci
* remove blank
* feat:add carpet core config & move some function to config load stage
* remove some unused value & logic
* fix up
* Update Luminol
* fix up
* remove imports update
* add warning to carpet system if it is enabled
* Update Luminol
* use new function to sync config
* oops!
* Update Luminol
* fix up a bug
* refactor
* Update Luminol
* move up directory
* Update Luminol
* oops!
* refactor need
* feat: add CoreConfig to enable general rules in CarpetCompatSync
* modify some default value
* fix: enhance HUD logger subscriptions and improve player data handling
---------
Co-authored-by: Helvetica Volubi <suisuroru@blue-millennium.fun>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
43 lines
1009 B
Java
43 lines
1009 B
Java
package fun.bm.lophine.carpet;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
public final class InteractionUpdateCompatHelper {
|
|
private static final ThreadLocal<Integer> SUPPRESSED_DEPTH = ThreadLocal.withInitial(() -> 0);
|
|
|
|
public static boolean shouldSkipUpdates() {
|
|
return SUPPRESSED_DEPTH.get() > 0;
|
|
}
|
|
|
|
public static void runWithSuppressedUpdates(Runnable action) {
|
|
push();
|
|
try {
|
|
action.run();
|
|
} finally {
|
|
pop();
|
|
}
|
|
}
|
|
|
|
public static <T> T supplyWithSuppressedUpdates(Supplier<T> action) {
|
|
push();
|
|
try {
|
|
return action.get();
|
|
} finally {
|
|
pop();
|
|
}
|
|
}
|
|
|
|
private static void push() {
|
|
SUPPRESSED_DEPTH.set(SUPPRESSED_DEPTH.get() + 1);
|
|
}
|
|
|
|
private static void pop() {
|
|
int depth = SUPPRESSED_DEPTH.get();
|
|
if (depth <= 1) {
|
|
SUPPRESSED_DEPTH.remove();
|
|
} else {
|
|
SUPPRESSED_DEPTH.set(depth - 1);
|
|
}
|
|
}
|
|
}
|