Skip to content

Commit

Permalink
Merge pull request #2606 from BentoBoxWorld/2604_dirt_dupe
Browse files Browse the repository at this point in the history
Add PODZOL flag to prevent podzol generation with big trees
  • Loading branch information
tastybento authored Jan 25, 2025
2 parents 7d7d3d1 + c712e7e commit c89ed27
Show file tree
Hide file tree
Showing 26 changed files with 181 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package world.bentobox.bentobox.listeners.flags.worldsettings;

import java.util.Optional;

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.world.StructureGrowEvent;

import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;

/**
* Podzol listener - prevents generation of podzol under large trees
* @since 3.2.4
*/
public class PodzolListener extends FlagListener {

@EventHandler(priority = EventPriority.NORMAL)
public void onTreeGrow(StructureGrowEvent e) {
if (!getIWM().inWorld(e.getWorld()) || Flags.PODZOL.isSetForWorld(e.getWorld())) {
// We do not want to run any check if this is not the right world or if it is allowed.
return;
}

// If there is no protected island at the location of the sapling, just cancel the event (prevents the sapling from growing).
Optional<Island> optionalProtectedIsland = getIslands().getProtectedIslandAt(e.getLocation());
if (optionalProtectedIsland.isEmpty()) {
e.setCancelled(true);
return;
}
// Now, run through all the blocks that will be generated and if there is no protected island at their location, or the protected island is not the same as the one growing the tree then turn them into AIR.
e.getBlocks().removeIf(blockState -> blockState.getType() == Material.PODZOL);
}
}
8 changes: 8 additions & 0 deletions src/main/java/world/bentobox/bentobox/lists/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineRedstoneListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.PetTeleportListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.PistonPushListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.PodzolListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.RemoveMobsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.SpawnerSpawnEggsListener;
import world.bentobox.bentobox.listeners.flags.worldsettings.TreesGrowingOutsideRangeListener;
Expand Down Expand Up @@ -705,6 +706,13 @@ private Flags() {}
.listener(new CandleListener())
.type(Type.PROTECTION).build();

/**
* Prevents podzol production when large trees grow
* @since 3.4.2
*/
public static final Flag PODZOL = new Flag.Builder("PODZOL", Material.PODZOL).type(Type.WORLD_SETTING)
.defaultSetting(false).listener(new PodzolListener()).build();

