forked from Solara-Development/Neptune
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlaceholderManager.java
More file actions
46 lines (38 loc) · 1.34 KB
/
PlaceholderManager.java
File metadata and controls
46 lines (38 loc) · 1.34 KB
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
package dev.lrxh.neptune.providers.placeholder;
import dev.lrxh.neptune.providers.placeholder.impl.*;
import org.bukkit.OfflinePlayer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class PlaceholderManager {
private static PlaceholderManager instance;
private final List<PAPIPlaceholder> placeholders;
public PlaceholderManager() {
this.placeholders = new ArrayList<>();
placeholders.addAll(Arrays.asList(
new GlobalPlaceholders(),
new KitPlaceholders(),
new LastKitPlaceholder(),
new LeaderboardPlaceholder(),
new MatchPlaceholders(),
new PartyPlaceholders(),
new PlayerPlaceholders(),
new RecentMatchPlaceholder(),
new TimePlaceholder()
));
}
public static PlaceholderManager get() {
if (instance == null) instance = new PlaceholderManager();
return instance;
}
public String parse(OfflinePlayer player, String text) {
for (PAPIPlaceholder placeholder : placeholders) {
if (placeholder.match(text)) {
String parsed = placeholder.parse(player, text);
if (parsed == null) continue;
text = parsed;
}
}
return text;
}
}