修复5项区域防护问题:

1. 点燃权限:onIgnite检查denyFire而非denyFireSpread
2. 农作物收获:BlockBreak+右键检测作物方块
3. 权限显示名称:点燃/农作物收获动态命名
4. GUI效果管理tooltip:修正为GUI选择描述
5. 容器扩展:isUIBlock覆盖工作台/铁砧/砂轮等
This commit is contained in:
2026-06-26 14:03:12 +08:00
parent 44a9edca1b
commit 48e1692822
3 changed files with 99 additions and 7 deletions
+10 -2
View File
@@ -621,7 +621,7 @@ public class AreaCLIManager {
perms.add(new PermItem("raid", land.denyRaid ? "禁止袭击" : "启用袭击", !land.denyRaid));
perms.add(new PermItem("bow", "弓箭射击", !land.denyBow));
perms.add(new PermItem("potion", "药水效果", !land.denyPotion));
perms.add(new PermItem("fire", "点燃", !land.denyFire));
perms.add(new PermItem("fire", land.denyFire ? "禁止点燃" : "启用点燃", !land.denyFire));
perms.add(new PermItem("fire_spread", "火焰蔓延", !land.denyFireSpread));
perms.add(new PermItem("pickup", "禁止拾取", !land.denyPickup));
perms.add(new PermItem("drop", "丢弃物品", !land.denyDrop));
@@ -635,7 +635,7 @@ public class AreaCLIManager {
perms.add(new PermItem("door", "禁止门禁(门/按钮/压力板)", !land.denyDoorInteraction));
perms.add(new PermItem("audio", "音频(音符盒/唱片机)", !land.denyNoteblockJukebox));
perms.add(new PermItem("lead", "拴绳使用", !land.denyLead));
perms.add(new PermItem("crop_harvest", "农作物收获", !land.denyCropHarvest));
perms.add(new PermItem("crop_harvest", land.denyCropHarvest ? "禁用农作物收获" : "启用农作物收获", !land.denyCropHarvest));
perms.add(new PermItem("wool_shear", "剪切羊毛/生物", !land.denyWoolShear));
perms.add(new PermItem("animal_feed", "投喂动物", !land.denyAnimalFeeding));
perms.add(new PermItem("glowing", "玩家发光", !land.denyGlowing));
@@ -1000,6 +1000,14 @@ public class AreaCLIManager {
if (field.equals("denyRaid")) {
name = landDefault ? "禁止袭击" : "启用袭击";
}
// ★ denyFire显示名称
if (field.equals("denyFire")) {
name = landDefault ? "禁止点燃" : "启用点燃";
}
// ★ denyCropHarvest显示名称
if (field.equals("denyCropHarvest")) {
name = landDefault ? "禁用农作物收获" : "启用农作物收获";
}
// 如果有per-player覆盖,使用覆盖值;否则使用领地默认
if (playerPerms.containsKey(field)) {
+15 -4
View File
@@ -452,6 +452,17 @@ public class AreaGUIManager implements Listener {
boolean isOverridden = playerPerms.containsKey(field);
boolean effective = isOverridden ? playerPerms.get(field) : landDefault;
// ★ denyRaid/denyFire/denyCropHarvest 动态名称
if (field.equals("denyRaid")) {
name = landDefault ? "禁止袭击" : "启用袭击";
}
if (field.equals("denyFire")) {
name = landDefault ? "禁止点燃" : "启用点燃";
}
if (field.equals("denyCropHarvest")) {
name = landDefault ? "禁用农作物收获" : "启用农作物收获";
}
// enabled = true 表示"允许操作"(即deny=false)
boolean allowed = !effective;
Material mat = allowed ? Material.LIME_DYE : Material.GRAY_DYE;
@@ -586,7 +597,7 @@ public class AreaGUIManager implements Listener {
perms.add(new PermEntry(land.denyRaid ? "禁止袭击" : "启用袭击", !land.denyRaid));
perms.add(new PermEntry("弓箭射击", !land.denyBow));
perms.add(new PermEntry("药水效果", !land.denyPotion));
perms.add(new PermEntry("点燃", !land.denyFire));
perms.add(new PermEntry(land.denyFire ? "禁止点燃" : "启用点燃", !land.denyFire));
perms.add(new PermEntry("火焰蔓延", !land.denyFireSpread));
perms.add(new PermEntry("禁止拾取", !land.denyPickup));
perms.add(new PermEntry("丢弃物品", !land.denyDrop));
@@ -600,7 +611,7 @@ public class AreaGUIManager implements Listener {
perms.add(new PermEntry("禁止门禁(门/按钮/压力板)", !land.denyDoorInteraction));
perms.add(new PermEntry("音频(音符盒/唱片机)", !land.denyNoteblockJukebox));
perms.add(new PermEntry("拴绳使用", !land.denyLead));
perms.add(new PermEntry("农作物收获", !land.denyCropHarvest));
perms.add(new PermEntry(land.denyCropHarvest ? "禁用农作物收获" : "启用农作物收获", !land.denyCropHarvest));
perms.add(new PermEntry("剪切羊毛/生物", !land.denyWoolShear));
perms.add(new PermEntry("投喂动物", !land.denyAnimalFeeding));
perms.add(new PermEntry("玩家发光", !land.denyGlowing));
@@ -1407,7 +1418,7 @@ public class AreaGUIManager implements Listener {
inv.setItem(48, createItem(Material.ARROW, "§c§l返回效果管理", ""));
inv.setItem(53, createItem(Material.BOOK, "§a§l添加效果",
"§7点击后在聊天栏输入效果名(如:缓慢、中毒)"));
"§7点击选择要清除的效果"));
p.openInventory(inv);
}
@@ -1433,7 +1444,7 @@ public class AreaGUIManager implements Listener {
inv.setItem(48, createItem(Material.ARROW, "§c§l返回效果管理", ""));
inv.setItem(53, createItem(Material.BOOK, "§a§l添加增益",
"§7点击后在聊天栏输入: 效果名 等级 秒数"));
"§7点击选择要添加的增益效果"));
p.openInventory(inv);
}
+74 -1
View File
@@ -4064,6 +4064,15 @@ public class AreaProtection implements Listener {
if (ac != null && getEffectiveDeny(p, ac, "denyBlockBreak")) {
e.setCancelled(true);
p.sendMessage("§c§l[区域防护] §f禁止破坏方块");
return;
}
// ★ 农作物收获:阻止破坏作物方块(独立于denyBlockBreak)
if (ac != null && ac.denyCropHarvest) {
Material blockMat = e.getBlock().getType();
if (isCropBlock(blockMat)) {
e.setCancelled(true);
p.sendMessage("§c§l[区域防护] §f禁止收获农作物");
}
}
}
@@ -4251,6 +4260,36 @@ public class AreaProtection implements Listener {
}
}
// ★ 农作物收获:右键检测(南瓜/西瓜用剪刀收获)
if (ac.denyCropHarvest && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block clicked = e.getClickedBlock();
if (clicked != null) {
Material clickedMat = clicked.getType();
if (clickedMat == Material.PUMPKIN || clickedMat == Material.MELON) {
if (getEffectiveDeny(p, ac, "denyCropHarvest")) {
e.setCancelled(true);
p.sendMessage("§c§l[区域防护] §f禁止收获农作物");
return;
}
}
}
}
// ★ 容器交互扩展:检测非Container类型UI方块(工作台、砂轮、制图台、告示牌等)
if (ac.denyContainer && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block clicked = e.getClickedBlock();
if (clicked != null) {
Material clickedMat = clicked.getType();
if (isUIBlock(clickedMat)) {
if (getEffectiveDeny(p, ac, "denyContainer")) {
e.setCancelled(true);
p.sendMessage("§c§l[区域防护] §f此领地禁止访问容器");
return;
}
}
}
}
// 没收检查
handleConfiscate(p, ac);
}
@@ -4538,6 +4577,40 @@ public class AreaProtection implements Listener {
}
}
// ★ 判断方块是否为农作物
private boolean isCropBlock(Material mat) {
String name = mat.name();
return name.contains("WHEAT") || name.contains("CARROT")
|| name.contains("POTATO") || name.contains("BEETROOT")
|| name.contains("MELON") || name.contains("PUMPKIN")
|| name.contains("COCOA") || name.contains("CROP")
|| name.contains("SWEET_BERRY") || name.contains("BAMBOO")
|| name.contains("SUGAR_CANE") || name.contains("NETHER_WART")
|| name.contains("KELP") || name.contains("SEA_PICKLE")
|| name.contains("CHORUS") || name.contains("TWISTING_VINES")
|| name.contains("WEEPING_VINES") || mat == Material.MELON_STEM
|| mat == Material.ATTACHED_MELON_STEM
|| mat == Material.PUMPKIN_STEM
|| mat == Material.ATTACHED_PUMPKIN_STEM;
}
// ★ 判断方块是否为UI交互方块(非Container类型,需要单独检测)
private boolean isUIBlock(Material mat) {
return mat == Material.CRAFTING_TABLE || mat == Material.STONECUTTER
|| mat == Material.GRINDSTONE || mat == Material.ANVIL
|| mat == Material.CHIPPED_ANVIL || mat == Material.DAMAGED_ANVIL
|| mat == Material.CARTOGRAPHY_TABLE || mat == Material.LOOM
|| mat == Material.SMITHING_TABLE || mat == Material.ENCHANTING_TABLE
|| mat == Material.BREWING_STAND || mat == Material.LEGACY_BREWING_STAND
|| mat.name().contains("SIGN") || mat.name().contains("BANNER")
|| mat == Material.BARREL || mat.name().contains("SHULKER_BOX")
|| mat == Material.ENDER_CHEST || mat.name().contains("CHEST")
|| mat.name().contains("FURNACE") || mat.name().contains("BLAST_FURNACE")
|| mat.name().contains("SMOKER") || mat == Material.HOPPER
|| mat.name().contains("DISPENSER") || mat.name().contains("DROPPER")
|| mat == Material.BEACON || mat.name().contains("LECTERN");
}
// ★ 采集羊毛检测
@EventHandler
public void onShearEntity(PlayerShearEntityEvent e) {
@@ -7953,7 +8026,7 @@ public class AreaProtection implements Listener {
AreaConfig ac = getArea(
block.getWorld().getName(),
block.getX(), block.getY(), block.getZ());
if (ac != null && ac.denyFireSpread) {
if (ac != null && ac.denyFire) {
e.setCancelled(true);
p.sendMessage("§c§l[区域防护] §f此区域禁止点燃物品");
}