From 6292d20aa2111933b7970d2e739db43befb45af4 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Fri, 29 Sep 2023 16:34:04 -0400 Subject: [PATCH] netherOnlyGenerator (#742) * 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 * Update BlockFormListener.java replaced condition to use variable name Co-authored-by: Peaches_MLG --------- Co-authored-by: Peaches_MLG --- .../com/iridium/iridiumskyblock/configs/Configuration.java | 1 + .../iridiumskyblock/listeners/BlockFormListener.java | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java index 8a692bddf..98194f612 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java @@ -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; diff --git a/src/main/java/com/iridium/iridiumskyblock/listeners/BlockFormListener.java b/src/main/java/com/iridium/iridiumskyblock/listeners/BlockFormListener.java index 15cbeb236..a337077c3 100644 --- a/src/main/java/com/iridium/iridiumskyblock/listeners/BlockFormListener.java +++ b/src/main/java/com/iridium/iridiumskyblock/listeners/BlockFormListener.java @@ -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; @@ -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 randomMaterialList = newMaterial == XMaterial.BASALT ? netherOreLevels.get(upgradeLevel) : normalOreLevels.get(upgradeLevel); + boolean isBasaltGenerator = newMaterial == XMaterial.BASALT; + RandomAccessList randomMaterialList = isBasaltGenerator ? netherOreLevels.get(upgradeLevel) : normalOreLevels.get(upgradeLevel); if (randomMaterialList == null) return; Optional 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); }); } - } \ No newline at end of file