@@ -930,46 +930,7 @@ private PanelItem createIslandRequirementButton(RequirementButton button) {
930930 description .add (this .user .getTranslation (Constants .CLICK_TO_CHANGE ));
931931 }
932932 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- }
933+ return this .createBiomeRequirementButton (requirements , reference , name );
973934 }
974935 default -> {
975936 icon = new ItemStack (Material .PAPER );
@@ -981,6 +942,67 @@ private PanelItem createIslandRequirementButton(RequirementButton button) {
981942 .clickHandler (clickHandler ).build ();
982943 }
983944
945+
946+ /**
947+ * Creates the "Required Biomes" button for island challenges. Left-click opens the biome
948+ * selector (hiding already-chosen biomes); right-click clears the list.
949+ *
950+ * @param requirements the island requirements being edited.
951+ * @param reference the translation reference for this button.
952+ * @param name the pre-translated button name.
953+ * @return the PanelItem for the biome requirement button.
954+ */
955+ private PanelItem createBiomeRequirementButton (IslandRequirements requirements , String reference , String name ) {
956+ final List <String > description = new ArrayList <>();
957+
958+ if (requirements .getRequiredBiomes ().isEmpty ()) {
959+ description .add (this .user .getTranslation (reference + "none" ));
960+ } else {
961+ description .add (this .user .getTranslation (reference + Constants .TITLE_KEY ));
962+ requirements .getRequiredBiomes ().forEach (biomeKey -> description .add (
963+ this .user .getTranslation (reference + "list" , "[biome]" , Utils .prettifyBiome (biomeKey ))));
964+ }
965+
966+ description .add ("" );
967+ description .add (this .user .getTranslation (Constants .CLICK_TO_ADD ));
968+
969+ if (!requirements .getRequiredBiomes ().isEmpty ()) {
970+ description .add (this .user .getTranslation (Constants .TIPS + "right-click-to-clear" ));
971+ }
972+
973+ return new PanelItemBuilder ().icon (new ItemStack (Material .GRASS_BLOCK )).name (name ).description (description )
974+ .glow (false ).clickHandler ((panel , user , clickType , slot ) -> {
975+ if (clickType .isRightClick ()) {
976+ requirements .getRequiredBiomes ().clear ();
977+ this .build ();
978+ } else {
979+ this .openBiomeSelector (requirements );
980+ }
981+ return true ;
982+ }).build ();
983+ }
984+
985+
986+ /**
987+ * Opens the biome selector for the given island requirements, excluding already-chosen
988+ * biomes, and adds the chosen biomes back to the requirement before rebuilding the panel.
989+ *
990+ * @param requirements the island requirements being edited.
991+ */
992+ private void openBiomeSelector (IslandRequirements requirements ) {
993+ Set <Biome > excluded = requirements .getRequiredBiomes ().stream ()
994+ .map (key -> Registry .BIOME .get (NamespacedKey .fromString (key )))
995+ .filter (Objects ::nonNull ).collect (Collectors .toSet ());
996+
997+ MultiBiomeSelector .open (this .user , excluded , (status , biomes ) -> {
998+ if (Boolean .TRUE .equals (status ) && biomes != null ) {
999+ biomes .forEach (biome -> requirements .getRequiredBiomes ().add (MultiBiomeSelector .biomeKey (biome )));
1000+ }
1001+
1002+ this .build ();
1003+ });
1004+ }
1005+
9841006 /**
9851007 * This method creates buttons for inventory requirements menu.
9861008 *
@@ -1138,7 +1160,7 @@ private PanelItem createInventoryRequirementButton(RequirementButton button) {
11381160 glow = false ;
11391161
11401162 description .add ("" );
1141- description .add (this .user .getTranslation (Constants .TIPS + "click-to-add" ));
1163+ description .add (this .user .getTranslation (Constants .CLICK_TO_ADD ));
11421164 }
11431165 case REMOVE_IGNORED_META -> {
11441166 icon = new ItemStack (Material .RED_SHULKER_BOX );
@@ -1843,7 +1865,7 @@ private PanelItem createRewardButton(RewardButton button) {
18431865 glow = false ;
18441866
18451867 description .add ("" );
1846- description .add (this .user .getTranslation (Constants .TIPS + "click-to-add" ));
1868+ description .add (this .user .getTranslation (Constants .CLICK_TO_ADD ));
18471869 }
18481870 case REMOVE_IGNORED_META -> {
18491871 icon = new ItemStack (Material .RED_SHULKER_BOX );
0 commit comments