From fbc350b0252010f7a54bd357c810f6a2fde651f8 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Sun, 25 Apr 2021 00:53:08 +0200 Subject: [PATCH] Fix bug where player inventory would not be sorted --- .../command/SortCommandExecutor.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/dev/w1zzrd/invtweaks/command/SortCommandExecutor.java b/src/dev/w1zzrd/invtweaks/command/SortCommandExecutor.java index 6b7d289..8546614 100644 --- a/src/dev/w1zzrd/invtweaks/command/SortCommandExecutor.java +++ b/src/dev/w1zzrd/invtweaks/command/SortCommandExecutor.java @@ -44,25 +44,24 @@ public class SortCommandExecutor implements CommandExecutor { // The block the player is currently looking at (if applicable) final Block targetBlock = player.getTargetBlockExact(6); - if (targetBlock == null) - return false; + if (targetBlock != null) { + final BlockState target = targetBlock.getState(); - final BlockState target = targetBlock.getState(); - - // Sort appropriate inventory holder - if (target instanceof Chest) { - sortChest((Chest) target); - player.spigot().sendMessage(new TextComponent("Sorted chest")); - } - else if (target instanceof ShulkerBox) { - sortShulkerBox((ShulkerBox) target); - player.spigot().sendMessage(new TextComponent("Sorted shulker box")); - } - else { - sortPlayer(player); - player.spigot().sendMessage(new TextComponent("Sorted inventory")); + // Sort appropriate inventory holder + if (target instanceof Chest) { + sortChest((Chest) target); + player.spigot().sendMessage(new TextComponent("Sorted chest")); + return true; + } + else if (target instanceof ShulkerBox) { + sortShulkerBox((ShulkerBox) target); + player.spigot().sendMessage(new TextComponent("Sorted shulker box")); + return true; + } } + sortPlayer(player); + player.spigot().sendMessage(new TextComponent("Sorted inventory")); return true; }