Search in sources :

Example 1 with BanListCommand

use of net.glowstone.command.minecraft.BanListCommand 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());
        }
    }
}
Also used : EnchantCommand(net.glowstone.command.minecraft.EnchantCommand) TitleCommand(net.glowstone.command.minecraft.TitleCommand) ListCommand(net.glowstone.command.minecraft.ListCommand) BanListCommand(net.glowstone.command.minecraft.BanListCommand) TellrawCommand(net.glowstone.command.minecraft.TellrawCommand) SeedCommand(net.glowstone.command.minecraft.SeedCommand) SayCommand(net.glowstone.command.minecraft.SayCommand) OpCommand(net.glowstone.command.minecraft.OpCommand) DifficultyCommand(net.glowstone.command.minecraft.DifficultyCommand) BanListCommand(net.glowstone.command.minecraft.BanListCommand) SpawnPointCommand(net.glowstone.command.minecraft.SpawnPointCommand) GameRuleCommand(net.glowstone.command.minecraft.GameRuleCommand) SummonCommand(net.glowstone.command.minecraft.SummonCommand) KickCommand(net.glowstone.command.minecraft.KickCommand) GiveCommand(net.glowstone.command.minecraft.GiveCommand) SetIdleTimeoutCommand(net.glowstone.command.minecraft.SetIdleTimeoutCommand) TimeCommand(net.glowstone.command.minecraft.TimeCommand) PlaySoundCommand(net.glowstone.command.minecraft.PlaySoundCommand) BanIpCommand(net.glowstone.command.minecraft.BanIpCommand) SaveToggleCommand(net.glowstone.command.minecraft.SaveToggleCommand) BanCommand(net.glowstone.command.minecraft.BanCommand) CloneCommand(net.glowstone.command.minecraft.CloneCommand) TeleportCommand(net.glowstone.command.minecraft.TeleportCommand) LinkstonePluginScanner(net.glowstone.util.linkstone.LinkstonePluginScanner) TestForBlockCommand(net.glowstone.command.minecraft.TestForBlockCommand) GlowstoneCommand(net.glowstone.command.glowstone.GlowstoneCommand) WeatherCommand(net.glowstone.command.minecraft.WeatherCommand) StopCommand(net.glowstone.command.minecraft.StopCommand) KillCommand(net.glowstone.command.minecraft.KillCommand) MeCommand(net.glowstone.command.minecraft.MeCommand) UuidListFile(net.glowstone.util.bans.UuidListFile) File(java.io.File) SetWorldSpawnCommand(net.glowstone.command.minecraft.SetWorldSpawnCommand) WhitelistCommand(net.glowstone.command.minecraft.WhitelistCommand) Boxes(net.glowstone.linkstone.runtime.Boxes) FieldSet(net.glowstone.linkstone.runtime.FieldSet) EffectCommand(net.glowstone.command.minecraft.EffectCommand) PardonIpCommand(net.glowstone.command.minecraft.PardonIpCommand) DefaultGameModeCommand(net.glowstone.command.minecraft.DefaultGameModeCommand) TpCommand(net.glowstone.command.minecraft.TpCommand) FunctionCommand(net.glowstone.command.minecraft.FunctionCommand) ClearCommand(net.glowstone.command.minecraft.ClearCommand) PardonCommand(net.glowstone.command.minecraft.PardonCommand) TestForCommand(net.glowstone.command.minecraft.TestForCommand) GameModeCommand(net.glowstone.command.minecraft.GameModeCommand) DefaultGameModeCommand(net.glowstone.command.minecraft.DefaultGameModeCommand) TestForBlocksCommand(net.glowstone.command.minecraft.TestForBlocksCommand) SaveAllCommand(net.glowstone.command.minecraft.SaveAllCommand) ToggleDownfallCommand(net.glowstone.command.minecraft.ToggleDownfallCommand) DeopCommand(net.glowstone.command.minecraft.DeopCommand) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) NotImplementedException(org.apache.commons.lang.NotImplementedException) NaetherException(com.tobedevoured.naether.NaetherException) TimeoutException(java.util.concurrent.TimeoutException) CommandException(org.bukkit.command.CommandException) MalformedURLException(java.net.MalformedURLException) WorldBorderCommand(net.glowstone.command.minecraft.WorldBorderCommand) SetBlockCommand(net.glowstone.command.minecraft.SetBlockCommand) TellCommand(net.glowstone.command.minecraft.TellCommand) XpCommand(net.glowstone.command.minecraft.XpCommand) ColorCommand(net.glowstone.command.glowstone.ColorCommand) Plugin(org.bukkit.plugin.Plugin)

Aggregations

NaetherException (com.tobedevoured.naether.NaetherException)1 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 ColorCommand (net.glowstone.command.glowstone.ColorCommand)1 GlowstoneCommand (net.glowstone.command.glowstone.GlowstoneCommand)1 BanCommand (net.glowstone.command.minecraft.BanCommand)1 BanIpCommand (net.glowstone.command.minecraft.BanIpCommand)1 BanListCommand (net.glowstone.command.minecraft.BanListCommand)1 ClearCommand (net.glowstone.command.minecraft.ClearCommand)1 CloneCommand (net.glowstone.command.minecraft.CloneCommand)1 DefaultGameModeCommand (net.glowstone.command.minecraft.DefaultGameModeCommand)1 DeopCommand (net.glowstone.command.minecraft.DeopCommand)1 DifficultyCommand (net.glowstone.command.minecraft.DifficultyCommand)1 EffectCommand (net.glowstone.command.minecraft.EffectCommand)1 EnchantCommand (net.glowstone.command.minecraft.EnchantCommand)1 FunctionCommand (net.glowstone.command.minecraft.FunctionCommand)1 GameModeCommand (net.glowstone.command.minecraft.GameModeCommand)1