Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG committed Sep 23, 2023
1 parent b6cba19 commit 1923acb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 70 deletions.
67 changes: 29 additions & 38 deletions src/main/java/com/iridium/iridiumskyblock/configs/Generators.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,49 @@
import com.iridium.iridiumcore.dependencies.xseries.XMaterial;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Generators {

public Map<String, Generators.GeneratorConfig> generators = ImmutableMap.<String, GeneratorConfig>builder()

.put("skyblock", new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorConfig(
new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorWorld(true),
new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorWorld(true),
new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorWorld(true)))

.put("ocean", new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorConfig(
new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorWorld(
XMaterial.SAND,
XMaterial.STONE,
XMaterial.WATER,
63, 48, 53, true
),
new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorWorld(
XMaterial.SOUL_SAND,
XMaterial.NETHERRACK,
XMaterial.LAVA,
63, 48, 53, true
),
new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorWorld(
XMaterial.END_STONE,
XMaterial.END_STONE,
XMaterial.VOID_AIR,
63, 48, 53, true
)))
.build();
public Generators.SkyblockGeneratorConfig skyblockGenerator = new SkyblockGeneratorConfig(
new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorWorld(true),
new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorWorld(true),
new com.iridium.iridiumskyblock.configs.Generators.SkyblockGeneratorWorld(true)
);
public Generators.OceanGeneratorConfig oceanGenerator = new OceanGeneratorConfig(
new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorWorld(
XMaterial.SAND,
XMaterial.STONE,
XMaterial.WATER,
63, 48, 53, true
),
new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorWorld(
XMaterial.SOUL_SAND,
XMaterial.NETHERRACK,
XMaterial.LAVA,
63, 48, 53, true
),
new com.iridium.iridiumskyblock.configs.Generators.OceanGeneratorWorld(
XMaterial.END_STONE,
XMaterial.END_STONE,
XMaterial.VOID_AIR,
63, 48, 53, true
));

@NoArgsConstructor
@AllArgsConstructor
public static class GeneratorConfig {
public Generators.SkyblockGeneratorConfig skyblock;
public Generators.OceanGeneratorConfig ocean;
}

@NoArgsConstructor
@AllArgsConstructor
public static class SkyblockGeneratorConfig extends GeneratorConfig{
public static class SkyblockGeneratorConfig {
public SkyblockGeneratorWorld overworld;
public SkyblockGeneratorWorld nether;
public SkyblockGeneratorWorld end;
}

@NoArgsConstructor
@AllArgsConstructor
public static class OceanGeneratorConfig extends GeneratorConfig{
public static class OceanGeneratorConfig {
public OceanGeneratorWorld overworld;
public OceanGeneratorWorld nether;
public OceanGeneratorWorld end;
Expand All @@ -72,7 +64,6 @@ public SkyblockGeneratorWorld(boolean canSpawnEntities) {

@NoArgsConstructor
public static class OceanGeneratorWorld {

public XMaterial floor;
public XMaterial underFloor;
public XMaterial liquidType;
Expand All @@ -81,13 +72,13 @@ public static class OceanGeneratorWorld {
public int maxFloorHeight;
public boolean canSpawnEntities;

public OceanGeneratorWorld( XMaterial floor, XMaterial underFloor, XMaterial liquidType, int liquidHeight, int minFloorHeight, int maxFloorHeight, boolean canSpawnEntities) {
public OceanGeneratorWorld(XMaterial floor, XMaterial underFloor, XMaterial liquidType, int liquidHeight, int minFloorHeight, int maxFloorHeight, boolean canSpawnEntities) {
this.floor = floor;
this.underFloor = underFloor;
this.liquidType = liquidType;
this.liquidHeight = liquidHeight;
this.minFloorHeight = minFloorHeight;
this. maxFloorHeight = maxFloorHeight;
this.maxFloorHeight = maxFloorHeight;
this.canSpawnEntities = canSpawnEntities;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,102 +126,100 @@ public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) {
return null;
}

Map<String, Generators.GeneratorConfig> generatorConfig = IridiumSkyblock.getInstance().getGenerators().generators;

public XMaterial getFloor(Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("floor").nether.floor;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.floor;
}
case THE_END: {
return generatorConfig.get("floor").ocean.end.floor;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.floor;
}
default: {
return generatorConfig.get("floor").ocean.overworld.floor;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.floor;
}
}
}

public XMaterial getUnderFloor(Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("underFloor").ocean.nether.underFloor;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.underFloor;
}
case THE_END: {
return generatorConfig.get("underFloor").ocean.end.underFloor;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.underFloor;
}
default: {
return generatorConfig.get("underFloor").ocean.overworld.underFloor;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.underFloor;
}
}
}

public XMaterial getLiquidType(Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("liquidType").ocean.nether.liquidType;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.liquidType;
}
case THE_END: {
return generatorConfig.get("liquidType").ocean.end.liquidType;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.liquidType;
}
default: {
return generatorConfig.get("liquidType").ocean.overworld.liquidType;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.liquidType;
}
}
}

public int getliquidHeight (Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("liquidHeight").ocean.nether.liquidHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.liquidHeight;
}
case THE_END: {
return generatorConfig.get("liquidHeight").ocean.end.liquidHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.liquidHeight;
}
default: {
return generatorConfig.get("liquidHeight").ocean.overworld.liquidHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.liquidHeight;
}
}
}

