[ANY] IDEA Reformat code

This commit is contained in:
Gravit 2019-04-03 20:27:40 +07:00
parent f1ccfbf58e
commit bda1c3658b
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
126 changed files with 1031 additions and 1101 deletions

View file

@ -11,24 +11,20 @@
import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.serialize.signed.SignedObjectHolder; import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
import ru.gravit.launchserver.auth.AuthProviderPair; import ru.gravit.launchserver.auth.AuthProviderPair;
import ru.gravit.launchserver.auth.protect.NoProtectHandler;
import ru.gravit.launchserver.auth.protect.ProtectHandler;
import ru.gravit.launchserver.components.AuthLimiterComponent;
import ru.gravit.launchserver.auth.handler.AuthHandler; import ru.gravit.launchserver.auth.handler.AuthHandler;
import ru.gravit.launchserver.auth.handler.MemoryAuthHandler; import ru.gravit.launchserver.auth.handler.MemoryAuthHandler;
import ru.gravit.launchserver.auth.hwid.AcceptHWIDHandler; import ru.gravit.launchserver.auth.hwid.AcceptHWIDHandler;
import ru.gravit.launchserver.auth.hwid.HWIDHandler; import ru.gravit.launchserver.auth.hwid.HWIDHandler;
import ru.gravit.launchserver.auth.permissions.JsonFilePermissionsHandler; import ru.gravit.launchserver.auth.permissions.JsonFilePermissionsHandler;
import ru.gravit.launchserver.auth.permissions.PermissionsHandler; import ru.gravit.launchserver.auth.permissions.PermissionsHandler;
import ru.gravit.launchserver.auth.protect.NoProtectHandler;
import ru.gravit.launchserver.auth.protect.ProtectHandler;
import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.AuthProvider;
import ru.gravit.launchserver.auth.provider.RejectAuthProvider; import ru.gravit.launchserver.auth.provider.RejectAuthProvider;
import ru.gravit.launchserver.binary.*; import ru.gravit.launchserver.binary.*;
import ru.gravit.launchserver.components.AuthLimiterComponent;
import ru.gravit.launchserver.components.Component; import ru.gravit.launchserver.components.Component;
import ru.gravit.utils.config.JsonConfigurable;
import ru.gravit.launchserver.config.adapter.*; import ru.gravit.launchserver.config.adapter.*;
import ru.gravit.utils.command.CommandHandler;
import ru.gravit.utils.command.JLineCommandHandler;
import ru.gravit.utils.command.StdCommandHandler;
import ru.gravit.launchserver.manangers.*; import ru.gravit.launchserver.manangers.*;
import ru.gravit.launchserver.manangers.hook.AuthHookManager; import ru.gravit.launchserver.manangers.hook.AuthHookManager;
import ru.gravit.launchserver.manangers.hook.BuildHookManager; import ru.gravit.launchserver.manangers.hook.BuildHookManager;
@ -38,6 +34,10 @@
import ru.gravit.launchserver.socket.ServerSocketHandler; import ru.gravit.launchserver.socket.ServerSocketHandler;
import ru.gravit.launchserver.texture.RequestTextureProvider; import ru.gravit.launchserver.texture.RequestTextureProvider;
import ru.gravit.launchserver.texture.TextureProvider; import ru.gravit.launchserver.texture.TextureProvider;
import ru.gravit.utils.command.CommandHandler;
import ru.gravit.utils.command.JLineCommandHandler;
import ru.gravit.utils.command.StdCommandHandler;
import ru.gravit.utils.config.JsonConfigurable;
import ru.gravit.utils.helper.*; import ru.gravit.utils.helper.*;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -96,25 +96,21 @@ public static final class Config {
private transient AuthProviderPair authDefault; private transient AuthProviderPair authDefault;
public AuthProviderPair getAuthProviderPair(String name) public AuthProviderPair getAuthProviderPair(String name) {
{ for (AuthProviderPair pair : auth) {
for(AuthProviderPair pair : auth)
{
if (pair.name.equals(name)) return pair; if (pair.name.equals(name)) return pair;
} }
return null; return null;
} }
public ProtectHandler protectHandler; public ProtectHandler protectHandler;
public PermissionsHandler permissionsHandler; public PermissionsHandler permissionsHandler;
public AuthProviderPair getAuthProviderPair() public AuthProviderPair getAuthProviderPair() {
{
if (authDefault != null) return authDefault; if (authDefault != null) return authDefault;
for(AuthProviderPair pair : auth) for (AuthProviderPair pair : auth) {
{ if (pair.isDefault) {
if(pair.isDefault)
{
authDefault = pair; authDefault = pair;
return pair; return pair;
} }
@ -196,12 +192,10 @@ public void verify() {
break; break;
} }
} }
if(protectHandler == null) if (protectHandler == null) {
{
throw new NullPointerException("ProtectHandler must not be null"); throw new NullPointerException("ProtectHandler must not be null");
} }
if(!isOneDefault) if (!isOneDefault) {
{
throw new IllegalStateException("No auth pairs declared by default."); throw new IllegalStateException("No auth pairs declared by default.");
} }
if (permissionsHandler == null) { if (permissionsHandler == null) {
@ -210,13 +204,12 @@ public void verify() {
if (env == null) { if (env == null) {
throw new NullPointerException("Env must not be null"); throw new NullPointerException("Env must not be null");
} }
if(netty == null) if (netty == null) {
{
throw new NullPointerException("Netty must not be null"); throw new NullPointerException("Netty must not be null");
} }
} }
public void close()
{ public void close() {
try { try {
for (AuthProviderPair p : auth) p.close(); for (AuthProviderPair p : auth) p.close();
} catch (IOException e) { } catch (IOException e) {
@ -248,8 +241,8 @@ public static class ExeConf {
public String txtFileVersion; public String txtFileVersion;
public String txtProductVersion; public String txtProductVersion;
} }
public class NettyConfig
{ public class NettyConfig {
public String bindAddress; public String bindAddress;
public int port; public int port;
public boolean clientEnabled; public boolean clientEnabled;
@ -257,8 +250,8 @@ public class NettyConfig
public String launcherEXEURL; public String launcherEXEURL;
public String address; public String address;
} }
public class GuardLicenseConf
{ public class GuardLicenseConf {
public String name; public String name;
public String key; public String key;
public String encryptKey; public String encryptKey;
@ -469,12 +462,10 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
} }
config.permissionsHandler.init(); config.permissionsHandler.init();
config.hwidHandler.init(); config.hwidHandler.init();
if(config.protectHandler != null) if (config.protectHandler != null) {
{
config.protectHandler.checkLaunchServerLicense(); config.protectHandler.checkLaunchServerLicense();
} }
if(config.components != null) if (config.components != null) {
{
LogHelper.debug("PreInit components"); LogHelper.debug("PreInit components");
config.components.forEach((k, v) -> { config.components.forEach((k, v) -> {
LogHelper.subDebug("PreInit component %s", k); LogHelper.subDebug("PreInit component %s", k);
@ -507,8 +498,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
// init modules // init modules
modulesManager.initModules(); modulesManager.initModules();
if(config.components != null) if (config.components != null) {
{
LogHelper.debug("Init components"); LogHelper.debug("Init components");
config.components.forEach((k, v) -> { config.components.forEach((k, v) -> {
LogHelper.subDebug("Init component %s", k); LogHelper.subDebug("Init component %s", k);
@ -542,8 +532,7 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
// post init modules // post init modules
modulesManager.postInitModules(); modulesManager.postInitModules();
if(config.components != null) if (config.components != null) {
{
LogHelper.debug("PostInit components"); LogHelper.debug("PostInit components");
config.components.forEach((k, v) -> { config.components.forEach((k, v) -> {
LogHelper.subDebug("PostInit component %s", k); LogHelper.subDebug("PostInit component %s", k);
@ -789,22 +778,17 @@ public void restart() {
} }
} }
public void registerObject(String name, Object object) public void registerObject(String name, Object object) {
{ if (object instanceof Reloadable) {
if(object instanceof Reloadable)
{
reloadManager.registerReloadable(name, (Reloadable) object); reloadManager.registerReloadable(name, (Reloadable) object);
} }
if(object instanceof Reconfigurable) if (object instanceof Reconfigurable) {
{
reconfigurableManager.registerReconfigurable(name, (Reconfigurable) object); reconfigurableManager.registerReconfigurable(name, (Reconfigurable) object);
} }
if(object instanceof NeedGarbageCollection) if (object instanceof NeedGarbageCollection) {
{
GarbageManager.registerNeedGC((NeedGarbageCollection) object); GarbageManager.registerNeedGC((NeedGarbageCollection) object);
} }
if(object instanceof JsonConfigurable) if (object instanceof JsonConfigurable) {
{
} }
} }

View file

@ -20,8 +20,7 @@ public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvi
this.name = name; this.name = name;
} }
public void init() public void init() {
{
provider.init(); provider.init();
handler.init(); handler.init();
} }

View file

@ -80,8 +80,7 @@ public synchronized Connection getConnection() throws SQLException {
hikari = false; hikari = false;
// Try using HikariCP // Try using HikariCP
source = mysqlSource; source = mysqlSource;
if(enableHikari) if (enableHikari) {
{
try { try {
Class.forName("com.zaxxer.hikari.HikariDataSource"); Class.forName("com.zaxxer.hikari.HikariDataSource");
hikari = true; // Used for shutdown. Not instanceof because of possible classpath error hikari = true; // Used for shutdown. Not instanceof because of possible classpath error

View file

@ -1,7 +1,6 @@
package ru.gravit.launchserver.auth.hwid; package ru.gravit.launchserver.auth.hwid;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import ru.gravit.launcher.ClientPermissions;
import ru.gravit.launcher.HWID; import ru.gravit.launcher.HWID;
import ru.gravit.launcher.Launcher; import ru.gravit.launcher.Launcher;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
@ -16,12 +15,10 @@
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
public class JsonFileHWIDHandler extends HWIDHandler { public class JsonFileHWIDHandler extends HWIDHandler {
public class Entry public class Entry {
{
public HWID hwid; public HWID hwid;
public String username; public String username;
public boolean isBanned = false; public boolean isBanned = false;
@ -43,22 +40,22 @@ public int hashCode() {
return Objects.hash(hwid); return Objects.hash(hwid);
} }
} }
public String filename = "hwids.json"; public String filename = "hwids.json";
public transient LinkedList<Entry> list = new LinkedList<>(); public transient LinkedList<Entry> list = new LinkedList<>();
public String banMessage = "You banned"; public String banMessage = "You banned";
@Override @Override
public void ban(List<HWID> hwid) throws HWIDException { public void ban(List<HWID> hwid) throws HWIDException {
for(Entry e : list) for (Entry e : list) {
{ for (HWID banHWID : hwid) {
for(HWID banHWID : hwid)
{
if (e.hwid.equals(banHWID)) e.isBanned = true; if (e.hwid.equals(banHWID)) e.isBanned = true;
} }
} }
} }
@Override @Override
public void init() public void init() {
{
Path path = Paths.get(filename); Path path = Paths.get(filename);
Type type = new TypeToken<LinkedList<Entry>>() { Type type = new TypeToken<LinkedList<Entry>>() {
}.getType(); }.getType();
@ -72,16 +69,13 @@ public void init()
@Override @Override
public void check0(HWID hwid, String username) throws HWIDException { public void check0(HWID hwid, String username) throws HWIDException {
boolean isOne = false; boolean isOne = false;
for(Entry e : list) for (Entry e : list) {
{ if (e.hwid.equals(hwid)) {
if(e.hwid.equals(hwid))
{
isOne = true; isOne = true;
if (e.isBanned) throw new HWIDException(banMessage); if (e.isBanned) throw new HWIDException(banMessage);
} }
} }
if(!isOne) if (!isOne) {
{
list.add(new Entry(hwid)); list.add(new Entry(hwid));
} }
} }
@ -89,8 +83,7 @@ public void check0(HWID hwid, String username) throws HWIDException {
@Override @Override
public void close() throws Exception { public void close() throws Exception {
Path path = Paths.get(filename); Path path = Paths.get(filename);
try(Writer writer = IOHelper.newWriter(path)) try (Writer writer = IOHelper.newWriter(path)) {
{
LaunchServer.gson.toJson(list, writer); LaunchServer.gson.toJson(list, writer);
} }
} }
@ -98,8 +91,7 @@ public void close() throws Exception {
@Override @Override
public List<HWID> getHwid(String username) throws HWIDException { public List<HWID> getHwid(String username) throws HWIDException {
LinkedList<HWID> hwids = new LinkedList<>(); LinkedList<HWID> hwids = new LinkedList<>();
for(Entry e : list) for (Entry e : list) {
{
if (e.username.equals(username)) hwids.add(e.hwid); if (e.username.equals(username)) hwids.add(e.hwid);
} }
return hwids; return hwids;
@ -107,10 +99,8 @@ public List<HWID> getHwid(String username) throws HWIDException {
@Override @Override
public void unban(List<HWID> hwid) throws HWIDException { public void unban(List<HWID> hwid) throws HWIDException {
for(Entry e : list) for (Entry e : list) {
{ for (HWID banHWID : hwid) {
for(HWID banHWID : hwid)
{
if (e.hwid.equals(banHWID)) e.isBanned = false; if (e.hwid.equals(banHWID)) e.isBanned = false;
} }
} }

View file

@ -7,8 +7,7 @@
import java.util.Objects; import java.util.Objects;
public class MemoryHWIDHandler extends HWIDHandler { public class MemoryHWIDHandler extends HWIDHandler {
public class Entry public class Entry {
{
public HWID hwid; public HWID hwid;
public String username; public String username;
public boolean isBanned = false; public boolean isBanned = false;
@ -30,14 +29,14 @@ public int hashCode() {
return Objects.hash(hwid); return Objects.hash(hwid);
} }
} }
public transient LinkedList<Entry> list = new LinkedList<>(); public transient LinkedList<Entry> list = new LinkedList<>();
public String banMessage = "You banned"; public String banMessage = "You banned";
@Override @Override
public void ban(List<HWID> hwid) throws HWIDException { public void ban(List<HWID> hwid) throws HWIDException {
for(Entry e : list) for (Entry e : list) {
{ for (HWID banHWID : hwid) {
for(HWID banHWID : hwid)
{
if (e.hwid.equals(banHWID)) e.isBanned = true; if (e.hwid.equals(banHWID)) e.isBanned = true;
} }
} }
@ -46,16 +45,13 @@ public void ban(List<HWID> hwid) throws HWIDException {
@Override @Override
public void check0(HWID hwid, String username) throws HWIDException { public void check0(HWID hwid, String username) throws HWIDException {
boolean isOne = false; boolean isOne = false;
for(Entry e : list) for (Entry e : list) {
{ if (e.hwid.equals(hwid)) {
if(e.hwid.equals(hwid))
{
isOne = true; isOne = true;
if (e.isBanned) throw new HWIDException(banMessage); if (e.isBanned) throw new HWIDException(banMessage);
} }
} }
if(!isOne) if (!isOne) {
{
list.add(new Entry(hwid)); list.add(new Entry(hwid));
} }
} }
@ -73,8 +69,7 @@ public void init() {
@Override @Override
public List<HWID> getHwid(String username) throws HWIDException { public List<HWID> getHwid(String username) throws HWIDException {
LinkedList<HWID> hwids = new LinkedList<>(); LinkedList<HWID> hwids = new LinkedList<>();
for(Entry e : list) for (Entry e : list) {
{
if (e.username.equals(username)) hwids.add(e.hwid); if (e.username.equals(username)) hwids.add(e.hwid);
} }
return hwids; return hwids;
@ -82,10 +77,8 @@ public List<HWID> getHwid(String username) throws HWIDException {
@Override @Override
public void unban(List<HWID> hwid) throws HWIDException { public void unban(List<HWID> hwid) throws HWIDException {
for(Entry e : list) for (Entry e : list) {
{ for (HWID banHWID : hwid) {
for(HWID banHWID : hwid)
{
if (e.hwid.equals(banHWID)) e.isBanned = false; if (e.hwid.equals(banHWID)) e.isBanned = false;
} }
} }

View file

@ -143,8 +143,7 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI
boolean isOne = false; boolean isOne = false;
while (set.next()) { while (set.next()) {
if (!oneCompareMode) isOne = true; if (!oneCompareMode) isOne = true;
if(compareMode) if (compareMode) {
{
OshiHWID db_hwid = new OshiHWID(); OshiHWID db_hwid = new OshiHWID();
db_hwid.serialNumber = set.getString(hwidFieldSerialNumber); db_hwid.serialNumber = set.getString(hwidFieldSerialNumber);
db_hwid.processorID = set.getString(hwidFieldProcessorID); db_hwid.processorID = set.getString(hwidFieldProcessorID);
@ -154,8 +153,7 @@ public void onCheckInfo(OshiHWID hwid, String username, Connection c) throws HWI
LogHelper.dev("Compare HWID: %s vs %s", hwid.getSerializeString(), db_hwid.getSerializeString()); LogHelper.dev("Compare HWID: %s vs %s", hwid.getSerializeString(), db_hwid.getSerializeString());
int compare_point = hwid.compare(db_hwid); int compare_point = hwid.compare(db_hwid);
if (compare_point < compare) continue; if (compare_point < compare) continue;
else else {
{
LogHelper.debug("User %s hwid check: found compare %d in %d", username, compare_point, set.getInt("id")); LogHelper.debug("User %s hwid check: found compare %d in %d", username, compare_point, set.getInt("id"));
} }
} }

View file

@ -37,8 +37,7 @@ public static void registerProviders() {
public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception; public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception;
public void preAuth(String login, String password, String customText, String ip) throws Exception public void preAuth(String login, String password, String customText, String ip) throws Exception {
{
return; return;
} }

View file

@ -29,8 +29,7 @@ public void init() {
@Override @Override
public AuthProviderResult auth(String login, String password, String ip) throws SQLException, AuthException { public AuthProviderResult auth(String login, String password, String ip) throws SQLException, AuthException {
try(Connection c = mySQLHolder.getConnection()) try (Connection c = mySQLHolder.getConnection()) {
{
PreparedStatement s = c.prepareStatement(query); PreparedStatement s = c.prepareStatement(query);
String[] replaceParams = {"login", login, "password", password, "ip", ip}; String[] replaceParams = {"login", login, "password", password, "ip", ip};
for (int i = 0; i < queryParams.length; i++) for (int i = 0; i < queryParams.length; i++)

View file

@ -70,6 +70,7 @@ public void setAddress(String address) {
body.append(address); body.append(address);
body.append("\";"); body.append("\";");
} }
public void setNettyAddress(String address) { public void setNettyAddress(String address) {
body.append("this.nettyAddress = \""); body.append("this.nettyAddress = \"");
body.append(address); body.append(address);
@ -139,6 +140,7 @@ public void setDownloadJava(boolean b) {
body.append(b ? "true" : "false"); body.append(b ? "true" : "false");
body.append(";"); body.append(";");
} }
public void setNettyEnabled(boolean b) { public void setNettyEnabled(boolean b) {
body.append("this.isNettyEnabled = "); body.append("this.isNettyEnabled = ");
body.append(b ? "true" : "false"); body.append(b ? "true" : "false");
@ -151,8 +153,7 @@ public void setWarningMissArchJava(boolean b) {
body.append(";"); body.append(";");
} }
public void setGuardLicense(String name, String key, String encryptKey) public void setGuardLicense(String name, String key, String encryptKey) {
{
body.append("this.guardLicenseName = \""); body.append("this.guardLicenseName = \"");
body.append(name); body.append(name);
body.append("\";"); body.append("\";");

View file

@ -6,7 +6,9 @@
import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.UnpackHelper; import ru.gravit.utils.helper.UnpackHelper;
import java.io.*; import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.security.SecureRandom; import java.security.SecureRandom;
@ -18,8 +20,7 @@ public class ProguardConf {
private static String generateString(SecureRandom rand, String lowString, String upString, int il) { private static String generateString(SecureRandom rand, String lowString, String upString, int il) {
StringBuilder sb = new StringBuilder(il + lowString.length()); StringBuilder sb = new StringBuilder(il + lowString.length());
for(int i = 0;i<lowString.length();++i) for (int i = 0; i < lowString.length(); ++i) {
{
sb.append(rand.nextBoolean() ? lowString.charAt(i) : upString.charAt(i)); sb.append(rand.nextBoolean() ? lowString.charAt(i) : upString.charAt(i));
} }
for (int i = 0; i < il - 1; i++) sb.append(chars.charAt(rand.nextInt(chars.length()))); for (int i = 0; i < il - 1; i++) sb.append(chars.charAt(rand.nextInt(chars.length())));

View file

@ -131,8 +131,7 @@ public Path process(Path inputJar) throws IOException {
jaConfigurator.setAddress(server.config.getAddress()); jaConfigurator.setAddress(server.config.getAddress());
jaConfigurator.setPort(server.config.port); jaConfigurator.setPort(server.config.port);
jaConfigurator.setNettyEnabled(server.config.netty.clientEnabled); jaConfigurator.setNettyEnabled(server.config.netty.clientEnabled);
if(server.config.netty.clientEnabled) if (server.config.netty.clientEnabled) {
{
jaConfigurator.setNettyPort(server.config.netty.port); jaConfigurator.setNettyPort(server.config.netty.port);
jaConfigurator.setNettyAddress(server.config.netty.address); jaConfigurator.setNettyAddress(server.config.netty.address);
} }

View file

@ -1,5 +1,8 @@
package ru.gravit.launchserver.binary.tasks; package ru.gravit.launchserver.binary.tasks;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.UnpackHelper; import ru.gravit.utils.helper.UnpackHelper;
@ -10,10 +13,6 @@
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.itzsomebody.radon.Radon;
import me.itzsomebody.radon.SessionInfo;
import me.itzsomebody.radon.config.ConfigurationParser;
public class RadonBuildTask implements LauncherBuildTask { public class RadonBuildTask implements LauncherBuildTask {
private final LaunchServer srv; private final LaunchServer srv;
public final Path config; public final Path config;
@ -33,7 +32,8 @@ public String getName() {
public Path process(Path inputFile) throws IOException { public Path process(Path inputFile) throws IOException {
Path outputFile = srv.launcherBinary.nextLowerPath(this); Path outputFile = srv.launcherBinary.nextLowerPath(this);
if (srv.config.enabledRadon) { if (srv.config.enabledRadon) {
if (!IOHelper.isFile(config)) UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config); if (!IOHelper.isFile(config))
UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config);
ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config)); ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config));
SessionInfo info = p.createSessionFromConfig(); SessionInfo info = p.createSessionFromConfig();
info.setInput(inputFile.toFile()); info.setInput(inputFile.toFile());

View file

@ -13,8 +13,7 @@
import ru.gravit.launchserver.command.service.*; import ru.gravit.launchserver.command.service.*;
public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler { public abstract class CommandHandler extends ru.gravit.utils.command.CommandHandler {
public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) public static void registerCommands(ru.gravit.utils.command.CommandHandler handler) {
{
LaunchServer server = LaunchServer.server; LaunchServer server = LaunchServer.server;
// Register basic commands // Register basic commands
handler.registerCommand("help", new HelpCommand(server)); handler.registerCommand("help", new HelpCommand(server));

View file

@ -4,8 +4,8 @@
import ru.gravit.launcher.profiles.ClientProfile.Version; import ru.gravit.launcher.profiles.ClientProfile.Version;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.HttpDownloader; import ru.gravit.utils.HttpDownloader;
import ru.gravit.utils.command.CommandException;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;

View file

@ -20,8 +20,7 @@ public String getUsageDescription() {
@Override @Override
public void invoke(String... args) throws Exception { public void invoke(String... args) throws Exception {
for(String arg : args) for (String arg : args) {
{
server.commandHandler.eval(arg, false); server.commandHandler.eval(arg, false);
} }
} }

View file

@ -25,8 +25,7 @@ public String getUsageDescription() {
return "component manager"; return "component manager";
} }
public void printHelp() public void printHelp() {
{
LogHelper.info("Print help for component:"); LogHelper.info("Print help for component:");
LogHelper.subInfo("component unload [componentName]"); LogHelper.subInfo("component unload [componentName]");
LogHelper.subInfo("component load [componentName] [filename]"); LogHelper.subInfo("component load [componentName] [filename]");
@ -38,53 +37,42 @@ public void invoke(String... args) throws Exception {
verifyArgs(args, 1); verifyArgs(args, 1);
String componentName = null; String componentName = null;
if (args.length > 1) componentName = args[1]; if (args.length > 1) componentName = args[1];
switch(args[0]) switch (args[0]) {
{ case "unload": {
case "unload":
{
if (componentName == null) throw new IllegalArgumentException("Must set componentName"); if (componentName == null) throw new IllegalArgumentException("Must set componentName");
Component component = server.config.components.get(componentName); Component component = server.config.components.get(componentName);
if (component == null) { if (component == null) {
LogHelper.error("Component %s not found", componentName); LogHelper.error("Component %s not found", componentName);
return; return;
} }
if(component instanceof AutoCloseable) if (component instanceof AutoCloseable) {
{
((AutoCloseable) component).close(); ((AutoCloseable) component).close();
} } else {
else
{
LogHelper.error("Component %s unload not supported", componentName); LogHelper.error("Component %s unload not supported", componentName);
return; return;
} }
break; break;
} }
case "gc": case "gc": {
{
if (componentName == null) throw new IllegalArgumentException("Must set componentName"); if (componentName == null) throw new IllegalArgumentException("Must set componentName");
Component component = server.config.components.get(componentName); Component component = server.config.components.get(componentName);
if (component == null) { if (component == null) {
LogHelper.error("Component %s not found", componentName); LogHelper.error("Component %s not found", componentName);
return; return;
} }
if(component instanceof NeedGarbageCollection) if (component instanceof NeedGarbageCollection) {
{
((NeedGarbageCollection) component).garbageCollection(); ((NeedGarbageCollection) component).garbageCollection();
} } else {
else
{
LogHelper.error("Component %s gc not supported", componentName); LogHelper.error("Component %s gc not supported", componentName);
return; return;
} }
break; break;
} }
case "load": case "load": {
{
if (componentName == null) throw new IllegalArgumentException("Must set componentName"); if (componentName == null) throw new IllegalArgumentException("Must set componentName");
if (args.length <= 2) throw new IllegalArgumentException("Must set file"); if (args.length <= 2) throw new IllegalArgumentException("Must set file");
String fileName = args[2]; String fileName = args[2];
try(Reader reader = IOHelper.newReader(Paths.get(fileName))) try (Reader reader = IOHelper.newReader(Paths.get(fileName))) {
{
Component component = LaunchServer.gson.fromJson(reader, Component.class); Component component = LaunchServer.gson.fromJson(reader, Component.class);
component.preInit(server); component.preInit(server);
component.init(server); component.init(server);
@ -92,12 +80,10 @@ public void invoke(String... args) throws Exception {
LogHelper.info("Component %s(%s) loaded", componentName, component.getClass().getName()); LogHelper.info("Component %s(%s) loaded", componentName, component.getClass().getName());
} }
} }
case "help": case "help": {
{
printHelp(); printHelp();
} }
default: default: {
{
printHelp(); printHelp();
} }
} }

View file

@ -27,25 +27,20 @@ public void invoke(String... args) throws Exception {
ClientPermissions permissions = server.config.permissionsHandler.getPermissions(username); ClientPermissions permissions = server.config.permissionsHandler.getPermissions(username);
String permission = args[1]; String permission = args[1];
boolean isEnabled = Boolean.valueOf(args[2]); boolean isEnabled = Boolean.valueOf(args[2]);
switch (permission) switch (permission) {
{ case "admin": {
case "admin":
{
permissions.canAdmin = isEnabled; permissions.canAdmin = isEnabled;
break; break;
} }
case "server": case "server": {
{
permissions.canServer = isEnabled; permissions.canServer = isEnabled;
break; break;
} }
case "bot": case "bot": {
{
permissions.canBot = isEnabled; permissions.canBot = isEnabled;
break; break;
} }
default: default: {
{
LogHelper.error("Unknown permission: %s", permission); LogHelper.error("Unknown permission: %s", permission);
return; return;
} }

View file

@ -34,8 +34,7 @@ public void invoke(String... args) {
LogHelper.info("Uptime: %d days %d hours %d minutes %d seconds", days, hour, min, second); LogHelper.info("Uptime: %d days %d hours %d minutes %d seconds", days, hour, min, second);
LogHelper.info("Uptime (double): %f", (double) JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000); LogHelper.info("Uptime (double): %f", (double) JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000);
LogHelper.info("Sessions: %d | Modules: %d | Commands: %d", server.sessionManager.getSessions().size(), server.modulesManager.modules.size(), server.commandHandler.commandsMap().size()); LogHelper.info("Sessions: %d | Modules: %d | Commands: %d", server.sessionManager.getSessions().size(), server.modulesManager.modules.size(), server.commandHandler.commandsMap().size());
for(AuthProviderPair pair : server.config.auth) for (AuthProviderPair pair : server.config.auth) {
{
if (pair.handler instanceof CachedAuthHandler) { if (pair.handler instanceof CachedAuthHandler) {
LogHelper.info("AuthHandler %s: EntryCache: %d | usernameCache: %d", pair.name, ((CachedAuthHandler) pair.handler).getEntryCache().size(), ((CachedAuthHandler) pair.handler).getUsernamesCache().size()); LogHelper.info("AuthHandler %s: EntryCache: %d | usernameCache: %d", pair.name, ((CachedAuthHandler) pair.handler).getEntryCache().size(), ((CachedAuthHandler) pair.handler).getUsernamesCache().size());
} }

View file

@ -4,7 +4,6 @@
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.launchserver.auth.provider.AuthProvider; import ru.gravit.launchserver.auth.provider.AuthProvider;
import ru.gravit.launchserver.components.Component;
import ru.gravit.launchserver.response.auth.AuthResponse; import ru.gravit.launchserver.response.auth.AuthResponse;
import ru.gravit.launchserver.socket.Client; import ru.gravit.launchserver.socket.Client;
@ -26,9 +25,9 @@ public void init(LaunchServer launchServer) {
public void postInit(LaunchServer launchServer) { public void postInit(LaunchServer launchServer) {
} }
public void preAuthHook(AuthResponse.AuthContext context, Client client) throws AuthException { public void preAuthHook(AuthResponse.AuthContext context, Client client) throws AuthException {
if(isLimit(context.ip)) if (isLimit(context.ip)) {
{
AuthProvider.authError(message); AuthProvider.authError(message);
} }
} }

View file

@ -9,6 +9,7 @@
public class CommandRemoverComponent extends Component implements AutoCloseable { public class CommandRemoverComponent extends Component implements AutoCloseable {
public String[] removeList = new String[]{}; public String[] removeList = new String[]{};
public transient Map<String, Command> commandsList = new HashMap<>(); public transient Map<String, Command> commandsList = new HashMap<>();
@Override @Override
public void preInit(LaunchServer launchServer) { public void preInit(LaunchServer launchServer) {
@ -21,8 +22,7 @@ public void init(LaunchServer launchServer) {
@Override @Override
public void postInit(LaunchServer launchServer) { public void postInit(LaunchServer launchServer) {
for(String cmd : removeList) for (String cmd : removeList) {
{
Command removedCmd = launchServer.commandHandler.unregisterCommand(cmd); Command removedCmd = launchServer.commandHandler.unregisterCommand(cmd);
if (removedCmd != null) if (removedCmd != null)
commandsList.put(cmd, removedCmd); commandsList.put(cmd, removedCmd);
@ -31,8 +31,7 @@ public void postInit(LaunchServer launchServer) {
@Override @Override
public void close() throws Exception { public void close() throws Exception {
for(Map.Entry<String, Command> e : commandsList.entrySet()) for (Map.Entry<String, Command> e : commandsList.entrySet()) {
{
LaunchServer.server.commandHandler.registerCommand(e.getKey(), e.getValue()); LaunchServer.server.commandHandler.registerCommand(e.getKey(), e.getValue());
} }
} }

View file

@ -35,7 +35,10 @@ public static void registerComponents() {
registredComp = true; registredComp = true;
} }
} }
public abstract void preInit(LaunchServer launchServer); public abstract void preInit(LaunchServer launchServer);
public abstract void init(LaunchServer launchServer); public abstract void init(LaunchServer launchServer);
public abstract void postInit(LaunchServer launchServer); public abstract void postInit(LaunchServer launchServer);
} }

View file

@ -13,8 +13,7 @@ public class AuthHandlerAdapter implements JsonSerializer<AuthHandler>, JsonDese
public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public AuthHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends AuthHandler> cls = AuthHandler.getHandlerClass(typename); Class<? extends AuthHandler> cls = AuthHandler.getHandlerClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("AuthHandler %s not found", typename); LogHelper.error("AuthHandler %s not found", typename);
return null; return null;
} }

View file

@ -13,8 +13,7 @@ public class AuthProviderAdapter implements JsonSerializer<AuthProvider>, JsonDe
public AuthProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public AuthProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends AuthProvider> cls = AuthProvider.getProviderClass(typename); Class<? extends AuthProvider> cls = AuthProvider.getProviderClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("AuthProvider %s not found", typename); LogHelper.error("AuthProvider %s not found", typename);
return null; return null;
} }

View file

@ -13,8 +13,7 @@ public class ComponentAdapter implements JsonSerializer<Component>, JsonDeserial
public Component deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public Component deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends Component> cls = Component.getComponentClass(typename); Class<? extends Component> cls = Component.getComponentClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("Component %s not found", typename); LogHelper.error("Component %s not found", typename);
return null; return null;
} }

View file

@ -13,8 +13,7 @@ public class HWIDHandlerAdapter implements JsonSerializer<HWIDHandler>, JsonDese
public HWIDHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public HWIDHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends HWIDHandler> cls = HWIDHandler.getHandlerClass(typename); Class<? extends HWIDHandler> cls = HWIDHandler.getHandlerClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("HWIDHandler %s not found", typename); LogHelper.error("HWIDHandler %s not found", typename);
return null; return null;
} }

View file

@ -13,8 +13,7 @@ public class PermissionsHandlerAdapter implements JsonSerializer<PermissionsHand
public PermissionsHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public PermissionsHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends PermissionsHandler> cls = PermissionsHandler.getHandlerClass(typename); Class<? extends PermissionsHandler> cls = PermissionsHandler.getHandlerClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("PermissionsHandler %s not found", typename); LogHelper.error("PermissionsHandler %s not found", typename);
return null; return null;
} }

View file

@ -13,8 +13,7 @@ public class ProtectHandlerAdapter implements JsonSerializer<ProtectHandler>, Js
public ProtectHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public ProtectHandler deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends ProtectHandler> cls = ProtectHandler.getHandlerClass(typename); Class<? extends ProtectHandler> cls = ProtectHandler.getHandlerClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("ProtectHandler %s not found", typename); LogHelper.error("ProtectHandler %s not found", typename);
return null; return null;
} }

View file

@ -13,8 +13,7 @@ public class TextureProviderAdapter implements JsonSerializer<TextureProvider>,
public TextureProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public TextureProvider deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString(); String typename = json.getAsJsonObject().getAsJsonPrimitive(PROP_NAME).getAsString();
Class<? extends TextureProvider> cls = TextureProvider.getProviderClass(typename); Class<? extends TextureProvider> cls = TextureProvider.getProviderClass(typename);
if(cls == null) if (cls == null) {
{
LogHelper.error("TextureProvider %s not found", typename); LogHelper.error("TextureProvider %s not found", typename);
return null; return null;
} }

View file

@ -1,7 +1,7 @@
package ru.gravit.launchserver.manangers; package ru.gravit.launchserver.manangers;
import ru.gravit.launcher.managers.SimpleModulesConfigManager;
import ru.gravit.launcher.managers.SimpleModuleManager; import ru.gravit.launcher.managers.SimpleModuleManager;
import ru.gravit.launcher.managers.SimpleModulesConfigManager;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.modules.CoreModule; import ru.gravit.launchserver.modules.CoreModule;
import ru.gravit.launchserver.modules.LaunchServerModuleContext; import ru.gravit.launchserver.modules.LaunchServerModuleContext;

View file

@ -34,8 +34,8 @@ public Client(long session) {
public void up() { public void up() {
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
} }
public void updateAuth()
{ public void updateAuth() {
if (!isAuth) return; if (!isAuth) return;
if (auth_id.isEmpty()) auth = LaunchServer.server.config.getAuthProviderPair(); if (auth_id.isEmpty()) auth = LaunchServer.server.config.getAuthProviderPair();
else auth = LaunchServer.server.config.getAuthProviderPair(auth_id); else auth = LaunchServer.server.config.getAuthProviderPair(auth_id);

View file

@ -86,6 +86,7 @@ public void registerResponses() {
public void sendObject(ChannelHandlerContext ctx, Object obj) { public void sendObject(ChannelHandlerContext ctx, Object obj) {
ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, ResultInterface.class))); ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, ResultInterface.class)));
} }
public void sendObject(ChannelHandlerContext ctx, Object obj, Type type) { public void sendObject(ChannelHandlerContext ctx, Object obj, Type type) {
ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, type))); ctx.channel().writeAndFlush(new TextWebSocketFrame(gson.toJson(obj, type)));
} }

View file

@ -10,6 +10,7 @@
public class AddLogListenerResponse implements JsonResponseInterface { public class AddLogListenerResponse implements JsonResponseInterface {
public LogHelper.OutputTypes outputType = LogHelper.OutputTypes.PLAIN; public LogHelper.OutputTypes outputType = LogHelper.OutputTypes.PLAIN;
@Override @Override
public String getType() { public String getType() {
return "addLogListener"; return "addLogListener";
@ -25,20 +26,15 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
service.sendObject(ctx, new ErrorRequestEvent("Access denied")); service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
return; return;
} }
if(client.logOutput != null) if (client.logOutput != null) {
{
LogHelper.info("Client %s remove log listener", client.username); LogHelper.info("Client %s remove log listener", client.username);
LogHelper.removeOutput(client.logOutput); LogHelper.removeOutput(client.logOutput);
} } else {
else
{
LogHelper.info("Client %s add log listener", client.username); LogHelper.info("Client %s add log listener", client.username);
LogHelper.Output output = (str) -> { LogHelper.Output output = (str) -> {
if(!ctx.isRemoved()) if (!ctx.isRemoved()) {
{
service.sendObject(ctx, new LogEvent(str)); service.sendObject(ctx, new LogEvent(str));
} } else {
else {
LogHelper.removeOutput(client.logOutput); LogHelper.removeOutput(client.logOutput);
LogHelper.info("Client %s remove log listener", client.username); LogHelper.info("Client %s remove log listener", client.username);
} }

View file

@ -42,8 +42,8 @@ public AuthResponse(String login, String password, String auth_id, OshiHWID hwid
public String auth_id; public String auth_id;
public ConnectTypes authType; public ConnectTypes authType;
public OshiHWID hwid; public OshiHWID hwid;
public enum ConnectTypes
{ public enum ConnectTypes {
SERVER, CLIENT, BOT SERVER, CLIENT, BOT
} }
@ -61,8 +61,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
AuthProvider.authError("Don't skip Launcher Update"); AuthProvider.authError("Don't skip Launcher Update");
return; return;
} }
if(password == null) if (password == null) {
{
try { try {
password = IOHelper.decode(SecurityHelper.newRSADecryptCipher(LaunchServer.server.privateKey). password = IOHelper.decode(SecurityHelper.newRSADecryptCipher(LaunchServer.server.privateKey).
doFinal(encryptedPassword)); doFinal(encryptedPassword));
@ -71,12 +70,10 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
} }
} }
clientData.permissions = LaunchServer.server.config.permissionsHandler.getPermissions(login); clientData.permissions = LaunchServer.server.config.permissionsHandler.getPermissions(login);
if(authType == ConnectTypes.BOT && !clientData.permissions.canBot) if (authType == ConnectTypes.BOT && !clientData.permissions.canBot) {
{
AuthProvider.authError("authType: BOT not allowed for this account"); AuthProvider.authError("authType: BOT not allowed for this account");
} }
if(authType == ConnectTypes.SERVER && !clientData.permissions.canServer) if (authType == ConnectTypes.SERVER && !clientData.permissions.canServer) {
{
AuthProvider.authError("authType: SERVER not allowed for this account"); AuthProvider.authError("authType: SERVER not allowed for this account");
} }
AuthProviderPair pair; AuthProviderPair pair;

View file

@ -19,8 +19,7 @@ public String getType() {
@Override @Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
if(!client.checkSign) if (!client.checkSign) {
{
service.sendObject(ctx, new ErrorRequestEvent("Access denied")); service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
return; return;
} }

View file

@ -13,6 +13,7 @@
public class SetProfileResponse implements JsonResponseInterface { public class SetProfileResponse implements JsonResponseInterface {
public String client; public String client;
@Override @Override
public String getType() { public String getType() {
return "setProfile"; return "setProfile";
@ -20,8 +21,7 @@ public String getType() {
@Override @Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
if(!client.isAuth) if (!client.isAuth) {
{
service.sendObject(ctx, new ErrorRequestEvent("Access denied")); service.sendObject(ctx, new ErrorRequestEvent("Access denied"));
return; return;
} }

View file

@ -11,12 +11,13 @@
import java.util.UUID; import java.util.UUID;
public class BatchProfileByUsername implements JsonResponseInterface { public class BatchProfileByUsername implements JsonResponseInterface {
class Entry class Entry {
{
String username; String username;
String client; String client;
} }
Entry[] list; Entry[] list;
@Override @Override
public String getType() { public String getType() {
return "batchProfileByUsername"; return "batchProfileByUsername";
@ -26,8 +27,7 @@ public String getType() {
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception { public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent(); BatchProfileByUsernameRequestEvent result = new BatchProfileByUsernameRequestEvent();
result.playerProfiles = new PlayerProfile[list.length]; result.playerProfiles = new PlayerProfile[list.length];
for(int i=0;i<list.length;++i) for (int i = 0; i < list.length; ++i) {
{
UUID uuid = client.auth.handler.usernameToUUID(list[i].username); UUID uuid = client.auth.handler.usernameToUUID(list[i].username);
result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider); result.playerProfiles[i] = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, list[i].username, list[i].client, client.auth.textureProvider);
} }

View file

@ -17,6 +17,7 @@
public class ProfileByUUIDResponse implements JsonResponseInterface { public class ProfileByUUIDResponse implements JsonResponseInterface {
public UUID uuid; public UUID uuid;
public String client; public String client;
public static PlayerProfile getProfile(LaunchServer server, UUID uuid, String username, String client, TextureProvider textureProvider) { public static PlayerProfile getProfile(LaunchServer server, UUID uuid, String username, String client, TextureProvider textureProvider) {
// Get skin texture // Get skin texture
Texture skin; Texture skin;

View file

@ -14,6 +14,7 @@
public class ProfileByUsername implements JsonResponseInterface { public class ProfileByUsername implements JsonResponseInterface {
String username; String username;
String client; String client;
@Override @Override
public String getType() { public String getType() {
return "profileByUsername"; return "profileByUsername";

View file

@ -11,6 +11,7 @@
public class UpdateResponse implements JsonResponseInterface { public class UpdateResponse implements JsonResponseInterface {
public String dir; public String dir;
@Override @Override
public String getType() { public String getType() {
return "update"; return "update";

View file

@ -8,13 +8,12 @@
public class ConsoleMain { public class ConsoleMain {
public static CommandHandler commandHandler; public static CommandHandler commandHandler;
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
if(ServerWrapper.config == null) if (ServerWrapper.config == null) {
{
LogHelper.warning("ServerWrapper not found"); LogHelper.warning("ServerWrapper not found");
} }
if(!ServerWrapper.permissions.canAdmin) if (!ServerWrapper.permissions.canAdmin) {
{
LogHelper.warning("Permission canAdmin not found"); LogHelper.warning("Permission canAdmin not found");
} }
try { try {

View file

@ -9,9 +9,9 @@
public class RemoteJLineCommandHandler extends JLineCommandHandler { public class RemoteJLineCommandHandler extends JLineCommandHandler {
public RemoteJLineCommandHandler() throws IOException { public RemoteJLineCommandHandler() throws IOException {
} }
@Override @Override
public void eval(String line, boolean bell) public void eval(String line, boolean bell) {
{
if (line.equals("exit")) System.exit(0); if (line.equals("exit")) System.exit(0);
ExecCommandRequest request = new ExecCommandRequest(System.out::println, line); ExecCommandRequest request = new ExecCommandRequest(System.out::println, line);
try { try {

View file

@ -8,9 +8,9 @@ public class RemoteStdCommandHandler extends StdCommandHandler {
public RemoteStdCommandHandler(boolean readCommands) { public RemoteStdCommandHandler(boolean readCommands) {
super(readCommands); super(readCommands);
} }
@Override @Override
public void eval(String line, boolean bell) public void eval(String line, boolean bell) {
{
if (line.equals("exit")) System.exit(0); if (line.equals("exit")) System.exit(0);
ExecCommandRequest request = new ExecCommandRequest(System.out::println, line); ExecCommandRequest request = new ExecCommandRequest(System.out::println, line);
try { try {

View file

@ -12,7 +12,9 @@
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="layout" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" visible="true" xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="layout" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="400.0" prefWidth="600.0" visible="true" xmlns="http://javafx.com/javafx/8.0.20"
xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<ImageView id="background" fitHeight="400.0" fitWidth="600.0"> <ImageView id="background" fitHeight="400.0" fitWidth="600.0">
<image> <image>
@ -30,17 +32,25 @@
</Pane> </Pane>
<Pane id="authPane" layoutX="1.0" layoutY="2.0" prefHeight="400.0" prefWidth="600.0"> <Pane id="authPane" layoutX="1.0" layoutY="2.0" prefHeight="400.0" prefWidth="600.0">
<children> <children>
<TextField id="login" alignment="CENTER" layoutX="175.0" layoutY="144.0" prefHeight="45.0" prefWidth="233.0" promptText="Логин" /> <TextField id="login" alignment="CENTER" layoutX="175.0" layoutY="144.0" prefHeight="45.0"
<PasswordField id="password" alignment="CENTER" layoutX="175.0" layoutY="197.0" prefHeight="45.0" prefWidth="233.0" promptText="Пароль" /> prefWidth="233.0" promptText="Логин"/>
<Button id="goAuth" layoutX="159.0" layoutY="319.0" mnemonicParsing="false" opacity="1.0" prefHeight="45.0" prefWidth="267.0" styleClass="btn" text="ВОЙТИ" visible="true" /> <PasswordField id="password" alignment="CENTER" layoutX="175.0" layoutY="197.0" prefHeight="45.0"
<CheckBox id="rememberchb" fx:id="savePassword" contentDisplay="CENTER" layoutX="224.0" layoutY="291.0" prefHeight="17.0" prefWidth="137.0" text="Сохранить пароль" textFill="#dadada" /> prefWidth="233.0" promptText="Пароль"/>
<Hyperlink id="link" fx:id="link" layoutY="371.0" prefHeight="30.0" prefWidth="158.0" textAlignment="CENTER" /> <Button id="goAuth" layoutX="159.0" layoutY="319.0" mnemonicParsing="false" opacity="1.0"
<Button id="discord_url" layoutX="278.0" layoutY="373.0" minHeight="16.0" minWidth="28.0" mnemonicParsing="false" prefHeight="16.0" prefWidth="28.0" text="" /> prefHeight="45.0" prefWidth="267.0" styleClass="btn" text="ВОЙТИ" visible="true"/>
<CheckBox id="rememberchb" fx:id="savePassword" contentDisplay="CENTER" layoutX="224.0" layoutY="291.0"
prefHeight="17.0" prefWidth="137.0" text="Сохранить пароль" textFill="#dadada"/>
<Hyperlink id="link" fx:id="link" layoutY="371.0" prefHeight="30.0" prefWidth="158.0"
textAlignment="CENTER"/>
<Button id="discord_url" layoutX="278.0" layoutY="373.0" minHeight="16.0" minWidth="28.0"
mnemonicParsing="false" prefHeight="16.0" prefWidth="28.0" text=""/>
</children> </children>
</Pane> </Pane>
<Pane id="mask" opacity="0.0" prefHeight="400.0" prefWidth="600.0" visible="false"/> <Pane id="mask" opacity="0.0" prefHeight="400.0" prefWidth="600.0" visible="false"/>
<Button id="hidebtn" focusTraversable="false" layoutX="535.0" layoutY="2.0" minHeight="25.0" minWidth="35.0" prefHeight="25.0" prefWidth="25.0" /> <Button id="hidebtn" focusTraversable="false" layoutX="535.0" layoutY="2.0" minHeight="25.0" minWidth="35.0"
<Button id="exitbtn" focusTraversable="false" layoutX="574.0" layoutY="2.0" minHeight="25.0" minWidth="20.0" prefHeight="25.0" prefWidth="20.0" /> prefHeight="25.0" prefWidth="25.0"/>
<Button id="exitbtn" focusTraversable="false" layoutX="574.0" layoutY="2.0" minHeight="25.0" minWidth="20.0"
prefHeight="25.0" prefWidth="20.0"/>
<ImageView fitHeight="12.0" fitWidth="11.0" layoutX="9.0" layoutY="8.0"> <ImageView fitHeight="12.0" fitWidth="11.0" layoutX="9.0" layoutY="8.0">
<image> <image>
<Image url="@images/icons/logo_small.png"/> <Image url="@images/icons/logo_small.png"/>

View file

@ -13,7 +13,8 @@
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="layout" maxHeight="-1.0" maxWidth="-1.0" prefHeight="400.0" prefWidth="600.0" visible="true" xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="layout" maxHeight="-1.0" maxWidth="-1.0" prefHeight="400.0" prefWidth="600.0" visible="true"
xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<ImageView id="background" fitHeight="400.0" fitWidth="600.0"> <ImageView id="background" fitHeight="400.0" fitWidth="600.0">
<image> <image>
@ -28,25 +29,37 @@
<Pane layoutX="171.0" layoutY="28.0" prefHeight="372.0" prefWidth="429.0" styleClass="menuPane"/> <Pane layoutX="171.0" layoutY="28.0" prefHeight="372.0" prefWidth="429.0" styleClass="menuPane"/>
<Pane id="serverPane" prefHeight="400.0" prefWidth="600.0"> <Pane id="serverPane" prefHeight="400.0" prefWidth="600.0">
<children> <children>
<Button id="hidebtn" focusTraversable="false" layoutX="545.0" layoutY="2.0" minHeight="25.0" minWidth="20.0" prefHeight="25.0" prefWidth="25.0" textAlignment="CENTER" /> <Button id="hidebtn" focusTraversable="false" layoutX="545.0" layoutY="2.0" minHeight="25.0"
<Button id="exitbtn" alignment="CENTER" contentDisplay="CENTER" focusTraversable="false" layoutX="572.0" layoutY="2.0" minHeight="25.0" minWidth="20.0" prefHeight="25.0" prefWidth="25.0" rotate="360.0" textAlignment="CENTER" translateX="0.0" /> minWidth="20.0" prefHeight="25.0" prefWidth="25.0" textAlignment="CENTER"/>
<ScrollPane id="serverlist" hbarPolicy="NEVER" layoutX="0.0" layoutY="27.0" prefHeight="306.0" prefWidth="171.0" visible="true"> <Button id="exitbtn" alignment="CENTER" contentDisplay="CENTER" focusTraversable="false" layoutX="572.0"
layoutY="2.0" minHeight="25.0" minWidth="20.0" prefHeight="25.0" prefWidth="25.0" rotate="360.0"
textAlignment="CENTER" translateX="0.0"/>
<ScrollPane id="serverlist" hbarPolicy="NEVER" layoutX="0.0" layoutY="27.0" prefHeight="306.0"
prefWidth="171.0" visible="true">
<content> <content>
<FlowPane id="servercontainer" alignment="TOP_LEFT" columnHalignment="LEFT" focusTraversable="false" hgap="0.0" maxHeight="0.0" maxWidth="0.0" orientation="HORIZONTAL" prefHeight="-1.0" prefWidth="161.0" prefWrapLength="0.0" rowValignment="TOP" vgap="7.0" visible="true"> <FlowPane id="servercontainer" alignment="TOP_LEFT" columnHalignment="LEFT"
focusTraversable="false" hgap="0.0" maxHeight="0.0" maxWidth="0.0"
orientation="HORIZONTAL" prefHeight="-1.0" prefWidth="161.0" prefWrapLength="0.0"
rowValignment="TOP" vgap="7.0" visible="true">
<padding> <padding>
<Insets top="10.0"/> <Insets top="10.0"/>
</padding> </padding>
</FlowPane> </FlowPane>
</content> </content>
</ScrollPane> </ScrollPane>
<ScrollPane id="serverinfo" hbarPolicy="NEVER" layoutX="170.0" layoutY="71.0" pannable="true" prefHeight="234.0" prefWidth="432.0" visible="true"> <ScrollPane id="serverinfo" hbarPolicy="NEVER" layoutX="170.0" layoutY="71.0" pannable="true"
prefHeight="234.0" prefWidth="432.0" visible="true">
<content> <content>
<FlowPane id="" focusTraversable="false" orientation="HORIZONTAL" prefHeight="219.0" prefWidth="428.0" rowValignment="TOP" visible="true"> <FlowPane id="" focusTraversable="false" orientation="HORIZONTAL" prefHeight="219.0"
prefWidth="428.0" rowValignment="TOP" visible="true">
<padding> <padding>
<Insets bottom="10.0" left="15.0" top="7.0"/> <Insets bottom="10.0" left="15.0" top="7.0"/>
</padding> </padding>
<children> <children>
<Label id="serverDescription" alignment="TOP_LEFT" contentDisplay="LEFT" nodeOrientation="LEFT_TO_RIGHT" prefHeight="204.0" prefWidth="407.0" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla convallis magna tellus, in bibendum tortor dignissim non. Phasellus vel tincidunt nulla, eu convallis ligula. Suspendisse ut diam vestibulum, tincidunt neque ut, posuere risus. Pellentesque posuere molestie eros, quis laoreet ante ornare quis. Morbi eu tortor fermentum, iaculis risus sit amet, fringilla augue. Aenean nulla purus, rutrum non sapien et, convallis tincidunt purus. Vivamus a eros pulvinar, dignissim leo lacinia, sodales nulla. Aliquam tortor augue, cursus a rutrum viverra, consequat non tellus. Donec porta nisl sed quam dictum commodo. Sed et vulputate dolor. Morbi ultrices justo vitae convallis semper. Donec sodales velit vel velit faucibus, et scelerisque felis finibus. Sed rutrum lacinia mauris, porta cursus mauris tempor eu. Duis turpis nulla, dictum vitae commodo rhoncus, pretium in turpis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos." textFill="#d3d3d3" wrapText="true"> <Label id="serverDescription" alignment="TOP_LEFT" contentDisplay="LEFT"
nodeOrientation="LEFT_TO_RIGHT" prefHeight="204.0" prefWidth="407.0"
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla convallis magna tellus, in bibendum tortor dignissim non. Phasellus vel tincidunt nulla, eu convallis ligula. Suspendisse ut diam vestibulum, tincidunt neque ut, posuere risus. Pellentesque posuere molestie eros, quis laoreet ante ornare quis. Morbi eu tortor fermentum, iaculis risus sit amet, fringilla augue. Aenean nulla purus, rutrum non sapien et, convallis tincidunt purus. Vivamus a eros pulvinar, dignissim leo lacinia, sodales nulla. Aliquam tortor augue, cursus a rutrum viverra, consequat non tellus. Donec porta nisl sed quam dictum commodo. Sed et vulputate dolor. Morbi ultrices justo vitae convallis semper. Donec sodales velit vel velit faucibus, et scelerisque felis finibus. Sed rutrum lacinia mauris, porta cursus mauris tempor eu. Duis turpis nulla, dictum vitae commodo rhoncus, pretium in turpis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos."
textFill="#d3d3d3" wrapText="true">
<font> <font>
<Font size="14.0" fx:id="x3"/> <Font size="14.0" fx:id="x3"/>
</font> </font>
@ -57,18 +70,23 @@
</ScrollPane> </ScrollPane>
<Pane id="serverentrance" layoutX="170.0" layoutY="27.0" prefHeight="372.0" prefWidth="430.0"> <Pane id="serverentrance" layoutX="170.0" layoutY="27.0" prefHeight="372.0" prefWidth="430.0">
<children> <children>
<Button id="serverLaunch" layoutX="180.0" layoutY="294.0" mnemonicParsing="false" prefHeight="60.0" prefWidth="182.0" text="ИГРАТЬ"> <Button id="serverLaunch" layoutX="180.0" layoutY="294.0" mnemonicParsing="false"
prefHeight="60.0" prefWidth="182.0" text="ИГРАТЬ">
<font> <font>
<Font size="22.0"/> <Font size="22.0"/>
</font> </font>
</Button> </Button>
<Button id="clientbtn" layoutX="363.0" layoutY="294.0" mnemonicParsing="false" prefHeight="60.0" prefWidth="50.0" text="" /> <Button id="clientbtn" layoutX="363.0" layoutY="294.0" mnemonicParsing="false" prefHeight="60.0"
<Label id="serverStatus" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="14.0" layoutY="312.0" opacity="0.61" prefHeight="25.0" prefWidth="153.0" text="12/100" textAlignment="RIGHT" textFill="WHITE"> prefWidth="50.0" text=""/>
<Label id="serverStatus" alignment="TOP_RIGHT" contentDisplay="RIGHT" layoutX="14.0"
layoutY="312.0" opacity="0.61" prefHeight="25.0" prefWidth="153.0" text="12/100"
textAlignment="RIGHT" textFill="WHITE">
<font> <font>
<Font name="System Bold" size="16.0"/> <Font name="System Bold" size="16.0"/>
</font> </font>
</Label> </Label>
<Label id="serverLabel" layoutX="2.0" layoutY="11.0" prefHeight="40.0" prefWidth="274.0" text="СЕРВЕР IFARM"> <Label id="serverLabel" layoutX="2.0" layoutY="11.0" prefHeight="40.0" prefWidth="274.0"
text="СЕРВЕР IFARM">
<font> <font>
<Font name="System Bold" size="18.0"/> <Font name="System Bold" size="18.0"/>
</font> </font>
@ -76,12 +94,16 @@
<Insets left="14.0"/> <Insets left="14.0"/>
</padding> </padding>
</Label> </Label>
<Button id="discord_url" alignment="BOTTOM_CENTER" contentDisplay="CENTER" layoutX="386.0" layoutY="23.0" minHeight="16.0" minWidth="28.0" mnemonicParsing="false" prefHeight="16.0" prefWidth="28.0" text="" textAlignment="CENTER" /> <Button id="discord_url" alignment="BOTTOM_CENTER" contentDisplay="CENTER" layoutX="386.0"
layoutY="23.0" minHeight="16.0" minWidth="28.0" mnemonicParsing="false"
prefHeight="16.0" prefWidth="28.0" text="" textAlignment="CENTER"/>
</children> </children>
</Pane> </Pane>
<Button id="logoutbtn" layoutX="19.0" layoutY="350.0" mnemonicParsing="false" prefHeight="31.0" prefWidth="133.0" styleClass="logoutbtn" text="Выйти" /> <Button id="logoutbtn" layoutX="19.0" layoutY="350.0" mnemonicParsing="false" prefHeight="31.0"
<Button id="settingsbtn" alignment="CENTER" contentDisplay="CENTER" layoutX="518.0" layoutY="2.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="25.0" text="" textAlignment="CENTER" /> prefWidth="133.0" styleClass="logoutbtn" text="Выйти"/>
<Button id="settingsbtn" alignment="CENTER" contentDisplay="CENTER" layoutX="518.0" layoutY="2.0"
mnemonicParsing="false" prefHeight="25.0" prefWidth="25.0" text="" textAlignment="CENTER"/>
</children> </children>
</Pane> </Pane>
<Pane id="mask" opacity="0.0" prefHeight="400.0" prefWidth="600.0" visible="false"/> <Pane id="mask" opacity="0.0" prefHeight="400.0" prefWidth="600.0" visible="false"/>

View file

@ -8,7 +8,8 @@
<body style="color:red"> <body style="color:red">
<h2>Offline-режим</h2> <h2>Offline-режим</h2>
Лаунчер запущен в Offline-режиме. В этом режиме Вы можете запустить любой ранее загруженный клиент Лаунчер запущен в Offline-режиме. В этом режиме Вы можете запустить любой ранее загруженный клиент
с любым именем пользователя, при этом вход на серверы с авторизацией, а так же система скинов и плащей <b>может не работать</b>. с любым именем пользователя, при этом вход на серверы с авторизацией, а так же система скинов и плащей <b>может не
работать</b>.
Скорее всего, проблема вызвана сбоем на сервере или неполадками в интернет-подключении. Скорее всего, проблема вызвана сбоем на сервере или неполадками в интернет-подключении.
Проверьте состояние интернет-подключения или обратитесь к администратору сервера. Проверьте состояние интернет-подключения или обратитесь к администратору сервера.
</body> </body>

View file

@ -7,13 +7,15 @@
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.20"> <Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/8.0.20">
<stylesheets> <stylesheets>
<URL value="@debug.css"/> <URL value="@debug.css"/>
</stylesheets> </stylesheets>
<!-- Debug controls --> <!-- Debug controls -->
<TextArea fx:id="output" layoutY="28.0" prefHeight="372.0" prefWidth="600.0"/> <TextArea fx:id="output" layoutY="28.0" prefHeight="372.0" prefWidth="600.0"/>
<Button fx:id="copy" defaultButton="true" layoutX="375.0" layoutY="352.0" prefHeight="30.0" prefWidth="100.0" text="Копировать" /> <Button fx:id="copy" defaultButton="true" layoutX="375.0" layoutY="352.0" prefHeight="30.0" prefWidth="100.0"
text="Копировать"/>
<Button fx:id="action" layoutX="480.0" layoutY="352.0" prefHeight="30.0" prefWidth="100.0"/> <Button fx:id="action" layoutX="480.0" layoutY="352.0" prefHeight="30.0" prefWidth="100.0"/>
</Pane> </Pane>

View file

@ -9,7 +9,8 @@
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20"
xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Pane id="holder" layoutX="171.0" layoutY="28.0" prefHeight="371.0" prefWidth="428.0"> <Pane id="holder" layoutX="171.0" layoutY="28.0" prefHeight="371.0" prefWidth="428.0">
<children> <children>
@ -24,7 +25,8 @@
</VBox> </VBox>
</content> </content>
</ScrollPane> </ScrollPane>
<Button fx:id="apply" defaultButton="true" layoutX="318.0" layoutY="336.0" prefHeight="25.0" prefWidth="100.0" text="Применить" /> <Button fx:id="apply" defaultButton="true" layoutX="318.0" layoutY="336.0" prefHeight="25.0"
prefWidth="100.0" text="Применить"/>
</children> </children>
</Pane> </Pane>
</children> </children>

View file

@ -8,15 +8,18 @@
<!-- DrLeonardo Design | Fixes by Yaroslavik --> <!-- DrLeonardo Design | Fixes by Yaroslavik -->
<Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20"
xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<ImageView id="spinner" fx:id="spinner" fitHeight="161.0" fitWidth="161.0" layoutX="213.0" layoutY="94.0" y="-6.0"> <ImageView id="spinner" fx:id="spinner" fitHeight="161.0" fitWidth="161.0" layoutX="213.0" layoutY="94.0"
y="-6.0">
<image> <image>
<Image url="@../../images/icons/loading.gif"/> <Image url="@../../images/icons/loading.gif"/>
</image> </image>
</ImageView> </ImageView>
<!-- Description --> <!-- Description -->
<Label fx:id="description" alignment="CENTER" contentDisplay="CENTER" layoutX="152.0" layoutY="249.0" prefHeight="64.0" prefWidth="283.0" text="..." textAlignment="CENTER" /> <Label fx:id="description" alignment="CENTER" contentDisplay="CENTER" layoutX="152.0" layoutY="249.0"
prefHeight="64.0" prefWidth="283.0" text="..." textAlignment="CENTER"/>
</children> </children>
<stylesheets> <stylesheets>
<URL value="@processing.css"/> <URL value="@processing.css"/>

View file

@ -13,16 +13,23 @@
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20"
xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Pane id="holder" layoutX="1.0" layoutY="28.0" prefHeight="371.0" prefWidth="598.0"> <Pane id="holder" layoutX="1.0" layoutY="28.0" prefHeight="371.0" prefWidth="598.0">
<children> <children>
<CheckBox fx:id="autoEnter" layoutX="14.0" layoutY="80.0" text="Автовход на сервер"/> <CheckBox fx:id="autoEnter" layoutX="14.0" layoutY="80.0" text="Автовход на сервер"/>
<Text fill="#8c8c8c" layoutX="38.0" layoutY="95.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Включение авто-входа означает что вы сразу после загрузки клиента попадете на сервер" wrappingWidth="533.0000102519989" y="15.0" /> <Text fill="#8c8c8c" layoutX="38.0" layoutY="95.0" strokeType="OUTSIDE" strokeWidth="0.0"
text="Включение авто-входа означает что вы сразу после загрузки клиента попадете на сервер"
wrappingWidth="533.0000102519989" y="15.0"/>
<CheckBox fx:id="fullScreen" layoutX="13.0" layoutY="185.0" text="Клиент в полный экран"/> <CheckBox fx:id="fullScreen" layoutX="13.0" layoutY="185.0" text="Клиент в полный экран"/>
<Text fill="#8c8c8c" layoutX="38.0" layoutY="200.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Включение данной функции позволяет запустить игру сразу в полноэкранном режиме" wrappingWidth="533.0000102519989" y="15.0" /> <Text fill="#8c8c8c" layoutX="38.0" layoutY="200.0" strokeType="OUTSIDE" strokeWidth="0.0"
text="Включение данной функции позволяет запустить игру сразу в полноэкранном режиме"
wrappingWidth="533.0000102519989" y="15.0"/>
<CheckBox id="debug" layoutX="13.0" layoutY="124.0" text="Режим Отладки"/> <CheckBox id="debug" layoutX="13.0" layoutY="124.0" text="Режим Отладки"/>
<Text fill="#8c8c8c" layoutX="38.0" layoutY="139.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Режим отладки позволяет просмотреть лог запуска и работы программы в реальном времени прямо из лаунчера, что упрощает поиск нужной информации" wrappingWidth="533.0000016447157" y="15.0" /> <Text fill="#8c8c8c" layoutX="38.0" layoutY="139.0" strokeType="OUTSIDE" strokeWidth="0.0"
text="Режим отладки позволяет просмотреть лог запуска и работы программы в реальном времени прямо из лаунчера, что упрощает поиск нужной информации"
wrappingWidth="533.0000016447157" y="15.0"/>
<!-- RAM settings --> <!-- RAM settings -->
<TextFlow layoutX="128.0" layoutY="6.0"> <TextFlow layoutX="128.0" layoutY="6.0">
@ -33,7 +40,8 @@
<!-- RAM settings --> <!-- RAM settings -->
<!-- Deldir settings --> <!-- Deldir settings -->
<Button fx:id="deleteDir" layoutX="15.0" layoutY="333.0" prefHeight="25.0" prefWidth="245.0" text="Очистить данные игровых клиентов" textAlignment="CENTER" wrapText="true"> <Button fx:id="deleteDir" layoutX="15.0" layoutY="333.0" prefHeight="25.0" prefWidth="245.0"
text="Очистить данные игровых клиентов" textAlignment="CENTER" wrapText="true">
<font> <font>
<Font name="System Bold" size="12.0"/> <Font name="System Bold" size="12.0"/>
</font> </font>
@ -41,21 +49,27 @@
<!-- Deldir settings --> <!-- Deldir settings -->
<!-- Changedir settings --> <!-- Changedir settings -->
<Button fx:id="changeDir" layoutX="14.0" layoutY="229.0" prefHeight="25.0" prefWidth="200.0" text="Сменить директорию загрузки" textAlignment="CENTER" wrapText="true" /> <Button fx:id="changeDir" layoutX="14.0" layoutY="229.0" prefHeight="25.0" prefWidth="200.0"
<Hyperlink id="dirLabel" alignment="TOP_LEFT" layoutX="215.0" layoutY="230.0" prefHeight="23.0" prefWidth="371.0" text="C:/Users" wrapText="true" /> text="Сменить директорию загрузки" textAlignment="CENTER" wrapText="true"/>
<Hyperlink id="dirLabel" alignment="TOP_LEFT" layoutX="215.0" layoutY="230.0" prefHeight="23.0"
prefWidth="371.0" text="C:/Users" wrapText="true"/>
<!-- Changedir settings --> <!-- Changedir settings -->
<Button fx:id="apply" defaultButton="true" layoutX="486.0" layoutY="335.0" prefHeight="23.0" prefWidth="100.0" text="Применить" /> <Button fx:id="apply" defaultButton="true" layoutX="486.0" layoutY="335.0" prefHeight="23.0"
prefWidth="100.0" text="Применить"/>
<Text layoutX="17.0" layoutY="19.0">Выделение памяти:</Text> <Text layoutX="17.0" layoutY="19.0">Выделение памяти:</Text>
<Pane fx:id="transferDialog" prefHeight="371.0" prefWidth="598.0"> <Pane fx:id="transferDialog" prefHeight="371.0" prefWidth="598.0">
<children> <children>
<Text fill="WHITE" layoutX="99.0" layoutY="155.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Перенести все данные в новую директорию?" wrappingWidth="400.13671875"> <Text fill="WHITE" layoutX="99.0" layoutY="155.0" strokeType="OUTSIDE" strokeWidth="0.0"
text="Перенести все данные в новую директорию?" wrappingWidth="400.13671875">
<font> <font>
<Font size="19.0"/> <Font size="19.0"/>
</font> </font>
</Text> </Text>
<Button fx:id="applyTransfer" layoutX="130.0" layoutY="186.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="124.0" text="Да, перенести!" /> <Button fx:id="applyTransfer" layoutX="130.0" layoutY="186.0" mnemonicParsing="false"
<Button fx:id="cancelTransfer" layoutX="344.0" layoutY="186.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="124.0" text="Нет, не нужно." /> prefHeight="25.0" prefWidth="124.0" text="Да, перенести!"/>
<Button fx:id="cancelTransfer" layoutX="344.0" layoutY="186.0" mnemonicParsing="false"
prefHeight="25.0" prefWidth="124.0" text="Нет, не нужно."/>
</children> </children>
</Pane> </Pane>

View file

@ -10,7 +10,8 @@
<!-- DrLeonardo Design --> <!-- DrLeonardo Design -->
<Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20" xmlns:fx="http://javafx.com/fxml/1"> <Pane fx:id="overlay" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.20"
xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<ImageView fitHeight="400.0" fitWidth="600.0" pickOnBounds="true" preserveRatio="true"> <ImageView fitHeight="400.0" fitWidth="600.0" pickOnBounds="true" preserveRatio="true">
<image> <image>
@ -23,10 +24,13 @@
<Image url="@../../images/icons/logo_small.png"/> <Image url="@../../images/icons/logo_small.png"/>
</image> </image>
</ImageView> </ImageView>
<Label fx:id="description" layoutX="12.0" layoutY="267.0" prefHeight="98.0" prefWidth="576.0" text="..." textFill="WHITE" /> <Label fx:id="description" layoutX="12.0" layoutY="267.0" prefHeight="98.0" prefWidth="576.0" text="..."
<ProgressBar fx:id="progress" disable="false" layoutX="-1.0" layoutY="376.0" opacity="1.0" prefHeight="24.0" prefWidth="600.0" progress="1.0" style="" /> textFill="WHITE"/>
<ProgressBar fx:id="progress" disable="false" layoutX="-1.0" layoutY="376.0" opacity="1.0" prefHeight="24.0"
prefWidth="600.0" progress="1.0" style=""/>
<!-- Update controls --> <!-- Update controls -->
<Label fx:id="utitle" alignment="TOP_LEFT" layoutX="15.0" layoutY="236.0" prefHeight="30.0" prefWidth="470.0" text="Обновление..." textFill="WHITE"> <Label fx:id="utitle" alignment="TOP_LEFT" layoutX="15.0" layoutY="236.0" prefHeight="30.0" prefWidth="470.0"
text="Обновление..." textFill="WHITE">
<font> <font>
<Font name="System Bold" size="20.0"/> <Font name="System Bold" size="20.0"/>
</font> </font>

View file

@ -303,8 +303,7 @@ public static Process launch(
LogHelper.debug("Writing ClientLauncher params"); LogHelper.debug("Writing ClientLauncher params");
ClientLauncherContext context = new ClientLauncherContext(); ClientLauncherContext context = new ClientLauncherContext();
clientStarted = false; clientStarted = false;
if(writeParamsThread != null && writeParamsThread.isAlive()) if (writeParamsThread != null && writeParamsThread.isAlive()) {
{
writeParamsThread.interrupt(); writeParamsThread.interrupt();
} }
writeParamsThread = CommonHelper.newThread("Client params writter", true, () -> writeParamsThread = CommonHelper.newThread("Client params writter", true, () ->
@ -394,23 +393,19 @@ public static Process launch(
// Let's rock! // Let's rock!
process = builder.start(); process = builder.start();
if (!LogHelper.isDebugEnabled()) { if (!LogHelper.isDebugEnabled()) {
for(int i=0;i<50;++i) for (int i = 0; i < 50; ++i) {
{ if (!process.isAlive()) {
if(!process.isAlive())
{
int exitCode = process.exitValue(); int exitCode = process.exitValue();
LogHelper.error("Process exit code %d", exitCode); LogHelper.error("Process exit code %d", exitCode);
if (writeParamsThread != null && writeParamsThread.isAlive()) writeParamsThread.interrupt(); if (writeParamsThread != null && writeParamsThread.isAlive()) writeParamsThread.interrupt();
break; break;
} }
if(clientStarted) if (clientStarted) {
{
break; break;
} }
Thread.sleep(200); Thread.sleep(200);
} }
if(!clientStarted) if (!clientStarted) {
{
LogHelper.error("Write Client Params not successful. Using debug mode for more information"); LogHelper.error("Write Client Params not successful. Using debug mode for more information");
} }
} }

View file

@ -64,9 +64,9 @@ public static Path getAppDataDir() throws IOException {
public static Path getLauncherDir(String projectname) throws IOException { public static Path getLauncherDir(String projectname) throws IOException {
return getAppDataDir().resolve(projectname); return getAppDataDir().resolve(projectname);
} }
@LauncherAPI @LauncherAPI
public static Path getGuardDir() public static Path getGuardDir() {
{
return dir.resolve("guard"); return dir.resolve("guard");
} }

View file

@ -82,19 +82,15 @@ public static long getTotalMemory() {
} }
@LauncherAPI @LauncherAPI
public static int getClientJVMBits() public static int getClientJVMBits() {
{
return LauncherGuardManager.guard.getClientJVMBits(); return LauncherGuardManager.guard.getClientJVMBits();
} }
@LauncherAPI @LauncherAPI
public static long getJVMTotalMemory() public static long getJVMTotalMemory() {
{ if (getClientJVMBits() == 32) {
if(getClientJVMBits() == 32)
{
return Math.min(getTotalMemory(), 1536); return Math.min(getTotalMemory(), 1536);
} } else {
else
{
return getTotalMemory(); return getTotalMemory();
} }
} }
@ -105,8 +101,7 @@ public static HasherStore getDefaultHasherStore() {
} }
@LauncherAPI @LauncherAPI
public static void setAuthParams(AuthRequestEvent event) public static void setAuthParams(AuthRequestEvent event) {
{
LauncherGuardManager.guard.setProtectToken(event.protectToken); LauncherGuardManager.guard.setProtectToken(event.protectToken);
} }

View file

@ -6,7 +6,10 @@
import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HInput;
import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.HOutput;
import ru.gravit.utils.helper.*; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;

View file

@ -6,10 +6,16 @@
public interface LauncherGuardInterface { public interface LauncherGuardInterface {
String getName(); String getName();
Path getJavaBinPath(); Path getJavaBinPath();
int getClientJVMBits(); int getClientJVMBits();
void init(boolean clientInstance); void init(boolean clientInstance);
void addCustomParams(ClientLauncherContext context); void addCustomParams(ClientLauncherContext context);
void addCustomEnv(ClientLauncherContext context); void addCustomEnv(ClientLauncherContext context);
void setProtectToken(String token); void setProtectToken(String token);
} }

View file

@ -6,21 +6,17 @@
public class LauncherGuardManager { public class LauncherGuardManager {
public static LauncherGuardInterface guard; public static LauncherGuardInterface guard;
public static void initGuard(boolean clientInstance)
{ public static void initGuard(boolean clientInstance) {
if(ClientLauncher.isUsingWrapper()) if (ClientLauncher.isUsingWrapper()) {
{
guard = new LauncherWrapperGuard(); guard = new LauncherWrapperGuard();
} } else if (ClientLauncher.isDownloadJava()) {
else if(ClientLauncher.isDownloadJava())
{
guard = new LauncherJavaGuard(); guard = new LauncherJavaGuard();
} } else guard = new LauncherNoGuard();
else guard = new LauncherNoGuard();
guard.init(clientInstance); guard.init(clientInstance);
} }
public static Path getGuardJavaBinPath()
{ public static Path getGuardJavaBinPath() {
return guard.getJavaBinPath(); return guard.getJavaBinPath();
} }
} }

View file

@ -4,7 +4,9 @@
import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.client.ClientLauncherContext; import ru.gravit.launcher.client.ClientLauncherContext;
import ru.gravit.launcher.client.DirBridge; import ru.gravit.launcher.client.DirBridge;
import ru.gravit.utils.helper.*; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.UnpackHelper;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
@ -23,13 +25,11 @@ public String getName() {
@Override @Override
public Path getJavaBinPath() { public Path getJavaBinPath() {
if(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
{
String projectName = Launcher.getConfig().projectname; String projectName = Launcher.getConfig().projectname;
String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe");
return DirBridge.getGuardDir().resolve(wrapperUnpackName); return DirBridge.getGuardDir().resolve(wrapperUnpackName);
} } else
else
return IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home"))); return IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home")));
} }
@ -69,8 +69,7 @@ public void addCustomEnv(ClientLauncherContext context) {
env.put("GUARD_TOKEN", protectToken); env.put("GUARD_TOKEN", protectToken);
if (config.guardLicenseName != null) if (config.guardLicenseName != null)
env.put("GUARD_LICENSE_NAME", config.guardLicenseName); env.put("GUARD_LICENSE_NAME", config.guardLicenseName);
if(config.guardLicenseKey != null) if (config.guardLicenseKey != null) {
{
env.put("GUARD_LICENSE_KEY", config.guardLicenseKey); env.put("GUARD_LICENSE_KEY", config.guardLicenseKey);
} }
} }

View file

@ -146,8 +146,7 @@ public void run(String[] args) throws ScriptException, NoSuchMethodException, IO
@Override @Override
public void preLoad() throws IOException, ScriptException { public void preLoad() throws IOException, ScriptException {
if(!isPreLoaded) if (!isPreLoaded) {
{
loadScript(Launcher.API_SCRIPT_FILE); loadScript(Launcher.API_SCRIPT_FILE);
loadScript(Launcher.CONFIG_SCRIPT_FILE); loadScript(Launcher.CONFIG_SCRIPT_FILE);
isPreLoaded = true; isPreLoaded = true;

View file

@ -64,21 +64,16 @@ public String getHWDisk() {
} }
} }
public String getSoundCardInfo() public String getSoundCardInfo() {
{ for (SoundCard soundcard : hardware.getSoundCards()) {
for(SoundCard soundcard : hardware.getSoundCards())
{
return soundcard.getName(); return soundcard.getName();
} }
return ""; return "";
} }
public String getMacAddr() public String getMacAddr() {
{ for (NetworkIF networkIF : hardware.getNetworkIFs()) {
for(NetworkIF networkIF : hardware.getNetworkIFs()) for (String ipv4 : networkIF.getIPv4addr()) {
{
for(String ipv4 : networkIF.getIPv4addr())
{
if (ipv4.startsWith("127.")) continue; if (ipv4.startsWith("127.")) continue;
if (ipv4.startsWith("10.")) continue; if (ipv4.startsWith("10.")) continue;
return networkIF.getMacaddr(); return networkIF.getMacaddr();
@ -110,21 +105,18 @@ public void printHardwareInformation() {
for (UsbDevice s : hardware.getUsbDevices(true)) { for (UsbDevice s : hardware.getUsbDevices(true)) {
LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName()); LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName());
} }
for(NetworkIF networkIF : hardware.getNetworkIFs()) for (NetworkIF networkIF : hardware.getNetworkIFs()) {
{
LogHelper.debug("Network Interface: %s mac: %s", networkIF.getName(), networkIF.getMacaddr()); LogHelper.debug("Network Interface: %s mac: %s", networkIF.getName(), networkIF.getMacaddr());
NetworkInterface network = networkIF.getNetworkInterface(); NetworkInterface network = networkIF.getNetworkInterface();
if (network.isLoopback() || network.isVirtual()) continue; if (network.isLoopback() || network.isVirtual()) continue;
LogHelper.debug("Network Interface display: %s name: %s", network.getDisplayName(), network.getName()); LogHelper.debug("Network Interface display: %s name: %s", network.getDisplayName(), network.getName());
for(String ipv4 : networkIF.getIPv4addr()) for (String ipv4 : networkIF.getIPv4addr()) {
{
if (ipv4.startsWith("127.")) continue; if (ipv4.startsWith("127.")) continue;
if (ipv4.startsWith("10.")) continue; if (ipv4.startsWith("10.")) continue;
LogHelper.subDebug("IPv4: %s", ipv4); LogHelper.subDebug("IPv4: %s", ipv4);
} }
} }
for(SoundCard soundcard : hardware.getSoundCards()) for (SoundCard soundcard : hardware.getSoundCards()) {
{
LogHelper.debug("SoundCard %s", soundcard.getName()); LogHelper.debug("SoundCard %s", soundcard.getName());
} }
CentralProcessor processor = hardware.getProcessor(); CentralProcessor processor = hardware.getProcessor();

View file

@ -1,13 +1,5 @@
package ru.gravit.launcher.downloader; package ru.gravit.launcher.downloader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.util.List;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler; import org.apache.http.client.ResponseHandler;
@ -15,9 +7,16 @@
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.LaxRedirectStrategy; import org.apache.http.impl.client.LaxRedirectStrategy;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.util.List;
public class ListDownloader { public class ListDownloader {
public void download(String base, List<String> applies, Path dstDirFile) throws IOException, URISyntaxException { public void download(String base, List<String> applies, Path dstDirFile) throws IOException, URISyntaxException {
try (CloseableHttpClient httpclient = HttpClients.custom() try (CloseableHttpClient httpclient = HttpClients.custom()
@ -39,9 +38,11 @@ public void download(String base, List<String> applies, Path dstDirFile) throws
static class FileDownloadResponseHandler implements ResponseHandler<Path> { static class FileDownloadResponseHandler implements ResponseHandler<Path> {
private final Path target; private final Path target;
public FileDownloadResponseHandler(Path target) { public FileDownloadResponseHandler(Path target) {
this.target = target; this.target = target;
} }
@Override @Override
public Path handleResponse(HttpResponse response) throws ClientProtocolException, IOException { public Path handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
InputStream source = response.getEntity().getContent(); InputStream source = response.getEntity().getContent();

View file

@ -71,10 +71,11 @@ public R request() throws Exception {
} }
} }
} }
protected R requestWebSockets() throws Exception
{ protected R requestWebSockets() throws Exception {
return null; return null;
} }
@LauncherAPI @LauncherAPI
protected abstract R requestDo(HInput input, HOutput output) throws Exception; protected abstract R requestDo(HInput input, HOutput output) throws Exception;

View file

@ -43,6 +43,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
this.auth_id = auth_id; this.auth_id = auth_id;
customText = ""; customText = "";
} }
@LauncherAPI @LauncherAPI
public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText, String auth_id) { public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hwid, String customText, String auth_id) {
super(config); super(config);
@ -57,11 +58,12 @@ public AuthRequest(LauncherConfig config, String login, byte[] password, HWID hw
public AuthRequest(String login, byte[] password, HWID hwid) { public AuthRequest(String login, byte[] password, HWID hwid) {
this(null, login, password, hwid); this(null, login, password, hwid);
} }
@Override @Override
public AuthRequestEvent requestWebSockets() throws Exception public AuthRequestEvent requestWebSockets() throws Exception {
{
return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this); return (AuthRequestEvent) LegacyRequestBridge.sendRequest(this);
} }
@LauncherAPI @LauncherAPI
public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) { public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) {
this(null, login, password, hwid, auth_id); this(null, login, password, hwid, auth_id);
@ -71,6 +73,7 @@ public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) {
public Integer getLegacyType() { public Integer getLegacyType() {
return RequestType.AUTH.getNumber(); return RequestType.AUTH.getNumber();
} }
/*public class EchoRequest implements RequestInterface /*public class EchoRequest implements RequestInterface
{ {
String echo; String echo;

View file

@ -21,11 +21,12 @@ public SetProfileRequest(LauncherConfig config, ClientProfile profile) {
this.profile = profile; this.profile = profile;
this.client = profile.getTitle(); this.client = profile.getTitle();
} }
@Override @Override
public SetProfileRequestEvent requestWebSockets() throws Exception public SetProfileRequestEvent requestWebSockets() throws Exception {
{
return (SetProfileRequestEvent) LegacyRequestBridge.sendRequest(this); return (SetProfileRequestEvent) LegacyRequestBridge.sendRequest(this);
} }
@Override @Override
public Integer getLegacyType() { public Integer getLegacyType() {
return RequestType.SETPROFILE.getNumber(); return RequestType.SETPROFILE.getNumber();

View file

@ -49,8 +49,7 @@ public static void update(LauncherConfig config, LauncherRequestEvent result) th
// Rewrite and start new instance // Rewrite and start new instance
if (result.binary != null) if (result.binary != null)
IOHelper.write(BINARY_PATH, result.binary); IOHelper.write(BINARY_PATH, result.binary);
else else {
{
URLConnection connection = IOHelper.newConnection(new URL(result.url)); URLConnection connection = IOHelper.newConnection(new URL(result.url));
connection.connect(); connection.connect();
try (OutputStream stream = connection.getOutputStream()) { try (OutputStream stream = connection.getOutputStream()) {
@ -70,8 +69,7 @@ public LauncherRequest() {
} }
@Override @Override
public LauncherRequestEvent requestWebSockets() throws Exception public LauncherRequestEvent requestWebSockets() throws Exception {
{
LauncherRequestEvent result = (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this); LauncherRequestEvent result = (LauncherRequestEvent) LegacyRequestBridge.sendRequest(this);
if (result.needUpdate) update(config, result); if (result.needUpdate) update(config, result);
return result; return result;

View file

@ -33,8 +33,7 @@ public Integer getLegacyType() {
} }
@Override @Override
public ProfilesRequestEvent requestWebSockets() throws Exception public ProfilesRequestEvent requestWebSockets() throws Exception {
{
return (ProfilesRequestEvent) LegacyRequestBridge.sendRequest(this); return (ProfilesRequestEvent) LegacyRequestBridge.sendRequest(this);
} }

View file

@ -26,8 +26,7 @@ public UpdateListRequest(LauncherConfig config) {
} }
@Override @Override
public UpdateListRequestEvent requestWebSockets() throws Exception public UpdateListRequestEvent requestWebSockets() throws Exception {
{
return (UpdateListRequestEvent) LegacyRequestBridge.sendRequest(this); return (UpdateListRequestEvent) LegacyRequestBridge.sendRequest(this);
} }

View file

@ -197,9 +197,9 @@ private static void fillActionsQueue(Queue<UpdateAction> queue, HashedDir mismat
} }
} }
} }
@Override @Override
public UpdateRequestEvent requestWebSockets() throws Exception public UpdateRequestEvent requestWebSockets() throws Exception {
{
return (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this); return (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this);
} }

View file

@ -1,14 +1,13 @@
package ru.gravit.launcher.request.websockets; package ru.gravit.launcher.request.websockets;
import java.net.URI;
import java.util.Map;
import org.java_websocket.client.WebSocketClient; import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455; import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshake;
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;
import java.net.URI;
import java.util.Map;
public class ClientJSONPoint extends WebSocketClient { public class ClientJSONPoint extends WebSocketClient {
public ClientJSONPoint(URI serverUri, Map<String, String> httpHeaders, int connectTimeout) { public ClientJSONPoint(URI serverUri, Map<String, String> httpHeaders, int connectTimeout) {

View file

@ -33,6 +33,7 @@ public ClientWebSocketService(GsonBuilder gsonBuilder, String address, int i) {
this.gsonBuilder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter()); this.gsonBuilder.registerTypeAdapter(HashedEntry.class, new HashedEntryAdapter());
this.gson = gsonBuilder.create(); this.gson = gsonBuilder.create();
} }
private static URI createURL(String address) { private static URI createURL(String address) {
try { try {
URI u = new URI(address); URI u = new URI(address);
@ -42,23 +43,24 @@ private static URI createURL(String address) {
return null; return null;
} }
} }
@Override @Override
public void onMessage(String message) { public void onMessage(String message) {
ResultInterface result = gson.fromJson(message, ResultInterface.class); ResultInterface result = gson.fromJson(message, ResultInterface.class);
for(EventHandler handler : handlers) for (EventHandler handler : handlers) {
{
handler.process(result); handler.process(result);
} }
} }
@Override @Override
public void onError(Exception e) public void onError(Exception e) {
{
LogHelper.error(e); LogHelper.error(e);
} }
public Class<? extends RequestInterface> getRequestClass(String key) { public Class<? extends RequestInterface> getRequestClass(String key) {
return requests.get(key); return requests.get(key);
} }
public Class<? extends ResultInterface> getResultClass(String key) { public Class<? extends ResultInterface> getResultClass(String key) {
return results.get(key); return results.get(key);
} }
@ -91,20 +93,20 @@ public void registerResults() {
registerResult("update", UpdateRequestEvent.class); registerResult("update", UpdateRequestEvent.class);
} }
public void registerHandler(EventHandler eventHandler) public void registerHandler(EventHandler eventHandler) {
{
handlers.add(eventHandler); handlers.add(eventHandler);
} }
public void sendObject(Object obj) throws IOException { public void sendObject(Object obj) throws IOException {
send(gson.toJson(obj, RequestInterface.class)); send(gson.toJson(obj, RequestInterface.class));
} }
public void sendObject(Object obj, Type type) throws IOException { public void sendObject(Object obj, Type type) throws IOException {
send(gson.toJson(obj, type)); send(gson.toJson(obj, type));
} }
@FunctionalInterface @FunctionalInterface
public interface EventHandler public interface EventHandler {
{
void process(ResultInterface resultInterface); void process(ResultInterface resultInterface);
} }
} }

View file

@ -8,33 +8,32 @@
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;
import java.io.IOException; import java.io.IOException;
public class LegacyRequestBridge { public class LegacyRequestBridge {
public static WaitEventHandler waitEventHandler = new WaitEventHandler(); public static WaitEventHandler waitEventHandler = new WaitEventHandler();
public static ClientWebSocketService service; public static ClientWebSocketService service;
public static ResultInterface sendRequest(RequestInterface request) throws IOException, InterruptedException { public static ResultInterface sendRequest(RequestInterface request) throws IOException, InterruptedException {
WaitEventHandler.ResultEvent e = new WaitEventHandler.ResultEvent(); WaitEventHandler.ResultEvent e = new WaitEventHandler.ResultEvent();
e.type = request.getType(); e.type = request.getType();
waitEventHandler.requests.add(e); waitEventHandler.requests.add(e);
service.sendObject(request); service.sendObject(request);
while(!e.ready) while (!e.ready) {
{ synchronized (e) {
synchronized(e)
{
e.wait(); e.wait();
LogHelper.debug("WAIT OK"); LogHelper.debug("WAIT OK");
} }
} }
ResultInterface result = e.result; ResultInterface result = e.result;
waitEventHandler.requests.remove(e); waitEventHandler.requests.remove(e);
if(e.result.getType().equals("error")) if (e.result.getType().equals("error")) {
{
ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) e.result; ErrorRequestEvent errorRequestEvent = (ErrorRequestEvent) e.result;
throw new RequestException(errorRequestEvent.error); throw new RequestException(errorRequestEvent.error);
} }
return result; return result;
} }
public static void initWebSockets(String address)
{ public static void initWebSockets(String address) {
service = new ClientWebSocketService(new GsonBuilder(), address, 5000); service = new ClientWebSocketService(new GsonBuilder(), address, 5000);
service.registerResults(); service.registerResults();
service.registerRequests(); service.registerRequests();
@ -46,6 +45,7 @@ public static void initWebSockets(String address)
e.printStackTrace(); e.printStackTrace();
} }
} }
static { static {
if (Launcher.getConfig().nettyPort != 0) if (Launcher.getConfig().nettyPort != 0)
initWebSockets(Launcher.getConfig().nettyAddress); initWebSockets(Launcher.getConfig().nettyAddress);

View file

@ -7,17 +7,15 @@
public class WaitEventHandler implements ClientWebSocketService.EventHandler { public class WaitEventHandler implements ClientWebSocketService.EventHandler {
public HashSet<ResultEvent> requests = new HashSet<>(); public HashSet<ResultEvent> requests = new HashSet<>();
@Override @Override
public void process(ResultInterface result) { public void process(ResultInterface result) {
LogHelper.debug("Processing event %s type", result.getType()); LogHelper.debug("Processing event %s type", result.getType());
for(ResultEvent r : requests) for (ResultEvent r : requests) {
{
LogHelper.subDebug("Processing %s", r.type); LogHelper.subDebug("Processing %s", r.type);
if(r.type.equals(result.getType()) || result.getType().equals("error")) if (r.type.equals(result.getType()) || result.getType().equals("error")) {
{
LogHelper.debug("Event %s type", r.type); LogHelper.debug("Event %s type", r.type);
synchronized (r) synchronized (r) {
{
r.result = result; r.result = result;
r.ready = true; r.ready = true;
r.notifyAll(); r.notifyAll();
@ -25,8 +23,8 @@ public void process(ResultInterface result) {
} }
} }
} }
public static class ResultEvent
{ public static class ResultEvent {
public ResultInterface result; public ResultInterface result;
public String type; public String type;
public boolean ready; public boolean ready;

View file

@ -1,7 +1,7 @@
package ru.gravit.launcher.server; package ru.gravit.launcher.server;
import ru.gravit.launcher.managers.SimpleModulesConfigManager;
import ru.gravit.launcher.managers.SimpleModuleManager; import ru.gravit.launcher.managers.SimpleModuleManager;
import ru.gravit.launcher.managers.SimpleModulesConfigManager;
import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.utils.PublicURLClassLoader;
import java.net.URL; import java.net.URL;

View file

@ -8,7 +8,10 @@
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
import java.nio.file.*; import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.util.jar.JarFile; import java.util.jar.JarFile;

View file

@ -18,8 +18,6 @@
import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper;
import java.io.IOException; import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType; import java.lang.invoke.MethodType;
@ -102,14 +100,12 @@ public static void initGson() {
Launcher.gson = Launcher.gsonBuilder.create(); Launcher.gson = Launcher.gsonBuilder.create();
} }
public void run(String... args) throws Throwable public void run(String... args) throws Throwable {
{
gsonBuiler = new GsonBuilder(); gsonBuiler = new GsonBuilder();
gsonBuiler.setPrettyPrinting(); gsonBuiler.setPrettyPrinting();
gson = gsonBuiler.create(); gson = gsonBuiler.create();
initGson(); initGson();
if(args.length > 0 && args[0].equals("setup") && !disableSetup) if (args.length > 0 && args[0].equals("setup") && !disableSetup) {
{
LogHelper.debug("Read ServerWrapperConfig.json"); LogHelper.debug("Read ServerWrapperConfig.json");
loadConfig(); loadConfig();
ServerWrapperSetup setup = new ServerWrapperSetup(); ServerWrapperSetup setup = new ServerWrapperSetup();
@ -170,24 +166,20 @@ public void run(String... args) throws Throwable
LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name); LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name);
LogHelper.info("Start Minecraft Server"); LogHelper.info("Start Minecraft Server");
LogHelper.debug("Invoke main method %s", mainClass.getName()); LogHelper.debug("Invoke main method %s", mainClass.getName());
if(config.args == null) if (config.args == null) {
{
String[] real_args; String[] real_args;
if(args.length > 0) if (args.length > 0) {
{
real_args = new String[args.length - 1]; real_args = new String[args.length - 1];
System.arraycopy(args, 1, real_args, 0, args.length - 1); System.arraycopy(args, 1, real_args, 0, args.length - 1);
} else real_args = args; } else real_args = args;
mainMethod.invoke(real_args); mainMethod.invoke(real_args);
} } else {
else
{
mainMethod.invoke(config.args); mainMethod.invoke(config.args);
} }
} }
public void updateLauncherConfig()
{ public void updateLauncherConfig() {
LauncherConfig cfg = null; LauncherConfig cfg = null;
try { try {

View file

@ -9,8 +9,8 @@
public class ServerWrapperCommands { public class ServerWrapperCommands {
public final CommandHandler commandHandler; public final CommandHandler commandHandler;
public void registerCommands()
{ public void registerCommands() {
//FUTURE //FUTURE
} }

View file

@ -1,15 +1,12 @@
package ru.gravit.launcher.server.setup; package ru.gravit.launcher.server.setup;
import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.server.ServerWrapper; import ru.gravit.launcher.server.ServerWrapper;
import ru.gravit.utils.PublicURLClassLoader; import ru.gravit.utils.PublicURLClassLoader;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;
import ru.gravit.utils.helper.SecurityHelper;
import java.io.BufferedWriter;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.net.URL; import java.net.URL;
@ -21,8 +18,8 @@
public class ServerWrapperSetup { public class ServerWrapperSetup {
public ServerWrapperCommands commands; public ServerWrapperCommands commands;
public PublicURLClassLoader urlClassLoader; public PublicURLClassLoader urlClassLoader;
public void run() throws IOException
{ public void run() throws IOException {
ServerWrapper wrapper = ServerWrapper.wrapper; ServerWrapper wrapper = ServerWrapper.wrapper;
System.out.println("Print jar filename:"); System.out.println("Print jar filename:");
String jarName = commands.commandHandler.readLine(); String jarName = commands.commandHandler.readLine();
@ -32,15 +29,13 @@ public void run() throws IOException
urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL}); urlClassLoader = new PublicURLClassLoader(new URL[]{jarURL});
LogHelper.info("Check jar MainClass"); LogHelper.info("Check jar MainClass");
String mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class"); String mainClassName = file.getManifest().getMainAttributes().getValue("Main-Class");
if(mainClassName == null) if (mainClassName == null) {
{
LogHelper.error("Main-Class not found in MANIFEST"); LogHelper.error("Main-Class not found in MANIFEST");
return; return;
} }
try { try {
Class mainClass = Class.forName(mainClassName, false, urlClassLoader); Class mainClass = Class.forName(mainClassName, false, urlClassLoader);
} catch (ClassNotFoundException e) } catch (ClassNotFoundException e) {
{
LogHelper.error(e); LogHelper.error(e);
return; return;
} }
@ -52,11 +47,9 @@ public void run() throws IOException
wrapper.config.mainclass = mainClassName; wrapper.config.mainclass = mainClassName;
wrapper.config.address = address; wrapper.config.address = address;
wrapper.config.port = port; wrapper.config.port = port;
if(!Files.exists(ServerWrapper.publicKeyFile)) if (!Files.exists(ServerWrapper.publicKeyFile)) {
{
LogHelper.error("public.key not found"); LogHelper.error("public.key not found");
for(int i=0;i<10;++i) for (int i = 0; i < 10; ++i) {
{
System.out.println("Print F to continue:"); System.out.println("Print F to continue:");
String printF = commands.commandHandler.readLine(); String printF = commands.commandHandler.readLine();
if (printF.equals("stop")) return; if (printF.equals("stop")) return;
@ -65,8 +58,7 @@ public void run() throws IOException
} }
} }
boolean stopOnError = wrapper.config.stopOnError; boolean stopOnError = wrapper.config.stopOnError;
for(int i=0;i<10;++i) for (int i = 0; i < 10; ++i) {
{
System.out.println("Print server account login:"); System.out.println("Print server account login:");
String login = commands.commandHandler.readLine(); String login = commands.commandHandler.readLine();
System.out.println("Print server account password:"); System.out.println("Print server account password:");
@ -79,12 +71,9 @@ public void run() throws IOException
wrapper.config.stopOnError = false; wrapper.config.stopOnError = false;
LauncherConfig cfg = null; LauncherConfig cfg = null;
if(wrapper.auth()) if (wrapper.auth()) {
{
break; break;
} } else {
else
{
LogHelper.error("Auth error. Recheck account params"); LogHelper.error("Auth error. Recheck account params");
} }
} }
@ -94,21 +83,17 @@ public void run() throws IOException
Path startScript; Path startScript;
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) startScript = Paths.get("start.bat"); if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) startScript = Paths.get("start.bat");
else startScript = Paths.get("start.sh"); else startScript = Paths.get("start.sh");
if(Files.exists(startScript)) if (Files.exists(startScript)) {
{
LogHelper.warning("start script found. Move to start.bak"); LogHelper.warning("start script found. Move to start.bak");
Path startScriptBak = Paths.get("start.bak"); Path startScriptBak = Paths.get("start.bak");
IOHelper.move(startScript, startScriptBak); IOHelper.move(startScript, startScriptBak);
} }
try(Writer writer = IOHelper.newWriter(startScript)) try (Writer writer = IOHelper.newWriter(startScript)) {
{ if (JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) {
if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX)
{
writer.append("#!/bin/sh\n\n"); writer.append("#!/bin/sh\n\n");
} }
writer.append("java "); writer.append("java ");
if(mainClassName.contains("bungee")) if (mainClassName.contains("bungee")) {
{
LogHelper.info("Found BungeeCord mainclass. Modules dir change to modules_srv"); LogHelper.info("Found BungeeCord mainclass. Modules dir change to modules_srv");
writer.append(JVMHelper.jvmProperty("serverwrapper.modulesDir", "modules_srv")); writer.append(JVMHelper.jvmProperty("serverwrapper.modulesDir", "modules_srv"));
writer.append(" "); writer.append(" ");
@ -117,8 +102,7 @@ public void run() throws IOException
writer.append("-cp "); writer.append("-cp ");
String pathServerWrapper = IOHelper.getCodeSource(ServerWrapper.class).getFileName().toString(); String pathServerWrapper = IOHelper.getCodeSource(ServerWrapper.class).getFileName().toString();
writer.append(pathServerWrapper); writer.append(pathServerWrapper);
if(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
{
writer.append(";"); writer.append(";");
} else writer.append(":"); } else writer.append(":");
writer.append(jarName); writer.append(jarName);

View file

@ -42,9 +42,9 @@ public ClientPermissions(long data) {
canUSR3 = (data & (1 << 4)) != 0; canUSR3 = (data & (1 << 4)) != 0;
canBot = (data & (1 << 5)) != 0; canBot = (data & (1 << 5)) != 0;
} }
@LauncherAPI @LauncherAPI
public long toLong() public long toLong() {
{
long result = 0; long result = 0;
result |= canAdmin ? 0 : 1; result |= canAdmin ? 0 : 1;
result |= canServer ? 0 : (1 << 1); result |= canServer ? 0 : (1 << 1);

View file

@ -125,10 +125,8 @@ public static Version getVersion() {
return new Version(MAJOR, MINOR, PATCH, BUILD, RELEASE); return new Version(MAJOR, MINOR, PATCH, BUILD, RELEASE);
} }
public static void applyLauncherEnv(LauncherConfig.LauncherEnvironment env) public static void applyLauncherEnv(LauncherConfig.LauncherEnvironment env) {
{ switch (env) {
switch (env)
{
case DEV: case DEV:
LogHelper.setDevEnabled(true); LogHelper.setDevEnabled(true);
LogHelper.setStacktraceEnabled(true); LogHelper.setStacktraceEnabled(true);

View file

@ -37,8 +37,7 @@ public int getLevel() //Уровень доверия, насколько уни
@Override @Override
public int compare(HWID hwid) { public int compare(HWID hwid) {
if(hwid instanceof OshiHWID) if (hwid instanceof OshiHWID) {
{
int rate = 0; int rate = 0;
OshiHWID oshi = (OshiHWID) hwid; OshiHWID oshi = (OshiHWID) hwid;
if (Math.abs(oshi.totalMemory - totalMemory) < 1024 * 1024) rate += 5; if (Math.abs(oshi.totalMemory - totalMemory) < 1024 * 1024) rate += 5;

View file

@ -10,8 +10,10 @@
public class AuthRequestEvent implements EventInterface, ResultInterface { public class AuthRequestEvent implements EventInterface, ResultInterface {
private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74"); private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74");
public AuthRequestEvent() { public AuthRequestEvent() {
} }
@LauncherNetworkAPI @LauncherNetworkAPI
public String error; public String error;
@LauncherNetworkAPI @LauncherNetworkAPI

View file

@ -7,8 +7,7 @@
import java.util.UUID; import java.util.UUID;
public class BatchProfileByUsernameRequestEvent implements EventInterface, ResultInterface public class BatchProfileByUsernameRequestEvent implements EventInterface, ResultInterface {
{
private static final UUID uuid = UUID.fromString("c1d6729e-be2c-48cc-b5ae-af8c012232c3"); private static final UUID uuid = UUID.fromString("c1d6729e-be2c-48cc-b5ae-af8c012232c3");
@LauncherNetworkAPI @LauncherNetworkAPI
public String error; public String error;

View file

@ -7,6 +7,7 @@
public class ErrorRequestEvent implements ResultInterface, EventInterface { public class ErrorRequestEvent implements ResultInterface, EventInterface {
public static UUID uuid = UUID.fromString("0af22bc7-aa01-4881-bdbb-dc62b3cdac96"); public static UUID uuid = UUID.fromString("0af22bc7-aa01-4881-bdbb-dc62b3cdac96");
public ErrorRequestEvent(String error) { public ErrorRequestEvent(String error) {
this.error = error; this.error = error;
} }

View file

@ -7,6 +7,7 @@ public class ExecCommandRequestEvent implements ResultInterface {
public String getType() { public String getType() {
return "execCmd"; return "execCmd";
} }
boolean success; boolean success;
public ExecCommandRequestEvent(boolean success) { public ExecCommandRequestEvent(boolean success) {

View file

@ -13,6 +13,7 @@ public JoinServerRequestEvent(boolean allow) {
} }
public boolean allow; public boolean allow;
@Override @Override
public UUID getUUID() { public UUID getUUID() {
return uuid; return uuid;

View file

@ -7,6 +7,7 @@ public class LogEvent implements ResultInterface {
public String getType() { public String getType() {
return "log"; return "log";
} }
public String string; public String string;
public LogEvent(String string) { public LogEvent(String string) {

View file

@ -7,8 +7,7 @@
import java.util.UUID; import java.util.UUID;
public class ProfileByUUIDRequestEvent implements EventInterface, ResultInterface public class ProfileByUUIDRequestEvent implements EventInterface, ResultInterface {
{
private static final UUID uuid = UUID.fromString("b9014cf3-4b95-4d38-8c5f-867f190a18a0"); private static final UUID uuid = UUID.fromString("b9014cf3-4b95-4d38-8c5f-867f190a18a0");
@LauncherNetworkAPI @LauncherNetworkAPI
public String error; public String error;

View file

@ -7,8 +7,7 @@
import java.util.UUID; import java.util.UUID;
public class ProfileByUsernameRequestEvent implements EventInterface, ResultInterface public class ProfileByUsernameRequestEvent implements EventInterface, ResultInterface {
{
private static final UUID uuid = UUID.fromString("06204302-ff6b-4779-b97d-541e3bc39aa1"); private static final UUID uuid = UUID.fromString("06204302-ff6b-4779-b97d-541e3bc39aa1");
@LauncherNetworkAPI @LauncherNetworkAPI
public String error; public String error;
@ -18,6 +17,7 @@ public class ProfileByUsernameRequestEvent implements EventInterface, ResultInte
public ProfileByUsernameRequestEvent(PlayerProfile playerProfile) { public ProfileByUsernameRequestEvent(PlayerProfile playerProfile) {
this.playerProfile = playerProfile; this.playerProfile = playerProfile;
} }
@Override @Override
public UUID getUUID() { public UUID getUUID() {
return uuid; return uuid;

View file

@ -8,8 +8,7 @@
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class ProfilesRequestEvent implements EventInterface, ResultInterface public class ProfilesRequestEvent implements EventInterface, ResultInterface {
{
private static final UUID uuid = UUID.fromString("2f26fbdf-598a-46dd-92fc-1699c0e173b1"); private static final UUID uuid = UUID.fromString("2f26fbdf-598a-46dd-92fc-1699c0e173b1");
@LauncherNetworkAPI @LauncherNetworkAPI
public List<ClientProfile> profiles; public List<ClientProfile> profiles;
@ -22,6 +21,7 @@ public ProfilesRequestEvent() {
} }
String error; String error;
@Override @Override
public UUID getUUID() { public UUID getUUID() {
return uuid; return uuid;

View file

@ -15,6 +15,7 @@ public class UpdateListRequestEvent implements EventInterface, ResultInterface {
public UpdateListRequestEvent(HashSet<String> dirs) { public UpdateListRequestEvent(HashSet<String> dirs) {
this.dirs = dirs; this.dirs = dirs;
} }
@Override @Override
public UUID getUUID() { public UUID getUUID() {
return uuid; return uuid;

View file

@ -7,6 +7,7 @@
public class UpdateRequestEvent implements ResultInterface { public class UpdateRequestEvent implements ResultInterface {
@LauncherNetworkAPI @LauncherNetworkAPI
public HashedDir hdir; public HashedDir hdir;
@Override @Override
public String getType() { public String getType() {
return "update"; return "update";

View file

@ -1,6 +1,7 @@
package ru.gravit.launcher.hasher; package ru.gravit.launcher.hasher;
import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherAPI;
import java.util.Collection; import java.util.Collection;
public final class FileNameMatcher { public final class FileNameMatcher {
@ -9,8 +10,7 @@ public final class FileNameMatcher {
private static boolean anyMatch(String[] entries, Collection<String> path) { private static boolean anyMatch(String[] entries, Collection<String> path) {
//return path.stream().anyMatch(e -> Arrays.stream(entries).anyMatch(p -> p.endsWith(e))); //return path.stream().anyMatch(e -> Arrays.stream(entries).anyMatch(p -> p.endsWith(e)));
String jpath = String.join("/", path); String jpath = String.join("/", path);
for(String e : entries) for (String e : entries) {
{
/*String[] split = e.split("/"); /*String[] split = e.split("/");
//int index = 0; //int index = 0;
//for(String p : path) //for(String p : path)

View file

@ -23,33 +23,27 @@ public void printConfigurables() {
LogHelper.info("Found %d configurables", CONFIGURABLE.size()); LogHelper.info("Found %d configurables", CONFIGURABLE.size());
} }
public void save(String name) throws IOException public void save(String name) throws IOException {
{
CONFIGURABLE.get(name).saveConfig(); CONFIGURABLE.get(name).saveConfig();
} }
public void load(String name) throws IOException public void load(String name) throws IOException {
{
CONFIGURABLE.get(name).loadConfig(); CONFIGURABLE.get(name).loadConfig();
} }
public void save(String name, Path path) throws IOException public void save(String name, Path path) throws IOException {
{
CONFIGURABLE.get(name).saveConfig(path); CONFIGURABLE.get(name).saveConfig(path);
} }
public void reset(String name) throws IOException public void reset(String name) throws IOException {
{
CONFIGURABLE.get(name).resetConfig(); CONFIGURABLE.get(name).resetConfig();
} }
public void load(String name, Path path) throws IOException public void load(String name, Path path) throws IOException {
{
CONFIGURABLE.get(name).loadConfig(path); CONFIGURABLE.get(name).loadConfig(path);
} }
public void reset(String name, Path path) throws IOException public void reset(String name, Path path) throws IOException {
{
CONFIGURABLE.get(name).resetConfig(path); CONFIGURABLE.get(name).resetConfig(path);
} }
} }

View file

@ -18,5 +18,7 @@ public interface Module extends AutoCloseable {
default void finish(ModuleContext context) { default void finish(ModuleContext context) {
// NOP // NOP
}; }
;
} }

View file

@ -286,33 +286,32 @@ public void pushOptionalFile(HashedDir dir, boolean digest) {
} }
} }
public void pushOptionalJvmArgs(Collection<String> jvmArgs1) public void pushOptionalJvmArgs(Collection<String> jvmArgs1) {
{
for (OptionalFile opt : updateOptional) { for (OptionalFile opt : updateOptional) {
if (opt.type.equals(OptionalType.JVMARGS) && opt.mark) { if (opt.type.equals(OptionalType.JVMARGS) && opt.mark) {
jvmArgs1.addAll(Arrays.asList(opt.list)); jvmArgs1.addAll(Arrays.asList(opt.list));
} }
} }
} }
public void pushOptionalClientArgs(Collection<String> clientArgs1)
{ public void pushOptionalClientArgs(Collection<String> clientArgs1) {
for (OptionalFile opt : updateOptional) { for (OptionalFile opt : updateOptional) {
if (opt.type.equals(OptionalType.CLIENTARGS) && opt.mark) { if (opt.type.equals(OptionalType.CLIENTARGS) && opt.mark) {
clientArgs1.addAll(Arrays.asList(opt.list)); clientArgs1.addAll(Arrays.asList(opt.list));
} }
} }
} }
public void pushOptionalClassPath(pushOptionalClassPathCallback callback) throws IOException
{ public void pushOptionalClassPath(pushOptionalClassPathCallback callback) throws IOException {
for (OptionalFile opt : updateOptional) { for (OptionalFile opt : updateOptional) {
if (opt.type.equals(OptionalType.CLASSPATH) && opt.mark) { if (opt.type.equals(OptionalType.CLASSPATH) && opt.mark) {
callback.run(opt.list); callback.run(opt.list);
} }
} }
} }
@FunctionalInterface @FunctionalInterface
public interface pushOptionalClassPathCallback public interface pushOptionalClassPathCallback {
{
void run(String[] opt) throws IOException; void run(String[] opt) throws IOException;
} }
@ -391,20 +390,16 @@ public void verify() {
// Client launcher // Client launcher
VerifyHelper.verify(getTitle(), VerifyHelper.NOT_EMPTY, "Main class can't be empty"); VerifyHelper.verify(getTitle(), VerifyHelper.NOT_EMPTY, "Main class can't be empty");
for(String s : classPath) for (String s : classPath) {
{
if (s == null) throw new IllegalArgumentException("Found null entry in classPath"); if (s == null) throw new IllegalArgumentException("Found null entry in classPath");
} }
for(String s : jvmArgs) for (String s : jvmArgs) {
{
if (s == null) throw new IllegalArgumentException("Found null entry in jvmArgs"); if (s == null) throw new IllegalArgumentException("Found null entry in jvmArgs");
} }
for(String s : clientArgs) for (String s : clientArgs) {
{
if (s == null) throw new IllegalArgumentException("Found null entry in clientArgs"); if (s == null) throw new IllegalArgumentException("Found null entry in clientArgs");
} }
for(OptionalFile f : updateOptional) for (OptionalFile f : updateOptional) {
{
if (f == null) throw new IllegalArgumentException("Found null entry in updateOptional"); if (f == null) throw new IllegalArgumentException("Found null entry in updateOptional");
if (f.name == null) throw new IllegalArgumentException("Optional: name must not be null"); if (f.name == null) throw new IllegalArgumentException("Optional: name must not be null");
if (f.list == null) throw new IllegalArgumentException("Optional: list must not be null"); if (f.list == null) throw new IllegalArgumentException("Optional: list must not be null");

View file

@ -48,31 +48,35 @@ public boolean equals(Object o) {
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(name);
} }
@LauncherAPI @LauncherAPI
public OptionalType getType() { public OptionalType getType() {
return OptionalType.FILE; return OptionalType.FILE;
} }
@LauncherAPI @LauncherAPI
public String getName() { public String getName() {
return name; return name;
} }
@LauncherAPI @LauncherAPI
public boolean isVisible() { public boolean isVisible() {
return visible; return visible;
} }
@LauncherAPI @LauncherAPI
public boolean isMark() { public boolean isMark() {
return mark; return mark;
} }
@LauncherAPI @LauncherAPI
public long getPermissions() { public long getPermissions() {
return permissions; return permissions;
} }
@LauncherAPI @LauncherAPI
public void writeType(HOutput output) throws IOException public void writeType(HOutput output) throws IOException {
{ switch (type) {
switch(type)
{
case FILE: case FILE:
output.writeInt(1); output.writeInt(1);
@ -91,13 +95,12 @@ public void writeType(HOutput output) throws IOException
break; break;
} }
} }
@LauncherAPI @LauncherAPI
public static OptionalType readType(HInput input) throws IOException public static OptionalType readType(HInput input) throws IOException {
{
int t = input.readInt(); int t = input.readInt();
OptionalType type; OptionalType type;
switch(t) switch (t) {
{
case 1: case 1:
type = OptionalType.FILE; type = OptionalType.FILE;
break; break;

View file

@ -3,8 +3,7 @@
import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherAPI;
@LauncherAPI @LauncherAPI
public enum OptionalType public enum OptionalType {
{
@LauncherAPI @LauncherAPI
FILE, FILE,
@LauncherAPI @LauncherAPI

View file

@ -1,7 +1,6 @@
package ru.gravit.launcher.request; package ru.gravit.launcher.request;
import com.google.gson.*; import com.google.gson.*;
import ru.gravit.launcher.request.ResultInterface;
import java.lang.reflect.Type; import java.lang.reflect.Type;

View file

@ -60,8 +60,7 @@ public static JsonElement jsonRequest(JsonElement request, URL url) throws IOExc
reader = new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8); reader = new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8);
try { try {
return parser.parse(reader); return parser.parse(reader);
} catch (Exception e) } catch (Exception e) {
{
return null; return null;
} }
} }

View file

@ -2,12 +2,7 @@
import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherAPI;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
public final class Version { public final class Version {
@LauncherAPI @LauncherAPI

View file

@ -76,8 +76,8 @@ public void registerCommand(String name, Command command) {
VerifyHelper.putIfAbsent(commands, name.toLowerCase(), Objects.requireNonNull(command, "command"), VerifyHelper.putIfAbsent(commands, name.toLowerCase(), Objects.requireNonNull(command, "command"),
String.format("Command has been already registered: '%s'", name.toLowerCase())); String.format("Command has been already registered: '%s'", name.toLowerCase()));
} }
public Command unregisterCommand(String name)
{ public Command unregisterCommand(String name) {
return commands.remove(name); return commands.remove(name);
} }
@ -91,7 +91,6 @@ public void run() {
} }
public abstract void bell() throws IOException; public abstract void bell() throws IOException;
@ -103,5 +102,4 @@ public Map<String, Command> commandsMap() {
} }
} }

Some files were not shown because too many files have changed in this diff Show more