Skip to content

Commit 06182a0

Browse files
committed
use Validate#getNumber to support any type of number as slot
1 parent d16c190 commit 06182a0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/me/hsgamer/bettergui/util/SlotUtil.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.hsgamer.bettergui.util;
22

3+
import me.hsgamer.hscore.common.Validate;
4+
5+
import java.math.BigDecimal;
36
import java.util.*;
47
import java.util.regex.Matcher;
58
import java.util.regex.Pattern;
@@ -69,10 +72,9 @@ public static Stream<Integer> generateSlots(String input) {
6972
}
7073
}
7174

72-
try {
73-
return Stream.of(Integer.parseInt(input));
74-
} catch (Exception ignored) {
75-
return Stream.empty();
76-
}
75+
return Validate.getNumber(input)
76+
.map(BigDecimal::intValue)
77+
.map(Stream::of)
78+
.orElseGet(Stream::empty);
7779
}
7880
}

0 commit comments

Comments
 (0)