Search in sources :

Example 91 with Island

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

the class GiveCommand method execute.

@Override
public boolean execute(CommandSender sender, String[] args) {
    if (args.length == 5) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(args[2]);
        User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
        Optional<Island> island = user.getIsland();
        if (island.isPresent()) {
            Optional<BankItem> bankItem = IridiumSkyblock.getInstance().getBankItemList().stream().filter(item -> item.getName().equalsIgnoreCase(args[3])).findFirst();
            if (bankItem.isPresent()) {
                try {
                    IslandBank islandBank = IridiumSkyblock.getInstance().getIslandManager().getIslandBank(island.get(), bankItem.get());
                    islandBank.setNumber(islandBank.getNumber() + Double.parseDouble(args[4]));
                    sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().gaveBank.replace("%player%", player.getName()).replace("%amount%", args[4]).replace("%item%", bankItem.get().getName()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
                    return true;
                } catch (NumberFormatException exception) {
                    sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notANumber.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
                }
            } else {
                sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noSuchBankItem.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
            }
        } else {
            sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().userNoIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        }
    } else {
        sender.sendMessage(StringUtils.color(syntax.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
    }
    return false;
}
Also used : CommandSender(org.bukkit.command.CommandSender) User(com.iridium.iridiumskyblock.database.User) Island(com.iridium.iridiumskyblock.database.Island) Collectors(java.util.stream.Collectors) StringUtils(com.iridium.iridiumcore.utils.StringUtils) OfflinePlayer(org.bukkit.OfflinePlayer) BankItem(com.iridium.iridiumskyblock.bank.BankItem) List(java.util.List) IslandBank(com.iridium.iridiumskyblock.database.IslandBank) Duration(java.time.Duration) PlayerUtils(com.iridium.iridiumskyblock.utils.PlayerUtils) Optional(java.util.Optional) Command(com.iridium.iridiumskyblock.commands.Command) Collections(java.util.Collections) IridiumSkyblock(com.iridium.iridiumskyblock.IridiumSkyblock) Bukkit(org.bukkit.Bukkit) IslandBank(com.iridium.iridiumskyblock.database.IslandBank) User(com.iridium.iridiumskyblock.database.User) OfflinePlayer(org.bukkit.OfflinePlayer) BankItem(com.iridium.iridiumskyblock.bank.BankItem) Island(com.iridium.iridiumskyblock.database.Island)

Example 92 with Island

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

the class SetCommand method execute.

@Override
public boolean execute(CommandSender sender, String[] args) {
    if (args.length == 5) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(args[2]);
        User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
        Optional<Island> island = user.getIsland();
        if (island.isPresent()) {
            Optional<BankItem> bankItem = IridiumSkyblock.getInstance().getBankItemList().stream().filter(item -> item.getName().equalsIgnoreCase(args[3])).findFirst();
            if (bankItem.isPresent()) {
                try {
                    IslandBank islandBank = IridiumSkyblock.getInstance().getIslandManager().getIslandBank(island.get(), bankItem.get());
                    islandBank.setNumber(Math.max(Double.parseDouble(args[4]), 0));
                    sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().setBank.replace("%player%", player.getName()).replace("%amount%", args[4]).replace("%item%", bankItem.get().getName()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
                    return true;
                } catch (NumberFormatException exception) {
                    sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notANumber.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
                }
            } else {
                sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noSuchBankItem.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
            }
        } else {
            sender.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().userNoIsland.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        }
    } else {
        sender.sendMessage(StringUtils.color(syntax.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
    }
    return false;
}
Also used : CommandSender(org.bukkit.command.CommandSender) User(com.iridium.iridiumskyblock.database.User) Island(com.iridium.iridiumskyblock.database.Island) Collectors(java.util.stream.Collectors) StringUtils(com.iridium.iridiumcore.utils.StringUtils) OfflinePlayer(org.bukkit.OfflinePlayer) BankItem(com.iridium.iridiumskyblock.bank.BankItem) List(java.util.List) IslandBank(com.iridium.iridiumskyblock.database.IslandBank) Duration(java.time.Duration) PlayerUtils(com.iridium.iridiumskyblock.utils.PlayerUtils) Optional(java.util.Optional) Command(com.iridium.iridiumskyblock.commands.Command) Collections(java.util.Collections) IridiumSkyblock(com.iridium.iridiumskyblock.IridiumSkyblock) Bukkit(org.bukkit.Bukkit) IslandBank(com.iridium.iridiumskyblock.database.IslandBank) User(com.iridium.iridiumskyblock.database.User) OfflinePlayer(org.bukkit.OfflinePlayer) BankItem(com.iridium.iridiumskyblock.bank.BankItem) Island(com.iridium.iridiumskyblock.database.Island)

Aggregations

Island (com.iridium.iridiumskyblock.database.Island)92 User (com.iridium.iridiumskyblock.database.User)76 Player (org.bukkit.entity.Player)60 EventHandler (org.bukkit.event.EventHandler)18 List (java.util.List)16 IridiumSkyblock (com.iridium.iridiumskyblock.IridiumSkyblock)15 OfflinePlayer (org.bukkit.OfflinePlayer)15 Collectors (java.util.stream.Collectors)14 IslandLog (com.iridium.iridiumskyblock.database.IslandLog)12 Optional (java.util.Optional)11 StringUtils (com.iridium.iridiumcore.utils.StringUtils)10 IslandBank (com.iridium.iridiumskyblock.database.IslandBank)10 Duration (java.time.Duration)10 Collections (java.util.Collections)9 CommandSender (org.bukkit.command.CommandSender)9 XMaterial (com.iridium.iridiumcore.dependencies.xseries.XMaterial)7 PlaceholderBuilder (com.iridium.iridiumskyblock.PlaceholderBuilder)6 BankItem (com.iridium.iridiumskyblock.bank.BankItem)6 IslandBooster (com.iridium.iridiumskyblock.database.IslandBooster)6 Bukkit (org.bukkit.Bukkit)6