X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fcore%2FCore.java;h=d39ee2bd0ffe241a933ad8ae0c844f99c21a93f4;hb=d8c6d72caaa1ba75d09bd28f2bb10ae6f4964bf4;hp=e24fa2ff3aeafae29df0b5601c2538b1fe48b64e;hpb=fd78c0b99be170906ab7954ccd59916566803c57;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 e24fa2f..d39ee2b 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -19,6 +19,7 @@ package net.pterodactylus.xdcc.core; import static java.lang.String.format; import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.banned; +import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.inviteOnly; import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.registeredNicknamesOnly; import static net.pterodactylus.irc.util.MessageCleaner.getDefaultInstance; import static net.pterodactylus.xdcc.data.Channel.TO_NETWORK; @@ -427,17 +428,17 @@ public class Core extends AbstractExecutionThreadService { } Map timesForNextConnects = new TreeMap<>(missingNetworks.stream() - .collect(Collectors.toMap(connectionBackoff::getBackoff, Function.identity(), (network, ignore) -> network))); + .collect(Collectors.toMap(connectionBackoff::getConnectionTime, Function.identity(), (network, ignore) -> network))); Optional> firstNetwork = Optional.fromNullable(timesForNextConnects.entrySet().stream().findFirst().orElse(null)); if (!firstNetwork.isPresent()) { continue; } - if (firstNetwork.get().getKey() > 0) { - eventBus.post(new GenericMessage(String.format("Waiting %d minutes to connect to %s...", TimeUnit.MILLISECONDS.toMinutes(firstNetwork.get().getKey()), firstNetwork.get().getValue().name()))); + if (firstNetwork.get().getKey() > System.currentTimeMillis()) { + eventBus.post(new GenericMessage(String.format("Will connect to %2$s at %1$tH:%1$tM...", firstNetwork.get().getKey(), firstNetwork.get().getValue().name()))); synchronized (syncObject) { try { - syncObject.wait(firstNetwork.get().getKey()); + syncObject.wait(firstNetwork.get().getKey() - System.currentTimeMillis()); } catch (InterruptedException ie1) { /* ignore. */ } @@ -445,6 +446,9 @@ public class Core extends AbstractExecutionThreadService { if (!isRunning()) { break; } + if (firstNetwork.get().getKey() > System.currentTimeMillis()) { + continue; + } } connectNetwork(firstNetwork.get().getValue()); @@ -654,23 +658,23 @@ public class Core extends AbstractExecutionThreadService { .forEach(bot -> networkBots.row(network.get()) .remove(bot.name())); + channelBanManager.ban(channel.get()); if (channelNotJoined.reason() == registeredNicknamesOnly) { - channels.remove(channel.get()); eventBus.post(new GenericMessage( format("Not trying to join %s anymore.", channel.get()))); - return; - } - if (channelNotJoined.reason() == banned) { - channelBanManager.ban(channel.get()); + } else if (channelNotJoined.reason() == inviteOnly) { + eventBus.post(new GenericMessage( + format("%s is invite-only, suspending join for a day.", + channel.get()))); + } else if (channelNotJoined.reason() == banned) { eventBus.post(new GenericMessage( format("Banned from %s, suspending join for a day.", channel.get()))); - return; + } else { + eventBus.post(new GenericMessage( + format("Could not join %s: %s", channelNotJoined.channel(), + channelNotJoined.reason()))); } - - eventBus.post(new GenericMessage( - format("Could not join %s: %s", channelNotJoined.channel(), - channelNotJoined.reason()))); } /**