use of net.ess3.nms.refl.providers.AdvancementListenerProvider in project Essentials by drtshock.
the class JDADiscordService method startup.
public void startup() throws LoginException, InterruptedException {
shutdown();
invalidStartup = true;
logger.log(Level.INFO, tl("discordLoggingIn"));
if (plugin.getSettings().getBotToken().replace("INSERT-TOKEN-HERE", "").trim().isEmpty()) {
throw new IllegalArgumentException(tl("discordErrorNoToken"));
}
jda = JDABuilder.createDefault(plugin.getSettings().getBotToken()).addEventListeners(new DiscordListener(this)).enableCache(CacheFlag.EMOTE).disableCache(CacheFlag.MEMBER_OVERRIDES, CacheFlag.VOICE_STATE).setContextEnabled(false).build().awaitReady();
invalidStartup = false;
updatePresence();
logger.log(Level.INFO, tl("discordLoggingInDone", jda.getSelfUser().getAsTag()));
if (jda.getGuilds().isEmpty()) {
invalidStartup = true;
throw new IllegalArgumentException(tl("discordErrorNoGuildSize"));
}
guild = jda.getGuildById(plugin.getSettings().getGuildId());
if (guild == null) {
invalidStartup = true;
throw new IllegalArgumentException(tl("discordErrorNoGuild"));
}
interactionController = new InteractionControllerImpl(this);
// Each will throw an exception if disabled
try {
interactionController.registerCommand(new ExecuteCommand(this));
} catch (InteractionException ignored) {
}
try {
interactionController.registerCommand(new MessageCommand(this));
} catch (InteractionException ignored) {
}
try {
interactionController.registerCommand(new ListCommand(this));
} catch (InteractionException ignored) {
}
// Load emotes into cache, JDA will handle updates from here on out.
guild.retrieveEmotes().queue();
updatePrimaryChannel();
updateConsoleRelay();
updateTypesRelay();
// We will see you in the future :balloon:
// DiscordUtil.cleanWebhooks(guild, DiscordUtil.CONSOLE_RELAY_NAME);
// DiscordUtil.cleanWebhooks(guild, DiscordUtil.ADVANCED_RELAY_NAME);
Bukkit.getPluginManager().registerEvents(new BukkitListener(this), plugin);
try {
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_12_0_R01)) {
try {
Class.forName("io.papermc.paper.advancement.AdvancementDisplay");
Bukkit.getPluginManager().registerEvents(new PaperAdvancementListenerProvider(), plugin);
} catch (ClassNotFoundException e) {
Bukkit.getPluginManager().registerEvents(new AdvancementListenerProvider(), plugin);
}
} else {
Bukkit.getPluginManager().registerEvents(new AchievementListenerProvider(), plugin);
}
} catch (final Throwable e) {
logger.log(Level.WARNING, "Error while loading the achievement/advancement listener. You will not receive achievement/advancement notifications on Discord.", e);
}
getPlugin().getEss().scheduleSyncDelayedTask(() -> DiscordUtil.dispatchDiscordMessage(JDADiscordService.this, MessageType.DefaultTypes.SERVER_START, getSettings().getStartMessage(), true, null, null, null));
Bukkit.getServicesManager().register(DiscordService.class, this, plugin, ServicePriority.Normal);
}
use of net.ess3.nms.refl.providers.AdvancementListenerProvider in project Essentials by EssentialsX.
the class JDADiscordService method startup.
public void startup() throws LoginException, InterruptedException {
shutdown();
invalidStartup = true;
logger.log(Level.INFO, tl("discordLoggingIn"));
if (plugin.getSettings().getBotToken().replace("INSERT-TOKEN-HERE", "").trim().isEmpty()) {
throw new IllegalArgumentException(tl("discordErrorNoToken"));
}
jda = JDABuilder.createDefault(plugin.getSettings().getBotToken()).addEventListeners(new DiscordListener(this)).enableCache(CacheFlag.EMOTE).disableCache(CacheFlag.MEMBER_OVERRIDES, CacheFlag.VOICE_STATE).setContextEnabled(false).build().awaitReady();
invalidStartup = false;
updatePresence();
logger.log(Level.INFO, tl("discordLoggingInDone", jda.getSelfUser().getAsTag()));
if (jda.getGuilds().isEmpty()) {
invalidStartup = true;
throw new IllegalArgumentException(tl("discordErrorNoGuildSize"));
}
guild = jda.getGuildById(plugin.getSettings().getGuildId());
if (guild == null) {
invalidStartup = true;
throw new IllegalArgumentException(tl("discordErrorNoGuild"));
}
interactionController = new InteractionControllerImpl(this);
// Each will throw an exception if disabled
try {
interactionController.registerCommand(new ExecuteCommand(this));
} catch (InteractionException ignored) {
}
try {
interactionController.registerCommand(new MessageCommand(this));
} catch (InteractionException ignored) {
}
try {
interactionController.registerCommand(new ListCommand(this));
} catch (InteractionException ignored) {
}
// Load emotes into cache, JDA will handle updates from here on out.
guild.retrieveEmotes().queue();
updatePrimaryChannel();
updateConsoleRelay();
updateTypesRelay();
// We will see you in the future :balloon:
// DiscordUtil.cleanWebhooks(guild, DiscordUtil.CONSOLE_RELAY_NAME);
// DiscordUtil.cleanWebhooks(guild, DiscordUtil.ADVANCED_RELAY_NAME);
Bukkit.getPluginManager().registerEvents(new BukkitListener(this), plugin);
try {
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_12_0_R01)) {
try {
Class.forName("io.papermc.paper.advancement.AdvancementDisplay");
Bukkit.getPluginManager().registerEvents(new PaperAdvancementListenerProvider(), plugin);
} catch (ClassNotFoundException e) {
Bukkit.getPluginManager().registerEvents(new AdvancementListenerProvider(), plugin);
}
} else {
Bukkit.getPluginManager().registerEvents(new AchievementListenerProvider(), plugin);
}
} catch (final Throwable e) {
logger.log(Level.WARNING, "Error while loading the achievement/advancement listener. You will not receive achievement/advancement notifications on Discord.", e);
}
getPlugin().getEss().scheduleSyncDelayedTask(() -> DiscordUtil.dispatchDiscordMessage(JDADiscordService.this, MessageType.DefaultTypes.SERVER_START, getSettings().getStartMessage(), true, null, null, null));
Bukkit.getServicesManager().register(DiscordService.class, this, plugin, ServicePriority.Normal);
}
Aggregations