better visibility/javadoc

By: Taylor Kelly <tkelly910@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-03 12:26:35 +08:00
parent b01c65f9bc
commit ca056597e1
3 changed files with 19 additions and 30 deletions

View file

@ -9,12 +9,12 @@ public class Checker {
private static String directory = Fillr.directory; private static String directory = Fillr.directory;
/** /**
* Checks all the .updatr files in Updatr/ for updates * Checks all the plugins in plugins/ for updates
* *
* @param player * @param player
* The player to send info to * The player to send info to
*/ */
public void check(Player player) { void check(Player player) {
File folder = new File(directory); File folder = new File(directory);
File[] files = folder.listFiles(new PluginFilter()); File[] files = folder.listFiles(new PluginFilter());
if (files.length == 0) { if (files.length == 0) {
@ -31,14 +31,14 @@ public class Checker {
} }
/** /**
* Checks for an update for a given .updatr file * Checks for an update for a given plugin
* *
* @param file * @param file
* The plugin file to check for an update * The plugin file to check for an update
* @param player * @param player
* The player to send info to * The player to send info to
*/ */
public void checkForUpdate(File file, Player player) { private void checkForUpdate(File file, Player player) {
PluginDescriptionFile pdfFile = Checker.getPDF(file); PluginDescriptionFile pdfFile = Checker.getPDF(file);
FillReader reader = needsUpdate(pdfFile); FillReader reader = needsUpdate(pdfFile);
if (reader != null) { if (reader != null) {
@ -58,7 +58,7 @@ public class Checker {
* The .yml file to check * The .yml file to check
* @return The FillReader for the online repo info on the plugin * @return The FillReader for the online repo info on the plugin
*/ */
public static FillReader needsUpdate(PluginDescriptionFile file) { static FillReader needsUpdate(PluginDescriptionFile file) {
FillReader reader = new FillReader(file.getName()); FillReader reader = new FillReader(file.getName());
String version = file.getVersion(); String version = file.getVersion();
String currVersion = reader.getCurrVersion(); String currVersion = reader.getCurrVersion();
@ -79,7 +79,7 @@ public class Checker {
* The plugin (jar) file * The plugin (jar) file
* @return The PluginDescriptionFile representing the .yml * @return The PluginDescriptionFile representing the .yml
*/ */
public static PluginDescriptionFile getPDF(File file) { static PluginDescriptionFile getPDF(File file) {
// TODO supports only jar files for now. how will yml's be stored in // TODO supports only jar files for now. how will yml's be stored in
// different languages? // different languages?
if (file.getName().endsWith(".jar")) { if (file.getName().endsWith(".jar")) {

View file

@ -19,7 +19,7 @@ public class Downloader {
* @param url * @param url
* The url to download from * The url to download from
*/ */
public static void downloadJar(String url) throws Exception { static void downloadJar(String url) throws Exception {
int index = url.lastIndexOf('/'); int index = url.lastIndexOf('/');
String name = url.substring(index + 1); String name = url.substring(index + 1);
@ -37,14 +37,14 @@ public class Downloader {
} }
/** /**
* Downloads the file for a given plugin (if it's updatr file exists); * Downloads the file for a given plugin
* *
* @param name * @param name
* The name of the plugin to download * The name of the plugin to download
* @param player * @param player
* The player to send info to * The player to send info to
*/ */
public void downloadFile(String name, Player player) throws Exception { void downloadFile(String name, Player player) throws Exception {
File file = new File(directory, name + ".jar"); File file = new File(directory, name + ".jar");
if (file.exists()) { if (file.exists()) {
player.sendMessage("Downloading " + name + "'s file"); player.sendMessage("Downloading " + name + "'s file");
@ -58,7 +58,7 @@ public class Downloader {
} }
/** /**
* Downloads the file to the Updatr/downloads directory * Downloads the file to the plugin/downloads directory
* *
* @param u * @param u
* The url of the file to download * The url of the file to download
@ -130,7 +130,7 @@ public class Downloader {
* OutputStream * OutputStream
* @throws IOException * @throws IOException
*/ */
public static final void copyInputStream(InputStream in, OutputStream out) private static final void copyInputStream(InputStream in, OutputStream out)
throws IOException { throws IOException {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len; int len;
@ -142,18 +142,6 @@ public class Downloader {
out.close(); out.close();
} }
/**
* Downloads the new updatr file
*
* @param url
* The url pointing to the updatr file
* @param name
* The name of the plugin
*/
public static void downloadUpdatr(String url, String name) throws Exception {
// try {
download(new URL(url), name + ".updatr", Fillr.directory);
}
/** /**
* Moves the file to the backup folder. * Moves the file to the backup folder.
@ -161,7 +149,7 @@ public class Downloader {
* @param file * @param file
* The file to backup * The file to backup
*/ */
public static void backupFile(File file) { private static void backupFile(File file) {
if (file.exists()) { if (file.exists()) {
System.out.println("Backing up old file: " + file.getName()); System.out.println("Backing up old file: " + file.getName());
if (!new File(backup).exists()) if (!new File(backup).exists())

View file

@ -12,17 +12,17 @@ public class Updater {
public static String directory = Fillr.directory; public static String directory = Fillr.directory;
private final Server server; private final Server server;
public Updater(Server server) { Updater(Server server) {
this.server = server; this.server = server;
} }
/** /**
* Checks and updates the plugins with updatr files * Checks and updates the plugins
* *
* @param player * @param player
* The player to send info to * The player to send info to
*/ */
public void updateAll(Player player) { void updateAll(Player player) {
File folder = new File(directory); File folder = new File(directory);
File[] files = folder.listFiles(new PluginFilter()); File[] files = folder.listFiles(new PluginFilter());
if (files.length == 0) { if (files.length == 0) {
@ -48,7 +48,7 @@ public class Updater {
* @param player * @param player
* The player to send info to * The player to send info to
*/ */
public void update(String string, Player player) { void update(String string, Player player) {
//TODO so much .jars //TODO so much .jars
File file = new File(directory, string + ".jar"); File file = new File(directory, string + ".jar");
if (file.exists()) { if (file.exists()) {
@ -68,9 +68,10 @@ public class Updater {
* Downloads the plugin specified by the URLReader * Downloads the plugin specified by the URLReader
* *
* @param update * @param update
* The URLReader representing the online .updatr file * The FillReader with all the plugin info
* @param player The player to send info to
*/ */
public void update(FillReader update, Player player) { private void update(FillReader update, Player player) {
disablePlugin(update); disablePlugin(update);
player.sendMessage("Disabling " + update.getName() + " for update"); player.sendMessage("Disabling " + update.getName() + " for update");
player.sendMessage("Downloading " + update.getName() + " " player.sendMessage("Downloading " + update.getName() + " "