use of com.iridium.iridiumskyblock.gui.ShopCategoryGUI in project IridiumSkyblock by Iridium-Development.
the class ShopCommand method execute.
/**
* Executes the command for the specified {@link CommandSender} with the provided arguments. Not
* called when the command execution was invalid (no permission, no player or command
* disabled).
*
* @param sender The CommandSender which executes this command
* @param arguments The arguments used with this command. They contain the sub-command
*/
@Override
public boolean execute(CommandSender sender, String[] arguments) {
Player player = (Player) sender;
User user = IridiumSkyblockAPI.getInstance().getUser(player);
if (!user.getIsland().isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
if (arguments.length == 1) {
player.openInventory(new ShopOverviewGUI(player.getOpenInventory().getTopInventory()).getInventory());
} else {
String[] commandArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
String categoryName = String.join(" ", commandArguments);
Optional<ShopCategory> category = IridiumSkyblock.getInstance().getShopManager().getCategoryByName(categoryName);
if (!category.isPresent()) {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noShopCategory.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
return false;
}
player.openInventory(new ShopCategoryGUI(category.get(), player.getOpenInventory().getTopInventory()).getInventory());
}
return true;
}
Aggregations