mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-03 06:16:10 +00:00
make bukkit warning less obnoxious
This commit is contained in:
@@ -6,6 +6,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
@@ -29,6 +30,8 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
private final LimitedRegion delegate;
|
||||
private final BlockState air;
|
||||
|
||||
private static final AtomicBoolean warn = new AtomicBoolean(true);
|
||||
|
||||
public BukkitProtoWorld(LimitedRegion delegate, BlockState air) {
|
||||
this.delegate = delegate;
|
||||
this.air = air;
|
||||
@@ -114,19 +117,25 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
private <T> Optional<T> access(int x, int y, int z, Supplier<T> action) {
|
||||
if(delegate.isInRegion(x, y, z)) {
|
||||
return Optional.of(action.get());
|
||||
} else {
|
||||
} else if(warn.getAndSet(false)) {
|
||||
LOGGER.warn("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
return Optional.empty();
|
||||
} else {
|
||||
LOGGER.debug("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private void access(int x, int y, int z, Runnable action) {
|
||||
if(delegate.isInRegion(x, y, z)) {
|
||||
action.run();
|
||||
} else {
|
||||
} else if(warn.getAndSet(false)) {
|
||||
LOGGER.warn("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
} else {
|
||||
LOGGER.debug("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user