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

View File

@ -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
if (target instanceof Chest) {
// Sort appropriate inventory holder sortChest((Chest) target);
if (target instanceof Chest) { player.spigot().sendMessage(new TextComponent("Sorted chest"));
sortChest((Chest) target); return true;
player.spigot().sendMessage(new TextComponent("Sorted chest")); }
} 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;
} }