X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fcore%2FCore.java;h=649db75114993bbd6d2896db7c311e2f2e99a3fe;hb=82dbd8dd4022906970f8851080df22c77d0111af;hp=fab43ab74284576ab5bae5b9c266a982741279e1;hpb=5e7f77e44cacc40da04ac9f744566de0710b12a1;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 fab43ab..649db75 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -202,7 +202,7 @@ public class Core extends AbstractExecutionThreadService { Connection connection = entry.getValue(); return new ConnectedNetwork(network, connection.hostname(), connection.port(), - connection.getUptime().get(), + connection.getUptime().orElse(Duration.ofSeconds(0)), connection.nickname(), channels.stream() .filter((channel) -> channel.network() @@ -339,13 +339,6 @@ public class Core extends AbstractExecutionThreadService { return; } - /* get connection. */ - Connection connection = networkConnections.get(bot.network()); - if (connection == null) { - /* request for unknown network? */ - return; - } - /* stop the DCC receiver. */ if (download.get().dccReceiver() != null) { download.get().dccReceiver().stop(); @@ -354,6 +347,13 @@ public class Core extends AbstractExecutionThreadService { downloads.remove(pack.name(), download.get()); } + /* get connection. */ + Connection connection = networkConnections.get(bot.network()); + if (connection == null) { + /* request for unknown network? */ + return; + } + /* remove the request from the bot, too. */ try { connection.sendMessage(bot.name(), String.format("XDCC %s", (download.get().dccReceiver() != null) ? "CANCEL" : "REMOVE")); @@ -508,10 +508,13 @@ public class Core extends AbstractExecutionThreadService { * The connection to remove */ private void removeConnection(Connection connection) { + logger.debug(String.format("Removing Connection %s...", connection)); Optional network = getNetwork(connection); if (!network.isPresent()) { + logger.debug(String.format("Connection %s did not belong to any network.", connection)); return; } + logger.debug(String.format("Connection %s belongs to network %s.", connection, network.get())); networkConnections.remove(network.get()); /* find all channels that need to be removed. */ @@ -521,7 +524,7 @@ public class Core extends AbstractExecutionThreadService { if (!joinedChannel.network().equals(network.get())) { continue; } - + logger.debug(String.format("Channel %s will be removed.", joinedChannel)); channelIterator.remove(); } }