Skip to content

Commit

Permalink
Apply spotless formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Dec 5, 2024
1 parent 51ea8f7 commit 1f672ed
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.faforever.iceadapter;

import static com.faforever.iceadapter.debug.Debug.debug;

import com.faforever.iceadapter.debug.Debug;
import com.faforever.iceadapter.gpgnet.GPGNetServer;
import com.faforever.iceadapter.gpgnet.GameState;
Expand All @@ -9,14 +11,11 @@
import com.faforever.iceadapter.util.ExecutorHolder;
import com.faforever.iceadapter.util.LockUtil;
import com.faforever.iceadapter.util.TrayIcon;
import lombok.extern.slf4j.Slf4j;
import picocli.CommandLine;

import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import static com.faforever.iceadapter.debug.Debug.debug;
import lombok.extern.slf4j.Slf4j;
import picocli.CommandLine;

@CommandLine.Command(
name = "faf-ice-adapter",
Expand Down Expand Up @@ -69,8 +68,8 @@ public void start() {
@Override
public void close() {
executor.shutdown();
CompletableFuture.runAsync(executor::shutdownNow,
CompletableFuture.delayedExecutor(250, TimeUnit.MILLISECONDS));
CompletableFuture.runAsync(
executor::shutdownNow, CompletableFuture.delayedExecutor(250, TimeUnit.MILLISECONDS));
}

public static void onHostGame(String mapName) {
Expand Down Expand Up @@ -164,8 +163,8 @@ public static void close(int status) {
Debug.close();
TrayIcon.close();
INSTANCE.close();
CompletableFuture.runAsync(() -> System.exit(status),
CompletableFuture.delayedExecutor(500, TimeUnit.MILLISECONDS));
CompletableFuture.runAsync(
() -> System.exit(status), CompletableFuture.delayedExecutor(500, TimeUnit.MILLISECONDS));
}

public static int getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.faforever.iceadapter.debug;

import com.faforever.iceadapter.IceAdapter;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Debug {
Expand Down Expand Up @@ -32,8 +31,8 @@ public static void remove(Debugger debugger) {
}

public static void init() {
telemetryDebugger = new TelemetryDebugger(
IceAdapter.getTelemetryServer(), IceAdapter.getGameId(), IceAdapter.getId());
telemetryDebugger =
new TelemetryDebugger(IceAdapter.getTelemetryServer(), IceAdapter.getGameId(), IceAdapter.getId());

// Debugger window is started and set to debugFuture when either window is requested as the info window can be
// used to open the debug window
Expand All @@ -51,9 +50,7 @@ public static void init() {
.invoke(null);
} catch (InvocationTargetException e) {
log.info("DebugWindows stopped");
} catch (IllegalAccessException
| ClassNotFoundException
| NoSuchMethodException e) {
} catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException e) {
log.error("Could not create DebugWindow. Running without debug window.", e);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
import com.faforever.iceadapter.ice.Peer;
import com.faforever.iceadapter.ice.PeerConnectivityCheckerModule;
import com.nbarraille.jjsonrpc.JJsonPeer;
import java.io.IOException;
import java.util.Comparator;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleBooleanProperty;
Expand All @@ -27,12 +32,6 @@
import org.ice4j.ice.Component;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.util.Comparator;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

@Slf4j
public class DebugWindow extends Application implements Debugger {
public static CompletableFuture<DebugWindow> INSTANCE = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.faforever.iceadapter.debug;

import com.faforever.iceadapter.IceAdapter;
import java.util.concurrent.CompletableFuture;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
Expand All @@ -10,8 +11,6 @@
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;

@Slf4j
public class DebugWindowController {
public static DebugWindowController INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import com.faforever.iceadapter.IceAdapter;
import com.faforever.iceadapter.util.TrayIcon;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import lombok.SneakyThrows;

import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import lombok.SneakyThrows;

public class InfoWindowController {
public Button killAdapterButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.common.util.concurrent.RateLimiter;
import com.nbarraille.jjsonrpc.JJsonPeer;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.ice4j.ice.Candidate;
import org.ice4j.ice.CandidatePair;
import org.ice4j.ice.Component;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.ConnectException;
import java.net.URI;
import java.time.Instant;
Expand All @@ -28,6 +20,13 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.ice4j.ice.Candidate;
import org.ice4j.ice.CandidatePair;
import org.ice4j.ice.Component;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

@Slf4j
public class TelemetryDebugger implements Debugger, AutoCloseable {
Expand Down Expand Up @@ -79,9 +78,7 @@ public void onError(Exception ex) {
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());

sendingLoopThread = Thread.ofVirtual()
.name("sendingLoop")
.start(this::sendingLoop);
sendingLoopThread = Thread.ofVirtual().name("sendingLoop").start(this::sendingLoop);
}

private void sendMessage(OutgoingMessageV1 message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.faforever.iceadapter.gpgnet;

import static com.faforever.iceadapter.debug.Debug.debug;

import com.faforever.iceadapter.IceAdapter;
import com.faforever.iceadapter.rpc.RPCService;
import com.faforever.iceadapter.util.LockUtil;
import com.faforever.iceadapter.util.NetworkToolbox;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
Expand All @@ -18,8 +17,8 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

import static com.faforever.iceadapter.debug.Debug.debug;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class GPGNetServer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import com.faforever.iceadapter.IceAdapter;
import com.faforever.iceadapter.gpgnet.GPGNetServer;
import com.faforever.iceadapter.util.LockUtil;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

/**
* Represents a peer in the current game session which we are connected to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.faforever.iceadapter.ice;

import static com.faforever.iceadapter.debug.Debug.debug;

import com.faforever.iceadapter.IceAdapter;
import com.faforever.iceadapter.util.LockUtil;
import com.google.common.primitives.Longs;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import static com.faforever.iceadapter.debug.Debug.debug;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
* Periodically sends echo requests via the ICE data channel and initiates a reconnect after timeout
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.faforever.iceadapter.ice;

import static com.faforever.iceadapter.debug.Debug.debug;
import static com.faforever.iceadapter.ice.IceState.*;

import com.faforever.iceadapter.IceAdapter;
import com.faforever.iceadapter.rpc.RPCService;
import com.faforever.iceadapter.util.CandidateUtil;
import com.faforever.iceadapter.util.LockUtil;
import com.faforever.iceadapter.util.TrayIcon;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.ice4j.TransportAddress;
import org.ice4j.ice.*;
import org.ice4j.ice.harvest.StunCandidateHarvester;
import org.ice4j.ice.harvest.TurnCandidateHarvester;
import org.ice4j.security.LongTermCredential;

import java.io.IOException;
import java.net.DatagramPacket;
import java.util.ArrayList;
Expand All @@ -22,9 +17,13 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

import static com.faforever.iceadapter.debug.Debug.debug;
import static com.faforever.iceadapter.ice.IceState.*;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.ice4j.TransportAddress;
import org.ice4j.ice.*;
import org.ice4j.ice.harvest.StunCandidateHarvester;
import org.ice4j.ice.harvest.TurnCandidateHarvester;
import org.ice4j.security.LongTermCredential;

@Getter
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.faforever.iceadapter.ice;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.Duration;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.ice4j.ice.RelayedCandidate;
Expand All @@ -9,11 +13,6 @@
import org.ice4j.message.Request;
import org.ice4j.stack.TransactionID;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.Duration;

/**
* Sends continuous refresh requests to the turn server
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
import com.faforever.iceadapter.ice.Peer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -18,14 +25,6 @@
import org.ice4j.ice.CandidateType;
import org.ice4j.ice.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
* Handles calls from JsonRPC (the client)
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.faforever.iceadapter.rpc;

import static com.faforever.iceadapter.debug.Debug.debug;

import com.faforever.iceadapter.IceAdapter;
import com.faforever.iceadapter.debug.Debug;
import com.faforever.iceadapter.debug.InfoWindow;
Expand All @@ -11,13 +13,10 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.nbarraille.jjsonrpc.JJsonPeer;
import com.nbarraille.jjsonrpc.TcpServer;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static com.faforever.iceadapter.debug.Debug.debug;
import lombok.extern.slf4j.Slf4j;

/**
* Handles communication between client and adapter, opens a server for the client to connect to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.faforever.iceadapter.util;

import lombok.experimental.UtilityClass;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import lombok.experimental.UtilityClass;

@UtilityClass
public class ExecutorHolder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.faforever.iceadapter.util;

import lombok.experimental.UtilityClass;

import java.util.concurrent.locks.Lock;
import lombok.experimental.UtilityClass;

@UtilityClass
public class LockUtil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.faforever.iceadapter.util;

import com.faforever.iceadapter.IceAdapter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.SocketException;
import java.util.Random;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NetworkToolbox {
Expand Down
Loading

0 comments on commit 1f672ed

Please sign in to comment.