mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-18 00:46:55 +01:00
Added documentation / explanation for the ServerLoadEvent
This commit is contained in:
parent
111f5462fc
commit
68fa793354
@ -1,6 +1,7 @@
|
|||||||
package me.clip.placeholderapi;
|
package me.clip.placeholderapi;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -8,20 +9,29 @@ import org.bukkit.event.server.ServerLoadEvent;
|
|||||||
|
|
||||||
public class ServerLoadEventListener implements Listener {
|
public class ServerLoadEventListener implements Listener {
|
||||||
|
|
||||||
private PlaceholderAPIPlugin plugin;
|
private PlaceholderAPIPlugin plugin;
|
||||||
|
|
||||||
public ServerLoadEventListener(PlaceholderAPIPlugin instance) {
|
public ServerLoadEventListener(PlaceholderAPIPlugin instance) {
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
Bukkit.getPluginManager().registerEvents(this, instance);
|
Bukkit.getPluginManager().registerEvents(this, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
/**
|
||||||
public void onServerLoad(ServerLoadEvent e) {
|
* This method will be called when the server is first loaded
|
||||||
plugin.getLogger().info("Placeholder expansion registration initializing...");
|
*
|
||||||
final Map<String, PlaceholderHook> alreadyRegistered = PlaceholderAPI.getPlaceholders();
|
* The goal of the method is to register all the expansions as soon as possible
|
||||||
plugin.getExpansionManager().registerAllExpansions();
|
* especially before players can join
|
||||||
if (alreadyRegistered != null && !alreadyRegistered.isEmpty()) {
|
*
|
||||||
alreadyRegistered.forEach(PlaceholderAPI::registerPlaceholderHook);
|
* This will ensure no issues with expanions and hooks.
|
||||||
|
* @param e the server load event
|
||||||
|
*/
|
||||||
|
@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.forEach(PlaceholderAPI::registerPlaceholderHook);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user