本文整理匯總了Java中org.pircbotx.hooks.ListenerAdapter類的典型用法代碼示例。如果您正苦於以下問題:Java ListenerAdapter類的具體用法?Java ListenerAdapter怎麽用?Java ListenerAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ListenerAdapter類屬於org.pircbotx.hooks包,在下文中一共展示了ListenerAdapter類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerListeners
import org.pircbotx.hooks.ListenerAdapter; //導入依賴的package包/類
private void registerListeners()
{
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
try
{
for (Class clazz : reflections.getSubTypesOf(ListenerAdapter.class))
{
classLoader.loadClass(clazz.getName());
Constructor clazzConstructor = clazz.getConstructor(getClass());
ListenerAdapter listener = (ListenerAdapter) clazzConstructor.newInstance(this);
configBuilder.getListenerManager().addListener(listener);
logger.info(String.format("Registered listener '%s'", listener.getClass().getSimpleName()));
}
}
catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException ex)
{
logger.error("Error registering listener", ex);
}
}
示例2: buildNewBot
import org.pircbotx.hooks.ListenerAdapter; //導入依賴的package包/類
protected Bot buildNewBot(CountDownLatch latch) {
Configuration.Builder cfgb = new Configuration.Builder()
.setBotFactory(new BotFactory(){
@Override
public InputParser createInputParser(PircBotX bot) {
return new SkylarkInputParser(bot);
}
})
.setEncoding(CHARSET)
.setName(botName)
.setAutoNickChange(true)
.setMessageDelay(messageDelay)
.setCapEnabled(true)
.addCapHandler(new EnableCapHandler("extended-join", true))
.addCapHandler(new EnableCapHandler("account-notify", true))
.setAutoReconnect(true)
.addListener(new ListenerAdapter(){
@Override
public void onConnect(ConnectEvent event) throws Exception {
latch.countDown();
}
});
if (port == null)
cfgb.addServer(host);
else
cfgb.addServer(host, port);
PluginManager pluginManager = serverManager.app.pluginManager;
pluginManager.plugins.iterate(plugin -> {
if (plugin instanceof ListenerPlugin)
cfgb.addListener(((ListenerPlugin)plugin).listener);
});
return new Bot(cfgb.buildConfiguration(), this);
}