Formatting

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-03 15:31:54 +00:00
parent 891a7dd5f8
commit 346e41a6e5
7 changed files with 427 additions and 430 deletions

View file

@ -24,7 +24,9 @@ public class Checker {
+ " plugins:");
for (File file : files) {
PluginDescriptionFile pdfFile = Checker.getPDF(file);
if(pdfFile == null) continue;
if (pdfFile == null) {
continue;
}
checkForUpdate(file, player);
}
}
@ -96,8 +98,8 @@ public class Checker {
e.printStackTrace();
return null;
}
} else
} else {
return null;
}
}
}

View file

@ -4,13 +4,12 @@ import org.bukkit.*;
import org.bukkit.plugin.PluginDescriptionFile;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
public class Downloader {
private static String directory = Fillr.directory;
private static String downloads = directory + File.separator + "downloads";
private static String backup = "backup";
private final static String directory = Fillr.directory;
private final static String downloads = directory + File.separator + "downloads";
private final static String backup = "backup";
/**
* Downloads the jar from a given url. If it is a compressed archive, it
@ -24,8 +23,9 @@ public class Downloader {
String name = url.substring(index + 1);
File file = new File(directory, name);
if (url.endsWith(".jar") && file.exists())
if (url.endsWith(".jar") && file.exists()) {
backupFile(file);
}
download(new URL(url), name, directory);
file = new File("plugins", name);
@ -86,20 +86,23 @@ public class Downloader {
// try {
inputStream = u.openStream();
if (!new File(directory).exists())
if (!new File(directory).exists()) {
new File(directory).mkdir();
}
File f = new File(directory, name);
if (f.exists())
if (f.exists()) {
f.delete();
}
f.createNewFile();
copyInputStream(inputStream, new BufferedOutputStream(
new FileOutputStream(f)));
try {
if (inputStream != null)
if (inputStream != null) {
inputStream.close();
}
} catch (IOException ioe) {
System.out.println("[UPDATR]: Error closing inputStream");
}
@ -135,14 +138,14 @@ public class Downloader {
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) >= 0)
while ((len = in.read(buffer)) >= 0) {
out.write(buffer, 0, len);
}
in.close();
out.close();
}
/**
* Moves the file to the backup folder.
*
@ -152,11 +155,10 @@ public class Downloader {
private static void backupFile(File file) {
if (file.exists()) {
System.out.println("Backing up old file: " + file.getName());
if (!new File(backup).exists())
if (!new File(backup).exists()) {
new File(backup).mkdir();
file.renameTo(new File(backup, file
.getName() + ".bak"));
}
file.renameTo(new File(backup, file.getName() + ".bak"));
}
}
}

View file

@ -1,6 +1,5 @@
package org.bukkit.fillr;
import java.util.*;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
@ -15,7 +14,6 @@ import org.json.simple.parser.ParseException;
public class FillReader {
//TODO change this to what it will actually be...
private static String baseUrl = "http://taylorkelly.me/pnfo.php";
private String currVersion;
private String file;
private String name;
@ -78,5 +76,4 @@ public class FillReader {
public boolean isStable() {
return stable;
}
}

View file

@ -7,7 +7,6 @@ import org.bukkit.plugin.java.*;
import org.bukkit.event.*;
import java.io.File;
import java.util.logging.Logger;
import org.bukkit.event.player.PlayerListener;
public class Fillr extends JavaPlugin {

View file

@ -28,7 +28,6 @@ public class Getter {
} catch (Exception e) {
e.printStackTrace();
}
}
private void enablePlugin(FillReader update) {
@ -41,6 +40,4 @@ public class Getter {
e.printStackTrace();
}
}
}

View file

@ -1,4 +1,5 @@
package org.bukkit.fillr;
import java.io.File;
import java.io.FilenameFilter;
@ -6,12 +7,11 @@ import java.io.FilenameFilter;
* Used to filter out non-updatr files
*/
public class PluginFilter implements FilenameFilter {
public boolean accept(File file, String name) {
if(name.endsWith(".jar"))
if (name.endsWith(".jar")) {
return true;
else
} else {
return false;
}
}
}

View file

@ -4,9 +4,6 @@ import org.bukkit.*;
import org.bukkit.plugin.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.*;
public class Updater {
public static String directory = Fillr.directory;
@ -32,13 +29,16 @@ public class Updater {
+ files.length + " plugins:");
for (File file : files) {
PluginDescriptionFile pdfFile = Checker.getPDF(file);
if(pdfFile == null) continue;
if (pdfFile == null) {
continue;
}
FillReader reader = Checker.needsUpdate(pdfFile);
if (reader != null)
if (reader != null) {
update(reader, player);
}
}
}
}
/**
* Checks if a given plugin needs an update, if it does, it updates it