Skip to content

Commit cfb2910

Browse files
committed
fix build placeholders
1 parent 68d6ab4 commit cfb2910

1 file changed

Lines changed: 25 additions & 20 deletions

File tree

src/main/java/com/extendedclip/papi/expansion/server/ServerUtils.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,50 @@
22

33
import org.bukkit.Bukkit;
44

5+
import java.util.LinkedHashMap;
6+
import java.util.Map;
7+
58
public final class ServerUtils {
69

710
public static final String VERSION = Bukkit.getBukkitVersion().split("-")[0];
811
public static final String BUILD;
912

1013
static {
14+
boolean isPaper = false;
15+
16+
try {
17+
Class.forName("com.destroystokyo.paper.PaperConfig");
18+
isPaper = true;
19+
} catch (ClassNotFoundException ignored) { }
20+
1121
String[] buildParts = Bukkit.getVersion().split("-");
1222

1323
if (buildParts.length >= 3) {
14-
BUILD = buildParts[2];
24+
BUILD = isPaper ? buildParts[2] : buildParts[0];
1525
} else {
1626
BUILD = "UNKNOWN";
1727
}
1828
}
1929

2030
private ServerUtils() { }
2131

32+
@SuppressWarnings("SpellCheckingInspection")
2233
public static String getServerVariant() {
23-
try {
24-
Class.forName("net.pl3x.purpur.PurpurConfig");
25-
return "Purpur";
26-
} catch (ClassNotFoundException e) {
34+
final Map<String, String> variants = new LinkedHashMap<>();
35+
variants.put("Purpur", "net.pl3x.purpur.PurpurConfig");
36+
variants.put("Airplane", "gg.airplane.AirplaneConfig");
37+
variants.put("Tuinity", "com.tuinity.tuinity.config.TuinityConfig");
38+
variants.put("Paper", "com.destroystokyo.paper.PaperConfig");
39+
variants.put("Spigot", "org.spigotmc.SpigotConfig");
40+
41+
for (Map.Entry<String, String> variant : variants.entrySet()) {
2742
try {
28-
Class.forName("com.tuinity.tuinity.config.TuinityConfig");
29-
return "Tuinity";
30-
} catch (ClassNotFoundException e1) {
31-
try {
32-
Class.forName("com.destroystokyo.paper.PaperConfig");
33-
return "Paper";
34-
} catch (ClassNotFoundException e2) {
35-
try {
36-
Class.forName("org.spigotmc.SpigotConfig");
37-
return "Spigot";
38-
} catch (ClassNotFoundException e3) {
39-
return "Unknown";
40-
}
41-
}
42-
}
43+
Class.forName(variant.getValue());
44+
return variant.getKey();
45+
} catch (ClassNotFoundException ignored) { }
4346
}
47+
48+
return "Unknown";
4449
}
4550

4651
}

0 commit comments

Comments
 (0)