-
Notifications
You must be signed in to change notification settings - Fork 4
/
PlaceholderAPI.java
54 lines (44 loc) · 1.5 KB
/
PlaceholderAPI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import xyz.derkades.ssx_connector.Addon;
public class PlaceholderAPI extends Addon {
@Override
public String getAuthor() {
return "Derkades";
}
@Override
public String getDescription() {
return "Send PlaceholderAPI placeholders as ServerSelectorX placeholders";
}
@Override
public String getLicense() {
return "MIT";
}
@Override
public String getVersion() {
return "1.1.1";
}
@Override
public void onLoad() {
if (config == null) {
System.err.println("Config was not loaded");
return;
}
if (config.isConfigurationSection("global")) {
final ConfigurationSection global = this.config.getConfigurationSection("global");
for (final String key : global.getKeys(false)) {
addPlaceholder(key, () -> me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(null, "%" + global.getString(key) + "%"));
}
} else {
System.err.println("Global placeholders configuration section missing");
}
if (config.isConfigurationSection("player")) {
final ConfigurationSection player = this.config.getConfigurationSection("player");
for (final String key : player.getKeys(false)) {
addPlayerPlaceholder(key, (uuid, name) -> me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(Bukkit.getOfflinePlayer(uuid), "%" + player.getString(key) + "%"));
}
} else {
System.err.println("Global placeholders configuration section missing");
}
}
}