Search in sources :

Example 1 with Color

use of com.iridium.iridiumcore.Color in project IridiumSkyblock by Iridium-Development.

the class IridiumSkyblock method loadConfigs.

/**
 * Loads the configurations required for this plugin.
 */
@Override
public void loadConfigs() {
    loadConfigFiles();
    for (Color color : Color.values()) {
        if (!border.enabled.containsKey(color)) {
            border.enabled.put(color, true);
        }
    }
    int maxSize = upgrades.sizeUpgrade.upgrades.values().stream().max(Comparator.comparing(sizeUpgrade -> sizeUpgrade.size)).get().size;
    if (configuration.distance <= maxSize) {
        configuration.distance = maxSize + 1;
    }
    if (inventories.confirmationGUI.yes.slot == null || inventories.confirmationGUI.yes.slot == 0) {
        inventories.confirmationGUI.yes.slot = 15;
    }
    if (inventories.confirmationGUI.no.slot == null || inventories.confirmationGUI.no.slot == 0) {
        inventories.confirmationGUI.no.slot = 1;
    }
    initializePermissionList();
    initializeSettingsList();
    for (Permission permission : permissionList.values()) {
        if (permission.getPage() == 0)
            permission.setPage(1);
    }
    if (bankItems.crystalsBankItem.getDisplayName() == null)
        bankItems.crystalsBankItem.setDisplayName("Crystal");
    if (bankItems.experienceBankItem.getDisplayName() == null)
        bankItems.experienceBankItem.setDisplayName("Experience");
    if (bankItems.moneyBankItem.getDisplayName() == null)
        bankItems.moneyBankItem.setDisplayName("Money");
    if (boosters.experienceBooster.name == null)
        boosters.experienceBooster.name = "Experience";
    if (boosters.farmingBooster.name == null)
        boosters.experienceBooster.name = "Farming";
    if (boosters.flightBooster.name == null)
        boosters.experienceBooster.name = "Flight";
    if (boosters.spawnerBooster.name == null)
        boosters.experienceBooster.name = "Spawner";
    if (upgrades.warpsUpgrade.name == null)
        upgrades.warpsUpgrade.name = "Warps";
    if (upgrades.sizeUpgrade.name == null)
        upgrades.sizeUpgrade.name = "Size";
    if (upgrades.blockLimitUpgrade.name == null)
        upgrades.blockLimitUpgrade.name = "Block Limit";
    if (upgrades.memberUpgrade.name == null)
        upgrades.memberUpgrade.name = "Members";
    if (upgrades.oresUpgrade.name == null)
        upgrades.oresUpgrade.name = "Ore Generator";
    this.bankItemList = new ArrayList<>();
    if (bankItems.crystalsBankItem.isEnabled()) {
        this.bankItemList.add(bankItems.crystalsBankItem);
    }
    if (bankItems.experienceBankItem.isEnabled()) {
        this.bankItemList.add(bankItems.experienceBankItem);
    }
    if (bankItems.moneyBankItem.isEnabled()) {
        this.bankItemList.add(bankItems.moneyBankItem);
    }
    for (Map.Entry<String, Schematics.SchematicConfig> schematics : schematics.schematics.entrySet()) {
        Schematics.SchematicConfig schematic = schematics.getValue();
        if (schematic.overworld.islandHeight == null)
            schematic.overworld.islandHeight = 90.0;
        if (schematic.overworld.ignoreAirBlocks == null)
            schematic.overworld.ignoreAirBlocks = true;
        if (schematic.nether.islandHeight == null)
            schematic.nether.islandHeight = 90.0;
        if (schematic.nether.ignoreAirBlocks == null)
            schematic.nether.ignoreAirBlocks = true;
        if (schematic.end.islandHeight == null)
            schematic.end.islandHeight = 90.0;
        if (schematic.end.ignoreAirBlocks == null)
            schematic.end.ignoreAirBlocks = true;
    }
    this.missionsList = new HashMap<>(missions.missions);
    this.upgradesList = new HashMap<>();
    if (upgrades.sizeUpgrade.enabled)
        upgradesList.put("size", upgrades.sizeUpgrade);
    if (upgrades.memberUpgrade.enabled)
        upgradesList.put("member", upgrades.memberUpgrade);
    if (upgrades.warpsUpgrade.enabled)
        upgradesList.put("warp", upgrades.warpsUpgrade);
    if (upgrades.blockLimitUpgrade.enabled)
        upgradesList.put("blocklimit", upgrades.blockLimitUpgrade);
    if (upgrades.oresUpgrade.enabled) {
        upgradesList.put("generator", upgrades.oresUpgrade);
        BlockFormListener.generateOrePossibilities();
    }
    this.boosterList = new HashMap<>();
    if (boosters.experienceBooster.enabled)
        boosterList.put("experience", boosters.experienceBooster);
    if (boosters.flightBooster.enabled)
        boosterList.put("flight", boosters.flightBooster);
    if (boosters.farmingBooster.enabled)
        boosterList.put("farming", boosters.farmingBooster);
    if (boosters.spawnerBooster.enabled)
        boosterList.put("spawner", boosters.spawnerBooster);
    saveSchematics();
    if (shopManager != null)
        shopManager.reloadCategories();
    if (commandManager != null)
        commandManager.reloadCommands();
    if (schematicManager != null)
        schematicManager.schematicPaster.clearCache();
    IridiumSkyblockReloadEvent reloadEvent = new IridiumSkyblockReloadEvent();
    Bukkit.getPluginManager().callEvent(reloadEvent);
}
Also used : Plugin(org.bukkit.plugin.Plugin) IridiumSkyblockAPI(com.iridium.iridiumskyblock.api.IridiumSkyblockAPI) java.util(java.util) Getter(lombok.Getter) ClipPlaceholderAPI(com.iridium.iridiumskyblock.placeholders.ClipPlaceholderAPI) IridiumCore(com.iridium.iridiumcore.IridiumCore) IridiumSkyblockReloadEvent(com.iridium.iridiumskyblock.api.IridiumSkyblockReloadEvent) SimplePie(org.bstats.charts.SimplePie) ChunkGenerator(org.bukkit.generator.ChunkGenerator) XMaterial(com.iridium.iridiumcore.dependencies.xseries.XMaterial) StandardCopyOption(java.nio.file.StandardCopyOption) BankItem(com.iridium.iridiumskyblock.bank.BankItem) MVDWPlaceholderAPI(com.iridium.iridiumskyblock.placeholders.MVDWPlaceholderAPI) SQLException(java.sql.SQLException) com.iridium.iridiumskyblock.managers(com.iridium.iridiumskyblock.managers) Color(com.iridium.iridiumcore.Color) World(org.bukkit.World) StackerSupport(com.iridium.iridiumskyblock.support.StackerSupport) UpdateChecker(de.jeff_media.updatechecker.UpdateChecker) NumberFormatter(com.iridium.iridiumcore.utils.NumberFormatter) ShopManager(com.iridium.iridiumskyblock.shop.ShopManager) CommandManager(com.iridium.iridiumskyblock.commands.CommandManager) Path(java.nio.file.Path) Bukkit(org.bukkit.Bukkit) RoseStackerSupport(com.iridium.iridiumskyblock.support.RoseStackerSupport) Economy(net.milkbowl.vault.economy.Economy) GUI(com.iridium.iridiumskyblock.gui.GUI) com.iridium.iridiumskyblock.configs(com.iridium.iridiumskyblock.configs) com.iridium.iridiumskyblock.listeners(com.iridium.iridiumskyblock.listeners) Files(java.nio.file.Files) Island(com.iridium.iridiumskyblock.database.Island) Metrics(org.bstats.bukkit.Metrics) IOException(java.io.IOException) EntityType(org.bukkit.entity.EntityType) Collectors(java.util.stream.Collectors) File(java.io.File) InventoryHolder(org.bukkit.inventory.InventoryHolder) Nullable(org.jetbrains.annotations.Nullable) WildStackerSupport(com.iridium.iridiumskyblock.support.WildStackerSupport) JavaPluginLoader(org.bukkit.plugin.java.JavaPluginLoader) PlayerUtils(com.iridium.iridiumskyblock.utils.PlayerUtils) NotNull(org.jetbrains.annotations.NotNull) RegisteredServiceProvider(org.bukkit.plugin.RegisteredServiceProvider) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) PluginManager(org.bukkit.plugin.PluginManager) InputStream(java.io.InputStream) Color(com.iridium.iridiumcore.Color) IridiumSkyblockReloadEvent(com.iridium.iridiumskyblock.api.IridiumSkyblockReloadEvent)

