Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit aa4afed

Browse files
committed
worldmod placeholderapi
1 parent d06f2d7 commit aa4afed

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

src/spigot/main/java/com/ampznetwork/chatmod/spigot/ChatMod$Spigot.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
@Slf4j(topic = ChatMod.Strings.AddonName)
4242
public class ChatMod$Spigot extends SubMod$Spigot implements ChatMod, ModuleContainerCore {
4343
private final @lombok.experimental.Delegate Container $delegate = new Container.Base();
44-
private final TextResourceProvider textResourceProvider = new TextResourceProvider(this);
44+
private final TextResourceProvider textResourceProvider = new TextResourceProvider(
45+
this);
4546
private ChatMessageFormatter formatter;
46-
private boolean hasPlaceholderApi;
47-
private List<Channel> channels;
47+
private List<Channel> channels;
4848

4949
public ChatMod$Spigot() {
5050
super(Set.of(), Set.of());
@@ -65,9 +65,17 @@ public ChatModules getChatModules() {
6565

6666
var modules = config.getConfigurationSection("modules");
6767
condElement(LogProviderConfig::builder, modules, "log", (bld, cfg) -> {}, caps::log);
68-
condElement(MinecraftProviderConfig::builder, modules, "minecraft", YmlConfigHelper::minecraft, caps::minecraft);
68+
condElement(MinecraftProviderConfig::builder,
69+
modules,
70+
"minecraft",
71+
YmlConfigHelper::minecraft,
72+
caps::minecraft);
6973
condElement(NativeProviderConfig::builder, modules, "rabbitmq", YmlConfigHelper::rabbitmq, caps::rabbitmq);
70-
condElement(AurionChatProviderConfig::builder, modules, "aurionchat", YmlConfigHelper::rabbitmq, caps::aurionchat);
74+
condElement(AurionChatProviderConfig::builder,
75+
modules,
76+
"aurionchat",
77+
YmlConfigHelper::rabbitmq,
78+
caps::aurionchat);
7179
condElement(DiscordProviderConfig::builder, modules, "discord", YmlConfigHelper::discord, caps::discord);
7280

7381
return caps.build();
@@ -101,7 +109,9 @@ public TextResourceProvider text() {
101109
@Override
102110
public String applyPlaceholderApi(UUID playerId, String input) {
103111
var player = getServer().getOfflinePlayer(playerId);
104-
return hasPlaceholderApi ? PlaceholderAPI.setPlaceholders(player, input) : ChatMod.super.applyPlaceholderApi(playerId, input);
112+
return lib.isPlaceholderApiPresent()
113+
? PlaceholderAPI.setPlaceholders(player, input)
114+
: ChatMod.super.applyPlaceholderApi(playerId, input);
105115
}
106116

107117
@Override
@@ -115,8 +125,6 @@ public void onLoad() {
115125
cmdr.register(this);
116126

117127
super.onLoad();
118-
119-
hasPlaceholderApi = getServer().getPluginManager().getPlugin("PlaceholderAPI") != null;
120128
}
121129

122130
@Override
@@ -130,7 +138,8 @@ public void onEnable() {
130138
public @NotNull TextComponent reload() {
131139
reloadConfig();
132140

133-
this.formatter = ChatMessageFormatter.of(Polyfill.<MemorySection>uncheckedCast(getConfig().get("formatting")).getValues(true));
141+
this.formatter = ChatMessageFormatter.of(Polyfill.<MemorySection>uncheckedCast(getConfig().get("formatting"))
142+
.getValues(true));
134143

135144
// reload channels
136145
reloadChannels();
@@ -149,8 +158,12 @@ private void reloadChannels() {
149158
if (channels != null) {
150159
// save user subscriptions
151160
channels.forEach(channel -> {
152-
channel.getPlayerIDs().forEach(id -> players.computeIfAbsent(channel.getName(), ($0) -> new HashMap<>()).computeIfAbsent(id, $1 -> false));
153-
channel.getSpyIDs().forEach(id -> players.computeIfAbsent(channel.getName(), ($0) -> new HashMap<>()).computeIfAbsent(id, $1 -> true));
161+
channel.getPlayerIDs()
162+
.forEach(id -> players.computeIfAbsent(channel.getName(), ($0) -> new HashMap<>())
163+
.computeIfAbsent(id, $1 -> false));
164+
channel.getSpyIDs()
165+
.forEach(id -> players.computeIfAbsent(channel.getName(), ($0) -> new HashMap<>())
166+
.computeIfAbsent(id, $1 -> true));
154167
});
155168

156169
channels.clear();
@@ -184,7 +197,11 @@ private List<Channel> loadChannels() {
184197

185198
var channels = new ArrayList<Channel>();
186199
for (var channelName : config.getKeys(false))
187-
condElement(Channel::builder, config, channelName, YmlConfigHelper::channel, it -> channels.add((Channel) it));
200+
condElement(Channel::builder,
201+
config,
202+
channelName,
203+
YmlConfigHelper::channel,
204+
it -> channels.add((Channel) it));
188205

189206
return channels;
190207
}

0 commit comments

Comments
 (0)