Added in some parsing of the loading from vminecraftusers.txt

This commit is contained in:
cerevisiae 2010-12-02 14:45:24 -06:00
parent 9e293645a3
commit 04c385d0dc
2 changed files with 67 additions and 37 deletions

View File

@ -32,6 +32,7 @@ public class vMinecraftChat {
//===================================================================== //=====================================================================
public static void sendMessage(Player sender, Player receiver, String msg){ public static void sendMessage(Player sender, Player receiver, String msg){
String[] message = applyColors(wordWrap(msg)); String[] message = applyColors(wordWrap(msg));
if
for(String out : message) for(String out : message)
receiver.sendMessage(out + " "); receiver.sendMessage(out + " ");
} }
@ -283,6 +284,12 @@ public class vMinecraftChat {
case 'F': case 'F':
color = Colors.White; color = Colors.White;
break; break;
case 'R':
color = "~";
break;
case 'r':
color = "~";
break;
default: default:
color = null; color = null;
break; break;
@ -401,6 +408,7 @@ public class vMinecraftChat {
} }
return false; return false;
} }
//===================================================================== //=====================================================================
//Function: emote //Function: emote
//Input: Player player: The player talking //Input: Player player: The player talking

View File

@ -10,8 +10,10 @@ public class vMinecraftUsers {
String file = "vminecraftusers.txt"; String file = "vminecraftusers.txt";
private PropertiesFile properties; private PropertiesFile properties;
String location = "vminecraftusers.txt"; String location = "vminecraftusers.txt";
private String[] ignoreList = new String[]{""}; //For datafiles
private String[] aliasList = new String[]{""}; //For datafiles ArrayList<PlayerList> players = new ArrayList<PlayerList>();
public void loadUsers(){ public void loadUsers(){
File theDir = new File("vminecraftusers.txt"); File theDir = new File("vminecraftusers.txt");
if(!theDir.exists()){ if(!theDir.exists()){
@ -158,6 +160,7 @@ class PlayerList
//===================================================================== //=====================================================================
class PlayerProfile class PlayerProfile
{ {
protected final Logger log = Logger.getLogger("Minecraft");
private Player playerName; private Player playerName;
private String nickName; private String nickName;
private String tag; private String tag;
@ -184,6 +187,7 @@ class PlayerList
nickName = new String(); nickName = new String();
tag = new String(); tag = new String();
suffix = new String(); suffix = new String();
String location = "vminecraftusers.txt";
//Try to apply what we can //Try to apply what we can
try { try {
Scanner scanner = new Scanner(new File(location)); Scanner scanner = new Scanner(new File(location));
@ -193,7 +197,7 @@ class PlayerList
continue; continue;
} }
String[] split = line.split(":"); String[] split = line.split(":");
if (!split[0].equalsIgnoreCase(name)) { if (!split[0].equalsIgnoreCase(player.getName())) {
continue; continue;
} }
nickName = (split[1].split(",").toString()); nickName = (split[1].split(",").toString());
@ -201,18 +205,36 @@ class PlayerList
if (split.length >= 4) { if (split.length >= 4) {
tag = (split[3]); tag = (split[3]);
} }
//Add all the ignored people to the player's ignore list
if (split.length >= 5) { if (split.length >= 5) {
//ignoreList = (split[4]); for(String name : split[4].split(","))
ignoreList.add(etc.getServer().getPlayer(name));
} }
if (split.length >= 6) { if (split.length >= 6) {
//aliasList //Loop through all the aliases
for(String alias : split[5].split(","))
{
//Break apart the two parts of the alias
String[] parts = alias.split("@");
if(parts.length > 1)
{
//Get the arguments for the alias if there are any
String[] command = parts[1].split(" ");
String[] args = null;
if(command.length > 1)
System.arraycopy(command, 1, args, 0, command.length - 2);
//Register the alias to the player's aliasList
aliasList.registerAlias(parts[0], command[0], args);
}
}
} }
} }
scanner.close(); scanner.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e);
} }
} }
//===================================================================== //=====================================================================