Merge branch 'javafx' into switch-to-https

This commit is contained in:
huanghongxun
2018-03-05 20:56:26 +08:00
committed by GitHub
120 changed files with 1676 additions and 1107 deletions

View File

@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.auth;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.util.Map;
import java.util.UUID;
@@ -64,4 +66,13 @@ public abstract class Account {
public abstract Map<Object, Object> toStorage();
public abstract void clearCache();
@Override
public String toString() {
return new ToStringBuilder(this)
.append("username", getUsername())
.append("character", getCharacter())
.append("uuid", getUUID())
.toString();
}
}

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.auth.yggdrasil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.jackhuang.hmcl.auth.*;
import org.jackhuang.hmcl.util.StringUtils;

View File

@@ -18,7 +18,6 @@
package org.jackhuang.hmcl.download;
import org.jackhuang.hmcl.download.game.*;
import org.jackhuang.hmcl.game.SimpleVersionProvider;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.ParallelTask;
import org.jackhuang.hmcl.task.Task;

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hmcl.download;
import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.TaskResult;

View File

@@ -28,7 +28,7 @@ import org.jackhuang.hmcl.download.optifine.OptiFineVersionList;
*/
public class MojangDownloadProvider implements DownloadProvider {
private boolean isChina;
private final boolean isChina;
public MojangDownloadProvider(boolean isChina) {
this.isChina = isChina;

View File

@@ -47,7 +47,7 @@ public final class ForgeInstallTask extends TaskResult<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private final File installer = new File("forge-installer.jar").getAbsoluteFile();
private ForgeRemoteVersion remote;
private final ForgeRemoteVersion remote;
private final List<Task> dependents = new LinkedList<>();
private final List<Task> dependencies = new LinkedList<>();

View File

@@ -82,7 +82,7 @@ public final class GameAssetDownloadTask extends Task {
AssetObject assetObject = entry.getValue();
String url = dependencyManager.getDownloadProvider().getAssetBaseURL() + assetObject.getLocation();
if (!FileUtils.makeDirectory(file.getAbsoluteFile().getParentFile())) {
Logging.LOG.log(Level.SEVERE, "Unable to create new file {0}, because parent directory cannot be created", file);
Logging.LOG.log(Level.SEVERE, "Unable to create new file " + file + ", because parent directory cannot be created");
continue;
}
if (file.isDirectory())

View File

@@ -20,9 +20,7 @@ package org.jackhuang.hmcl.download.game;
import org.jackhuang.hmcl.download.AbstractDependencyManager;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.NetworkUtils;
import java.io.File;
import java.util.LinkedList;

View File

@@ -4,8 +4,6 @@ import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.jackhuang.hmcl.download.AbstractDependencyManager;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Scheduler;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.*;

View File

@@ -41,7 +41,7 @@ public final class LiteLoaderInstallTask extends TaskResult<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private LiteLoaderRemoteVersion remote;
private final LiteLoaderRemoteVersion remote;
private final List<Task> dependents = new LinkedList<>();
private final List<Task> dependencies = new LinkedList<>();

View File

@@ -18,7 +18,6 @@
package org.jackhuang.hmcl.download.liteloader;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.download.VersionList;
import org.jackhuang.hmcl.task.GetTask;
import org.jackhuang.hmcl.task.Task;

View File

@@ -38,7 +38,7 @@ public final class OptiFineInstallTask extends TaskResult<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private OptiFineRemoteVersion remote;
private final OptiFineRemoteVersion remote;
private final List<Task> dependents = new LinkedList<>();
private final List<Task> dependencies = new LinkedList<>();

View File

@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.util.Objects;
/**
@@ -28,13 +30,13 @@ public class Event {
/**
* The object on which the Event initially occurred.
*/
protected transient Object source;
protected final transient Object source;
/**
* Constructs a prototypical Event.
*
* @param source The object on which the Event initially occurred.
* @throws NullPointerException if source is null.
* @throws NullPointerException if source is null.
*/
public Event(Object source) {
Objects.requireNonNull(source);
@@ -54,10 +56,10 @@ public class Event {
/**
* Returns a String representation of this Event.
*
* @return A a String representation of this Event.
* @return A a String representation of this Event.
*/
public String toString() {
return getClass().getName() + "[source=" + source + "]";
return new ToStringBuilder(this).append("source", source).toString();
}
private boolean canceled;
@@ -72,7 +74,6 @@ public class Event {
}
/**
*
* @param canceled new value
* @throws UnsupportedOperationException if trying to cancel a non-cancelable event.
*/

View File

@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.Logging;
import java.util.HashMap;
/**
@@ -36,6 +38,8 @@ public final class EventBus {
@SuppressWarnings("unchecked")
public Event.Result fireEvent(Event obj) {
Logging.LOG.info(obj + " gets fired");
return channel((Class<Event>) obj.getClass()).fireEvent(obj);
}

View File

@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.io.File;
/**
@@ -49,4 +51,13 @@ public final class GameJsonParseFailedEvent extends Event {
public String getVersion() {
return version;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("jsonFile", jsonFile)
.append("version", version)
.toString();
}
}

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ManagedProcess;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when we launch the JVM and it got crashed.
@@ -44,4 +45,12 @@ public class JVMLaunchFailedEvent extends Event {
public ManagedProcess getProcess() {
return process;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("process", process)
.toString();
}
}

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when a minecraft version has been loaded.
@@ -48,4 +49,12 @@ public final class LoadedOneVersionEvent extends Event {
public boolean hasResult() {
return true;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("version", version)
.toString();
}
}

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ManagedProcess;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when a JavaProcess exited abnormally and the exit code is not zero.
@@ -44,4 +45,12 @@ public final class ProcessExitedAbnormallyEvent extends Event {
public ManagedProcess getProcess() {
return process;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("process", process)
.toString();
}
}

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ManagedProcess;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when minecraft process exited successfully and the exit code is 0.
@@ -44,4 +45,12 @@ public class ProcessStoppedEvent extends Event {
public ManagedProcess getProcess() {
return process;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("process", process)
.toString();
}
}

View File

@@ -35,4 +35,8 @@ public final class RefreshingVersionsEvent extends Event {
super(source);
}
@Override
public boolean hasResult() {
return true;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2018 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when a minecraft version is being removed.
* <br>
* This event is fired on the {@link org.jackhuang.hmcl.event.EventBus#EVENT_BUS}
*
* @author huangyuhui
*/
public class RemoveVersionEvent extends Event {
private final String version;
/**
*
* @param source {@link org.jackhuang.hmcl.game.GameRepository}
* @param version the version id.
*/
public RemoveVersionEvent(Object source, String version) {
super(source);
this.version = version;
}
public String getVersion() {
return version;
}
@Override
public boolean hasResult() {
return true;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("version", version)
.toString();
}
}

View File

@@ -0,0 +1,65 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2018 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when a minecraft version is being removed.
* <br>
* This event is fired on the {@link org.jackhuang.hmcl.event.EventBus#EVENT_BUS}
*
* @author huangyuhui
*/
public class RenameVersionEvent extends Event {
private final String from, to;
/**
*
* @param source {@link org.jackhuang.hmcl.game.GameRepository}
* @param from the version id.
*/
public RenameVersionEvent(Object source, String from, String to) {
super(source);
this.from = from;
this.to = to;
}
public String getFromVersion() {
return from;
}
public String getToVersion() {
return to;
}
@Override
public boolean hasResult() {
return true;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("from", from)
.append("to", to)
.toString();
}
}

View File

@@ -24,6 +24,7 @@ import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.FileUtils;
import org.jackhuang.hmcl.util.Logging;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.io.File;
import java.io.IOException;
@@ -61,7 +62,7 @@ public class DefaultGameRepository implements GameRepository {
@Override
public Version getVersion(String id) {
if (!hasVersion(id))
throw new VersionNotFoundException("Version '" + id + "' does not exist.");
throw new VersionNotFoundException("Version '" + id + "' does not exist in " + versions.keySet() + ".");
return versions.get(id);
}
@@ -116,6 +117,9 @@ public class DefaultGameRepository implements GameRepository {
@Override
public boolean renameVersion(String from, String to) {
if (EventBus.EVENT_BUS.fireEvent(new RenameVersionEvent(this, from, to)) == Event.Result.DENY)
return false;
try {
Version fromVersion = getVersion(from);
File fromDir = getVersionRoot(from);
@@ -145,6 +149,8 @@ public class DefaultGameRepository implements GameRepository {
public boolean removeVersionFromDisk(String id) {
if (!versions.containsKey(id))
return true;
if (EventBus.EVENT_BUS.fireEvent(new RemoveVersionEvent(this, id)) == Event.Result.DENY)
return false;
File file = getVersionRoot(id);
if (!file.exists())
return true;
@@ -201,7 +207,7 @@ public class DefaultGameRepository implements GameRepository {
try {
FileUtils.writeText(json, Constants.GSON.toJson(version));
} catch (Exception e) {
Logging.LOG.log(Level.WARNING, "Ignoring version {0} because wrong id {1} is set and cannot correct it.", new Object[]{id, version.getId()});
Logging.LOG.log(Level.WARNING, "Ignoring version " + id + " because wrong id " + version.getId() + " is set and cannot correct it.");
continue;
}
}
@@ -217,7 +223,7 @@ public class DefaultGameRepository implements GameRepository {
EventBus.EVENT_BUS.fireEvent(new LoadedOneVersionEvent(this, resolved)) != Event.Result.DENY)
versions.put(version.getId(), version);
} catch (VersionNotFoundException e) {
Logging.LOG.log(Level.WARNING, "Ignoring version {0} because it inherits from a nonexistent version.", version.getId());
Logging.LOG.log(Level.WARNING, "Ignoring version " + version.getId() + " because it inherits from a nonexistent version.");
}
}
@@ -227,7 +233,9 @@ public class DefaultGameRepository implements GameRepository {
@Override
public void refreshVersions() {
EventBus.EVENT_BUS.fireEvent(new RefreshingVersionsEvent(this));
if (EventBus.EVENT_BUS.fireEvent(new RefreshingVersionsEvent(this)) == Event.Result.DENY)
return;
Schedulers.newThread().schedule(() -> {
refreshVersionsImpl();
EventBus.EVENT_BUS.fireEvent(new RefreshedVersionsEvent(this));
@@ -337,4 +345,11 @@ public class DefaultGameRepository implements GameRepository {
return getModpackConfiguration(version).exists();
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("versions", versions == null ? null : versions.keySet())
.append("baseDirectory", baseDirectory)
.toString();
}
}

View File

@@ -39,7 +39,7 @@ public final class LibrariesDownloadInfo {
public LibrariesDownloadInfo(LibraryDownloadInfo artifact, Map<String, LibraryDownloadInfo> classifiers) {
this.artifact = artifact;
this.classifiers = new HashMap<>(classifiers);
this.classifiers = classifiers == null ? null : new HashMap<>(classifiers);
}
public LibraryDownloadInfo getArtifact() {

View File

@@ -45,7 +45,7 @@ public final class StringArgument implements Argument {
@Override
public List<String> toString(Map<String, String> keys, Map<String, Boolean> features) {
String res = argument;
Pattern pattern = Pattern.compile("\\$\\{(.*?)\\}");
Pattern pattern = Pattern.compile("\\$\\{(.*?)}");
Matcher m = pattern.matcher(argument);
while (m.find()) {
String entry = m.group();

View File

@@ -156,7 +156,7 @@ public class Version implements Comparable<Version>, Validation {
// To maximize the compatibility.
if (!resolvedSoFar.add(id)) {
Logging.LOG.log(Level.WARNING, "Found circular dependency versions: {0}", resolvedSoFar);
Logging.LOG.log(Level.WARNING, "Found circular dependency versions: " + resolvedSoFar);
return this;
}
@@ -233,6 +233,11 @@ public class Version implements Comparable<Version>, Validation {
return id.compareTo(o.id);
}
@Override
public String toString() {
return new ToStringBuilder(this).append("id", id).toString();
}
@Override
public void validate() throws JsonParseException {
if (StringUtils.isBlank(id))

View File

@@ -44,23 +44,20 @@ import java.util.Objects;
*/
public final class MultiMCModpackInstallTask extends Task {
private final DefaultDependencyManager dependencyManager;
private final File zipFile;
private final MultiMCInstanceConfiguration manifest;
private final String name;
private final File run;
private final DefaultGameRepository repository;
private final List<Task> dependencies = new LinkedList<>();
private final List<Task> dependents = new LinkedList<>();
public MultiMCModpackInstallTask(DefaultDependencyManager dependencyManager, File zipFile, MultiMCInstanceConfiguration manifest, String name) {
this.dependencyManager = dependencyManager;
this.zipFile = zipFile;
this.manifest = manifest;
this.name = name;
this.repository = dependencyManager.getGameRepository();
this.run = repository.getRunDirectory(name);
File run = repository.getRunDirectory(name);
File json = repository.getModpackConfiguration(name);
if (repository.hasVersion(name) && !json.exists())
throw new IllegalArgumentException("Version " + name + " already exists.");

View File

@@ -119,7 +119,7 @@ public class FileDownloadTask extends Task {
@Override
public void execute() throws Exception {
URL currentURL = url;
Logging.LOG.log(Level.FINER, "Downloading {0} to {1}", new Object[] { currentURL, file });
Logging.LOG.log(Level.FINER, "Downloading " + currentURL + " to " + file);
Exception exception = null;
for (int repeat = 0; repeat < retry; repeat++) {

View File

@@ -84,7 +84,7 @@ public final class GetTask extends TaskResult<String> {
Exception exception = null;
for (int time = 0; time < retry; ++time) {
if (time > 0)
Logging.LOG.log(Level.WARNING, "Failed to download, repeat times: {0}", time);
Logging.LOG.log(Level.WARNING, "Failed to download, repeat times: " + time);
try {
updateProgress(0);
HttpURLConnection conn = NetworkUtils.createConnection(url, proxy);

View File

@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.task;
import org.jackhuang.hmcl.util.Constants;
import org.jackhuang.hmcl.util.Logging;
import java.util.concurrent.*;
@@ -35,9 +36,7 @@ public final class Schedulers {
private static synchronized ExecutorService getCachedExecutorService() {
if (CACHED_EXECUTOR == null)
CACHED_EXECUTOR = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60, TimeUnit.SECONDS, new SynchronousQueue<>(), runnable -> {
return Executors.defaultThreadFactory().newThread(runnable);
});
60, TimeUnit.SECONDS, new SynchronousQueue<>(), Executors.defaultThreadFactory());
return CACHED_EXECUTOR;
}
@@ -117,6 +116,8 @@ public final class Schedulers {
static final Scheduler NONE = new SchedulerImpl(Constants.emptyConsumer());
public static synchronized void shutdown() {
Logging.LOG.info("Shutting down executor services.");
if (CACHED_EXECUTOR != null)
CACHED_EXECUTOR.shutdown();

View File

@@ -205,6 +205,13 @@ public abstract class Task {
return new TaskExecutor(this);
}
public final TaskExecutor executor(boolean start) {
TaskExecutor executor = new TaskExecutor(this);
if (start)
executor.start();
return executor;
}
public final TaskExecutor executor(TaskListener taskListener) {
TaskExecutor executor = new TaskExecutor(this);
executor.addTaskListener(taskListener);

View File

@@ -134,7 +134,7 @@ public final class TaskExecutor {
task.setState(Task.TaskState.READY);
if (task.getSignificance().shouldLog())
Logging.LOG.log(Level.FINE, "Executing task: {0}", task.getName());
Logging.LOG.log(Level.FINE, "Executing task: " + task.getName());
taskListeners.forEach(it -> it.onReady(task));
@@ -176,7 +176,7 @@ public final class TaskExecutor {
flag = true;
if (task.getSignificance().shouldLog()) {
Logging.LOG.log(Level.FINER, "Task finished: {0}", task.getName());
Logging.LOG.log(Level.FINER, "Task finished: " + task.getName());
}
task.onDone().fireEvent(new TaskEvent(this, task, false));

View File

@@ -43,11 +43,14 @@ public final class IntVersionNumber extends VersionNumber {
if (!(o instanceof IntVersionNumber))
return 0;
IntVersionNumber other = (IntVersionNumber) o;
int len = Math.min(this.version.size(), other.version.size());
for (int i = 0; i < len; ++i)
if (!version.get(i).equals(other.version.get(i)))
return version.get(i).compareTo(other.version.get(i));
return Integer.compare(this.version.size(), other.version.size());
int len = Math.max(this.version.size(), other.version.size());
for (int i = 0; i < len; ++i) {
int thisInt = Lang.get(this.version, i).orElse(0);
int otherInt = Lang.get(other.version, i).orElse(0);
if (thisInt != otherInt)
return Integer.compare(thisInt, otherInt);
}
return 0;
}
@Override

View File

@@ -54,8 +54,8 @@ public enum Log4jLevel {
public boolean lessOrEqual(Log4jLevel level) {
return this.level <= level.level;
}
public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
public static final Pattern MINECRAFT_LOGGER_CATEGORY = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\] \\[(?<category>[^\\]]+)\\]");
public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)] \\[[^/]+/(?<level>[^]]+)]");
public static final Pattern MINECRAFT_LOGGER_CATEGORY = Pattern.compile("\\[(?<timestamp>[0-9:]+)] \\[[^/]+/(?<level>[^]]+)] \\[(?<category>[^]]+)]");
public static final String JAVA_SYMBOL = "([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$][a-zA-Z\\d_$]*";
public static Log4jLevel guessLevel(String line) {

View File

@@ -20,7 +20,6 @@ package org.jackhuang.hmcl.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.*;
@@ -32,9 +31,13 @@ import java.util.logging.*;
public final class Logging {
public static final Logger LOG;
private static final ByteArrayOutputStream OUTPUT_STREAM = new ByteArrayOutputStream();
static {
LOG = Logger.getLogger("HMCL");
}
public static void start() {
LOG.setLevel(Level.FINER);
LOG.setUseParentHandlers(false);
@@ -51,6 +54,25 @@ public final class Logging {
consoleHandler.setLevel(Level.FINER);
consoleHandler.setFormatter(DefaultFormatter.INSTANCE);
LOG.addHandler(consoleHandler);
StreamHandler streamHandler = new StreamHandler(OUTPUT_STREAM, DefaultFormatter.INSTANCE) {
@Override
public synchronized void publish(LogRecord record) {
super.publish(record);
flush();
}
};
streamHandler.setLevel(Level.FINEST);
LOG.addHandler(streamHandler);
}
public static void stop() {
for (Handler handler : LOG.getHandlers())
LOG.removeHandler(handler);
}
public static String getLogs() {
return OUTPUT_STREAM.toString();
}
static final class DefaultFormatter extends Formatter {
@@ -63,7 +85,7 @@ public final class Logging {
String date = format.format(new Date(record.getMillis()));
String log = String.format("[%s] [%s.%s/%s] %s%n",
date, record.getSourceClassName(), record.getSourceMethodName(),
record.getLevel().getName(), MessageFormat.format(record.getMessage(), record.getParameters())
record.getLevel().getName(), record.getMessage()
);
ByteArrayOutputStream builder = new ByteArrayOutputStream();
if (record.getThrown() != null)

View File

@@ -40,13 +40,11 @@ public abstract class VersionNumber implements Comparable<VersionNumber> {
throw new IllegalArgumentException("The version " + version + " is malformed, only dots and digits are allowed.");
String[] s = version.split("\\.");
int last = s.length - 1;
for (int i = s.length - 1; i >= 0; --i)
if (Integer.parseInt(s[i]) == 0)
last = i;
ArrayList<Integer> versions = new ArrayList<>(last + 1);
for (int i = 0; i <= last; ++i)
versions.add(Integer.parseInt(s[i]));
ArrayList<Integer> versions = new ArrayList<>(s.length);
for (String value : s) versions.add(Integer.parseInt(value));
while (!versions.isEmpty() && versions.get(versions.size() - 1) == 0)
versions.remove(versions.size() - 1);
return new IntVersionNumber(Collections.unmodifiableList(versions));
}

View File

@@ -70,10 +70,10 @@ public final class ZipEngine implements Closeable {
* modified pathName, null if you dont want this file zipped
*/
private void putDirectoryImpl(File source, String basePath, BiFunction<String, Boolean, String> pathNameCallback) throws IOException {
File[] files;
File[] files = null;
if (source.isDirectory())
files = source.listFiles();
else
else if (source.isFile())
files = new File[] { source };
if (files == null)