Search in sources :

Example 16 with IslandBank

use of com.iridium.iridiumskyblock.database.IslandBank in project IridiumSkyblock by Iridium-Development.

the class Reward method claim.

/**
 * Claims this reward for the provided user and island.
 * Sets the experience, executes the commands and plays the sound.
 *
 * @param player The Player which should receive the reward
 * @param island The Island of the Player
 */
public void claim(Player player, Island island) {
    User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
    island.setExperience(island.getTotalExperience() + islandExperience);
    commands.forEach(command -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", player.getName())));
    sound.play(player);
    IslandBank islandCrystals = IridiumSkyblock.getInstance().getIslandManager().getIslandBank(island, IridiumSkyblock.getInstance().getBankItems().crystalsBankItem);
    IslandBank islandExperience = IridiumSkyblock.getInstance().getIslandManager().getIslandBank(island, IridiumSkyblock.getInstance().getBankItems().experienceBankItem);
    IslandBank islandMoney = IridiumSkyblock.getInstance().getIslandManager().getIslandBank(island, IridiumSkyblock.getInstance().getBankItems().moneyBankItem);
    islandCrystals.setNumber(islandCrystals.getNumber() + crystals);
    islandExperience.setNumber(islandExperience.getNumber() + experience);
    islandMoney.setNumber(islandMoney.getNumber() + money);
    IslandLog islandLog = new IslandLog(island, LogAction.REWARD_REDEEMED, user, null, 0, ChatColor.stripColor(item.displayName));
    IridiumSkyblock.getInstance().getDatabaseManager().getIslandLogTableManager().addEntry(islandLog);
}
Also used : IslandBank(com.iridium.iridiumskyblock.database.IslandBank) IslandLog(com.iridium.iridiumskyblock.database.IslandLog) User(com.iridium.iridiumskyblock.database.User)

Aggregations

IslandBank (com.iridium.iridiumskyblock.database.IslandBank)16 Island (com.iridium.iridiumskyblock.database.Island)11 User (com.iridium.iridiumskyblock.database.User)10 BankItem (com.iridium.iridiumskyblock.bank.BankItem)5 IridiumSkyblock (com.iridium.iridiumskyblock.IridiumSkyblock)4 Collections (java.util.Collections)4 Optional (java.util.Optional)4 StringUtils (com.iridium.iridiumcore.utils.StringUtils)3 Command (com.iridium.iridiumskyblock.commands.Command)3 PlayerUtils (com.iridium.iridiumskyblock.utils.PlayerUtils)3 Duration (java.time.Duration)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Bukkit (org.bukkit.Bukkit)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 CommandSender (org.bukkit.command.CommandSender)3 Placeholder (com.iridium.iridiumcore.utils.Placeholder)2 Economy (net.milkbowl.vault.economy.Economy)2 XMaterial (com.iridium.iridiumcore.dependencies.xseries.XMaterial)1 InventoryUtils (com.iridium.iridiumcore.utils.InventoryUtils)1