mirror of
https://github.com/songoda/UltimateTimber.git
synced 2024-11-29 13:25:23 +01:00
Added setting to prevent destroying leaves
This commit is contained in:
parent
f6a22966da
commit
fdac6ef040
@ -2,6 +2,7 @@ package com.songoda.ultimatetimber.manager;
|
|||||||
|
|
||||||
import com.songoda.ultimatetimber.UltimateTimber;
|
import com.songoda.ultimatetimber.UltimateTimber;
|
||||||
import com.songoda.ultimatetimber.adapter.VersionAdapterType;
|
import com.songoda.ultimatetimber.adapter.VersionAdapterType;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -13,6 +14,7 @@ public class ConfigurationManager extends Manager {
|
|||||||
SERVER_TYPE(SettingType.STRING),
|
SERVER_TYPE(SettingType.STRING),
|
||||||
DISABLED_WORLDS(SettingType.STRING_LIST),
|
DISABLED_WORLDS(SettingType.STRING_LIST),
|
||||||
MAX_LOGS_PER_CHOP(SettingType.INT),
|
MAX_LOGS_PER_CHOP(SettingType.INT),
|
||||||
|
DESTROY_LEAVES(SettingType.BOOLEAN),
|
||||||
LEAVES_REQUIRED_FOR_TREE(SettingType.INT),
|
LEAVES_REQUIRED_FOR_TREE(SettingType.INT),
|
||||||
REALISTIC_TOOL_DAMAGE(SettingType.BOOLEAN),
|
REALISTIC_TOOL_DAMAGE(SettingType.BOOLEAN),
|
||||||
PROTECT_TOOL(SettingType.BOOLEAN),
|
PROTECT_TOOL(SettingType.BOOLEAN),
|
||||||
@ -109,21 +111,22 @@ public class ConfigurationManager extends Manager {
|
|||||||
if (this.value != null)
|
if (this.value != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
FileConfiguration config = UltimateTimber.getInstance().getConfigurationManager().getConfig();
|
||||||
switch (this.settingType) {
|
switch (this.settingType) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getBoolean(this.getNameAsKey());
|
this.value = config.getBoolean(this.getNameAsKey());
|
||||||
break;
|
break;
|
||||||
case INT:
|
case INT:
|
||||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getInt(this.getNameAsKey());
|
this.value = config.getInt(this.getNameAsKey());
|
||||||
break;
|
break;
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getDouble(this.getNameAsKey());
|
this.value = config.getDouble(this.getNameAsKey());
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getString(this.getNameAsKey());
|
this.value = config.getString(this.getNameAsKey());
|
||||||
break;
|
break;
|
||||||
case STRING_LIST:
|
case STRING_LIST:
|
||||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getStringList(this.getNameAsKey());
|
this.value = config.getStringList(this.getNameAsKey());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,8 @@ public class TreeDetectionManager extends Manager {
|
|||||||
private final Set<Vector> VALID_TRUNK_OFFSETS, VALID_BRANCH_OFFSETS, VALID_LEAF_OFFSETS;
|
private final Set<Vector> VALID_TRUNK_OFFSETS, VALID_BRANCH_OFFSETS, VALID_LEAF_OFFSETS;
|
||||||
|
|
||||||
private TreeDefinitionManager treeDefinitionManager;
|
private TreeDefinitionManager treeDefinitionManager;
|
||||||
private int maxBranchBlocksAllowed;
|
private int maxBranchBlocksAllowed, numLeavesRequiredForTree;
|
||||||
private int numLeavesRequiredForTree;
|
private boolean onlyBreakLogsUpwards, destroyBaseLog, entireTreeBase, destroyLeaves;
|
||||||
private boolean onlyBreakLogsUpwards;
|
|
||||||
private boolean destroyBaseLog;
|
|
||||||
private boolean entireTreeBase;
|
|
||||||
|
|
||||||
public TreeDetectionManager(UltimateTimber ultimateTimber) {
|
public TreeDetectionManager(UltimateTimber ultimateTimber) {
|
||||||
super(ultimateTimber);
|
super(ultimateTimber);
|
||||||
@ -57,6 +54,7 @@ public class TreeDetectionManager extends Manager {
|
|||||||
this.onlyBreakLogsUpwards = ConfigurationManager.Setting.ONLY_DETECT_LOGS_UPWARDS.getBoolean();
|
this.onlyBreakLogsUpwards = ConfigurationManager.Setting.ONLY_DETECT_LOGS_UPWARDS.getBoolean();
|
||||||
this.destroyBaseLog = ConfigurationManager.Setting.DESTROY_INITIATED_BLOCK.getBoolean();
|
this.destroyBaseLog = ConfigurationManager.Setting.DESTROY_INITIATED_BLOCK.getBoolean();
|
||||||
this.entireTreeBase = ConfigurationManager.Setting.BREAK_ENTIRE_TREE_BASE.getBoolean();
|
this.entireTreeBase = ConfigurationManager.Setting.BREAK_ENTIRE_TREE_BASE.getBoolean();
|
||||||
|
this.destroyLeaves = ConfigurationManager.Setting.DESTROY_LEAVES.getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,6 +136,10 @@ public class TreeDetectionManager extends Manager {
|
|||||||
if (this.destroyBaseLog)
|
if (this.destroyBaseLog)
|
||||||
detectedTreeBlocks.remove(initialTreeBlock);
|
detectedTreeBlocks.remove(initialTreeBlock);
|
||||||
|
|
||||||
|
// Remove all leaves if applicable
|
||||||
|
if (!this.destroyLeaves)
|
||||||
|
detectedTreeBlocks.removeAll(detectedTreeBlocks.getLeafBlocks());
|
||||||
|
|
||||||
return new DetectedTree(actualTreeDefinition, detectedTreeBlocks);
|
return new DetectedTree(actualTreeDefinition, detectedTreeBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ max-logs-per-chop: 120
|
|||||||
# Default: 5
|
# Default: 5
|
||||||
leaves-required-for-tree: 5
|
leaves-required-for-tree: 5
|
||||||
|
|
||||||
|
# If leaves should be destroyed
|
||||||
|
# Default: true
|
||||||
|
destroy-leaves: true
|
||||||
|
|
||||||
# Apply realistic damage to the tools based on the number of logs chopped
|
# Apply realistic damage to the tools based on the number of logs chopped
|
||||||
# If false, only one durability will be removed from the tool
|
# If false, only one durability will be removed from the tool
|
||||||
# Default: true
|
# Default: true
|
||||||
|
@ -24,6 +24,10 @@ max-logs-per-chop: 120
|
|||||||
# Default: 5
|
# Default: 5
|
||||||
leaves-required-for-tree: 5
|
leaves-required-for-tree: 5
|
||||||
|
|
||||||
|
# If leaves should be destroyed
|
||||||
|
# Default: true
|
||||||
|
destroy-leaves: true
|
||||||
|
|
||||||
# Apply realistic damage to the tools based on the number of logs chopped
|
# Apply realistic damage to the tools based on the number of logs chopped
|
||||||
# If false, only one durability will be removed from the tool
|
# If false, only one durability will be removed from the tool
|
||||||
# Default: true
|
# Default: true
|
||||||
|
Loading…
Reference in New Issue
Block a user