[ANY] Удаление устаревших классов

This commit is contained in:
Gravit 2020-01-18 17:33:18 +07:00
parent 495dba899d
commit 5939ed758f
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 0 additions and 334 deletions

View file

@ -1,153 +0,0 @@
package pro.gravit.launcher.client;
import pro.gravit.launcher.ClientLauncherWrapper;
import pro.gravit.launcher.guard.LauncherGuardManager;
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.managers.ClientHookManager;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.utils.DirWatcher;
import pro.gravit.utils.helper.EnvHelper;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import static pro.gravit.launcher.client.ClientLauncher.checkJVMBitsAndVersion;
public class ClientProcessBuilder {
private HashedDir assetHDir;
private HashedDir clientHDir;
private ClientProfile profile;
private ClientLauncher.Params params;
private Path nativesDir = IOHelper.toPath("natives");
private Path resourcepacksDir = IOHelper.toPath("resourcepacks");
private boolean pipeOutput = false;
private boolean clientLaunchStarting = false;
public interface ParamsWriter
{
void write(ClientLauncherContext context);
}
private ParamsWriter paramsWriter;
private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump";
public ClientProcessBuilder setAssetHDir(HashedDir assetHDir) {
this.assetHDir = assetHDir;
return this;
}
public ClientProcessBuilder setClientHDir(HashedDir clientHDir) {
this.clientHDir = clientHDir;
return this;
}
public ClientProcessBuilder setProfile(ClientProfile profile) {
this.profile = profile;
return this;
}
public ClientProcessBuilder setParams(ClientLauncher.Params params) {
this.params = params;
return this;
}
public ClientProcessBuilder setNativesDir(Path nativesDir) {
this.nativesDir = nativesDir;
return this;
}
public ClientProcessBuilder setResourcepacksDir(Path resourcepacksDir) {
this.resourcepacksDir = resourcepacksDir;
return this;
}
public ClientProcessBuilder setPipeOutput(boolean pipeOutput) {
this.pipeOutput = pipeOutput;
return this;
}
public ClientProcessBuilder setParamsWriter(ParamsWriter paramsWriter) {
this.paramsWriter = paramsWriter;
return this;
}
public ClientLauncherContext build() throws IOException {
LogHelper.debug("Writing ClientLauncher params");
ClientLauncherContext context = new ClientLauncherContext();
clientLaunchStarting = true;
checkJVMBitsAndVersion();
LogHelper.debug("Resolving JVM binary");
Path javaBin = LauncherGuardManager.getGuardJavaBinPath();
context.javaBin = javaBin;
context.clientProfile = profile;
context.playerProfile = params.pp;
context.args.add(javaBin.toString());
context.args.add(MAGICAL_INTEL_OPTION);
context.params = params;
if(paramsWriter != null) paramsWriter.write(context);
if (params.ram > 0) {
context.args.add("-Xms" + params.ram + 'M');
context.args.add("-Xmx" + params.ram + 'M');
}
context.args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled())));
context.args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled())));
context.args.add(JVMHelper.jvmProperty(LogHelper.DEV_PROPERTY, Boolean.toString(LogHelper.isDevEnabled())));
context.args.add(JVMHelper.jvmProperty(LogHelper.NO_JANSI_PROPERTY, "true")); // Отключаем JAnsi для нормального вывода в DEBUG окно
JVMHelper.addSystemPropertyToArgs(context.args, DirBridge.CUSTOMDIR_PROPERTY);
JVMHelper.addSystemPropertyToArgs(context.args, DirBridge.USE_CUSTOMDIR_PROPERTY);
JVMHelper.addSystemPropertyToArgs(context.args, DirBridge.USE_OPTDIR_PROPERTY);
JVMHelper.addSystemPropertyToArgs(context.args, DirWatcher.IGN_OVERFLOW);
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
if (JVMHelper.OS_VERSION.startsWith("10.")) {
LogHelper.debug("MustDie 10 fix is applied");
context.args.add(JVMHelper.jvmProperty("os.name", "Windows 10"));
context.args.add(JVMHelper.jvmProperty("os.version", "10.0"));
}
}
// Add classpath and main class
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
context.pathLauncher = pathLauncher;
context.args.add(ClientLauncherWrapper.MAGIC_ARG);
Collections.addAll(context.args, profile.getJvmArgs());
profile.pushOptionalJvmArgs(context.args);
context.args.add("-Djava.library.path=".concat(params.clientDir.resolve(nativesDir).toString())); // Add Native Path
context.args.add("-javaagent:".concat(pathLauncher));
ClientHookManager.clientLaunchHook.hook(context);
LauncherGuardManager.guard.addCustomParams(context);
context.args.add(ClientLauncher.class.getName());
ClientHookManager.clientLaunchFinallyHook.hook(context);
// Print commandline debug message
LogHelper.debug("Commandline: " + context.args);
// Build client process
LogHelper.debug("Launching client instance");
ProcessBuilder builder = new ProcessBuilder(context.args);
context.builder = builder;
LauncherGuardManager.guard.addCustomEnv(context);
//else
//builder.environment().put("CLASSPATH", classPathString.toString());
EnvHelper.addEnv(builder);
builder.directory(params.clientDir.toFile());
builder.inheritIO();
if (pipeOutput) {
builder.redirectErrorStream(true);
builder.redirectOutput(ProcessBuilder.Redirect.PIPE);
}
List<String> command = builder.command();
// Let's rock!
ClientHookManager.preStartHook.hook(context, builder);
context.process = builder.start();
if (builder.command() != command) {
LogHelper.error("Something strange cheating...");
System.exit(100);
return null;
}
ClientHookManager.postStartHook.hook(context, builder);
return context;
}
}

View file