Example 2 with Color

use of com.iridium.iridiumcore.Color in project IridiumSkyblock by Iridium-Development.

the class BorderCommand 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).
 * Changes the Island Border
 *
 * @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;
    }
    if (!IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), IridiumSkyblock.getInstance().getUserManager().getUser(player), PermissionType.BORDER)) {
        player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotManageBorder.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        return false;
    }
    if (args.length != 2) {
        player.openInventory(new InventoryConfigGUI(IridiumSkyblock.getInstance().getInventories().islandBorder, player.getOpenInventory().getTopInventory()).getInventory());
        return true;
    }
    Color color = Color.getColor(args[1]);
    if (color == null) {
        player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().notAColor.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        return false;
    }
    if (!IridiumSkyblock.getInstance().getBorder().enabled.getOrDefault(color, true)) {
        player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().borderColorDisabled.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
        return false;
    }
    island.get().setColor(color);
    island.get().getMembers().stream().map(islandUser -> Bukkit.getPlayer(islandUser.getUuid())).filter(Objects::nonNull).forEach(islandPlayer -> islandPlayer.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().islandBorderChanged.replace("%player%", player.getName()).replace("%color%", color.toString()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix))));
    return true;
}
Also used : Player(org.bukkit.entity.Player) User(com.iridium.iridiumskyblock.database.User) Color(com.iridium.iridiumcore.Color) Island(com.iridium.iridiumskyblock.database.Island) InventoryConfigGUI(com.iridium.iridiumskyblock.gui.InventoryConfigGUI)

