Fix bug where player inventory would not be sorted

This commit is contained in:
Gabriel Tofvesson 2021-04-25 00:53:08 +02:00
parent 1b21a19c4d
commit fbc350b025

@ -44,25 +44,24 @@ public class SortCommandExecutor implements CommandExecutor {
// The block the player is currently looking at (if applicable) // The block the player is currently looking at (if applicable)
final Block targetBlock = player.getTargetBlockExact(6); final Block targetBlock = player.getTargetBlockExact(6);
if (targetBlock == null) if (targetBlock != null) {
return false;
final BlockState target = targetBlock.getState(); final BlockState target = targetBlock.getState();
// Sort appropriate inventory holder // Sort appropriate inventory holder
if (target instanceof Chest) { if (target instanceof Chest) {
sortChest((Chest) target); sortChest((Chest) target);
player.spigot().sendMessage(new TextComponent("Sorted chest")); player.spigot().sendMessage(new TextComponent("Sorted chest"));
return true;
} }
else if (target instanceof ShulkerBox) { else if (target instanceof ShulkerBox) {
sortShulkerBox((ShulkerBox) target); sortShulkerBox((ShulkerBox) target);
player.spigot().sendMessage(new TextComponent("Sorted shulker box")); player.spigot().sendMessage(new TextComponent("Sorted shulker box"));
return true;
} }
else {
sortPlayer(player);
player.spigot().sendMessage(new TextComponent("Sorted inventory"));
} }
sortPlayer(player);
player.spigot().sendMessage(new TextComponent("Sorted inventory"));
return true; return true;
} }