From dcd9b46a5c0afd0859ff6dc9c966881226456394 Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Mon, 19 Nov 2018 20:44:44 +0000 Subject: [PATCH] Update src/main/java/com/songoda/ultimatetimber/configurations/DefaultConfig.java, src/main/java/com/songoda/ultimatetimber/treefall/EventFilter.java files --- .../songoda/ultimatetimber/configurations/DefaultConfig.java | 2 ++ .../java/com/songoda/ultimatetimber/treefall/EventFilter.java | 4 ++++ 2 files changed, 6 insertions(+) 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");