From f36a842fc74a372986ad583a8d00c0a098370e82 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 2 Dec 2010 01:39:17 -0800 Subject: [PATCH] Very early version of trying to get this stuff to work, its half done and won't compile as is. Got sleepy. Not even sure If I'm approaching it right, I'll look at it with a clear head in the morning. Feel free to tweak it if you want, I'll resume once I wake up if not. --- vMinecraftUsers.java | 71 +++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/vMinecraftUsers.java b/vMinecraftUsers.java index efda9b5dd..029d8205c 100644 --- a/vMinecraftUsers.java +++ b/vMinecraftUsers.java @@ -10,6 +10,8 @@ public class vMinecraftUsers { String file = "vminecraftusers.txt"; private PropertiesFile properties; String location = "vminecraftusers.txt"; + private String[] ignoreList = new String[]{""}; //For datafiles + private String[] aliasList = new String[]{""}; //For datafiles public void loadUsers(){ File theDir = new File("vminecraftusers.txt"); if(!theDir.exists()){ @@ -40,7 +42,6 @@ public class vMinecraftUsers { } } } - public boolean doesPlayerExist(String player) { try { Scanner scanner = new Scanner(new File(location)); @@ -61,38 +62,6 @@ public class vMinecraftUsers { } return false; } - public Player getPlayer(String name) { - Player player = new Player(); - try { - Scanner scanner = new Scanner(new File(location)); - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - if (line.startsWith("#") || line.equals("") || line.startsWith("")) { - continue; - } - String[] split = line.split(":"); - if (!split[0].equalsIgnoreCase(name)) { - continue; - } - if (split.length >= 2) { - //player.setNickname(split[1] - } - if (split.length >= 3) { - //player.setSuffix(split[2]); - } - if (split.length >= 5) { - //player.setIgnoreList(split[4].split(",")); - } - if (split.length >= 6) { - //player.setAlias(split[5].split(",")); - } - } - scanner.close(); - } catch (Exception e) { - log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); - } - return player; - } public static void addUser(Player player){ FileWriter writer = null; String location = "vminecraftusers.txt"; @@ -192,6 +161,7 @@ class PlayerList private Player playerName; private String nickName; private String tag; + private String suffix; private ArrayList ignoreList; private commandList aliasList; @@ -208,8 +178,41 @@ class PlayerList //===================================================================== public PlayerProfile(Player player) { + //Declare things ignoreList = new ArrayList(); - aliasList = new commandList(); + aliasList = new commandList(); + nickName = new String(); + tag = new String(); + suffix = new String(); + //Try to apply what we can + try { + Scanner scanner = new Scanner(new File(location)); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + if (line.startsWith("#") || line.equals("") || line.startsWith("")) { + continue; + } + String[] split = line.split(":"); + if (!split[0].equalsIgnoreCase(name)) { + continue; + } + nickName = (split[1].split(",").toString()); + + if (split.length >= 4) { + tag = (split[3]); + } + if (split.length >= 5) { + //ignoreList = (split[4]); + } + if (split.length >= 6) { + //aliasList + } + } + scanner.close(); + } catch (Exception e) { + log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); + } + } //=====================================================================