[ANY] Рефакторинг

This commit is contained in:
Zaxar163 2019-12-17 06:46:55 +01:00
parent 3bfed5c3c7
commit dcf9a56c01
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B
12 changed files with 22 additions and 24 deletions

View file

@ -1,6 +1,5 @@
package pro.gravit.launchserver.binary.tasks;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.X500NameBuilder;
import org.bouncycastle.asn1.x500.style.BCStyle;

View file

@ -12,7 +12,6 @@
import pro.gravit.launcher.managers.ClientGsonManager;
import pro.gravit.launcher.managers.ClientHookManager;
import pro.gravit.launcher.managers.ConsoleManager;
import pro.gravit.launcher.modules.events.ClosePhase;
import pro.gravit.launcher.modules.events.PreConfigPhase;
import pro.gravit.launcher.request.Request;
import pro.gravit.launcher.request.RequestException;
@ -88,7 +87,7 @@ public static void main(String... args) throws Throwable {
ConsoleManager.initConsole();
HWIDProvider.registerHWIDs();
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
LauncherConfig config = Launcher.getConfig();
Launcher.getConfig(); // init config
long startTime = System.currentTimeMillis();
try {
new LauncherEngine().start(args);

View file

@ -2,7 +2,6 @@
import pro.gravit.launcher.client.UserSettings;
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.profiles.ClientProfile;
import java.nio.file.Path;
import java.util.*;

View file

@ -22,8 +22,6 @@
import pro.gravit.launcher.serialize.HOutput;
import pro.gravit.launcher.serialize.stream.StreamObject;
import pro.gravit.launcher.utils.DirWatcher;
import pro.gravit.launcher.utils.NativeJVMHalt;
import pro.gravit.utils.PublicURLClassLoader;
import pro.gravit.utils.Version;
import pro.gravit.utils.helper.*;
import pro.gravit.utils.helper.JVMHelper.OS;

View file

@ -5,18 +5,15 @@
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.hasher.HashedEntry;
import pro.gravit.launcher.hasher.HashedFile;
import pro.gravit.launcher.managers.SettingsManager;
import pro.gravit.launcher.request.update.UpdateRequest;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
@Deprecated
public class LauncherUpdateController {

View file

@ -5,7 +5,6 @@
import pro.gravit.utils.PublicURLClassLoader;
import pro.gravit.utils.Version;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.launcher.LauncherTrustManager;

View file

@ -46,7 +46,6 @@ public R request(StdWebSocketService service) throws Exception {
return requestDo(service);
}
@SuppressWarnings("unchecked")
protected R requestDo(StdWebSocketService service) throws Exception {
return service.requestSync(this);
}

View file

@ -20,7 +20,6 @@
import java.lang.reflect.Type;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashSet;
public abstract class ClientWebSocketService extends ClientJSONPoint {
public final Gson gson;

View file

@ -18,6 +18,7 @@
import java.util.concurrent.ExecutionException;
public class StdWebSocketService extends ClientWebSocketService {
@SuppressWarnings("rawtypes")
private final ConcurrentHashMap<UUID, CompletableFuture> futureMap = new ConcurrentHashMap<>();
private final HashSet<EventHandler> eventHandlers = new HashSet<>();
public void registerEventHandler(EventHandler handler)
@ -50,6 +51,7 @@ public<T extends WebSocketEvent> void eventHandle(T webSocketEvent) {
processEventHandlers(webSocketEvent);
return;
}
@SuppressWarnings("rawtypes")
CompletableFuture future = futureMap.get(event.requestUUID);
if(future != null) {
if (event instanceof ErrorRequestEvent) {

View file

@ -17,12 +17,13 @@
import java.util.concurrent.Executor;
public class AsyncDownloader {
public static final Callback IGNORE = (ignored) -> {};
public AsyncDownloader(Callback callback) {
this.callback = callback;
}
public AsyncDownloader() {
callback = (ignored) -> {};
callback = IGNORE;
}
@FunctionalInterface
@ -33,11 +34,18 @@ public interface Callback
public final Callback callback;
public static class SizedFile
{
public final String path;
public final String urlPath, filePath;
public final long size;
public SizedFile(String path, long size) {
this.path = path;
this.urlPath = path;
this.filePath = path;
this.size = size;
}
public SizedFile(String urlPath, String filePath, long size) {
this.urlPath = urlPath;
this.filePath = filePath;
this.size = size;
}
}
@ -67,8 +75,8 @@ public void downloadListInOneThread(List<SizedFile> files, String baseURL, Path
String path = baseUri.getPath();
for(AsyncDownloader.SizedFile currentFile : files)
{
URL url = new URI(scheme,host,path + currentFile.path, "", "").toURL();
downloadFile(url, targetDir.resolve(currentFile.path), currentFile.size);
URL url = new URI(scheme, host, path + currentFile.urlPath, "", "").toURL();
downloadFile(url, targetDir.resolve(currentFile.filePath), currentFile.size);
}
}
public List<List<SizedFile>> sortFiles(List<SizedFile> files, int threads)
@ -90,6 +98,7 @@ public List<List<SizedFile>> sortFiles(List<SizedFile> files, int threads)
return result;
}
@SuppressWarnings("rawtypes")
public CompletableFuture[] runDownloadList(List<List<SizedFile>> files, String baseURL, Path targetDir, Executor executor) {
int threads = files.size();
CompletableFuture[] futures = new CompletableFuture[threads];

View file

@ -2,12 +2,10 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

@ -1 +1 @@
Subproject commit 3bee30b78fb6a2e92fc97e3b6a257a8c4e9d4d54
Subproject commit c3ce7d13bf9b31a6121b35198059d7289f855d0f