mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-18 00:46:55 +01:00
Possible solution for placeholders that register externally before PlaceholderAPI registers expansions
This commit is contained in:
parent
5386b7c23d
commit
a2d408aea9
@ -140,7 +140,14 @@ public class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
@Override
|
||||
public void run() {
|
||||
getLogger().info("Placeholder expansion registration initializing...");
|
||||
//fetch any hooks that may have registered externally onEnable first otherwise they will be lost
|
||||
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
|
||||
getExpansionManager().registerAllExpansions();
|
||||
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
|
||||
alreadyRegistered.entrySet().stream().forEach(hook -> {
|
||||
PlaceholderAPI.registerPlaceholderHook(hook.getKey(), hook.getValue());
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 20*15);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.clip.placeholderapi;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -17,6 +18,12 @@ public class ServerLoadEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onServerLoad(ServerLoadEvent e) {
|
||||
plugin.getLogger().info("Placeholder expansion registration initializing...");
|
||||
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
|
||||
plugin.getExpansionManager().registerAllExpansions();
|
||||
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
|
||||
alreadyRegistered.entrySet().stream().forEach(hook -> {
|
||||
PlaceholderAPI.registerPlaceholderHook(hook.getKey(), hook.getValue());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user