diff --git a/build.gradle.kts b/build.gradle.kts index 7c69929..1c2e9aa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "me.zombie_striker" -version = "2.3.9" +version = "2.3.10-SNAPSHOT" description = "QualityArmoryVehicles" java.sourceCompatibility = JavaVersion.VERSION_1_8 @@ -32,19 +32,19 @@ repositories { dependencies { // Libraries - implementation("com.github.cryptomorin:XSeries:11.0.0") + implementation("com.github.cryptomorin:XSeries:11.2.1") implementation("net.jodah:expiringmap:0.5.11") - implementation("org.codemc.worldguardwrapper:worldguardwrapper:1.2.0-SNAPSHOT") + implementation("org.codemc.worldguardwrapper:worldguardwrapper:1.2.1-SNAPSHOT") implementation("dev.triumphteam:triumph-gui:3.1.10") compileOnly("org.jetbrains:annotations:24.1.0") // API compileOnly("net.kyori:adventure-api:4.17.0") - compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT") // Compatibilities compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0") - compileOnly("me.zombie_striker:QualityArmory:2.0.13") + compileOnly("me.zombie_striker:QualityArmory:2.0.14.1") compileOnly("com.github.TownyAdvanced:Towny:0.100.2.0") compileOnly("net.milkbowl.vault:VaultAPI:1.7") compileOnly("com.ticxo.modelengine:api:R3.2.0") diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..b740cf1 100644 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/src/main/java/me/zombie_striker/qav/util/BlockCollisionUtil.java b/src/main/java/me/zombie_striker/qav/util/BlockCollisionUtil.java index d0e32f9..217b870 100644 --- a/src/main/java/me/zombie_striker/qav/util/BlockCollisionUtil.java +++ b/src/main/java/me/zombie_striker/qav/util/BlockCollisionUtil.java @@ -1,83 +1,101 @@ package me.zombie_striker.qav.util; +import com.cryptomorin.xseries.reflection.XReflection; import net.jodah.expiringmap.ExpirationPolicy; import net.jodah.expiringmap.ExpiringMap; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.concurrent.TimeUnit; public class BlockCollisionUtil { - private static final ExpiringMap CACHE; - private static final HashMap customBlockHeights = new HashMap<>(); - - static{ - CACHE = ExpiringMap.builder() - .expiration(5, TimeUnit.MINUTES) - .expirationPolicy(ExpirationPolicy.CREATED) - .build(); - - for(Material m : Material.values()){ - if(m.name().endsWith("_WALL")) - customBlockHeights.put(m,1.5); - if(m.name().endsWith("_FENCE_GATE")||m.name().endsWith("_FENCE")) - customBlockHeights.put(m,1.5); - if(m.name().endsWith("_BED")) - customBlockHeights.put(m,0.5); - if(m.name().endsWith("_SLAB")||m.name().endsWith("_FENCE")) - customBlockHeights.put(m,0.5); - if(m.name().endsWith("DAYLIGHT_DETECTOR")) - customBlockHeights.put(m,0.4); - if(m.name().endsWith("CARPET")) - customBlockHeights.put(m,0.1); - if(m.name().endsWith("TRAPDOOR")) - customBlockHeights.put(m,0.2); - if(m.name().endsWith("RAIL")) - customBlockHeights.put(m,0.0); - } - } - - public static double getHeight(Block b){ - Material type = getMaterial(b.getLocation()); - if (type == null) return 0; - if (type.name().contains("SLAB") || type.name().contains("STEP")) { - if (b.getData() == 0) - return 0.5; - if (b.getData() == 1) - return 1; - } - if(customBlockHeights.containsKey(type)) - return customBlockHeights.get(type); - return type.isSolid()?1:0; - } - - public static boolean isSolidAt(Location loc){ - Block b = loc.getBlock(); - if(b.getLocation().getY()+getHeight(b)>loc.getY()) - return true; - Block temp = b.getRelative(0,-1,0); - return temp.getLocation().getY() + getHeight(temp) > loc.getY(); - } - - - public static Material getMaterial(Location location) { - if (CACHE.containsKey(location)) { - return CACHE.get(location); - } - - Material material = location.getBlock().getType(); - CACHE.put(location,material); - return material; - } - - public static boolean isSolid(Location loc) { - return isSolid(getMaterial(loc)); - } - - public static boolean isSolid(Material material) { - return material.isSolid(); - } + private static final ExpiringMap CACHE; + private static final HashMap customBlockHeights = new HashMap<>(); + + static { + CACHE = ExpiringMap.builder() + .expiration(5, TimeUnit.MINUTES) + .expirationPolicy(ExpirationPolicy.CREATED) + .build(); + + for (Material m : Material.values()) { + if (m.name().endsWith("_WALL")) + customBlockHeights.put(m, 1.5); + if (m.name().endsWith("_FENCE_GATE") || m.name().endsWith("_FENCE")) + customBlockHeights.put(m, 1.5); + if (m.name().endsWith("_BED")) + customBlockHeights.put(m, 0.5); + if (m.name().endsWith("_SLAB") || m.name().endsWith("_FENCE")) + customBlockHeights.put(m, 0.5); + if (m.name().endsWith("DAYLIGHT_DETECTOR")) + customBlockHeights.put(m, 0.4); + if (m.name().endsWith("CARPET")) + customBlockHeights.put(m, 0.1); + if (m.name().endsWith("TRAPDOOR")) + customBlockHeights.put(m, 0.2); + if (m.name().endsWith("RAIL")) + customBlockHeights.put(m, 0.0); + } + } + + public static double getHeight(Block b) { + Material type = getMaterial(b.getLocation()); + if (type == null) return 0; + if (type.name().contains("SLAB") || type.name().contains("STEP")) { + boolean modernCheck = XReflection.supports(13); + + if (modernCheck) { + try { + if (b.getBlockData().getAsString().toLowerCase().contains("type=double")) { + return 1; + } + + return 0.5; + } catch (Exception ignored) { + modernCheck = false; + } + } + + if (!modernCheck) { + if (b.getData() == 0) + return 0.5; + if (b.getData() == 1) + return 1; + } + } + + if (customBlockHeights.containsKey(type)) + return customBlockHeights.get(type); + + return type.isSolid() ? 1 : 0; + } + + public static boolean isSolidAt(Location loc) { + Block b = loc.getBlock(); + if (b.getLocation().getY() + getHeight(b) > loc.getY()) + return true; + Block temp = b.getRelative(0, -1, 0); + return temp.getLocation().getY() + getHeight(temp) > loc.getY(); + } + + + public static Material getMaterial(Location location) { + if (CACHE.containsKey(location)) { + return CACHE.get(location); + } + + Material material = location.getBlock().getType(); + CACHE.put(location, material); + return material; + } + + public static boolean isSolid(Location loc) { + return isSolid(getMaterial(loc)); + } + + public static boolean isSolid(Material material) { + return material.isSolid(); + } }