updated LocalExpansionManager to accept a command sender to notify of load completion details

This commit is contained in:
Sxtanna 2020-07-24 19:02:17 -04:00
parent 00ced0495d
commit 50cee40531
4 changed files with 13 additions and 12 deletions

View File

@ -28,7 +28,6 @@ import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
import me.clip.placeholderapi.updatechecker.UpdateChecker;
import me.clip.placeholderapi.util.Msg;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -128,7 +127,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
reloadConfig();
getLocalExpansionManager().load();
getLocalExpansionManager().load(sender);
if (config.isCloudEnabled())
{
@ -138,9 +137,6 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
{
getCloudExpansionManager().kill();
}
Msg.msg(sender,
getLocalExpansionManager().getIdentifiers().size() + " &aplaceholder hooks successfully registered!");
}
@ -232,7 +228,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin
}
catch (final ExceptionInInitializerError | ClassNotFoundException ignored)
{
Bukkit.getScheduler().runTaskLater(this, getLocalExpansionManager()::load, 1);
Bukkit.getScheduler().runTaskLater(this, () -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1);
}
}

View File

@ -21,7 +21,6 @@ public final class CommandReload extends PlaceholderCommand
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, @NotNull final CommandSender sender, @NotNull final String alias, @NotNull @Unmodifiable final List<String> params)
{
plugin.reloadConf(sender);
Msg.msg(sender, "&fPlaceholder&7API &bconfiguration reloaded!");
}
}

View File

@ -13,7 +13,9 @@ import me.clip.placeholderapi.expansion.Taskable;
import me.clip.placeholderapi.expansion.VersionSpecific;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.util.FileUtil;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -63,9 +65,9 @@ public final class LocalExpansionManager implements Listener
}
}
public void load()
public void load(@NotNull final CommandSender sender)
{
registerAll();
registerAll(sender);
}
public void kill()
@ -266,7 +268,7 @@ public final class LocalExpansionManager implements Listener
}
private void registerAll()
private void registerAll(@NotNull final CommandSender sender)
{
plugin.getLogger().info("Placeholder expansion registration initializing...");
@ -277,7 +279,11 @@ public final class LocalExpansionManager implements Listener
return;
}
Bukkit.getScheduler().runTask(plugin, () -> classes.forEach(this::register));
Bukkit.getScheduler().runTask(plugin, () -> {
final long registered = classes.stream().map(this::register).filter(Optional::isPresent).count();
Msg.msg(sender,
registered == 0 ? "&6No expansions were registered!" : registered + "&a placeholder hooks successfully registered!");
});
});
}

View File

@ -55,7 +55,7 @@ public final class ServerLoadEventListener implements Listener
public void onServerLoad(@NotNull final ServerLoadEvent event)
{
HandlerList.unregisterAll(this);
plugin.getLocalExpansionManager().load();
plugin.getLocalExpansionManager().load(Bukkit.getConsoleSender());
}
}