@@ -743,9 +743,14 @@ private PanelItem createRequirementButton(RequirementButton button) {
743743 }
744744 // Buttons for Island Requirements
745745 case REQUIRED_ENTITIES , REMOVE_ENTITIES , REQUIRED_BLOCKS , REMOVE_BLOCKS , SEARCH_RADIUS ,
746- REQUIRED_MATERIALTAGS , REQUIRED_ENTITYTAGS , REQUIRED_BIOMES -> {
746+ REQUIRED_MATERIALTAGS , REQUIRED_ENTITYTAGS -> {
747747 return this .createIslandRequirementButton (button );
748748 }
749+ // Biome requirement is a self-contained island requirement, kept out of the large
750+ // createIslandRequirementButton switch.
751+ case REQUIRED_BIOMES -> {
752+ return this .createBiomeRequirementButton ();
753+ }
749754 // Buttons for Inventory Requirements
750755 case REQUIRED_ITEMS , REMOVE_ITEMS , ADD_IGNORED_META , REMOVE_IGNORED_META -> {
751756 return this .createInventoryRequirementButton (button );
@@ -929,48 +934,6 @@ private PanelItem createIslandRequirementButton(RequirementButton button) {
929934 description .add ("" );
930935 description .add (this .user .getTranslation (Constants .CLICK_TO_CHANGE ));
931936 }
932- case REQUIRED_BIOMES -> {
933- if (requirements .getRequiredBiomes ().isEmpty ()) {
934- description .add (this .user .getTranslation (reference + "none" ));
935- } else {
936- description .add (this .user .getTranslation (reference + Constants .TITLE_KEY ));
937- requirements .getRequiredBiomes ()
938- .forEach (biomeKey -> description .add (this .user .getTranslation (reference + "list" , "[biome]" ,
939- Utils .prettifyBiome (biomeKey ))));
940- }
941-
942- icon = new ItemStack (Material .GRASS_BLOCK );
943- clickHandler = (panel , user , clickType , slot ) -> {
944- if (clickType .isRightClick ()) {
945- // Right click clears the biome list.
946- requirements .getRequiredBiomes ().clear ();
947- this .build ();
948- } else {
949- // Left click opens the selector, hiding already-chosen biomes.
950- Set <Biome > excluded = requirements .getRequiredBiomes ().stream ()
951- .map (key -> Registry .BIOME .get (NamespacedKey .fromString (key )))
952- .filter (Objects ::nonNull ).collect (Collectors .toSet ());
953-
954- MultiBiomeSelector .open (this .user , excluded , (status , biomes ) -> {
955- if (Boolean .TRUE .equals (status ) && biomes != null ) {
956- biomes .forEach (biome -> requirements .getRequiredBiomes ()
957- .add (MultiBiomeSelector .biomeKey (biome )));
958- }
959-
960- this .build ();
961- });
962- }
963- return true ;
964- };
965- glow = false ;
966-
967- description .add ("" );
968- description .add (this .user .getTranslation (Constants .TIPS + "click-to-add" ));
969-
970- if (!requirements .getRequiredBiomes ().isEmpty ()) {
971- description .add (this .user .getTranslation (Constants .TIPS + "right-click-to-clear" ));
972- }
973- }
974937 default -> {
975938 icon = new ItemStack (Material .PAPER );
976939 clickHandler = null ;
@@ -981,6 +944,68 @@ private PanelItem createIslandRequirementButton(RequirementButton button) {
981944 .clickHandler (clickHandler ).build ();
982945 }
983946
947+
948+ /**
949+ * Creates the "Required Biomes" button for island challenges. Left-click opens the biome
950+ * selector (hiding already-chosen biomes); right-click clears the list.
951+ *
952+ * @return the PanelItem for the biome requirement button.
953+ */
954+ private PanelItem createBiomeRequirementButton () {
955+ final String reference = Constants .BUTTON + RequirementButton .REQUIRED_BIOMES .name ().toLowerCase () + "." ;
956+ final String name = this .user .getTranslation (reference + "name" );
957+ final IslandRequirements requirements = this .challenge .getRequirements ();
958+ final List <String > description = new ArrayList <>();
959+ description .add (this .user .getTranslation (reference + Constants .DESCRIPTION_KEY ));
960+
961+ if (requirements .getRequiredBiomes ().isEmpty ()) {
962+ description .add (this .user .getTranslation (reference + "none" ));
963+ } else {
964+ description .add (this .user .getTranslation (reference + Constants .TITLE_KEY ));
965+ requirements .getRequiredBiomes ().forEach (biomeKey -> description .add (
966+ this .user .getTranslation (reference + "list" , "[biome]" , Utils .prettifyBiome (biomeKey ))));
967+ }
968+
969+ description .add ("" );
970+ description .add (this .user .getTranslation (Constants .CLICK_TO_ADD ));
971+
972+ if (!requirements .getRequiredBiomes ().isEmpty ()) {
973+ description .add (this .user .getTranslation (Constants .TIPS + "right-click-to-clear" ));
974+ }
975+
976+ return new PanelItemBuilder ().icon (new ItemStack (Material .GRASS_BLOCK )).name (name ).description (description )
977+ .glow (false ).clickHandler ((panel , user , clickType , slot ) -> {
978+ if (clickType .isRightClick ()) {
979+ requirements .getRequiredBiomes ().clear ();
980+ this .build ();
981+ } else {
982+ this .openBiomeSelector (requirements );
983+ }
984+ return true ;
985+ }).build ();
986+ }
987+
988+
989+ /**
990+ * Opens the biome selector for the given island requirements, excluding already-chosen
991+ * biomes, and adds the chosen biomes back to the requirement before rebuilding the panel.
992+ *
993+ * @param requirements the island requirements being edited.
994+ */
995+ private void openBiomeSelector (IslandRequirements requirements ) {
996+ Set <Biome > excluded = requirements .getRequiredBiomes ().stream ()
997+ .map (key -> Registry .BIOME .get (NamespacedKey .fromString (key )))
998+ .filter (Objects ::nonNull ).collect (Collectors .toSet ());
999+
1000+ MultiBiomeSelector .open (this .user , excluded , (status , biomes ) -> {
1001+ if (Boolean .TRUE .equals (status ) && biomes != null ) {
1002+ biomes .forEach (biome -> requirements .getRequiredBiomes ().add (MultiBiomeSelector .biomeKey (biome )));
1003+ }
1004+
1005+ this .build ();
1006+ });
1007+ }
1008+
9841009 /**
9851010 * This method creates buttons for inventory requirements menu.
9861011 *
@@ -1138,7 +1163,7 @@ private PanelItem createInventoryRequirementButton(RequirementButton button) {
11381163 glow = false ;
11391164
11401165 description .add ("" );
1141- description .add (this .user .getTranslation (Constants .TIPS + "click-to-add" ));
1166+ description .add (this .user .getTranslation (Constants .CLICK_TO_ADD ));
11421167 }
11431168 case REMOVE_IGNORED_META -> {
11441169 icon = new ItemStack (Material .RED_SHULKER_BOX );
@@ -1843,7 +1868,7 @@ private PanelItem createRewardButton(RewardButton button) {
18431868 glow = false ;
18441869
18451870 description .add ("" );
1846- description .add (this .user .getTranslation (Constants .TIPS + "click-to-add" ));
1871+ description .add (this .user .getTranslation (Constants .CLICK_TO_ADD ));
18471872 }
18481873 case REMOVE_IGNORED_META -> {
18491874 icon = new ItemStack (Material .RED_SHULKER_BOX );
0 commit comments