Skip to content

Commit bd370a1

Browse files
committed
Implemented %server_variant%
1 parent d1eb946 commit bd370a1

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.extendedclip.papi.expansion.server</groupId>
44
<artifactId>server-expansion</artifactId>
5-
<version>2.4.0</version>
5+
<version>2.5.0</version>
66
<name>PAPI-Expansion-Server</name>
77
<description>PlaceholderAPI expansion for server placeholders</description>
88

@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>org.spigotmc</groupId>
2323
<artifactId>spigot-api</artifactId>
24-
<version>1.16.3-R0.1-SNAPSHOT</version>
24+
<version>1.16.4-R0.1-SNAPSHOT</version>
2525
<scope>provided</scope>
2626
</dependency>
2727
<dependency>

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class ServerExpansion extends PlaceholderExpansion implements Cacheable,
5454
private String low = "&c";
5555
private String medium = "&e";
5656
private String high = "&a";
57+
private String variant;
5758

5859
private final String VERSION = getClass().getPackage().getImplementationVersion();
5960

@@ -62,6 +63,7 @@ public ServerExpansion() {
6263
version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
6364
craftServer = Class.forName("net.minecraft.server." + version + ".MinecraftServer").getMethod("getServer").invoke(null);
6465
tps = craftServer.getClass().getField("recentTps");
66+
variant = initializeVariant();
6567
} catch (Exception e) {
6668
e.printStackTrace();
6769
}
@@ -99,6 +101,30 @@ public String getVersion() {
99101
return VERSION;
100102
}
101103

104+
public String initializeVariant() {
105+
try {
106+
Class.forName("net.pl3x.purpur.PurpurConfig");
107+
return "Purpur";
108+
} catch (ClassNotFoundException e) {
109+
try {
110+
Class.forName("com.tuinity.tuinity.config.TuinityConfig");
111+
return "Tuinity";
112+
} catch (ClassNotFoundException e1) {
113+
try {
114+
Class.forName("com.destroystokyo.paper.PaperConfig");
115+
return "Paper";
116+
} catch (ClassNotFoundException e2) {
117+
try {
118+
Class.forName("org.spigotmc.SpigotConfig");
119+
return "Spigot";
120+
} catch (ClassNotFoundException e3) {
121+
return "Unknown";
122+
}
123+
}
124+
}
125+
}
126+
}
127+
102128
@Override
103129
public Map<String, Object> getDefaults() {
104130
final Map<String, Object> defaults = new HashMap<>();
@@ -115,6 +141,8 @@ public String onRequest(OfflinePlayer p, String identifier) {
115141
switch (identifier) {
116142
case "name":
117143
return serverName == null ? "" : serverName;
144+
case "variant":
145+
return variant;
118146
case "tps":
119147
return getTps(null);
120148
case "online":

0 commit comments

Comments
 (0)