11package me .hsgamer .bettergui .util ;
22
3+ import io .github .projectunified .craftux .common .Position ;
34import me .hsgamer .hscore .common .Validate ;
45
56import java .math .BigDecimal ;
@@ -21,28 +22,35 @@ private SlotUtil() {
2122 }
2223
2324 /**
24- * Get the slots
25+ * Get the position from the settings
2526 *
26- * @param map the value map
27+ * @param map the settings
2728 *
28- * @return the slots
29+ * @return the position
2930 */
30- public static IntStream getSlots (Map <String , Object > map ) {
31- IntStream slots = IntStream .empty ();
32-
31+ public static Optional <Position > getPosition (Map <String , Object > map ) {
3332 if (map .containsKey (POS_X ) || map .containsKey (POS_Y )) {
3433 Optional <Integer > x = Validate .getNumber (String .valueOf (map .get (POS_X ))).map (BigDecimal ::intValue );
3534 Optional <Integer > y = Validate .getNumber (String .valueOf (map .get (POS_Y ))).map (BigDecimal ::intValue );
3635 if (x .isPresent () && y .isPresent ()) {
37- slots = IntStream .of (( y .get () - 1 ) * 9 + x .get () - 1 );
36+ return Optional .of (Position . of ( x .get (), y .get ()) );
3837 }
3938 }
39+ return Optional .empty ();
40+ }
4041
42+ /**
43+ * Get the slots from the settings
44+ *
45+ * @param map the settings
46+ *
47+ * @return the slots
48+ */
49+ public static IntStream getSlot (Map <String , Object > map ) {
4150 if (map .containsKey (POS_SLOT )) {
42- slots = IntStream . concat ( slots , generateSlots (String .valueOf (map .get (POS_SLOT ) )));
51+ return generateSlots (String .valueOf (map .get (POS_SLOT )));
4352 }
44-
45- return slots ;
53+ return IntStream .empty ();
4654 }
4755
4856 /**
0 commit comments