This commit is contained in:
Gabriele C 2015-07-28 17:06:54 +02:00
parent 47211ab803
commit 88530542ac
3 changed files with 32 additions and 26 deletions

View File

@ -210,15 +210,18 @@ public class Utils {
LOGGEDIN
}
public static void purgeDirectory(File dir) {
if (dir != null && dir.listFiles() != null)
for (File file : dir.listFiles()) {
if (file != null){
if (file.isDirectory())
purgeDirectory(file);
file.delete();
public static void purgeDirectory(File file){
String files[] = file.list();
if (files != null && files.length != 0){
for (String temp : files) {
File fileDelete = new File(file, temp);
if (fileDelete.isDirectory()){
purgeDirectory(fileDelete);
fileDelete.delete();
} else {
fileDelete.delete();
}
}
}
}
}

View File

@ -45,9 +45,9 @@ public class FileCache {
try {
path = player.getUniqueId().toString();
} catch (Exception e) {
path = player.getName();
path = player.getName().toLowerCase();
} catch (Error e) {
path = player.getName();
path = player.getName().toLowerCase();
}
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "playerdatas.cache");
@ -198,9 +198,9 @@ public class FileCache {
try {
path = player.getUniqueId().toString();
} catch (Exception e) {
path = player.getName();
path = player.getName().toLowerCase();
} catch (Error e) {
path = player.getName();
path = player.getName().toLowerCase();
}
try {
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "playerdatas.cache");
@ -537,22 +537,25 @@ public class FileCache {
try {
path = player.getUniqueId().toString();
} catch (Exception e) {
path = player.getName();
path = player.getName().toLowerCase();
} catch (Error e) {
path = player.getName();
path = player.getName().toLowerCase();
}
try {
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path);
if (!file.exists()) {
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
}
if (file.exists()) {
if (file.isDirectory() && file.listFiles() != null) {
if (file.list() != null) {
Utils.purgeDirectory(file);
} else file.delete();
file.delete();
} else {
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + player.getName().toLowerCase() + ".cache");
if(file.isFile()){
file.delete();
} else {
ConsoleLogger.showError("Failed to remove" + player.getName() + "cache, it doesn't exist!");
}
}
} catch (Exception e) {
ConsoleLogger.showError("File cannot be removed correctly :/");
ConsoleLogger.showError("Failed to remove" + player.getName() + "cache :/");
}
}
@ -561,9 +564,9 @@ public class FileCache {
try {
path = player.getUniqueId().toString();
} catch (Exception e) {
path = player.getName();
path = player.getName().toLowerCase();
} catch (Error e) {
path = player.getName();
path = player.getName().toLowerCase();
}
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "playerdatas.cache");
if (!file.exists()) {

View File

@ -438,7 +438,7 @@ public class AuthMePlayerListener implements Listener {
if (Settings.antiBotInAction){
if (!plugin.database.isAuthAvailable(name)) {
event.setKickMessage(m.send("AntiBot service in action! Non registered players can't connect until the bot attack stops!")[0]); //Need to add string to messages
event.setKickMessage("AntiBot service in action! Non registered players can't connect until the bot attack stops!"); //Need to add string to messages
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
return;
}