修复即使没有权限也能破坏展示框的问题

This commit is contained in:
zhangyuheng 2024-07-25 15:48:41 +08:00
parent bdec39272c
commit 8b9e984917
3 changed files with 5 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.42.0-beta</version>
<version>1.42.1-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -20,7 +20,7 @@ public enum Flag {
BEACON("beacon", "信标交互", "是否允许与信标交互", false, false, true),
BED("bed", "床交互", "是否允许使用床睡觉或设置重生点", false, false, true),
BREW("brew", "使用酿造台", "是否可以使用酿造台", false, false, true),
BREAK_BLOCK("break", "破坏方块", "是否可以破坏方块(包括:一般方块、展示框", false, false, true),
BREAK_BLOCK("break", "破坏方块", "是否可以破坏方块(包括:一般方块、展示框、盔甲架", false, false, true),
BUTTON("button", "使用按钮", "是否可以使用各种材质的按钮", false, false, true),
CAKE("cake", "吃蛋糕", "是否可以吃蛋糕", false, false, true),
CONTAINER("container", "一般容器", "包含:箱子/木桶/潜影盒/盔甲架/展示框", false, false, true),

View File

@ -140,21 +140,19 @@ public class PlayerEvents implements Listener {
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST) // break - item frame
@EventHandler(priority = EventPriority.HIGHEST) // break - item frame && armor stand
public void onItemFrameBreak(HangingBreakByEntityEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof ItemFrame)) {
if (!(entity instanceof ItemFrame) && !(entity instanceof ArmorStand)) {
return;
}
ItemFrame itemFrame = (ItemFrame) entity;
Entity remover = event.getRemover();
if (!(remover instanceof Player)) {
return;
}
if (onBreak((Player) event.getRemover(), itemFrame.getLocation())) {
if (onBreak((Player) event.getRemover(), entity.getLocation())) {
return;
}
itemFrame.remove();
event.setCancelled(true);
}