@ -1,104 +0,0 @@
package pro.gravit.launcher.client;
import pro.gravit.launcher.NewLauncherSettings;
import pro.gravit.launcher.events.request.UpdateRequestEvent;
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.hasher.HashedEntry;
import pro.gravit.launcher.hasher.HashedFile;
import pro.gravit.launcher.request.update.UpdateRequest;
import pro.gravit.utils.helper.LogHelper;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
@Deprecated
public class LauncherUpdateController {
public void postDiff(UpdateRequest request, UpdateRequestEvent e, HashedDir.Diff diff) throws IOException {
/*
if (e.zip && e.fullDownload) return;
LogHelper.info("Enabled HStore feature. Find");
AtomicReference<NewLauncherSettings.HashedStoreEntry> lastEn = new AtomicReference<>(null);
//ArrayList<String> removed = new ArrayList<>();
diff.mismatch.walk(File.separator, (path, name, entry) -> {
if (entry.getType() == HashedEntry.Type.DIR) {
Files.createDirectories(request.getDir().resolve(path));
return HashedDir.WalkAction.CONTINUE;
}
HashedFile file = (HashedFile) entry;
//Первый экспериментальный способ - честно обходим все возможные Store
Path ret = null;
if (lastEn.get() == null) {
for (NewLauncherSettings.HashedStoreEntry en : SettingsManager.settings.lastHDirs) {
ret = tryFind(en, file);
if (ret != null) {
lastEn.set(en);
break;
}
}
} else {
ret = tryFind(lastEn.get(), file);
}
if (ret == null) {
for (NewLauncherSettings.HashedStoreEntry en : SettingsManager.settings.lastHDirs) {
ret = tryFind(en, file);
if (ret != null) {
lastEn.set(en);
break;
}
}
}
if (ret != null) {
//Еще раз проверим корректность хеша
//Возможно эта проверка избыточна
//if(file.isSame(ret, true))
{
Path source = request.getDir().resolve(path);
if (LogHelper.isDebugEnabled()) {
LogHelper.debug("Copy file %s to %s", ret.toAbsolutePath().toString(), source.toAbsolutePath().toString());
}
//Let's go!
Files.deleteIfExists(source);
Files.copy(ret, source);
try (InputStream input = IOHelper.newInput(ret)) {
IOHelper.transfer(input, source);
}
entry.flag = true;
//removed.add(path.replace('\\', '/'));
}
}
return HashedDir.WalkAction.CONTINUE;
});
*/
}
public Path tryFind(NewLauncherSettings.HashedStoreEntry en, HashedFile file) throws IOException {
AtomicReference<Path> ret = new AtomicReference<>(null);
en.hdir.walk(File.separator, (path, name, entry) -> {
if (entry.getType() == HashedEntry.Type.DIR) return HashedDir.WalkAction.CONTINUE;
HashedFile tfile = (HashedFile) entry;
if (tfile.isSame(file)) {
if (LogHelper.isDevEnabled()) {
LogHelper.dev("[DIR:%s] Found file %s in %s", en.name, name, path);
}
Path tdir = Paths.get(en.fullPath).resolve(path);
try {
if (tfile.isSame(tdir, true)) {
if (LogHelper.isDevEnabled()) {
LogHelper.dev("[DIR:%s] Confirmed file %s in %s", en.name, name, path);
}
ret.set(tdir);
return HashedDir.WalkAction.STOP;
}
} catch (IOException e) {
LogHelper.error("Check file error %s %s", e.getClass().getName(), e.getMessage());
}
}
return HashedDir.WalkAction.CONTINUE;
});
return ret.get();
}
}

View file

@ -1,9 +0,0 @@
package pro.gravit.launcher.managers;
public class HasherManager {
public static final HasherStore defaultStore = new HasherStore();
public static HasherStore getDefaultStore() {
return defaultStore;
}
}

View file

@ -1,68 +0,0 @@
package pro.gravit.launcher.managers;
import pro.gravit.launcher.hasher.FileNameMatcher;
import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.launcher.hasher.HashedEntry;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
public class HasherStore {
public Map<String, HasherStoreEnity> store;
public static class HasherStoreEnity {
public HashedDir hdir;
public Path dir;
public Collection<String> shared;
}
public void addProfileUpdateDir(ClientProfile profile, Path dir, HashedDir hdir) {
HasherStoreEnity e = new HasherStoreEnity();
e.hdir = hdir;
e.dir = dir;
e.shared = profile.getShared();
store.put(profile.getTitle(), e);
}
public void copyCompareFilesTo(String name, Path targetDir, HashedDir targetHDir, String[] shared) {
store.forEach((key, e) -> {
if (key.equals(name)) return;
FileNameMatcher nm = new FileNameMatcher(shared, null, null);
HashedDir compare = targetHDir.sideCompare(e.hdir, nm, new LinkedList<>(), true);
compare.map().forEach((arg1, arg2) -> recurseCopy(arg1, arg2, name, targetDir, e.dir));
});
}
public void recurseCopy(String filename, HashedEntry entry, String name, Path targetDir, Path sourceDir) {
if (!IOHelper.isDir(targetDir)) {
try {
Files.createDirectories(targetDir);
} catch (IOException e1) {
LogHelper.error(e1);
}
}
if (entry.getType().equals(HashedEntry.Type.DIR)) {
((HashedDir) entry).map().forEach((arg1, arg2) -> recurseCopy(arg1, arg2, name, targetDir.resolve(filename), sourceDir.resolve(filename)));
} else if (entry.getType().equals(HashedEntry.Type.FILE)) {
try {
IOHelper.copy(sourceDir.resolve(filename), targetDir.resolve(filename));
} catch (IOException e) {
LogHelper.error(e);
}
}
}
}