[ANY] IDEA Code Cleanup

This commit is contained in:
Gravit 2019-01-15 10:32:46 +07:00
parent dc6e87ef30
commit a2b3ac523b
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
25 changed files with 73 additions and 93 deletions

View file

@ -98,7 +98,7 @@ public ArrayList<String> getSuperClasses(String type) {
}
@Override
public void close() throws IOException {
public void close() {
cp.stream().forEach(IOHelper::close);
cp.clear();
}

View file

@ -22,7 +22,7 @@ public class JsonFilePermissionsHandler extends PermissionsHandler implements Re
public static Map<String,ClientPermissions> map;
@Override
public void reload() throws Exception {
public void reload() {
map.clear();
Path path = Paths.get(filename);
Type type = new TypeToken<Map<String,ClientPermissions>>(){}.getType();

View file

@ -40,24 +40,22 @@ public void close() {
@Override
public void reconfig(String action, String[] args) {
if(action.equals("message"))
{
switch (action) {
case "message":
message = args[0];
LogHelper.info("New reject message: %s", message);
}
else if(action.equals("whitelist.add"))
{
if(whitelist == null) whitelist = new ArrayList<>();
break;
case "whitelist.add":
if (whitelist == null) whitelist = new ArrayList<>();
whitelist.add(args[0]);
}
else if(action.equals("whitelist.remove"))
{
if(whitelist == null) whitelist = new ArrayList<>();
break;
case "whitelist.remove":
if (whitelist == null) whitelist = new ArrayList<>();
whitelist.remove(args[0]);
}
else if(action.equals("whitelist.clear"))
{
break;
case "whitelist.clear":
whitelist.clear();
break;
}
}

View file

@ -8,22 +8,14 @@
public final class TaskUtil {
public static void addCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskAdd) {
List<LauncherBuildTask> indexes = new ArrayList<>();
tasks.stream().filter(pred).forEach(e -> {
indexes.add(e);
});
indexes.forEach(e -> {
tasks.add(tasks.indexOf(e)+count, taskAdd);
});
tasks.stream().filter(pred).forEach(e -> indexes.add(e));
indexes.forEach(e -> tasks.add(tasks.indexOf(e)+count, taskAdd));
}
public static void replaceCounted(List<LauncherBuildTask> tasks, int count, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskRep) {
List<LauncherBuildTask> indexes = new ArrayList<>();
tasks.stream().filter(pred).forEach(e -> {
indexes.add(e);
});
indexes.forEach(e -> {
tasks.set(tasks.indexOf(e)+count, taskRep);
});
tasks.stream().filter(pred).forEach(e -> indexes.add(e));
indexes.forEach(e -> tasks.set(tasks.indexOf(e)+count, taskRep));
}
public static void addPre(List<LauncherBuildTask> tasks, Predicate<LauncherBuildTask> pred, LauncherBuildTask taskAdd) {

View file

@ -19,7 +19,7 @@ public String getUsageDescription() {
}
@Override
public void invoke(String... args) throws Exception {
public void invoke(String... args) {
server.reconfigurableManager.printReconfigurables();
}
}

View file

@ -19,7 +19,7 @@ public String getUsageDescription() {
}
@Override
public void invoke(String... args) throws Exception {
public void invoke(String... args) {
server.reloadManager.printReloadables();
}
}

View file

@ -22,7 +22,7 @@ public String getUsageDescription() {
}
@Override
public void invoke(String... args) throws Exception {
public void invoke(String... args) {
LogHelper.info("Show server status");
LogHelper.info("Memory: free %d | total: %d | max: %d", JVMHelper.RUNTIME.freeMemory(), JVMHelper.RUNTIME.totalMemory(),JVMHelper.RUNTIME.maxMemory());
long uptime = JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000;

View file

@ -29,38 +29,34 @@ public void invoke(String... args) throws Exception {
verifyArgs(args,2);
if(providersCache == null) providersCache = new AuthProvider[server.config.authProvider.length];
int index = Integer.valueOf(args[0]);
if(args[1].equals("accept"))
{
if(providersCache[index] == null)
{
switch (args[1]) {
case "accept":
if (providersCache[index] == null) {
AcceptAuthProvider provider = new AcceptAuthProvider();
providersCache[index] = server.config.authProvider[index];
server.config.authProvider[index] = provider;
LogHelper.info("AuthProvider[%d] is AcceptAuthProvider",index);
}
else LogHelper.error("Changes detected. Use undo");
} else if(args[1].equals("reject"))
{
if(providersCache[index] == null)
{
LogHelper.info("AuthProvider[%d] is AcceptAuthProvider", index);
} else LogHelper.error("Changes detected. Use undo");
break;
case "reject":
if (providersCache[index] == null) {
RejectAuthProvider rejectAuthProvider;
if(args.length < 3) rejectAuthProvider = new RejectAuthProvider();
if (args.length < 3) rejectAuthProvider = new RejectAuthProvider();
else rejectAuthProvider = new RejectAuthProvider(args[2]);
providersCache[index] = server.config.authProvider[index];
server.config.authProvider[index] = rejectAuthProvider;
LogHelper.info("AuthProvider[%d] is RejectAuthProvider",index);
}
else LogHelper.error("Changes detected. Use undo");
} else if(args[1].equals("undo"))
{
if(providersCache[index] == null) LogHelper.error("Cache clean. Undo impossible");
else
{
LogHelper.info("AuthProvider[%d] is RejectAuthProvider", index);
} else LogHelper.error("Changes detected. Use undo");
break;
case "undo":
if (providersCache[index] == null) LogHelper.error("Cache clean. Undo impossible");
else {
server.config.authProvider[index].close();
server.config.authProvider[index] = providersCache[index];
providersCache[index] = null;
}
break;
}
}
}

View file

@ -34,7 +34,7 @@ public URL getClientsURL(String client) throws MalformedURLException {
protected ArrayList<Mirror> list = new ArrayList<>();
private Mirror defaultMirror;
public void addMirror(String mirror) throws MalformedURLException {
public void addMirror(String mirror) {
Mirror m = new Mirror(mirror);
m.enabled = true;
if (defaultMirror == null) defaultMirror = m;

View file

@ -19,7 +19,7 @@ public void printHelp(String name)
{
RECONFIGURABLE.get(name).printConfigHelp();
}
public void call(String name, String action, String[] args) throws Exception {
public void call(String name, String action, String[] args) {
RECONFIGURABLE.get(name).reconfig(action,args);
}
public void printReconfigurables()

View file

@ -31,7 +31,7 @@ public void channelActive(ChannelHandlerContext ctx) {
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) {
// ping and pong frames already handled
if (frame instanceof TextWebSocketFrame) {

View file

@ -11,7 +11,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
}
}

View file

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

View file

@ -18,7 +18,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
try {
LaunchServer.server.config.authHandler.checkServer(username, serverID);
} catch (AuthException e) {

View file

@ -19,7 +19,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
boolean success;
try {
success = LaunchServer.server.config.authHandler.joinServer(username, accessToken, serverID);

View file

@ -24,7 +24,7 @@ public String getType() {
}
@Override
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) throws Exception {
public void execute(WebSocketService service, ChannelHandlerContext ctx, Client client) {
byte[] bytes = Base64.getDecoder().decode(hash);
if (launcher_type == 1) // JAR
{

View file

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

View file

@ -61,7 +61,7 @@ public static Path getLauncherDir(String projectname) throws IOException {
}
@LauncherAPI
public static Path getLegacyLauncherDir(String projectname) throws IOException {
public static Path getLegacyLauncherDir(String projectname) {
return IOHelper.HOME_DIR.resolve(projectname);
}

View file

@ -17,7 +17,6 @@
import java.io.IOException;
import java.nio.file.Path;
import java.security.SignatureException;
import java.util.concurrent.atomic.AtomicReference;
public class FunctionalBridge {
@ -33,7 +32,7 @@ public class FunctionalBridge {
public static Thread getHWID = null;
@LauncherAPI
public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, SignedObjectHolder<HashedDir> hdir, FileNameMatcher matcher, boolean digest) throws Exception {
public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, SignedObjectHolder<HashedDir> hdir, FileNameMatcher matcher, boolean digest) {
return () -> {
if (hdir == null) {
Request.requestError(java.lang.String.format("Директории '%s' нет в кэше", dirName));
@ -44,7 +43,7 @@ public static HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, S
}
@LauncherAPI
public static LegacyLauncherRequest.Result offlineLauncherRequest() throws IOException, SignatureException {
public static LegacyLauncherRequest.Result offlineLauncherRequest() throws IOException {
if (settings.lastDigest == null || settings.lastProfiles.isEmpty()) {
Request.requestError("Запуск в оффлайн-режиме невозможен");
}

View file

@ -62,7 +62,7 @@ public void load() throws SignatureException {
}
@LauncherAPI
public void save() throws SignatureException {
public void save() {
LogHelper.debug("Save settings file");
try {
try (HOutput output = new HOutput(IOHelper.newOutput(file))) {

View file

@ -14,7 +14,6 @@
import java.io.IOException;
import java.nio.file.Path;
import java.security.SignatureException;
import java.util.ArrayList;
import java.util.List;
@ -46,7 +45,7 @@ public byte[] getDigest() {
public static final boolean EXE_BINARY = IOHelper.hasExtension(BINARY_PATH, "exe");
@LauncherAPI
public static void update(LauncherConfig config, Result result) throws SignatureException, IOException {
public static void update(LauncherConfig config, Result result) throws IOException {
List<String> args = new ArrayList<>(8);
args.add(IOHelper.resolveJavaBin(null).toString());
if (LogHelper.isDebugEnabled())

View file

@ -51,7 +51,7 @@ public void send(String js) throws IOException {
session.getBasicRemote().sendText(js);
}
public void sendAsync(String js) throws IOException {
public void sendAsync(String js) {
session.getAsyncRemote().sendText(js);
}
}

View file

@ -30,7 +30,7 @@ public static void addJVMClassPath(String path) throws IOException {
inst.appendToSystemClassLoaderSearch(new JarFile(path));
}
public static void addJVMClassPath(JarFile file) throws IOException {
public static void addJVMClassPath(JarFile file) {
LogHelper.debug("Load %s", file.getName());
inst.appendToSystemClassLoaderSearch(file);
}

View file

@ -6,7 +6,6 @@
import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.VerifyHelper;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.*;
@ -383,7 +382,7 @@ else if(f.dependenciesCount.size() <= 1)
}
}
public void pushOptional(HashedDir dir, boolean digest) throws IOException {
public void pushOptional(HashedDir dir, boolean digest) {
for (OptionalFile opt : updateOptional) {
if (!opt.mark) dir.removeR(opt.file);
}
@ -592,10 +591,7 @@ public boolean equals(Object obj) {
} else if (!version.equals(other.version))
return false;
if (whitelist == null) {
if (other.whitelist != null)
return false;
} else if (!whitelist.equals(other.whitelist))
return false;
return true;
return other.whitelist == null;
} else return whitelist.equals(other.whitelist);
}
}

@ -1 +1 @@
Subproject commit ee2f9e6646a8f1972ceda68d56e88e71ab74f78f
Subproject commit bb4430df933db257638191857577824820b18c4a