Add tests for CommandUtils, move purgeDirectory to its only use

This commit is contained in:
ljacqu
2015-12-14 21:37:20 +01:00
parent 282f777311
commit bfebf6dc44
3 changed files with 74 additions and 24 deletions
@@ -15,7 +15,6 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
@@ -207,27 +206,6 @@ public final class Utils {
}
}
/**
* Delete a given directory and all his content.
*
* @param directory File
*/
public static void purgeDirectory(File directory) {
if (!directory.isDirectory()) {
return;
}
File[] files = directory.listFiles();
if (files == null) {
return;
}
for (File target : files) {
if (target.isDirectory()) {
purgeDirectory(target);
}
target.delete();
}
}
/**
* Safe way to retrieve the list of online players from the server. Depending on the
* implementation of the server, either an array of {@link Player} instances is being returned,