feat(hamster-chain-break): 添加nbt检测开关
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
version = '1.0.0'
|
||||
version = '1.1.0'
|
||||
setArchivesBaseName("HamsterChainBreak")
|
||||
|
||||
dependencies {
|
||||
|
@@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ConfigManager {
|
||||
private static boolean enableCheckEnergy;
|
||||
private static int maxChainBlocks;
|
||||
private static List<ToolGroup> toolGroups;
|
||||
|
||||
@@ -22,6 +23,7 @@ public final class ConfigManager {
|
||||
plugin.reloadConfig();
|
||||
FileConfiguration pluginConfig = plugin.getConfig();
|
||||
|
||||
enableCheckEnergy = pluginConfig.getBoolean("enable-check-energy");
|
||||
maxChainBlocks = pluginConfig.getInt("max-chain-blocks", 300);
|
||||
|
||||
toolGroups = new ArrayList<>();
|
||||
@@ -34,6 +36,10 @@ public final class ConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEnableCheckEnergy() {
|
||||
return enableCheckEnergy;
|
||||
}
|
||||
|
||||
public static int getMaxChainBlocks() {
|
||||
return maxChainBlocks;
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -87,12 +88,14 @@ public final class MainListener implements Listener {
|
||||
breakBlockWithCreative(player, stack, eventBlock, searchResultBlocks);
|
||||
return;
|
||||
}
|
||||
if (ConfigManager.isEnableCheckEnergy()) {
|
||||
NBTItem nbtItem = new NBTItem(stack);
|
||||
if (nbtItem.hasKey("Energy")) {
|
||||
breakBlockWithEnergy(player, stack, nbtItem, eventBlock, searchResultBlocks);
|
||||
} else {
|
||||
breakBlockWithDurability(player, stack, eventBlock, searchResultBlocks);
|
||||
}
|
||||
return;
|
||||
}
|
||||
breakBlockWithDurability(player, stack, eventBlock, searchResultBlocks);
|
||||
}
|
||||
|
||||
private void bfsSearchBlock(@NotNull ToolGroup group, @NotNull List<Block> result, @NotNull List<Block> searchBlocks) {
|
||||
@@ -176,7 +179,8 @@ public final class MainListener implements Listener {
|
||||
}
|
||||
for (Block block : searchResultBlocks) {
|
||||
boolean leaves = block.getType().name().endsWith("_LEAVES");
|
||||
dropItemList.addAll(block.getDrops(stack, player));
|
||||
Collection<ItemStack> drops = block.getDrops(stack, player);
|
||||
dropItemList.addAll(drops);
|
||||
block.setType(Material.AIR, true);
|
||||
if (!leaves) {
|
||||
durability++;
|
||||
|
@@ -1,3 +1,6 @@
|
||||
# 是否启用能量检测,适用于模组物品
|
||||
enable-check-energy: false
|
||||
|
||||
# 最大连锁破坏的方块数量
|
||||
max-chain-blocks: 300
|
||||
|
||||
@@ -8,7 +11,6 @@ tool-groups:
|
||||
# 该工具组内的物品名称,支持正则表达式匹配
|
||||
tool-types:
|
||||
- ".*_AXE"
|
||||
- "THERMAL_FLUX_SAW"
|
||||
# 该工具组内可以连锁破坏的方块,支持正则表达式匹配
|
||||
block-types:
|
||||
- ".*_WOOD"
|
||||
@@ -17,7 +19,5 @@ tool-groups:
|
||||
pickaxe:
|
||||
tool-types:
|
||||
- ".*_PICKAXE"
|
||||
- ".*MANASTEEL_PICK"
|
||||
- "THERMAL_FLUX_DRILL"
|
||||
block-types:
|
||||
- ".*_ORE"
|
||||
|
@@ -3,6 +3,9 @@ main: cn.hamster3.mc.plugin.chain.breaks.ChainBreakPlugin
|
||||
version: ${version}
|
||||
api-version: 1.13
|
||||
|
||||
softdepend:
|
||||
- NBTAPI
|
||||
|
||||
author: MiniDay
|
||||
website: https://github.com/MiniDay/hamster-little-plugins
|
||||
description: 仓鼠连锁破坏:一键挖矿 & 砍树
|
||||
|
Reference in New Issue
Block a user