Aggregations

Color (com.iridium.iridiumcore.Color)2 Island (com.iridium.iridiumskyblock.database.Island)2 IridiumCore (com.iridium.iridiumcore.IridiumCore)1 XMaterial (com.iridium.iridiumcore.dependencies.xseries.XMaterial)1 NumberFormatter (com.iridium.iridiumcore.utils.NumberFormatter)1 IridiumSkyblockAPI (com.iridium.iridiumskyblock.api.IridiumSkyblockAPI)1 IridiumSkyblockReloadEvent (com.iridium.iridiumskyblock.api.IridiumSkyblockReloadEvent)1 BankItem (com.iridium.iridiumskyblock.bank.BankItem)1 CommandManager (com.iridium.iridiumskyblock.commands.CommandManager)1 com.iridium.iridiumskyblock.configs (com.iridium.iridiumskyblock.configs)1 User (com.iridium.iridiumskyblock.database.User)1 GUI (com.iridium.iridiumskyblock.gui.GUI)1 InventoryConfigGUI (com.iridium.iridiumskyblock.gui.InventoryConfigGUI)1 com.iridium.iridiumskyblock.listeners (com.iridium.iridiumskyblock.listeners)1 com.iridium.iridiumskyblock.managers (com.iridium.iridiumskyblock.managers)1 ClipPlaceholderAPI (com.iridium.iridiumskyblock.placeholders.ClipPlaceholderAPI)1 MVDWPlaceholderAPI (com.iridium.iridiumskyblock.placeholders.MVDWPlaceholderAPI)1 ShopManager (com.iridium.iridiumskyblock.shop.ShopManager)1 RoseStackerSupport (com.iridium.iridiumskyblock.support.RoseStackerSupport)1 StackerSupport (com.iridium.iridiumskyblock.support.StackerSupport)1