diff --git a/src/main/java/com/songoda/ultimatetimber/configurations/DefaultConfig.java b/src/main/java/com/songoda/ultimatetimber/configurations/DefaultConfig.java index e462b8e..0e5a14d 100644 --- a/src/main/java/com/songoda/ultimatetimber/configurations/DefaultConfig.java +++ b/src/main/java/com/songoda/ultimatetimber/configurations/DefaultConfig.java @@ -20,6 +20,7 @@ public class DefaultConfig { Also they are easier to refer to using an IDE. */ public static final String AXES_ONLY = "Only topple down trees cut down using axes"; + public static final String SNEAK_ONLY = "Only topple down trees cut down while sneaking"; public static final String ACCURATE_AXE_DURABILITY = "Lower durability proportionately to the amount of blocks toppled down"; public static final String CREATIVE_DISALLOWED = "Players in creative mode can't topple down trees"; public static final String PERMISSIONS_ONLY = "Only allow players with the permission node to topple down trees"; @@ -38,6 +39,7 @@ public class DefaultConfig { Configuration configuration = plugin.getConfig(); configuration.addDefault(AXES_ONLY, true); + configuration.addDefault(SNEAK_ONLY, true); configuration.addDefault(ACCURATE_AXE_DURABILITY, true); configuration.addDefault(CREATIVE_DISALLOWED, true); configuration.addDefault(PERMISSIONS_ONLY, true); diff --git a/src/main/java/com/songoda/ultimatetimber/treefall/EventFilter.java b/src/main/java/com/songoda/ultimatetimber/treefall/EventFilter.java index 61b3e09..6ef5fea 100644 --- a/src/main/java/com/songoda/ultimatetimber/treefall/EventFilter.java +++ b/src/main/java/com/songoda/ultimatetimber/treefall/EventFilter.java @@ -42,6 +42,10 @@ public class EventFilter { event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.WOODEN_AXE))) return false; + if (fileConfiguration.getBoolean(DefaultConfig.SNEAK_ONLY) && + !event.getPlayer().isSneaking()) + return false; + return !fileConfiguration.getBoolean(DefaultConfig.PERMISSIONS_ONLY) || event.getPlayer().hasPermission("ultimatetimber.chop");