From 9418025b81201289615d503fbd4d33f97da98769 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Thu, 21 Mar 2024 22:06:51 +0100 Subject: [PATCH] Upgrade Java version and refactor WorldGuardProtection class The Java version in pom.xml has been updated from 1.8 to 17. Also, the WorldGuardProtection.java class has been refactored for cleaner code. Specifically, a condition check and player definition are now combined into a single line to improve readability and efficiency. --- pom.xml | 8 +++++++- .../yardwatch/hooks/WorldGuardProtection.java | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2ca3795..146e840 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ Implementation of YardWatchAPI for common protection plugins - 1.8 + 17 UTF-8 https://youhavetrouble.me @@ -81,6 +81,12 @@ com.sk89q.worldguard worldguard-bukkit 7.0.4-SNAPSHOT + + + org.bstats + bstats-bukkit + + provided diff --git a/src/main/java/me/youhavetrouble/yardwatch/hooks/WorldGuardProtection.java b/src/main/java/me/youhavetrouble/yardwatch/hooks/WorldGuardProtection.java index 31ed401..d8b5916 100644 --- a/src/main/java/me/youhavetrouble/yardwatch/hooks/WorldGuardProtection.java +++ b/src/main/java/me/youhavetrouble/yardwatch/hooks/WorldGuardProtection.java @@ -81,8 +81,7 @@ public class WorldGuardProtection implements Protection { @Override public boolean canDamage(Entity attacker, Entity target) { if (!isEnabled()) return true; - if (!(attacker instanceof Player)) return true; - Player player = (Player) attacker; + if (!(attacker instanceof Player player)) return true; com.sk89q.worldedit.util.Location wgLocation = BukkitAdapter.adapt(target.getLocation()); LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player, true); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();