forked from Clones/Controlify
✏️ Force-enable reach-around on the client if the server specifically allows it, regardless of option in settings
24 lines
645 B
Java
24 lines
645 B
Java
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;
|
|
}
|
|
}
|