Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Stacker Support #812

Closed
wants to merge 12 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.iridium.iridiumteams.IridiumTeams;
import com.iridium.iridiumteams.managers.MissionManager;
import com.iridium.iridiumteams.managers.ShopManager;
import com.iridium.iridiumteams.managers.SupportManager;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class IridiumSkyblock extends IridiumTeams<Island, User> {
private SchematicManager schematicManager;
private ShopManager<Island, User> shopManager;
private BiomeManager biomeManager;
private SupportManager<Island, User> supportManager;

private Economy economy;

Expand Down Expand Up @@ -116,6 +118,9 @@ public void onEnable() {

Bukkit.getServer().getOnlinePlayers().forEach(player -> getIslandManager().sendIslandBorder(player));

this.supportManager = new SupportManager(this);
supportManager.registerSupport();

addBstats(5825);
startUpdateChecker(62480);
super.onEnable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
import com.iridium.iridiumteams.missions.Mission;
import com.iridium.iridiumteams.missions.MissionData;
import com.iridium.iridiumteams.missions.MissionType;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.OfflinePlayer;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
Expand Down Expand Up @@ -407,7 +414,7 @@ public synchronized TeamBank getTeamBank(Island island, String bankItem) {
}

@Override
public synchronized TeamSpawners getTeamSpawners(Island island, EntityType entityType) {
public synchronized Teams getTeamSpawners(Island island, EntityType entityType) {
PeachesMLG marked this conversation as resolved.
Show resolved Hide resolved
Optional<TeamSpawners> teamSpawner = IridiumSkyblock.getInstance().getDatabaseManager().getTeamSpawnerTableManager().getEntry(new TeamSpawners(island, entityType, 0));
if (teamSpawner.isPresent()) {
return teamSpawner.get();
Expand Down Expand Up @@ -478,18 +485,25 @@ public CompletableFuture<Void> recalculateTeam(Island island) {
}
}
}

getSpawners(chunk, island).join().forEach(creatureSpawner ->
teamSpawners.put(creatureSpawner.getSpawnedType(), teamSpawners.getOrDefault(creatureSpawner.getSpawnedType(), 0) + 1)
teamSpawners.put(creatureSpawner.getSpawnedType(), teamSpawners.getOrDefault(creatureSpawner.getSpawnedType(), 0) + 1)
);
}
}).thenRun(() -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {
List<TeamBlock> blocks = IridiumSkyblock.getInstance().getDatabaseManager().getTeamBlockTableManager().getEntries(island);
List<TeamSpawners> spawners = IridiumSkyblock.getInstance().getDatabaseManager().getTeamSpawnerTableManager().getEntries(island);
for (TeamBlock teamBlock : blocks) {
teamBlock.setAmount(teamBlocks.getOrDefault(teamBlock.getXMaterial(), 0));
int stackedBlocks = IridiumSkyblock.getInstance().getSupportManager().getStackerSupport().stream().mapToInt(
stackerSupport -> stackerSupport.getExtraBlocks(island, teamBlock.getXMaterial())
).sum();
teamBlock.setAmount(teamBlocks.getOrDefault(teamBlock.getXMaterial(), 0) + stackedBlocks);
}
for (TeamSpawners teamSpawner : spawners) {
teamSpawner.setAmount(teamSpawners.getOrDefault(teamSpawner.getEntityType(), 0));
int spawnerBlocks = IridiumSkyblock.getInstance().getSupportManager().getSpawnerSupport().stream().mapToInt(
spawnerSupport -> spawnerSupport.getExtraSpawners(island, teamSpawner.getEntityType())
).sum();
teamSpawner.setAmount(teamSpawners.getOrDefault(teamSpawner.getEntityType(), 0) + spawnerBlocks);
}
}));
}
Expand Down Expand Up @@ -642,6 +656,11 @@ public void deleteTeamReward(TeamReward teamReward) {
return null;
}

@Override
public boolean isInTeam(Island island, Location location){
return island.isInIsland(location);
}

public boolean isInSkyblockWorld(World world) {
if(world == null) return false;
return world.getName().equals(getWorldName(World.Environment.NORMAL)) || world.getName().equals(getWorldName(World.Environment.NETHER)) || world.getName().equals(getWorldName(World.Environment.THE_END));
Expand Down
Loading