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.
This commit is contained in:
2024-03-21 22:06:51 +01:00
parent e516cf2ec6
commit 9418025b81
2 changed files with 8 additions and 3 deletions
@@ -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();