11package com .elikill58 .negativity .spigot ;
22
3- import java . util . concurrent . Callable ;
3+ import com . elikill58 . negativity . universal . utils . ReflectionUtils ;
44
55public enum SubPlatform {
66
7- CRAFTBUKKIT ("CraftBukkit" , () -> {
8- try {
9- Class .forName ("org.spigotmc.SpigotConfig" );
10- return false ;
11- } catch (ClassNotFoundException e ) {
12- return true ;
13- }
14- }),
15- SPIGOT ("Spigot" , () -> false ),
16- FOLIA ("Folia" , () -> {
17- try {
18- Class .forName ("io.papermc.paper.threadedregions.RegionizedServer" );
19- return true ;
20- } catch (ClassNotFoundException e ) {}
21- return false ;
22- }),
23- PAPER ("Paper" , () -> {
24- try {
25- Class .forName ("com.destroystokyo.paper.PaperVersionFetcher" );
26- return true ;
27- } catch (ClassNotFoundException e ) {}
28- return false ;
29- }),
30- MOHIST ("Mohist" , () -> {
31- try {
32- Class .forName ("com.mohistmc.MohistMC" );
33- return true ;
34- } catch (ClassNotFoundException e ) {}
35- return false ;
36- });
7+ CRAFTBUKKIT ("CraftBukkit" , ReflectionUtils .isClassExist ("org.spigotmc.SpigotConfig" )),
8+ SPIGOT ("Spigot" , false ),
9+ FOLIA ("Folia" , ReflectionUtils .isClassExist ("io.papermc.paper.threadedregions.RegionizedServer" )),
10+ PAPER ("Paper" , ReflectionUtils .isClassExist ("com.destroystokyo.paper.PaperVersionFetcher" )),
11+ MOHIST ("Mohist" , ReflectionUtils .isClassExist ("com.mohistmc.MohistMC" ));
3712
3813 private final String name ;
39- private final Callable < Boolean > isThis ;
14+ private final boolean isThis ;
4015
41- private SubPlatform (String name , Callable < Boolean > isThis ) {
16+ private SubPlatform (String name , boolean isThis ) {
4217 this .name = name ;
4318 this .isThis = isThis ;
4419 }
@@ -48,12 +23,7 @@ public String getName() {
4823 }
4924
5025 public boolean isThis () {
51- try {
52- return isThis != null && isThis .call ();
53- } catch (Exception e ) {
54- e .printStackTrace ();
55- return false ;
56- }
26+ return isThis ;
5727 }
5828
5929 public static SubPlatform getSubPlatform () {
0 commit comments