X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fcore%2FCore.java;h=3414d1810fc446086b8780157d0a117dc3255e83;hb=c775ff7d7371d3a4ef8663afca7de364daeda526;hp=10cb06d7e5f8a2f8b17d05d3484022ea82e3ffdb;hpb=57e8c8f027adafe3323eb19912476fbd3b1fc317;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index 10cb06d..3414d18 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -184,7 +184,7 @@ public class Core extends AbstractExecutionThreadService { return networkConnections.entrySet().stream().map((entry) -> { Network network = entry.getKey(); Collection bots = networkBots.row(network).values(); - int packCount = bots.stream().mapToInt((bot) -> bot.packs().size()).reduce((a, b) -> a + b).getAsInt(); + int packCount = bots.stream().mapToInt((bot) -> bot.packs().size()).reduce((a, b) -> a + b).orElse(0); return new ConnectedNetwork(network, entry.getValue().hostname(), entry.getValue().port(), entry.getValue().nickname(), channels.stream() @@ -577,6 +577,16 @@ public class Core extends AbstractExecutionThreadService { return; } + /* remove all bots for this channel, we might have been kicked. */ + Collection botsToRemove = networkBots.row(network.get()) + .values().stream() + .filter(bot -> bot.channel() + .equalsIgnoreCase(channel.get().name())) + .collect(Collectors.toSet()); + botsToRemove.stream() + .forEach(bot -> networkBots.row(network.get()) + .remove(bot.name())); + if (channelNotJoined.reason() == registeredNicknamesOnly) { channels.remove(channel.get()); eventBus.post(new GenericMessage( @@ -586,7 +596,7 @@ public class Core extends AbstractExecutionThreadService { if (channelNotJoined.reason() == banned) { channelBanManager.ban(channel.get()); eventBus.post(new GenericMessage( - format("Banned from %s, suspending join for day.", + format("Banned from %s, suspending join for a day.", channel.get()))); return; } @@ -739,7 +749,8 @@ public class Core extends AbstractExecutionThreadService { Bot bot; synchronized (networkBots) { if (!networkBots.contains(network.get(), channelMessageReceived.source().nick().get())) { - bot = new Bot(network.get(), channelMessageReceived.source().nick().get()); + bot = new Bot(network.get(), channelMessageReceived.channel(), + channelMessageReceived.source().nick().get()); networkBots.put(network.get(), channelMessageReceived.source().nick().get(), bot); eventBus.post(new BotAdded(bot)); } else {