Skip to content

Commit

Permalink
netherOnlyGenerator (#742)
Browse files Browse the repository at this point in the history
* netherOnlyGenerator

added `netherOnlyGenerator` config option and a check to `BlockFormListener` to determine whether to activate the basalt generator in the overworld & end or be nether exclusive

* Update BlockFormListener.java

added variable for checking if its a basalt generator

Co-authored-by: Peaches_MLG <[email protected]>

* Update BlockFormListener.java

replaced condition to use variable name

Co-authored-by: Peaches_MLG <[email protected]>

---------

Co-authored-by: Peaches_MLG <[email protected]>
  • Loading branch information
sh0inx and PeachesMLG authored Sep 29, 2023
1 parent 0335000 commit 6292d20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public Configuration() {


public boolean obsidianBucket = true;
public boolean netherOnlyGenerator = false;
public boolean endPortalPick = true;
public boolean removeIslandBlocksOnDelete = false;
public boolean clearInventoryOnRegen = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.iridium.iridiumskyblock.RandomAccessList;
import com.iridium.iridiumskyblock.enhancements.GeneratorEnhancementData;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFormEvent;
Expand All @@ -31,16 +32,18 @@ public void onBlockForm(BlockFormEvent event) {
if (!generatorMaterials.contains(newMaterial)) return;
IridiumSkyblock.getInstance().getIslandManager().getTeamViaLocation(event.getNewState().getLocation()).ifPresent(island -> {
int upgradeLevel = IridiumSkyblock.getInstance().getIslandManager().getTeamEnhancement(island, "generator").getLevel();
RandomAccessList<XMaterial> randomMaterialList = newMaterial == XMaterial.BASALT ? netherOreLevels.get(upgradeLevel) : normalOreLevels.get(upgradeLevel);
boolean isBasaltGenerator = newMaterial == XMaterial.BASALT;
RandomAccessList<XMaterial> randomMaterialList = isBasaltGenerator ? netherOreLevels.get(upgradeLevel) : normalOreLevels.get(upgradeLevel);
if (randomMaterialList == null) return;

Optional<XMaterial> xMaterialOptional = randomMaterialList.nextElement();
if (!xMaterialOptional.isPresent()) return;

if( isBasaltGenerator && IridiumSkyblock.getInstance().getConfiguration().netherOnlyGenerator && event.getNewState().getWorld().getEnvironment() != World.Environment.NETHER) return;

Material material = xMaterialOptional.get().parseMaterial();
if (material == Material.COBBLESTONE && newMaterial == XMaterial.STONE) material = Material.STONE;
if (material != null) event.getNewState().setType(material);
});
}

}

0 comments on commit 6292d20

Please sign in to comment.