本文整理汇总了Java中net.dv8tion.jda.core.hooks.EventListener类的典型用法代码示例。如果您正苦于以下问题:Java EventListener类的具体用法?Java EventListener怎么用?Java EventListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventListener类属于net.dv8tion.jda.core.hooks包,在下文中一共展示了EventListener类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadEventListeners
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
private static List<EventListener> loadEventListeners() {
List<EventListener> eventListeners = new ArrayList<>();
Logger.info("Loading AutoMod...");
eventListeners.add(new AutoMod(messageFactory));
Logger.info("Loading Welcome Manager...");
eventListeners.add(new WelcomeMessage(messageFactory));
Logger.info("Loading AutoReact...");
eventListeners.add(new AutoReact());
Logger.info("Loading Message Starer...");
eventListeners.add(new StarMessages());
return eventListeners;
}
示例2: addEventListener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public void addEventListener(EventListener eventListener) {
if (eventListener != null) {
if (this.eventListeners.contains(eventListener)) {
return;
}
this.eventListeners.add(eventListener);
if (this.jda != null) {
this.jda.addEventListener(eventListener);
}
}
}
示例3: removeEventListener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public void removeEventListener(EventListener eventListener) {
if (eventListener != null) {
if (!this.eventListeners.contains(eventListener)) {
return;
}
this.eventListeners.remove(eventListener);
if (this.jda != null) {
this.jda.removeEventListener(eventListener);
}
}
}
示例4: initJDA
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
/**
* Initializes the JDA instance.
*/
public static void initJDA() {
if (instance == null)
throw new NullPointerException("RubiconBot has not been initialized yet.");
JDABuilder builder = new JDABuilder(AccountType.BOT);
builder.setToken(instance.configuration.getString("token"));
builder.setGame(Game.playing("Starting...."));
// add all EventListeners
for (EventListener listener : instance.eventListeners)
builder.addEventListener(listener);
new ListenerManager(builder);
try {
instance.jda = builder.buildBlocking();
} catch (LoginException | InterruptedException e) {
Logger.error(e.getMessage());
}
CommandVote.loadPolls(instance.jda);
Info.lastRestart = new Date();
// CommandGiveaway.startGiveawayManager(instance.jda);
getJDA().getPresence().setGame(Game.playing("Started."));
GameAnimator.start();
}
示例5: registerEventListener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
/**
* Adds an EventListener to the event pipe. EventListeners registered here will be re-registered when the JDA
* instance is initialized again.
*
* @param listener the EventListener to register.
* @return false if the bot has never been initialized or if the EventListener is already registered.
*/
public static boolean registerEventListener(EventListener listener) {
if (instance != null && instance.eventListeners.add(listener)) {
if (instance.jda != null)
instance.jda.addEventListener(listener);
return true;
}
return false;
}
示例6: register
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
@Override
public void register(Object listener) {
if(listener instanceof EventListener) {
listener = new ProxyListener((EventListener)listener);
}
eventBus.register(listener);
listeners.add(listener);
}
示例7: listener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public static EventListener listener() {
return LISTENER;
}
示例8: main
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public static void main(String[] args) throws IOException, IllegalArgumentException, LoginException {
new Logger();
Logger.info("Initializing the bot...");
Logger.log("Loading Config Files...");
createConfigFiles();
String token = readFirstLineOfFile("config.yml", "There is no token in your config, welcome to stack trace city!");
theme = readFirstLineOfFile("theme.yml", "Error receiving theme");
String sqlPassword;
sqlPassword = readFirstLineOfFile("sql.yml", "Error receiving your SQL Password");
themeManager = loadThemeManager();
messageFactory = loadMessageFactory();
loadTweetMonitor();
//Load our SQL Stuff
sqlManager = new SQLManager(sqlPassword);
Logger.info("Loading Warning Manager...");
warningManager = new WarningManager(sqlManager);
Logger.info("Loading Report Manager...");
reportManager = new ReportManager(sqlManager);
Logger.info("Loading the Hypixel API...");
loadHypixelAPI();
List<EventListener> eventListeners = loadEventListeners();
loadClientBuilder();
Logger.info("Constructing the JDA Instance...");
JDABuilder builder = new JDABuilder(AccountType.BOT)
.setToken(token)
.setStatus(OnlineStatus.DO_NOT_DISTURB)
//Listens to the MessageReceivedEvent.
.addEventListener(clientBuilder.build())
.setGame(Game.of(Game.GameType.DEFAULT, "Loading"));
for (EventListener listener : eventListeners)
builder.addEventListener(listener);
jda = builder.buildAsync();
// new RichPresence((JDAImpl) jda);
Logger.info("Bot has been loaded!");
}
示例9: ProxyListener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public ProxyListener(EventListener listener) {
this.listener = listener;
}
示例10: listener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public static EventListener listener() {
return LISTENER;
}
示例11: addExtraListenerToBeAddedAfterStartUp
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public void addExtraListenerToBeAddedAfterStartUp(EventListener listener) {
extraListeners.add(listener);
}
示例12: addEventListener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public static void addEventListener(final EventListener eventListener) {
shardManager.addEventListener(eventListener);
}
示例13: removeEventListener
import net.dv8tion.jda.core.hooks.EventListener; //导入依赖的package包/类
public static void removeEventListener(final EventListener eventListener) {
shardManager.removeEventListener(eventListener);
}