Search in sources :

Example 1 with IslandRewardsGUI

use of com.iridium.iridiumskyblock.gui.IslandRewardsGUI in project IridiumSkyblock by Iridium-Development.

the class RewardsCommand 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).
 * Opens the Island rewards GUI.
 *
 * @param sender The CommandSender which executes this command
 * @param args   The arguments used with this command. They contain the sub-command
 */
@Override
public boolean execute(CommandSender sender, String[] args) {
    Player player = (Player) sender;
    User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
    Optional<Island> island = user.getIsland();
    if (!island.isPresent()) {
        player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        return false;
    }
    player.openInventory(new IslandRewardsGUI(island.get(), player.getOpenInventory().getTopInventory()).getInventory());
    return true;
}
Also used : Player(org.bukkit.entity.Player) User(com.iridium.iridiumskyblock.database.User) IslandRewardsGUI(com.iridium.iridiumskyblock.gui.IslandRewardsGUI) Island(com.iridium.iridiumskyblock.database.Island)

Aggregations

Island (com.iridium.iridiumskyblock.database.Island)1 User (com.iridium.iridiumskyblock.database.User)1 IslandRewardsGUI (com.iridium.iridiumskyblock.gui.IslandRewardsGUI)1 Player (org.bukkit.entity.Player)1