Skip to content

Commit

Permalink
Fixes #754
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Jul 20, 2024
1 parent 20d0e1f commit a201bb8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
8 changes: 1 addition & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
### Fixed:
- Issue with /crazycrates migrator.
- Multiple null checks in commands.
- Issue with invalid argument output not outputting the proper syntax.

### Changes:
- Updated migrator command format.
- Updated invalid argument output to just describe it better.
- Play knockback/sounds if they don't have the required keys.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.7"
rootProject.version = if (buildNumber != null) "${libs.versions.minecraft.get()}-$buildNumber" else "3.5.8"

val isSnapshot = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public void onRightClick(PlayerInteractEvent event) {

player.sendRichMessage(Messages.required_keys.getMessage(player, placeholders));

lackingKey(player, crate, clickedBlock, false);

key.setCancelled(true);

return;
Expand Down Expand Up @@ -215,25 +217,7 @@ public void onRightClick(PlayerInteractEvent event) {
return;
}

final String keyName = crate.getKeyName();

final Map<String, String> 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));
}
lackingKey(player, crate, clickedBlock, true);

key.setCancelled(true);
}
Expand Down Expand Up @@ -278,6 +262,27 @@ public void onPlayerQuit(PlayerQuitEvent event) {

if (this.crateManager.isInOpeningList(player)) this.crateManager.removePlayerFromOpeningList(player);
}

private void lackingKey(final Player player, final Crate crate, final Block clickedBlock, final boolean sendMessage) {
final String keyName = crate.getKeyName();

final Map<String, String> 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());

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);
}

if (sendMessage) player.sendRichMessage(Messages.no_keys.getMessage(player, placeholders));
}
}

private void knockBack(final Player player, final Location location) {
final Vector vector = player.getLocation().toVector().subtract(location.toVector()).normalize().multiply(1).setY(.1);
Expand Down

0 comments on commit a201bb8

Please sign in to comment.