Search in sources :

Example 1 with MetricsLite

use of org.bstats.bungeecord.MetricsLite in project SkinsRestorerX by DoNotSpamPls.

the class SkinsRestorer method onEnable.

@Override
public void onEnable() {
    @SuppressWarnings("unused") MetricsLite metrics = new MetricsLite(this);
    instance = this;
    Config.load(getResourceAsStream("config.yml"));
    Locale.load();
    if (Config.USE_MYSQL) {
        SkinStorage.init(mysql = new MySQL(Config.MYSQL_HOST, Config.MYSQL_PORT, Config.MYSQL_DATABASE, Config.MYSQL_USERNAME, Config.MYSQL_PASSWORD));
    } else {
        SkinStorage.init(getDataFolder());
    }
    getProxy().getPluginManager().registerListener(this, new LoginListener());
    getProxy().getPluginManager().registerCommand(this, new AdminCommands());
    getProxy().getPluginManager().registerCommand(this, new PlayerCommands());
    getProxy().registerChannel("SkinsRestorer");
    SkinApplier.init();
    multibungee = Config.MULTIBUNGEE_ENABLED || ProxyServer.getInstance().getPluginManager().getPlugin("RedisBungee") != null;
    ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
        CommandSender console = getProxy().getConsole();
        if (Config.UPDATER_ENABLED)
            if (checkVersion(console).equals(getVersion())) {
                outdated = false;
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a----------------------------------------------"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    +===============+"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    | SkinsRestorer |"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    +===============+"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a----------------------------------------------"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §b    Current version: §a" + getVersion()));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    This is the latest version!"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a----------------------------------------------"));
            } else {
                outdated = true;
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a----------------------------------------------"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    +===============+"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    | SkinsRestorer |"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a    +===============+"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a----------------------------------------------"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §b    Current version: §c" + getVersion()));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §e    A new version is available! Download it at:"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §e    https://www.spigotmc.org/resources/skinsrestorer.2124"));
                console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §a----------------------------------------------"));
            }
        if (Config.DEFAULT_SKINS_ENABLED)
            for (String skin : Config.DEFAULT_SKINS) try {
                SkinStorage.setSkinData(skin, MojangAPI.getSkinProperty(MojangAPI.getUUID(skin)));
            } catch (SkinRequestException e) {
                if (SkinStorage.getSkinData(skin) == null)
                    console.sendMessage(new TextComponent("§e[§2SkinsRestorer§e] §cDefault Skin '" + skin + "' request error:" + e.getReason()));
            }
    });
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) MetricsLite(org.bstats.bungeecord.MetricsLite) LoginListener(skinsrestorer.bungee.listeners.LoginListener) MySQL(skinsrestorer.shared.utils.MySQL) AdminCommands(skinsrestorer.bungee.commands.AdminCommands) PlayerCommands(skinsrestorer.bungee.commands.PlayerCommands) CommandSender(net.md_5.bungee.api.CommandSender) SkinRequestException(skinsrestorer.shared.utils.MojangAPI.SkinRequestException)

Aggregations

CommandSender (net.md_5.bungee.api.CommandSender)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1 MetricsLite (org.bstats.bungeecord.MetricsLite)1 AdminCommands (skinsrestorer.bungee.commands.AdminCommands)1 PlayerCommands (skinsrestorer.bungee.commands.PlayerCommands)1 LoginListener (skinsrestorer.bungee.listeners.LoginListener)1 SkinRequestException (skinsrestorer.shared.utils.MojangAPI.SkinRequestException)1 MySQL (skinsrestorer.shared.utils.MySQL)1