2010-12-01 19:59:51 +01:00
|
|
|
import java.io.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2010-12-01 22:15:37 +01:00
|
|
|
|
2010-12-01 19:59:51 +01:00
|
|
|
public class vMinecraftUsers {
|
|
|
|
private static volatile vMinecraftUsers instance;
|
|
|
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
|
|
|
String file = "vminecraftusers.txt";
|
|
|
|
private PropertiesFile properties;
|
|
|
|
String location = "vminecraftusers.txt";
|
|
|
|
public void loadUsers(){
|
|
|
|
File theDir = new File("vminecraftusers.txt");
|
|
|
|
if(!theDir.exists()){
|
|
|
|
properties = new PropertiesFile("vminecraftusers.txt");
|
|
|
|
FileWriter writer = null;
|
|
|
|
try {
|
|
|
|
writer = new FileWriter(location);
|
|
|
|
writer.write("#Storage place for user information\r\n");
|
|
|
|
writer.write("#username:nickname:suffix:ignore,list,names:alias,commands,here\r\n");
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (writer != null) {
|
|
|
|
writer.close();
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
properties = new PropertiesFile("vminecraftusers.txt");
|
|
|
|
try {
|
|
|
|
properties.load();
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while loading vminecraftusers.txt", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static void addUser(Player player){
|
|
|
|
FileWriter writer = null;
|
|
|
|
String location = "vminecraftusers.txt";
|
|
|
|
try {
|
2010-12-01 22:17:18 +01:00
|
|
|
BufferedWriter bw = new BufferedWriter(new FileWriter(location, true));
|
2010-12-01 22:33:20 +01:00
|
|
|
bw.append(player.getName()+"::::\r");
|
2010-12-01 22:15:37 +01:00
|
|
|
bw.newLine();
|
|
|
|
bw.close();
|
2010-12-01 22:33:20 +01:00
|
|
|
} catch (Exception e) {
|
2010-12-01 22:15:37 +01:00
|
|
|
log.log(Level.SEVERE, "Exception while trying to add user with BufferedWriter to " + location, e);
|
2010-12-01 21:28:50 +01:00
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (writer != null) {
|
|
|
|
writer.close();
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
2010-12-01 22:33:20 +01:00
|
|
|
log.log(Level.SEVERE, "Exception while closing BufferedWriter to " + location, e);
|
2010-12-01 21:28:50 +01:00
|
|
|
}
|
|
|
|
}
|
2010-12-01 19:59:51 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
public static vMinecraftUsers getInstance() {
|
|
|
|
if (instance == null) {
|
|
|
|
instance = new vMinecraftUsers();
|
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
}
|
2010-12-01 22:15:37 +01:00
|
|
|
public static void getRow(){
|
|
|
|
|
|
|
|
}
|
2010-12-01 19:59:51 +01:00
|
|
|
}
|