diff --git a/CHANGELOG.md b/CHANGELOG.md index d35c64cef..033a338d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,5 @@ +### Changes: +- The fix below required preview to be only opened through left click so right click can function as for only opening the crate. + ### Fixed: -- Issue with file manager not properly loading/reloading files. \ No newline at end of file +- The key check on right-clicking a crate was working, however we didn't inform the player they had no key. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 7e2fa850f..feb7758cd 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.5.2" +rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.5.3" val isSnapshot = true diff --git a/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java b/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java index 132dc44a1..b2f78abca 100644 --- a/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java +++ b/src/main/java/com/badbones69/crazycrates/listeners/CrateControlListener.java @@ -70,6 +70,8 @@ public void onGroundClick(PlayerInteractEvent event) { public void onCrateInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); + if (!event.getAction().isLeftClick()) return; + final Block clickedBlock = event.getClickedBlock(); if (clickedBlock == null) return; @@ -136,7 +138,32 @@ public void onRightClick(PlayerInteractEvent event) { final boolean isKey = event.getHand() == EquipmentSlot.OFF_HAND ? ItemUtils.isSimilar(player.getInventory().getItemInOffHand(), crate) : ItemUtils.isSimilar(player.getInventory().getItemInMainHand(), crate); - if (!isKey) return; + if (!isKey) { + final String keyName = crate.getKeyName(); + + final Map placeholders = new HashMap<>() {{ + put("{crate}", crate.getName()); + put("{key}", keyName); + }}; + + if (crate.getCrateType() != CrateType.crate_on_the_go) { + if (this.config.getProperty(ConfigKeys.knock_back)) knockBack(player, clickedBlock.getLocation()); + + //todo() convert this to a bean property! + if (this.config.getProperty(ConfigKeys.need_key_sound_toggle)) { + net.kyori.adventure.sound.Sound sound = net.kyori.adventure.sound.Sound.sound(Key.key(this.config.getProperty(ConfigKeys.need_key_sound)), Sound.Source.PLAYER, 1f, 1f); + + player.playSound(sound); + } + + player.sendRichMessage(Messages.no_keys.getMessage(player, placeholders)); + } + + event.setUseInteractedBlock(Event.Result.DENY); + event.setUseItemInHand(Event.Result.DENY); + + return; + } event.setUseInteractedBlock(Event.Result.DENY); event.setUseItemInHand(Event.Result.DENY); @@ -150,8 +177,6 @@ public void onRightClick(PlayerInteractEvent event) { boolean isPhysical = false; boolean useQuickCrateAgain = false; - final String keyName = crate.getKeyName(); - final int requiredKeys = crate.getRequiredKeys(); final int totalKeys = this.userManager.getTotalKeys(player.getUniqueId(), crate.getName()); @@ -177,11 +202,6 @@ public void onRightClick(PlayerInteractEvent event) { if (this.config.getProperty(ConfigKeys.physical_accepts_virtual_keys) && this.userManager.getVirtualKeys(player.getUniqueId(), crate.getName()) >= 1) hasKey = true; - final Map placeholders = new HashMap<>() {{ - put("{crate}", crate.getName()); - put("{key}", keyName); - }}; - if (hasKey) { // Checks if the player uses the quick crate again. if (this.crateManager.isInOpeningList(player) && this.crateManager.getOpeningCrate(player).getCrateType() == CrateType.quick_crate && this.crateManager.isCrateInUse(player) && this.crateManager.getCrateInUseLocation(player).equals(crateLocation.getLocation())) { @@ -221,19 +241,6 @@ public void onRightClick(PlayerInteractEvent event) { return; } - - if (crate.getCrateType() != CrateType.crate_on_the_go) { - if (this.config.getProperty(ConfigKeys.knock_back)) knockBack(player, clickedBlock.getLocation()); - - //todo() convert this to a bean property! - if (this.config.getProperty(ConfigKeys.need_key_sound_toggle)) { - net.kyori.adventure.sound.Sound sound = net.kyori.adventure.sound.Sound.sound(Key.key(this.config.getProperty(ConfigKeys.need_key_sound)), Sound.Source.PLAYER, 1f, 1f); - - player.playSound(sound); - } - - player.sendRichMessage(Messages.no_keys.getMessage(player, placeholders)); - } } @EventHandler