From d00bb4fd7db068272552e80a5ef7cf3a55a47655 Mon Sep 17 00:00:00 2001 From: Ryder Belserion Date: Fri, 23 Aug 2024 19:05:45 -0400 Subject: [PATCH] properly check the permissions lol --- build.gradle.kts | 2 +- .../api/builders/CrateBuilder.java | 14 ++++++++--- .../listeners/crates/CrateOpenListener.java | 25 ++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0004a9153..146b5715e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { val buildNumber: String? = System.getenv("BUILD_NUMBER") -rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.7" +rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.7.1" val isSnapshot = false diff --git a/src/main/java/com/badbones69/crazycrates/api/builders/CrateBuilder.java b/src/main/java/com/badbones69/crazycrates/api/builders/CrateBuilder.java index c53159f0b..f288ffd25 100644 --- a/src/main/java/com/badbones69/crazycrates/api/builders/CrateBuilder.java +++ b/src/main/java/com/badbones69/crazycrates/api/builders/CrateBuilder.java @@ -347,10 +347,18 @@ public final boolean isCrateEventValid(@NotNull final KeyType keyType, final boo if (MiscUtils.isLogging()) { final String fileName = crate.getFileName(); - if (this.player.hasPermission(this.config.getProperty(ConfigKeys.use_new_permission_system) ? "crazycrates.deny.open." + fileName : "crazycrates.open." + fileName)) { - this.plugin.getComponentLogger().warn("{} could not open {} due to having the permission preventing them from opening the crate.", this.player.getName(), fileName); + if (this.config.getProperty(ConfigKeys.use_new_permission_system)) { + if (this.player.hasPermission("crazycrates.deny.open." + fileName)) { + this.plugin.getComponentLogger().warn("{} could not open {} due to having the permission preventing them from opening the crate.", this.player.getName(), fileName); + } else { + this.plugin.getComponentLogger().warn("{} could not open {} due to no valid prizes being found which led to the event being cancelled.", this.player.getName(), fileName); + } } else { - this.plugin.getComponentLogger().warn("{} could not open {} due to no valid prizes being found which led to the event being cancelled.", this.player.getName(), fileName); + if (!this.player.hasPermission("crazycrates.open." + fileName)) { + this.plugin.getComponentLogger().warn("{} could not open {} due to having the permission preventing them from opening the crate.", this.player.getName(), fileName); + } else { + this.plugin.getComponentLogger().warn("{} could not open {} due to no valid prizes being found which led to the event being cancelled.", this.player.getName(), fileName); + } } } } diff --git a/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java b/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java index b05a2e985..17e5da2f8 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/crates/CrateOpenListener.java @@ -53,15 +53,28 @@ public void onCrateOpen(CrateOpenEvent event) { } } - if (player.hasPermission(this.config.getProperty(ConfigKeys.use_new_permission_system) ? "crazycrates.deny.open." + fileName : "crazycrates.open." + fileName)) { - Messages.no_crate_permission.sendMessage(player, "{crate}", fancyName); + if (this.config.getProperty(ConfigKeys.use_new_permission_system)) { + if (player.hasPermission("crazycrates.deny.open." + fileName)) { + Messages.no_crate_permission.sendMessage(player, "{crate}", fancyName); - this.crateManager.removePlayerFromOpeningList(player); - this.crateManager.removeCrateInUse(player); + this.crateManager.removePlayerFromOpeningList(player); + this.crateManager.removeCrateInUse(player); + + event.setCancelled(true); - event.setCancelled(true); + return; + } + } else { + if (!player.hasPermission("crazycrates.open." + fileName)) { + Messages.no_crate_permission.sendMessage(player, "{crate}", fancyName); - return; + this.crateManager.removePlayerFromOpeningList(player); + this.crateManager.removeCrateInUse(player); + + event.setCancelled(true); + + return; + } } this.crateManager.addPlayerToOpeningList(player, crate);