diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/worldsettings/PodzolListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/worldsettings/PodzolListener.java new file mode 100644 index 000000000..7deacda8b --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/worldsettings/PodzolListener.java @@ -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 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); + } +} diff --git a/src/main/java/world/bentobox/bentobox/lists/Flags.java b/src/main/java/world/bentobox/bentobox/lists/Flags.java index 0a9b71776..d7137dd6f 100644 --- a/src/main/java/world/bentobox/bentobox/lists/Flags.java +++ b/src/main/java/world/bentobox/bentobox/lists/Flags.java @@ -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; @@ -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. diff --git a/src/main/resources/locales/cs.yml b/src/main/resources/locales/cs.yml index 08bf39136..8dd152ad0 100644 --- a/src/main/resources/locales/cs.yml +++ b/src/main/resources/locales/cs.yml @@ -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: |- diff --git a/src/main/resources/locales/de.yml b/src/main/resources/locales/de.yml index be8bb01b8..eed405ca6 100644 --- a/src/main/resources/locales/de.yml +++ b/src/main/resources/locales/de.yml @@ -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." diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 43e180e4e..8d655eba8 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -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: |- diff --git a/src/main/resources/locales/es.yml b/src/main/resources/locales/es.yml index 78ea4e4fb..e29a4eb3b 100644 --- a/src/main/resources/locales/es.yml +++ b/src/main/resources/locales/es.yml @@ -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: |- diff --git a/src/main/resources/locales/fr.yml b/src/main/resources/locales/fr.yml index a11d49bf0..a72c59b60 100644 --- a/src/main/resources/locales/fr.yml +++ b/src/main/resources/locales/fr.yml @@ -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: |- diff --git a/src/main/resources/locales/hr.yml b/src/main/resources/locales/hr.yml index 7b18b87b2..f06819e2e 100644 --- a/src/main/resources/locales/hr.yml +++ b/src/main/resources/locales/hr.yml @@ -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: |- diff --git a/src/main/resources/locales/hu.yml b/src/main/resources/locales/hu.yml index 707300b67..8b24d30b0 100644 --- a/src/main/resources/locales/hu.yml +++ b/src/main/resources/locales/hu.yml @@ -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: |- diff --git a/src/main/resources/locales/id.yml b/src/main/resources/locales/id.yml index c4d8b07c0..8db9571b8 100644 --- a/src/main/resources/locales/id.yml +++ b/src/main/resources/locales/id.yml @@ -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: |- diff --git a/src/main/resources/locales/it.yml b/src/main/resources/locales/it.yml index 839203554..35a851bca 100644 --- a/src/main/resources/locales/it.yml +++ b/src/main/resources/locales/it.yml @@ -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. diff --git a/src/main/resources/locales/ja.yml b/src/main/resources/locales/ja.yml index d00185f7b..d15e324c1 100644 --- a/src/main/resources/locales/ja.yml +++ b/src/main/resources/locales/ja.yml @@ -1233,6 +1233,12 @@ protection: description: トグル配置 name: ブロックの配置 hint: ブロック配置は無効です + PODZOL: + name: 木のポドゾル生産 + description: |- + &a 無効にすると、大きな木が + &a 育つときに木のポドゾル + &a 生産を防ぎます POTION_THROWING: name: ポーション投げ description: |- diff --git a/src/main/resources/locales/ko.yml b/src/main/resources/locales/ko.yml index d59fd2d5f..8cb49592a 100644 --- a/src/main/resources/locales/ko.yml +++ b/src/main/resources/locales/ko.yml @@ -1068,6 +1068,12 @@ protection: description: 설치 가능여부 설정 name: 블록 설치 hint: 블록을 설치 할수 없습니다 + PODZOL: + name: 나무 포졸 생산 + description: |- + &a 비활성화하면 큰 나무가 + &a 자랄 때 나무 포졸 + &a 생산을 방지합니다 POTION_THROWING: name: 물약 던지기 description: |- diff --git a/src/main/resources/locales/lv.yml b/src/main/resources/locales/lv.yml index 5db8f3762..ec49e6389 100644 --- a/src/main/resources/locales/lv.yml +++ b/src/main/resources/locales/lv.yml @@ -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. diff --git a/src/main/resources/locales/nl.yml b/src/main/resources/locales/nl.yml index 0fd449321..36a0e0a7f 100644 --- a/src/main/resources/locales/nl.yml +++ b/src/main/resources/locales/nl.yml @@ -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: |- diff --git a/src/main/resources/locales/pl.yml b/src/main/resources/locales/pl.yml index ef61e1d1c..af2d70193 100644 --- a/src/main/resources/locales/pl.yml +++ b/src/main/resources/locales/pl.yml @@ -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.' diff --git a/src/main/resources/locales/pt.yml b/src/main/resources/locales/pt.yml index 7c5c4447a..3b98b0bb2 100644 --- a/src/main/resources/locales/pt.yml +++ b/src/main/resources/locales/pt.yml @@ -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: |- diff --git a/src/main/resources/locales/pt_BR.yml b/src/main/resources/locales/pt_BR.yml index 44482b5cf..3216d3329 100644 --- a/src/main/resources/locales/pt_BR.yml +++ b/src/main/resources/locales/pt_BR.yml @@ -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: |- diff --git a/src/main/resources/locales/ro.yml b/src/main/resources/locales/ro.yml index b1c3039b0..9a3394239 100644 --- a/src/main/resources/locales/ro.yml +++ b/src/main/resources/locales/ro.yml @@ -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: |- diff --git a/src/main/resources/locales/ru.yml b/src/main/resources/locales/ru.yml index db6a27067..f552b2b54 100644 --- a/src/main/resources/locales/ru.yml +++ b/src/main/resources/locales/ru.yml @@ -1244,6 +1244,12 @@ protection: description: Переключатель возможности взаимодействовать name: Установка блоков hint: Установка блоков запрещена + PODZOL: + name: Производство древесного подзола + description: |- + &a Если отключено, предотвратит + &a производство древесного подзола + &a при росте больших деревьев POTION_THROWING: name: Бросание зелий description: |- diff --git a/src/main/resources/locales/tr.yml b/src/main/resources/locales/tr.yml index e780728d8..7f398b274 100644 --- a/src/main/resources/locales/tr.yml +++ b/src/main/resources/locales/tr.yml @@ -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." diff --git a/src/main/resources/locales/uk.yml b/src/main/resources/locales/uk.yml index 25b227a1a..331c15647 100644 --- a/src/main/resources/locales/uk.yml +++ b/src/main/resources/locales/uk.yml @@ -1321,6 +1321,12 @@ protection: description: Перемкнути розміщення name: Розмістіть блоки hint: Розміщення блоку вимкнено + PODZOL: + name: Виробництво деревного подзолу + description: |- + &a Якщо вимкнено, це запобігатиме + &a виробництву подзолу дерева + &a при вирощуванні великих дерев POTION_THROWING: name: Кидання зілля description: |- diff --git a/src/main/resources/locales/vi.yml b/src/main/resources/locales/vi.yml index 15038b2fc..ae3f998a8 100644 --- a/src/main/resources/locales/vi.yml +++ b/src/main/resources/locales/vi.yml @@ -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: |- diff --git a/src/main/resources/locales/zh-CN.yml b/src/main/resources/locales/zh-CN.yml index 38da2cfa4..02bb4c136 100644 --- a/src/main/resources/locales/zh-CN.yml +++ b/src/main/resources/locales/zh-CN.yml @@ -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: |- diff --git a/src/main/resources/locales/zh-HK.yml b/src/main/resources/locales/zh-HK.yml index 9dfa89e71..5d14f773c 100644 --- a/src/main/resources/locales/zh-HK.yml +++ b/src/main/resources/locales/zh-HK.yml @@ -1167,6 +1167,11 @@ protection: description: 允許/禁止 在島上放置方塊 name: '&a&l放置方塊' hint: '&c已被禁止在島上放置方塊' + PODZOL: + name: 樹蔭土生成 + description: |- + &a 如果停用,將防止在大樹 + &a 成長時生成樹蔭土 POTION_THROWING: description: |- &7允許/禁止 在島上投擲藥水瓶 diff --git a/src/test/java/world/bentobox/bentobox/managers/FlagsManagerTest.java b/src/test/java/world/bentobox/bentobox/managers/FlagsManagerTest.java index c9f53635d..5a00599b6 100644 --- a/src/test/java/world/bentobox/bentobox/managers/FlagsManagerTest.java +++ b/src/test/java/world/bentobox/bentobox/managers/FlagsManagerTest.java @@ -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