forked from LogBlock/LogBlock
Minor cleanup
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import static de.diddiz.util.Utils.download;
|
||||
import static de.diddiz.util.Utils.downloadIfNotExists;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
@@ -23,9 +23,6 @@ import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import de.diddiz.LogBlock.QueryParams.BlockChangeType;
|
||||
import de.diddiz.util.MySQLConnectionPool;
|
||||
|
||||
// TODO Add painting logging
|
||||
// TODO Add Button, lever etc logging
|
||||
|
||||
public class LogBlock extends JavaPlugin
|
||||
{
|
||||
private Logger log;
|
||||
@@ -62,7 +59,11 @@ public class LogBlock extends JavaPlugin
|
||||
updater = new Updater(this);
|
||||
log.info("[LogBlock] Version check: " + updater.checkVersion());
|
||||
config = new Config(this);
|
||||
downloadIfNotExists(log, new File("lib/mysql-connector-java-bin.jar"), new URL("http://diddiz.insane-architects.net/download/mysql-connector-java-bin.jar"));
|
||||
final File file = new File("lib/mysql-connector-java-bin.jar");
|
||||
if (!file.exists() || file.length() == 0)
|
||||
download(log, new URL("http://diddiz.insane-architects.net/download/mysql-connector-java-bin.jar"), file);
|
||||
if (!file.exists() || file.length() == 0)
|
||||
throw new FileNotFoundException(file.getAbsolutePath() + file.getName());
|
||||
log.info("[LogBlock] Connecting to " + config.user + "@" + config.url + "...");
|
||||
pool = new MySQLConnectionPool(config.url, config.user, config.password);
|
||||
getConnection().close();
|
||||
|
@@ -3,7 +3,6 @@ package de.diddiz.util;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -33,7 +32,7 @@ public class Utils
|
||||
out.write(buffer, 0, len);
|
||||
downloaded += len;
|
||||
if ((int)((System.currentTimeMillis() - start) / 500) > msgs) {
|
||||
log.info((int)((double)downloaded / (double)size * 100d) + "%");
|
||||
log.info((int)(downloaded / (double)size * 100d) + "%");
|
||||
msgs++;
|
||||
}
|
||||
}
|
||||
@@ -42,13 +41,6 @@ public class Utils
|
||||
log.info("Download finished");
|
||||
}
|
||||
|
||||
public static void downloadIfNotExists(Logger log, File file, URL url) throws IOException {
|
||||
if (!file.exists() || file.length() == 0)
|
||||
Utils.download(log, url, file);
|
||||
if (!file.exists() || file.length() == 0)
|
||||
throw new FileNotFoundException(file.getAbsolutePath() + file.getName());
|
||||
}
|
||||
|
||||
public static String readURL(URL url) throws IOException {
|
||||
final StringBuilder content = new StringBuilder();
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
|
Reference in New Issue
Block a user