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
+7 -1
View File
@@ -13,7 +13,7 @@
<description>Implementation of YardWatchAPI for common protection plugins</description>
<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>https://youhavetrouble.me</url>
@@ -81,6 +81,12 @@
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.4-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
@@ -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();