Update src/main/java/com/songoda/ultimatetimber/configurations/DefaultConfig.java, src/main/java/com/songoda/ultimatetimber/treefall/EventFilter.java files

This commit is contained in:
Brianna O'Keefe 2018-11-19 20:44:44 +00:00
parent bca27ee82e
commit dcd9b46a5c
2 changed files with 6 additions and 0 deletions

View File

@ -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);

View File

@ -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");