@@ -38,7 +38,10 @@ private FitsInRemover() {}
3838
3939 public static void apply (List <Component > tooltip ) {
4040 String mode = Config .GEM_TOOLTIP_MODE .get ();
41- if ("full" .equalsIgnoreCase (mode )) return ;
41+ if ("full" .equalsIgnoreCase (mode )) {
42+ applyFullCategoryFilter (tooltip );
43+ return ;
44+ }
4245
4346 boolean hidden = "hidden" .equalsIgnoreCase (mode );
4447 boolean compact = "compact" .equalsIgnoreCase (mode );
@@ -71,17 +74,45 @@ public static void apply(List<Component> tooltip) {
7174
7275 if (isFits ) {
7376 if (ultra ) {
74- List <String > names = sortByGroup (extractCategoryNames (tooltip , i + 1 , afterBullets ));
77+ List <String > names = sortByGroup (filterHidden ( extractCategoryNames (tooltip , i + 1 , afterBullets ) ));
7578 removeRange (tooltip , i , afterBullets );
7679 if (!names .isEmpty ()) {
7780 tooltip .add (i , joinedCategoryBullet (String .join (", " , names )));
7881 i ++;
7982 }
8083 continue ;
8184 }
82- // compact: replace the header with a plain teal "Fits in:" line, leave category bullets below.
85+ // compact: replace the header with a plain teal "Fits in:" line, then drop any
86+ // hidden categories from the bullets below it.
8387 tooltip .set (i , fitsInHeaderBullet ());
88+ int headerIndex = i ;
8489 i ++;
90+ int bulletIndex = i ;
91+ while (bulletIndex < afterBullets
92+ && TooltipMatcher .keyStartsWith (tooltip .get (bulletIndex ), "text.apotheosis.dot_prefix" )) {
93+ String inner = extractBulletText (tooltip .get (bulletIndex ));
94+ if (inner == null || inner .isEmpty ()) {
95+ bulletIndex ++;
96+ continue ;
97+ }
98+ List <String > names = splitCategories (inner );
99+ List <String > kept = filterHidden (names );
100+ if (kept .size () == names .size ()) {
101+ bulletIndex ++;
102+ } else if (kept .isEmpty ()) {
103+ tooltip .remove (bulletIndex );
104+ afterBullets --;
105+ } else {
106+ tooltip .set (bulletIndex , categoryBullet (String .join (", " , kept )));
107+ bulletIndex ++;
108+ }
109+ }
110+ // Every category bullet filtered out leaves the header with nothing below it; drop it.
111+ if (headerIndex + 1 >= tooltip .size ()
112+ || !TooltipMatcher .keyStartsWith (tooltip .get (headerIndex + 1 ), "text.apotheosis.dot_prefix" )) {
113+ tooltip .remove (headerIndex );
114+ i --;
115+ }
85116 continue ;
86117 }
87118
@@ -118,6 +149,59 @@ public static void apply(List<Component> tooltip) {
118149 cleanupOrphanBlanks (tooltip );
119150 }
120151
152+ // Full mode preserves Apoth's native gem layout, so we only filter the Fits In category list
153+ // and leave everything else (header text, bonus block, blank lines) untouched.
154+ private static void applyFullCategoryFilter (List <Component > tooltip ) {
155+ List <? extends String > hiddenCategories = Config .HIDDEN_GEM_CATEGORIES .get ();
156+ if (hiddenCategories == null || hiddenCategories .isEmpty ()) return ;
157+
158+ int i = 0 ;
159+ while (i < tooltip .size ()) {
160+ String key = TooltipMatcher .getKey (tooltip .get (i ));
161+ boolean isFits = key != null
162+ && (key .startsWith ("text.apotheosis.socketable_into" ) || key .startsWith ("text.apotheosis.fits_in" ));
163+ if (!isFits ) {
164+ i ++;
165+ continue ;
166+ }
167+
168+ int headerIndex = i ;
169+ int bulletIndex = i + 1 ;
170+ int afterBullets = bulletIndex ;
171+ while (afterBullets < tooltip .size ()
172+ && TooltipMatcher .keyStartsWith (tooltip .get (afterBullets ), "text.apotheosis.dot_prefix" )) {
173+ afterBullets ++;
174+ }
175+
176+ while (bulletIndex < afterBullets ) {
177+ String inner = extractBulletText (tooltip .get (bulletIndex ));
178+ if (inner == null || inner .isEmpty ()) {
179+ bulletIndex ++;
180+ continue ;
181+ }
182+ List <String > names = splitCategories (inner );
183+ List <String > kept = filterHidden (names );
184+ if (kept .size () == names .size ()) {
185+ bulletIndex ++;
186+ } else if (kept .isEmpty ()) {
187+ tooltip .remove (bulletIndex );
188+ afterBullets --;
189+ } else {
190+ tooltip .set (bulletIndex , categoryBullet (String .join (", " , kept )));
191+ bulletIndex ++;
192+ }
193+ }
194+
195+ if (headerIndex + 1 >= tooltip .size ()
196+ || !TooltipMatcher .keyStartsWith (tooltip .get (headerIndex + 1 ), "text.apotheosis.dot_prefix" )) {
197+ tooltip .remove (headerIndex );
198+ i = headerIndex ;
199+ } else {
200+ i = afterBullets ;
201+ }
202+ }
203+ }
204+
121205 private static Component joinedCategoryBullet (String text ) {
122206 return Component .translatable ("text.apotheosis.dot_prefix" ,
123207 Component .literal ("Fits in: " + text ))
@@ -176,14 +260,42 @@ private static List<String> extractCategoryNames(List<Component> tooltip, int fr
176260 for (int k = from ; k < toExclusive ; k ++) {
177261 String inner = extractBulletText (tooltip .get (k ));
178262 if (inner == null || inner .isEmpty ()) continue ;
179- for (String part : inner .split ("," )) {
180- String trimmed = part .trim ();
181- if (!trimmed .isEmpty ()) names .add (trimmed );
182- }
263+ names .addAll (splitCategories (inner ));
183264 }
184265 return names ;
185266 }
186267
268+ // Splits a category bullet's inner text ("Swords, Bows, ...") into trimmed, non-empty names.
269+ private static List <String > splitCategories (String inner ) {
270+ List <String > names = new ArrayList <>();
271+ for (String part : inner .split ("," )) {
272+ String trimmed = part .trim ();
273+ if (!trimmed .isEmpty ()) names .add (trimmed );
274+ }
275+ return names ;
276+ }
277+
278+ // Drops any category names listed in the hidden_gem_categories config, case-insensitively.
279+ private static List <String > filterHidden (List <String > categories ) {
280+ List <? extends String > hidden = Config .HIDDEN_GEM_CATEGORIES .get ();
281+ if (hidden == null || hidden .isEmpty ()) return categories ;
282+ Set <String > hiddenSet = new TreeSet <>(String .CASE_INSENSITIVE_ORDER );
283+ hiddenSet .addAll (hidden );
284+ List <String > filtered = new ArrayList <>(categories .size ());
285+ for (String name : categories ) {
286+ if (!hiddenSet .contains (name )) filtered .add (name );
287+ }
288+ return filtered ;
289+ }
290+
291+ // Rebuilds a Fits-In category bullet after hidden categories are dropped, preserving the teal
292+ // styling Apoth uses natively. Used by compact mode (after the synthesized header) and full mode
293+ // (under Apoth's original header).
294+ private static Component categoryBullet (String text ) {
295+ return Component .translatable ("text.apotheosis.dot_prefix" , Component .literal (text ))
296+ .withStyle (Style .EMPTY .withColor (FITS_IN_COLOR ));
297+ }
298+
187299 private static void stripUnique (List <Component > tooltip ) {
188300 int j = 0 ;
189301 while (j < tooltip .size ()) {
0 commit comments