forked from Clones/Controlify
🐛 Fix reach-around policy not being loaded from server config
✏️ Force-enable reach-around on the client if the server specifically allows it, regardless of option in settings
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
package dev.isxander.controlify.reacharound;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public enum ReachAroundPolicy {
|
||||
ALLOWED(mode -> true),
|
||||
DISALLOWED(mode -> false),
|
||||
UNSET(ReachAroundMode::canReachAround);
|
||||
|
||||
private final Function<ReachAroundMode, Boolean> canReachAround;
|
||||
|
||||
ReachAroundPolicy(Function<ReachAroundMode, Boolean> canReachAround) {
|
||||
this.canReachAround = canReachAround;
|
||||
}
|
||||
|
||||
public boolean canReachAround(ReachAroundMode mode) {
|
||||
return canReachAround.apply(mode);
|
||||
}
|
||||
|
||||
public static ReachAroundPolicy fromServer(boolean allowed) {
|
||||
return allowed ? ALLOWED : DISALLOWED;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user