/**
* Provides a list of all the Flag instances contained in this class using reflection.
* Deprecated Flags are ignored.
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,12 @@ protection:
description: Přepnout pokládání
name: Pokládat bloky
hint: Pokládání bloků zakázáno
PODZOL:
name: Stromová produkce podzolu
description: |-
&a Pokud je zakázáno, zabrání
&a produkci stromového podzolu
&a při růstu velkých stromů
POTION_THROWING:
name: Házení lektvarů
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,12 @@ protection:
description: Platzieren umschalten
name: Blöcke platzieren
hint: Blockplatzierung deaktiviert
PODZOL:
name: Baum-Podzol-Produktion
description: |-
&a Wenn deaktiviert, wird die
&a Baum-Podzol-Produktion
&a bei großen Baumwachstum verhindert
POTION_THROWING:
name: Trank werfen
description: "&a Umschalten der Tränke \n&a Dazu gehören Wurf- und Verweiltränke."
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,12 @@ protection:
description: Toggle placing
name: Place blocks
hint: Block placing disabled
PODZOL:
name: Tree Podzol Production
description: |-
&a If disabled will prevent
&a tree podzol production
&a when large trees grow
POTION_THROWING:
name: Potion throwing
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,12 @@ protection:
description: Modificar construccion
name: Poner Bloques
hint: No se permite colocar bloques.
PODZOL:
name: Producción de Podzol de Árbol
description: |-
&a Si se desactiva, evitará la
&a producción de podzol de árbol
&a cuando crezcan árboles grandes
POTION_THROWING:
name: Lanzamiento de pociones
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,12 @@ protection:
description: Toggle placing
name: Place blocks
hint: Blocage du placement désactivé
PODZOL:
name: Production de podzol d'arbre
description: |-
&a Si désactivé, empêchera la
&a production de podzol d'arbre
&a lorsque les grands arbres poussent
POTION_THROWING:
name: Potion throwing
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,12 @@ protection:
description: Uključi/isključi postavljanje
name: Postavite blokove
hint: Onemogućeno postavljanje blokova
PODZOL:
name: Proizvodnja podzola na drvetu
description: |-
&a Ako je onemogućeno, spriječit će
&a proizvodnju podzola na drvetu
&a kada rastu velika stabla
POTION_THROWING:
name: Bacanje napitaka
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/hu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,12 @@ protection:
description: Elhelyezés váltása
name: Helyezzen el blokkokat
hint: A blokk elhelyezése letiltva
PODZOL:
name: Fa podzol termelés
description: |-
&a Ha letiltva, megakadályozza a
&a fa podzol termelést, amikor
&a nagy fák nőnek
POTION_THROWING:
name: bájitaldobás
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,12 @@ protection:
description: Alihkan penempatan
name: Tempatkan blok
hint: Penempatan blok dinonaktifkan
PODZOL:
name: Produksi Podzol Pohon
description: |-
&a Jika dinonaktifkan, akan mencegah
&a produksi podzol pohon
&a saat pohon besar tumbuh
POTION_THROWING:
name: Melempar ramuan
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,12 @@ protection:
description: Abilita/disabilita piazzamento
hint: Piazzamento blocchi non permesso
name: Piazza blocchi
PODZOL:
name: Produzione di podzol degli alberi
description: |-
&a Se disabilitato, impedirà
&a la produzione di podzol
&a quando crescono grandi alberi
POTION_THROWING:
description: |-
&aAbilita/disabilita lancio di pozioni.
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,12 @@ protection:
description: トグル配置
name: ブロックの配置
hint: ブロック配置は無効です
PODZOL:
name: 木のポドゾル生産
description: |-
&a 無効にすると、大きな木が
&a 育つときに木のポドゾル
&a 生産を防ぎます
POTION_THROWING:
name: ポーション投げ
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,12 @@ protection:
description: 설치 가능여부 설정
name: 블록 설치
hint: 블록을 설치 할수 없습니다
PODZOL:
name: 나무 포졸 생산
description: |-
&a 비활성화하면 큰 나무가
&a 자랄 때 나무 포졸
&a 생산을 방지합니다
POTION_THROWING:
name: 물약 던지기
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/lv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,12 @@ protection:
&auz salas.
hint: Bloku likšana nav atļauta
name: Bloku nolikšana
PODZOL:
name: Koku podzola ražošana
description: |-
&a Ja atspējots, tas novērsīs
&a koku podzola ražošanu, kad
&a aug lieli koki
POTION_THROWING:
description: |-
&aPārslēdz iespēju mest dziras.
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,12 @@ protection:
description: Schakelen tussen plaatsen
name: Plaats blokken
hint: Blok plaatsen uitgeschakeld
PODZOL:
name: Boom-Podzolproductie
description: |-
&a Als uitgeschakeld, wordt de
&a productie van boom-podzol
&a bij grote bomen gestopt
POTION_THROWING:
name: Drankje gooien
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,12 @@ protection:
description: Przełącz interakcje
name: Stawianie bloków
hint: Stawianie bloków jest wyłączone.
PODZOL:
name: Produkcja podzolu drzewnego
description: |-
&a Wyłączenie zapobiega
&a produkcji podzolu drzewnego
&a podczas wzrostu dużych drzew
POTION_THROWING:
name: Rzucanie mikstur
description: '&a Przełącz rzucanie mikstur trwałych i rzucanych.'
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,12 @@ protection:
description: Alternar posicionamento
name: Coloque blocos
hint: Colocação de bloco desativada
PODZOL:
name: Produção de Podzol de Árvore
description: |-
&a Se desativado, impedirá
&a a produção de podzol de árvore
&a quando árvores grandes crescerem
POTION_THROWING:
name: Lançamento de poção
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/pt_BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,12 @@ protection:
description: Permitir colocação
name: Colocar blocos
hint: Colocação de blocos desabilitada
PODZOL:
name: Produção de Podzol de Árvore
description: |-
&a Se desativado, impedirá
&a a produção de podzol de árvore
&a quando grandes árvores crescerem
POTION_THROWING:
name: Arremesso de poção
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/ro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,12 @@ protection:
description: Comutați plasarea
name: Plasați blocuri
hint: Blocarea plasării este dezactivată
PODZOL:
name: Producția de podzol de copac
description: |-
&a Dacă este dezactivat, va preveni
&a producția de podzol de copac
&a când cresc copaci mari
POTION_THROWING:
name: Aruncarea poției
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,12 @@ protection:
description: Переключатель возможности взаимодействовать
name: Установка блоков
hint: Установка блоков запрещена
PODZOL:
name: Производство древесного подзола
description: |-
&a Если отключено, предотвратит
&a производство древесного подзола
&a при росте больших деревьев
POTION_THROWING:
name: Бросание зелий
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,12 @@ protection:
description: Blok koyma ayarı değişimi
name: Blok yerleştirme
hint: Blok koymaya izin verilmez.
PODZOL:
name: Ağaç Podzol Üretimi
description: |-
&a Devre dışı bırakılırsa,
&a büyük ağaçlar büyüdüğünde
&a ağaç podzol üretimini önler
POTION_THROWING:
name: Potion throwing
description: "&aİksirlerin atılmasını ayarlar."
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,12 @@ protection:
description: Перемкнути розміщення
name: Розмістіть блоки
hint: Розміщення блоку вимкнено
PODZOL:
name: Виробництво деревного подзолу
description: |-
&a Якщо вимкнено, це запобігатиме
&a виробництву подзолу дерева
&a при вирощуванні великих дерев
POTION_THROWING:
name: Кидання зілля
description: |-
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/locales/vi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,12 @@ protection:
description: Bật/Tắt đặt khối
name: Đặt khối
hint: Đã tắt đặt khối
PODZOL:
name: Sản xuất Podzol cây
description: |-
&a Nếu bị vô hiệu hóa, sẽ ngăn
&a sản xuất podzol cây khi
&a cây lớn phát triển
POTION_THROWING:
name: Quăng bình thuốc
description: |-
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,11 @@ protection:
description: '&a允许&#FAFAD2或&c禁止&#FAFAD2放置方块'
name: '&b&l放置方块'
hint: 禁止放置方块
PODZOL:
name: 树荫土生成
description: |-
&a 如果禁用,将防止在大树
&a 生长时生成树荫土
POTION_THROWING:
name: '&b&l投掷药水'
description: |-
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/locales/zh-HK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,11 @@ protection:
description: 允許/禁止 在島上放置方塊
name: '&a&l放置方塊'
hint: '&c已被禁止在島上放置方塊'
PODZOL:
name: 樹蔭土生成
description: |-
&a 如果停用,將防止在大樹
&a 成長時生成樹蔭土
POTION_THROWING:
description: |-
&7允許/禁止 在島上投擲藥水瓶
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class FlagsManagerTest {
/**
* Update this value if the number of registered listeners changes
*/
private static final int NUMBER_OF_LISTENERS = 55;
private static final int NUMBER_OF_LISTENERS = 56;
@Mock
private BentoBox plugin;
@Mock
Expand Down

0 comments on commit c89ed27

Please sign in to comment.