1313import org .bukkit .Material ;
1414import org .bukkit .NamespacedKey ;
1515import org .bukkit .Registry ;
16+ import org .bukkit .Tag ;
1617import org .bukkit .World ;
1718import org .bukkit .event .inventory .ClickType ;
1819import org .bukkit .inventory .ItemStack ;
1920
2021import com .google .common .base .Enums ;
2122
23+ import world .bentobox .bentobox .BentoBox ;
2224import world .bentobox .bentobox .api .localization .TextVariables ;
2325import world .bentobox .bentobox .api .panels .PanelItem ;
2426import world .bentobox .bentobox .api .panels .TemplatedPanel ;
@@ -134,11 +136,12 @@ private ValuePanel(Level addon,
134136
135137 this .activeFilter = Filter .NAME_ASC ;
136138
137- addon .getBlockConfig ().getBlockValues ().entrySet ().stream ().filter (en -> this .getIcon (en .getKey ()) != null )
138- .filter (en -> addon .getBlockConfig ().isNotHiddenBlock (en .getKey ()))
139- .forEach (en -> blockRecordList
140- .add (new BlockRecord (en .getKey (), Objects .requireNonNullElse (en .getValue (), 0 ),
141- Objects .requireNonNullElse (addon .getBlockConfig ().getLimit (en .getKey ()), 0 ))));
139+ addon .getBlockConfig ().getBlockValues ().entrySet ().stream ()
140+ .filter (en -> this .getIcon (en .getKey ()) != null )
141+ .filter (en -> addon .getBlockConfig ().isNotHiddenBlock (en .getKey ()))
142+ .forEach (en -> blockRecordList
143+ .add (new BlockRecord (en .getKey (), Objects .requireNonNullElse (en .getValue (), 0 ),
144+ Objects .requireNonNullElse (addon .getBlockConfig ().getLimit (en .getKey ()), 0 ))));
142145
143146 this .elementList = new ArrayList <>();
144147 this .searchText = "" ;
@@ -649,7 +652,7 @@ private PanelItem createMaterialButton(ItemTemplateRecord template, TemplatedPan
649652 {
650653 if (this .elementList .isEmpty ())
651654 {
652- // Does not contain any generators .
655+ // Does not contain any.
653656 return null ;
654657 }
655658
@@ -665,16 +668,71 @@ private PanelItem createMaterialButton(ItemTemplateRecord template, TemplatedPan
665668 }
666669
667670 private Material getIcon (String key ) {
671+ // Filter out some names
672+ key = key .replaceAll ("wall_" , "" );
673+ key = key .replaceAll ("_hanging" , "" );
668674 Material icon = Registry .MATERIAL .get (NamespacedKey .fromString (key ));
669675 if (icon == null && key .endsWith ("_spawner" )) {
670676 icon = Registry .MATERIAL .get (NamespacedKey .fromString (key .substring (0 , key .length () - 2 ) + "_egg" ));
671677 }
678+ // ItemsAdder
672679 if (icon == null && addon .isItemsAdder () && ItemsAdderHook .isInRegistry (key )) {
673680 icon = ItemsAdderHook .getItemStack (key ).map (ItemStack ::getType ).orElse (null );
674681 }
675682 if (icon != null && icon .isItem ()) {
676683 return icon ;
677684 }
685+ // Not an item, but maybe still something
686+ if (icon != null ) {
687+ switch (icon ) {
688+ case BUBBLE_COLUMN : return Material .WATER_BUCKET ;
689+ case NETHER_PORTAL : return Material .PURPLE_STAINED_GLASS_PANE ;
690+ case END_GATEWAY : return Material .BLACK_STAINED_GLASS_PANE ;
691+ case END_PORTAL : return Material .BLACK_STAINED_GLASS_PANE ;
692+ case SOUL_FIRE : return Material .SOUL_TORCH ;
693+ case WALL_TORCH : return Material .TORCH ;
694+ case TWISTING_VINES_PLANT : return Material .VINE ;
695+ case CAVE_VINES_PLANT : return Material .VINE ;
696+ case BAMBOO_SAPLING : return Material .BAMBOO ;
697+ case KELP_PLANT : return Material .KELP ;
698+ case SWEET_BERRY_BUSH : return Material .SWEET_BERRIES ;
699+ case LAVA , FIRE : return Material .LAVA_BUCKET ;
700+ case PISTON_HEAD : return Material .PISTON ;
701+ case REDSTONE_WIRE : return Material .REDSTONE ;
702+ case TORCHFLOWER_CROP : return Material .TORCHFLOWER_SEEDS ;
703+ case TALL_SEAGRASS : return Material .SEAGRASS ;
704+ case WATER : return Material .WATER_BUCKET ;
705+ case VOID_AIR : return Material .BARRIER ;
706+ case COCOA : return Material .COCOA_BEANS ;
707+ case TRIPWIRE : return Material .TRIPWIRE_HOOK ;
708+ case BEETROOTS : return Material .BEETROOT_SEEDS ;
709+ case POTATOES : return Material .POTATO ;
710+ case CARROTS : return Material .CARROT ;
711+ case PITCHER_CROP : return Material .PITCHER_POD ;
712+ case BIG_DRIPLEAF_STEM : return Material .BIG_DRIPLEAF ;
713+ default : {}
714+ }
715+ if (Tag .FLOWER_POTS .isTagged (icon )) {
716+ return Material .FLOWER_POT ;
717+ }
718+ if (Tag .WALL_SIGNS .isTagged (icon ) || Tag .ALL_HANGING_SIGNS .isTagged (icon )) {
719+ return Material .OAK_SIGN ;
720+ }
721+ if (Tag .CANDLE_CAKES .isTagged (icon )) {
722+ return Material .CAKE ;
723+ }
724+ if (Tag .CAULDRONS .isTagged (icon )) {
725+ return Material .CAULDRON ;
726+ }
727+ if (Tag .ICE .isTagged (icon )) {
728+ return Material .ICE ;
729+ }
730+
731+ }
732+ // Try Oraxen
733+ if (key .startsWith ("oraxen:" ) && BentoBox .getInstance ().getHooks ().getHook ("Oraxen" ).isPresent ()) {
734+ return Material .PAPER ;
735+ }
678736 return null ;
679737 }
680738
@@ -702,13 +760,15 @@ private PanelItem createMaterialButton(ItemTemplateRecord template, BlockRecord
702760 String .valueOf (blockValue ));
703761 String limitTranslation = blockLimit > 0
704762 ? this .user .getTranslationOrNothing (baseKey + "limit" , TextVariables .NUMBER , String .valueOf (blockLimit ))
705- : "" ;
763+ : "" ;
706764
707765 // Determine icon and display material text
708766 Material icon = getIcon (key );
709767 builder .icon ((icon == null || icon == Material .AIR ) ? Material .PAPER : icon );
710-
711- String displayMaterial = (icon == null ) ? Util .prettifyText (key ) : Utils .prettifyObject (icon , user );
768+ if (key .startsWith ("oraxen:" )) {
769+ key = key .substring (7 );
770+ }
771+ String displayMaterial = (icon == null ) ? Util .prettifyText (key ) : Utils .prettifyObject (key , user );
712772 // Special handling for spawn eggs
713773 if (icon != null && icon .name ().endsWith ("_SPAWN_EGG" )) {
714774 displayMaterial = Util .prettifyText (key );
0 commit comments