Closed GoogleCodeExporter closed 9 years ago
Sorry about that, the generics changes were implemented over many days and I
didn't always test everything. Fixed in the latest snapshot:
class MyCustomBot extends PircBotX {
public MyCustomBot(Configuration<? extends PircBotX> configuration) {
super(configuration);
}
}
class MyCustomListenerManager extends ThreadedListenerManager<MyCustomBot> {
}
public class Sandbox {
void run() {
//Compiles!
Configuration<PircBotX> config = new Configuration.Builder<PircBotX>()
.setListenerManager(new MyCustomListenerManager())
.buildConfiguration();
}
}
Original comment by Lord.Qua...@gmail.com
on 26 Jun 2013 at 12:54
Thanks seems to work perfectly apart from getConfiguration().getistenerManager()
That still seems to be storing and returning a copy of the PircBotX version of
Configuration and subsequently the ListenerManager.
I can easily work around this by keeping my own reference to my extended
ListenerManager.
Thanks again.
Original comment by Jamie.Re...@gmail.com
on 27 Jun 2013 at 7:09
Both Configuration<B> and Configuration.Builder<B> return ListenerManager<B>.
Using Configuration<PircBotX> above was only an example to prove that it would
compile since it takes an extended type.
You probably are wanting to use Configuration<MyCustomBot>
Original comment by Lord.Qua...@gmail.com
on 27 Jun 2013 at 9:14
Exact code is:
ThreadedListenerManager<IrcBot> lm = new ThreadedListenerManager<IrcBot>();
Configuration<IrcBot> configuration = new Configuration.Builder<IrcBot>()
.setName(nick) //Set the nick of the bot.
.setLogin(ident) //login part of hostmask, eg name:login@host
.setAutoNickChange(true) //Automatically change nick
.setVersion(VERSION)
.setCapEnabled(true) //Enable CAP features
.setFinger(FINGER_MSG)
.setAutoReconnect(true)
.setIdentServerEnabled(useident)
.setServerPort(port)
.setServerHostname(addr)
.setMessageDelay(1)
.setNickservPassword(password)
.setListenerManager(lm)
// TODO:
//.setLocalAddress(local)
.setSocketTimeout(SOCKET_TIMEOUT)
.buildConfiguration();
newbot = new IrcBot(configuration);
and
bot.getConfiguration().getListenerManager().addListener(listener);
returns an error as it is receiving Configuration<PircBotX> which in turn
forces it to return a ListenerManager<PircBotX>.
Original comment by Jamie.Re...@gmail.com
on 27 Jun 2013 at 9:21
On another note, providing any argument to .setLocalAddress() produces a null
socket but I'm fairly sure this isn't related to your code.
Original comment by Jamie.Re...@gmail.com
on 27 Jun 2013 at 9:22
This is because your getting the configuration after the fact which always
returns Configuration<PircBotX>. There was no other clean way to return the
subclass so thats the signature I was stuck with
However listenerExists, addListener, and removeListener don't really care about
the generic type, so I removed them in Revision 13a5ccb05a94
Original comment by Lord.Qua...@gmail.com
on 27 Jun 2013 at 3:09
Fantastic, I'll give it a try shortly.
I really appreciate your hard work, quick responses and more than anything the
vast improvement you've made on PircBot.
Original comment by Jamie.Re...@gmail.com
on 27 Jun 2013 at 3:12
Always happy to help :-)
With setLocalAddress I'm not sure what could be causing the problem. Its usage
is pretty basic (
https://code.google.com/p/pircbotx/source/browse/src/main/java/org/pircbotx/Pirc
BotX.java#181 ) and some quick tests with InetAddress.getLocalAddress() (can't
connect) and InetAddress.getByName("192.168.0.X") (working) show expected
results. My only guess is an exception is being swallowed somewhere, but its
not in PircBotX
Original comment by Lord.Qua...@gmail.com
on 27 Jun 2013 at 3:25
Original issue reported on code.google.com by
Jamie.Re...@gmail.com
on 19 Jun 2013 at 3:34