use of com.loohp.interactivechatdiscordsrvaddon.listeners.DiscordReadyEvents in project InteractiveChat-DiscordSRV-Addon by LOOHP.
the class InteractiveChatDiscordSrvAddon method onEnable.
@Override
public void onEnable() {
plugin = this;
interactivechat = InteractiveChat.plugin;
discordsrv = DiscordSRV.getPlugin();
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
}
AssetsDownloader.loadLibraries(getDataFolder());
try {
Config.loadConfig(CONFIG_ID, new File(getDataFolder(), "config.yml"), getClass().getClassLoader().getResourceAsStream("config.yml"), getClass().getClassLoader().getResourceAsStream("config.yml"), true);
} catch (IOException e) {
e.printStackTrace();
getServer().getPluginManager().disablePlugin(this);
return;
}
reloadConfig();
metrics = new Metrics(this, BSTATS_PLUGIN_ID);
Charts.setup(metrics);
DiscordSRV.api.subscribe(new DiscordReadyEvents());
DiscordSRV.api.subscribe(new OutboundToDiscordEvents());
DiscordSRV.api.subscribe(new InboundToGameEvents());
getServer().getPluginManager().registerEvents(this, this);
getServer().getPluginManager().registerEvents(new InboundToGameEvents(), this);
getServer().getPluginManager().registerEvents(new OutboundToDiscordEvents(), this);
getServer().getPluginManager().registerEvents(new ICPlayerEvents(), this);
getServer().getPluginManager().registerEvents(new Debug(), this);
getServer().getPluginManager().registerEvents(new Updater(), this);
getCommand("interactivechatdiscordsrv").setExecutor(new Commands());
File resourcepacks = new File(getDataFolder(), "resourcepacks");
if (!resourcepacks.exists()) {
File resources = new File(getDataFolder(), "resources");
if (resources.exists() && resources.isDirectory()) {
try {
Files.move(resources.toPath(), resourcepacks.toPath(), StandardCopyOption.ATOMIC_MOVE);
} catch (IOException e) {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "[ICDiscordSrvAddon] Unable to move folder, are any files opened?");
e.printStackTrace();
getServer().getPluginManager().disablePlugin(this);
return;
}
} else {
resourcepacks.mkdirs();
}
}
if (!compatible()) {
for (int i = 0; i < 10; i++) {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "[ICDiscordSrvAddon] VERSION NOT COMPATIBLE WITH INSTALLED INTERACTIVECHAT VERSION, PLEASE UPDATE BOTH TO LATEST!!!!");
}
getServer().getPluginManager().disablePlugin(this);
return;
} else {
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[ICDiscordSrvAddon] InteractiveChat DiscordSRV Addon has been Enabled!");
}
reloadTextures(false, false);
modelRenderer = new ModelRenderer(str -> new ThreadFactoryBuilder().setNameFormat(str).build(), () -> InteractiveChatDiscordSrvAddon.plugin.cacheTimeout, image -> ImageGeneration.getEnchantedImage(image), image -> ImageGeneration.getRawEnchantedImage(image), () -> 8, () -> Runtime.getRuntime().availableProcessors());
ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("InteractiveChatDiscordSRVAddon Async Media Reading Thread #%d").build();
mediaReadingService = Executors.newFixedThreadPool(4, factory);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
for (ICPlayer player : ICPlayerFactory.getOnlineICPlayers()) {
cachePlayerSkin(player);
}
AssetsDownloader.loadExtras();
}, 600, 6000);
}
Aggregations