use of net.glowstone.util.linkstone.LinkstonePluginScanner in project Glowstone by GlowstoneMC.
the class GlowServer method loadPlugins.
/**
* Loads all plugins, calling onLoad, &c.
*/
@SuppressWarnings("HardCodedStringLiteral")
private void loadPlugins() {
// clear the map
commandMap.clearCommands();
// glowstone commands
commandMap.register("glowstone", new ColorCommand());
commandMap.register("glowstone", new GlowstoneCommand());
// vanilla commands
commandMap.register("minecraft", new TellrawCommand());
commandMap.register("minecraft", new TitleCommand());
commandMap.register("minecraft", new TeleportCommand());
commandMap.register("minecraft", new SummonCommand());
commandMap.register("minecraft", new WorldBorderCommand());
commandMap.register("minecraft", new SayCommand());
commandMap.register("minecraft", new StopCommand());
commandMap.register("minecraft", new OpCommand());
commandMap.register("minecraft", new GameModeCommand());
commandMap.register("minecraft", new FunctionCommand());
commandMap.register("minecraft", new DeopCommand());
commandMap.register("minecraft", new KickCommand());
commandMap.register("minecraft", new GameRuleCommand());
commandMap.register("minecraft", new TellCommand());
commandMap.register("minecraft", new ListCommand());
commandMap.register("minecraft", new BanCommand());
commandMap.register("minecraft", new BanIpCommand());
commandMap.register("minecraft", new BanListCommand());
commandMap.register("minecraft", new GiveCommand());
commandMap.register("minecraft", new DifficultyCommand());
commandMap.register("minecraft", new KillCommand());
commandMap.register("minecraft", new PardonCommand());
commandMap.register("minecraft", new PardonIpCommand());
commandMap.register("minecraft", new WhitelistCommand());
commandMap.register("minecraft", new TimeCommand());
commandMap.register("minecraft", new WeatherCommand());
commandMap.register("minecraft", new SaveAllCommand());
commandMap.register("minecraft", new SaveToggleCommand(true));
commandMap.register("minecraft", new SaveToggleCommand(false));
commandMap.register("minecraft", new ClearCommand());
commandMap.register("minecraft", new TpCommand());
commandMap.register("minecraft", new MeCommand());
commandMap.register("minecraft", new SeedCommand());
commandMap.register("minecraft", new XpCommand());
commandMap.register("minecraft", new DefaultGameModeCommand());
commandMap.register("minecraft", new SetIdleTimeoutCommand());
commandMap.register("minecraft", new SpawnPointCommand());
commandMap.register("minecraft", new ToggleDownfallCommand());
commandMap.register("minecraft", new SetWorldSpawnCommand());
commandMap.register("minecraft", new PlaySoundCommand());
commandMap.register("minecraft", new EffectCommand());
commandMap.register("minecraft", new EnchantCommand());
commandMap.register("minecraft", new TestForCommand());
commandMap.register("minecraft", new TestForBlockCommand());
commandMap.register("minecraft", new SetBlockCommand());
commandMap.register("minecraft", new CloneCommand());
commandMap.register("minecraft", new TestForBlocksCommand());
File folder = new File(config.getString(Key.PLUGIN_FOLDER));
if (!folder.isDirectory() && !folder.mkdirs()) {
ConsoleMessages.Error.Plugin.MKDIR.log(folder);
}
// detect plugin types
pluginTypeDetector = new GlowPluginTypeDetector(folder);
pluginTypeDetector.scan();
// scan plugins for @Field and @Box annotated fields
FieldSet annotatedFields = new FieldSet();
Boxes boxes = new Boxes();
LinkstoneRuntimeData.setFields(annotatedFields);
LinkstoneRuntimeData.setBoxes(boxes);
new LinkstonePluginScanner(annotatedFields, boxes).scanPlugins(pluginTypeDetector.bukkitPlugins);
// clear plugins and prepare to load (Bukkit)
pluginManager.clearPlugins();
pluginManager.registerInterface(LinkstonePluginLoader.class);
Plugin[] plugins = pluginManager.loadPlugins(folder, pluginTypeDetector.bukkitPlugins);
// call onLoad methods
for (Plugin plugin : plugins) {
try {
plugin.onLoad();
} catch (Exception ex) {
ConsoleMessages.Error.Plugin.LOADING.log(ex, plugin.getDescription().getFullName());
}
}
if (!pluginTypeDetector.spongePlugins.isEmpty()) {
boolean hasSponge = false;
for (Plugin plugin : plugins) {
if (plugin.getName().equals("Bukkit2Sponge")) {
hasSponge = // TODO: better detection method, plugin description file
true;
// annotation APIs?
break;
}
}
boolean spongeOnlyPlugins = false;
for (File spongePlugin : pluginTypeDetector.spongePlugins) {
if (!pluginTypeDetector.bukkitPlugins.contains(spongePlugin)) {
spongeOnlyPlugins = true;
}
}
if (!hasSponge && spongeOnlyPlugins) {
ConsoleMessages.Warn.Plugin.NO_SPONGE.log();
for (File file : getSpongePlugins()) {
ConsoleMessages.Warn.Plugin.UNSUPPORTED_SPONGE.log(file.getPath());
}
ConsoleMessages.Warn.Plugin.BUKKIT2SPONGE.log();
}
}
if (!pluginTypeDetector.canaryPlugins.isEmpty() || !pluginTypeDetector.forgefPlugins.isEmpty() || !pluginTypeDetector.forgenPlugins.isEmpty() || !pluginTypeDetector.unrecognizedPlugins.isEmpty()) {
ConsoleMessages.Warn.Plugin.UNSUPPORTED.log();
for (File file : pluginTypeDetector.canaryPlugins) {
ConsoleMessages.Warn.Plugin.UNSUPPORTED_CANARY.log(file.getPath());
}
for (File file : pluginTypeDetector.forgefPlugins) {
ConsoleMessages.Warn.Plugin.UNSUPPORTED_FORGE.log(file.getPath());
}
for (File file : pluginTypeDetector.forgenPlugins) {
ConsoleMessages.Warn.Plugin.UNSUPPORTED_FORGE.log(file.getPath());
}
for (File file : pluginTypeDetector.unrecognizedPlugins) {
ConsoleMessages.Warn.Plugin.UNSUPPORTED_OTHER.log(file.getPath());
}
}
}
Aggregations