From fbb0b4a2f97a06a5884c7ed570891145234f6426 Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Mon, 26 Aug 2024 14:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=9B=94=E7=94=B2=E6=9E=B6?= =?UTF-8?q?=E6=94=BE=E7=BD=AE=E6=8E=A7=E5=88=B6=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 +- .../dominion/events_v1_20_1/PlayerEvents.java | 16 ++++++++++++++++ .../dominion/events_v1_21/PlayerEvents.java | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index dc488d66..a595a856 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "cn.lunadeer" -version = "2.3.4-beta" +version = "2.3.5-beta" java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) diff --git a/v1_20_1/src/main/java/cn/lunadeer/dominion/events_v1_20_1/PlayerEvents.java b/v1_20_1/src/main/java/cn/lunadeer/dominion/events_v1_20_1/PlayerEvents.java index cd6e7273..2150ec23 100644 --- a/v1_20_1/src/main/java/cn/lunadeer/dominion/events_v1_20_1/PlayerEvents.java +++ b/v1_20_1/src/main/java/cn/lunadeer/dominion/events_v1_20_1/PlayerEvents.java @@ -685,6 +685,22 @@ public void placeItemFrame(HangingPlaceEvent event) { event.setCancelled(true); } + @EventHandler(priority = EventPriority.HIGHEST) // place - armor stand + public void placeArmorStand(EntityPlaceEvent event) { + Player player = event.getPlayer(); + if (player == null) { + return; + } + Entity entity = event.getEntity(); + if (!(entity instanceof ArmorStand)) { + return; + } + if (onPlace(player, entity.getLocation())) { + return; + } + event.setCancelled(true); + } + public static boolean onPlace(Player player, Location location) { DominionDTO dom = Cache.instance.getDominionByLoc(location); return checkFlag(dom, Flag.PLACE, player, null); diff --git a/v1_21/src/main/java/cn/lunadeer/dominion/events_v1_21/PlayerEvents.java b/v1_21/src/main/java/cn/lunadeer/dominion/events_v1_21/PlayerEvents.java index d9ee4195..7c8ec7e2 100644 --- a/v1_21/src/main/java/cn/lunadeer/dominion/events_v1_21/PlayerEvents.java +++ b/v1_21/src/main/java/cn/lunadeer/dominion/events_v1_21/PlayerEvents.java @@ -681,6 +681,22 @@ public void placeItemFrame(HangingPlaceEvent event) { event.setCancelled(true); } + @EventHandler(priority = EventPriority.HIGHEST) // place - armor stand + public void placeArmorStand(EntityPlaceEvent event) { + Player player = event.getPlayer(); + if (player == null) { + return; + } + Entity entity = event.getEntity(); + if (!(entity instanceof ArmorStand)) { + return; + } + if (onPlace(player, entity.getLocation())) { + return; + } + event.setCancelled(true); + } + public static boolean onPlace(Player player, Location location) { DominionDTO dom = Cache.instance.getDominionByLoc(location); return checkFlag(dom, Flag.PLACE, player, null);