X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fcore%2FCore.java;h=00d1fbdf4a949ffd78da8d3873ce6351601f3890;hb=44825f1cf5ddb021cbf9b8416e8649e768905e77;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..00d1fbd 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("Waiting %d minutes to connect to %s...", TimeUnit.MILLISECONDS.toMinutes(firstNetwork.get().getKey() - System.currentTimeMillis()), 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()); @@ -660,6 +664,13 @@ public class Core extends AbstractExecutionThreadService { format("Not trying to join %s anymore.", channel.get()))); return; } + if (channelNotJoined.reason() == inviteOnly) { + channelBanManager.ban(channel.get()); + eventBus.post(new GenericMessage( + format("%s is invite-only, suspending join for a day.", + channel.get()))); + return; + } if (channelNotJoined.reason() == banned) { channelBanManager.ban(channel.get()); eventBus.post(new GenericMessage(