public int getMinFloorHeight(Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("minFloorHeight").ocean.nether.minFloorHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.minFloorHeight;
}
case THE_END: {
return generatorConfig.get("minFloorHeight").ocean.end.minFloorHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.minFloorHeight;
}
default: {
return generatorConfig.get("minFloorHeight").ocean.overworld.minFloorHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.minFloorHeight;
}
}
}

public int getMaxFloorHeight(Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("maxFloorHeight").ocean.nether.maxFloorHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.maxFloorHeight;
}
case THE_END: {
return generatorConfig.get("maxFloorHeight").ocean.end.maxFloorHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.maxFloorHeight;
}
default: {
return generatorConfig.get("maxFloorHeight").ocean.overworld.maxFloorHeight;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.maxFloorHeight;
}
}
}

public boolean getCanSpawnEntities(Environment environment) {
switch(environment) {
case NETHER: {
return generatorConfig.get("canSpawnEntities").ocean.nether.canSpawnEntities;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.nether.canSpawnEntities;
}
case THE_END: {
return generatorConfig.get("canSpawnEntities").ocean.end.canSpawnEntities;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.end.canSpawnEntities;
}
default: {
return generatorConfig.get("canSpawnEntities").ocean.overworld.canSpawnEntities;
return IridiumSkyblock.getInstance().getGenerators().oceanGenerator.overworld.canSpawnEntities;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.iridium.iridiumskyblock.generators;

import com.iridium.iridiumskyblock.IridiumSkyblock;
import com.iridium.iridiumskyblock.configs.Generators;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class VoidGenerator extends ChunkGenerator {
Expand All @@ -30,18 +28,15 @@ public byte[][] generateBlockSections(World world, Random random, int x, int z,

@Override
public boolean canSpawn(@NotNull World world, int x, int z) {

Map<String, Generators.GeneratorConfig> generatorConfig = IridiumSkyblock.getInstance().getGenerators().generators;

switch(world.getEnvironment()) {
switch (world.getEnvironment()) {
case NETHER: {
return generatorConfig.get("canSpawnEntities").skyblock.nether.canSpawnEntities;
return IridiumSkyblock.getInstance().getGenerators().skyblockGenerator.nether.canSpawnEntities;
}
case THE_END: {
return generatorConfig.get("canSpawnEntities").skyblock.end.canSpawnEntities;
return IridiumSkyblock.getInstance().getGenerators().skyblockGenerator.end.canSpawnEntities;
}
default: {
return generatorConfig.get("canSpawnEntities").skyblock.overworld.canSpawnEntities;
return IridiumSkyblock.getInstance().getGenerators().skyblockGenerator.overworld.canSpawnEntities;
}
}
}
Expand Down

0 comments on commit 1923acb

Please sign in to comment.