From 06677a4b2aff79cdc0ae0d2ccb42141316a3d49b Mon Sep 17 00:00:00 2001 From: TehBrian <tehbrian@proton.me> Date: Mon, 30 Oct 2023 08:44:52 -0400 Subject: [PATCH] skip physics checks if not enabled --- .../buildersutilities/setting/SettingsListener.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/dev/tehbrian/buildersutilities/setting/SettingsListener.java b/src/main/java/dev/tehbrian/buildersutilities/setting/SettingsListener.java index 522435e..2c4178f 100644 --- a/src/main/java/dev/tehbrian/buildersutilities/setting/SettingsListener.java +++ b/src/main/java/dev/tehbrian/buildersutilities/setting/SettingsListener.java @@ -55,8 +55,19 @@ public void onSpectate(final PlayerStartSpectatingEntityEvent event) { } } + private boolean shouldCheckPhysics() { + return this.configConfig.data().settings().disableRedstone() + || this.configConfig.data().settings().disableGravityPhysics() + || this.configConfig.data().settings().disablePhysics(); + } + @EventHandler public void onBlockPhysics(final BlockPhysicsEvent event) { + // don't perform any relatively expensive checks if we don't need to. + if (!this.shouldCheckPhysics()) { + return; + } + final Block block = event.getBlock(); if (block.getLocation().add(0, -1, 0).getBlock().getType().name().toLowerCase().contains("grass_block")) {