The upgrade system allows islands to progressively improve their capabilities by purchasing upgrades. Each upgrade has multiple levels, with each level providing enhanced benefits and requiring payment of a cost.
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;import com.bgsoftware.superiorskyblock.api.upgrades.Upgrade;// Get specific upgrade by nameUpgrade upgrade = SuperiorSkyblockAPI.getUpgrades().getUpgrade("upgrade-name");// Get all upgradesCollection<Upgrade> allUpgrades = SuperiorSkyblockAPI.getUpgrades().getUpgrades();
Control how many of each block type can be placed:
// Get limit for specific blockint getBlockLimit(Key blockKey);int getExactBlockLimit(Key blockKey);// Get all block limitsMap<Key, Integer> getBlockLimits();
// Get entity limit by typeint getEntityLimit(EntityType entityType);int getEntityLimit(Key entityKey);// Get all entity limitsMap<Key, Integer> getEntityLimitsAsKeys();
Example:
// Check if island can spawn more cowsint cowLimit = level.getEntityLimit(EntityType.COW);int currentCows = island.getEntitiesTracker().getEntityCount(EntityType.COW);if (currentCows >= cowLimit) { event.setCancelled(true); player.sendMessage("Cow limit reached!");}
// Get generation rate for block in dimensionint getGeneratorAmount(Key blockKey, Dimension dimension);// Get all generator rates for dimensionMap<String, Integer> getGeneratorAmounts(Dimension dimension);
Example Configuration:
UpgradeLevel level = upgrade.getUpgradeLevel(3);Key diamondOre = Key.of("DIAMOND_ORE");int diamondRate = level.getGeneratorAmount(diamondOre, Dimension.NORMAL);// Rate of 10 means 10% chance to generate diamond ore
// The cost system is extensibleUpgradeCost cost = level.getCost();// Cost implementations handle:// - Checking if player can afford// - Withdrawing the cost// - Displaying cost information
import com.bgsoftware.superiorskyblock.api.island.Island;Island island = player.getIsland();Upgrade upgrade = SuperiorSkyblockAPI.getUpgrades().getUpgrade("crop-growth");// Get current levelint currentLevel = island.getUpgradeLevel(upgrade).getLevel();// Get next levelUpgradeLevel nextLevel = upgrade.getUpgradeLevel(currentLevel + 1);// Check if can upgradeif (nextLevel.getLevel() > currentLevel) { // Check cost, requirements, etc. // Then upgrade: island.setUpgradeLevel(upgrade, nextLevel.getLevel());}
Always validate costs, permissions, and requirements before applying upgrades.
// Get all slots for this upgradeList<Integer> slots = upgrade.getSlots();// Check if upgrade is in specific slotif (upgrade.isSlot(22)) { // Handle click on slot 22}// Set upgrade slots (usually done via config)upgrade.setSlots(Arrays.asList(20, 21, 22));