Remove automatic WorldEdit downloading. What.A.Joke.

This commit is contained in:
md_5
2012-08-05 20:21:39 +10:00
parent 0290305b23
commit 8bc648e971
2 changed files with 2 additions and 58 deletions

View File

@@ -12,12 +12,10 @@ import static de.diddiz.LogBlock.config.Config.toolsByType;
import static de.diddiz.LogBlock.config.Config.url;
import static de.diddiz.LogBlock.config.Config.useBukkitScheduler;
import static de.diddiz.LogBlock.config.Config.user;
import static de.diddiz.util.Utils.download;
import static org.bukkit.Bukkit.getPluginManager;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -116,15 +114,8 @@ public class LogBlock extends JavaPlugin
}
if (noDb)
return;
if (pm.getPlugin("WorldEdit") == null && !new File("lib/WorldEdit.jar").exists() && !new File("WorldEdit.jar").exists())
try {
download(getLogger(), new URL("http://diddiz.insane-architects.net/download/WorldEdit.jar"), new File("lib/WorldEdit.jar"));
getLogger().info("[LogBlock] You've to restart/reload your server now.");
pm.disablePlugin(this);
return;
} catch (final Exception ex) {
getLogger().warning("[LogBlock] Failed to download WorldEdit. You may have to download it manually. You don't have to install it, just place the jar in the lib folder.");
}
if (pm.getPlugin("WorldEdit") == null)
new Exception("WorldEdit is not installed please download and install").printStackTrace();
commandsHandler = new CommandsHandler(this);
getCommand("lb").setExecutor(commandsHandler);
if (enableAutoClearLog && autoClearLogDelay > 0)

View File

@@ -1,60 +1,13 @@
package de.diddiz.util;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.logging.Logger;
public class Utils
{
public static String newline = System.getProperty("line.separator");
public static void download(Logger log, URL url, File file) throws IOException {
if (!file.getParentFile().exists())
file.getParentFile().mkdir();
if (file.exists())
file.delete();
file.createNewFile();
final int size = url.openConnection().getContentLength();
log.info("Downloading " + file.getName() + " (" + size / 1024 + "kb) ...");
final InputStream in = url.openStream();
final OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
final byte[] buffer = new byte[1024];
int len, downloaded = 0, msgs = 0;
final long start = System.currentTimeMillis();
while ((len = in.read(buffer)) >= 0) {
out.write(buffer, 0, len);
downloaded += len;
if ((int)((System.currentTimeMillis() - start) / 500) > msgs) {
log.info((int)(downloaded / (double)size * 100d) + "%");
msgs++;
}
}
in.close();
out.close();
log.info("Download finished");
}
public static String readURL(URL url) throws IOException {
final StringBuilder content = new StringBuilder();
final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
content.append(inputLine);
in.close();
return content.toString();
}
public static boolean isInt(String str) {
try {
Integer.parseInt(str);