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");
|
|
|
|
private PropertiesFile properties;
|
2010-12-11 07:28:56 +01:00
|
|
|
String location = "vminecraft.users";
|
2010-12-02 21:45:24 +01:00
|
|
|
|
2010-12-08 05:00:32 +01:00
|
|
|
public static PlayerList players = new PlayerList();
|
2010-12-02 21:45:24 +01:00
|
|
|
|
|
|
|
|
2010-12-01 19:59:51 +01:00
|
|
|
public void loadUsers(){
|
2010-12-11 07:28:56 +01:00
|
|
|
File theDir = new File(location);
|
2010-12-01 19:59:51 +01:00
|
|
|
if(!theDir.exists()){
|
2010-12-11 07:28:56 +01:00
|
|
|
properties = new PropertiesFile(location);
|
2010-12-01 19:59:51 +01:00
|
|
|
FileWriter writer = null;
|
|
|
|
try {
|
|
|
|
writer = new FileWriter(location);
|
|
|
|
writer.write("#Storage place for user information\r\n");
|
2010-12-12 20:40:39 +01:00
|
|
|
writer.write("#username:nickname:suffix:tag:ignore,list,names:alias,commands,here\r\n");
|
2010-12-01 19:59:51 +01:00
|
|
|
} 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 {
|
2010-12-11 07:28:56 +01:00
|
|
|
properties = new PropertiesFile(location);
|
2010-12-01 19:59:51 +01:00
|
|
|
try {
|
|
|
|
properties.load();
|
|
|
|
} catch (IOException e) {
|
2010-12-11 07:28:56 +01:00
|
|
|
log.log(Level.SEVERE, "Exception while loading " + location, e);
|
2010-12-01 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-10 02:18:35 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: addUser
|
|
|
|
//Input: Player player: The player to create a profile for
|
|
|
|
//Output: none
|
2010-12-12 22:01:17 +01:00
|
|
|
//Use: Loads the profile for the specified player
|
2010-12-10 02:18:35 +01:00
|
|
|
//=====================================================================
|
2010-12-01 19:59:51 +01:00
|
|
|
public static void addUser(Player player){
|
2010-12-08 05:53:51 +01:00
|
|
|
players.addPlayer(player);
|
2010-12-01 19:59:51 +01:00
|
|
|
}
|
2010-12-10 02:18:35 +01:00
|
|
|
|
2010-12-12 22:01:17 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: removeUser
|
|
|
|
//Input: Player player: The player to stop following
|
|
|
|
//Output: none
|
|
|
|
//Use: Creates the player profile
|
|
|
|
//=====================================================================
|
|
|
|
public static void removeUser(Player player){
|
|
|
|
players.removePlayer(player);
|
|
|
|
}
|
|
|
|
|
2010-12-10 02:18:35 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: getProfile
|
|
|
|
//Input: Player player: The player to find the profile for
|
|
|
|
//Output: PlayerList.PlayerProfile: The profile
|
|
|
|
//Use: Gets the player profile
|
|
|
|
//=====================================================================
|
|
|
|
public static PlayerList.PlayerProfile getProfile(Player player){
|
|
|
|
return players.findProfile(player);
|
|
|
|
}
|
2010-12-08 05:53:51 +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
|
|
|
}
|
2010-12-02 07:17:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Class: PlayerList
|
|
|
|
//Use: Encapsulates the player list
|
|
|
|
//Author: cerevisiae
|
|
|
|
//=====================================================================
|
|
|
|
class PlayerList
|
2010-12-02 22:42:59 +01:00
|
|
|
{
|
2010-12-08 10:47:42 +01:00
|
|
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
2010-12-02 07:17:42 +01:00
|
|
|
ArrayList<PlayerProfile> players;
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: PlayerList
|
|
|
|
//Input: Player player: The player to create a profile object for
|
|
|
|
//Output: none
|
|
|
|
//Use: Initializes the ArrayList
|
|
|
|
//=====================================================================
|
|
|
|
public PlayerList() { players = new ArrayList<PlayerProfile>(); }
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: addPlayer
|
|
|
|
//Input: Player player: The player to add
|
|
|
|
//Output: None
|
|
|
|
//Use: Add a profile of the specified player
|
|
|
|
//=====================================================================
|
|
|
|
public void addPlayer(Player player)
|
|
|
|
{
|
|
|
|
players.add(new PlayerProfile(player));
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: removePlayer
|
|
|
|
//Input: Player player: The player to remove
|
|
|
|
//Output: None
|
|
|
|
//Use: Remove the profile of the specified player
|
|
|
|
//=====================================================================
|
|
|
|
public void removePlayer(Player player)
|
|
|
|
{
|
|
|
|
players.remove(findProfile(player));
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: findProfile
|
|
|
|
//Input: Player player: The player to find's profile
|
|
|
|
//Output: PlayerProfile: The profile of the specified player
|
|
|
|
//Use: Get the profile for the specified player
|
|
|
|
//=====================================================================
|
2010-12-08 05:00:32 +01:00
|
|
|
public PlayerProfile findProfile(Player player)
|
2010-12-02 07:17:42 +01:00
|
|
|
{
|
|
|
|
for(PlayerProfile ply : players)
|
|
|
|
{
|
2010-12-08 05:00:32 +01:00
|
|
|
if(ply.isPlayer(player))
|
2010-12-02 07:17:42 +01:00
|
|
|
return ply;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Class: PlayerProfile
|
|
|
|
//Use: Encapsulates all commands for player options
|
|
|
|
//Author: cerevisiae
|
|
|
|
//=====================================================================
|
|
|
|
class PlayerProfile
|
|
|
|
{
|
2010-12-02 21:45:24 +01:00
|
|
|
protected final Logger log = Logger.getLogger("Minecraft");
|
2010-12-08 05:00:32 +01:00
|
|
|
private String playerName,
|
|
|
|
lastMessage,
|
|
|
|
nickName,
|
|
|
|
tag,
|
2010-12-12 20:40:39 +01:00
|
|
|
suffix;
|
2010-12-20 08:53:56 +01:00
|
|
|
private double tpx,
|
|
|
|
tpy,
|
|
|
|
tpz;
|
2010-12-12 20:40:39 +01:00
|
|
|
|
2010-12-14 01:15:04 +01:00
|
|
|
private boolean dead;
|
|
|
|
|
2010-12-12 20:40:39 +01:00
|
|
|
char defaultColor;
|
2010-12-11 07:28:56 +01:00
|
|
|
|
|
|
|
String location = "vminecraft.users";
|
2010-12-10 10:15:39 +01:00
|
|
|
|
2010-12-08 20:29:13 +01:00
|
|
|
private ArrayList<String> ignoreList;
|
2010-12-02 07:17:42 +01:00
|
|
|
private commandList aliasList;
|
|
|
|
|
|
|
|
static final int EXIT_FAIL = 0,
|
|
|
|
EXIT_SUCCESS = 1,
|
|
|
|
EXIT_CONTINUE = 2;
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: PlayerProfile
|
|
|
|
//Input: Player player: The player to create a profile object for
|
|
|
|
//Output: none
|
|
|
|
//Use: Loads settings for the player or creates them if they don't
|
|
|
|
// exist.
|
|
|
|
//=====================================================================
|
|
|
|
public PlayerProfile(Player player)
|
|
|
|
{
|
2010-12-08 05:00:32 +01:00
|
|
|
//Declare things
|
2010-12-08 10:47:42 +01:00
|
|
|
playerName = player.getName();
|
2010-12-02 21:45:24 +01:00
|
|
|
tag = new String();
|
2010-12-12 20:40:39 +01:00
|
|
|
nickName = new String();
|
2010-12-02 21:45:24 +01:00
|
|
|
suffix = new String();
|
2010-12-12 20:40:39 +01:00
|
|
|
defaultColor = 'f';
|
2010-12-08 20:29:13 +01:00
|
|
|
ignoreList = new ArrayList<String>();
|
2010-12-08 05:00:32 +01:00
|
|
|
aliasList = new commandList();
|
2010-12-14 01:15:04 +01:00
|
|
|
dead = false;
|
2010-12-08 05:00:32 +01:00
|
|
|
|
2010-12-12 20:40:39 +01:00
|
|
|
//Try to load the player and if they aren't found, append them
|
|
|
|
if(!load())
|
|
|
|
addPlayer();
|
|
|
|
}
|
2010-12-08 05:00:32 +01:00
|
|
|
|
2010-12-12 20:40:39 +01:00
|
|
|
public boolean load()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
//Open the user file
|
|
|
|
FileReader file = new FileReader(location);
|
|
|
|
BufferedReader in = new BufferedReader(file);
|
|
|
|
String line = "";
|
|
|
|
while((line = in.readLine()) != null)
|
|
|
|
{
|
|
|
|
//Find if the line contains the player we want.
|
|
|
|
String[] character = line.split(":");
|
|
|
|
if(!character[0].equals(playerName)){continue;}
|
|
|
|
|
|
|
|
//Get the tag
|
|
|
|
if(character.length > 1)
|
|
|
|
tag = character[1];
|
|
|
|
//Get the nickname
|
|
|
|
if(character.length > 2)
|
|
|
|
nickName = character[2];
|
|
|
|
//Get the suffix
|
|
|
|
if(character.length > 3)
|
|
|
|
suffix = character[3];
|
|
|
|
//Get the color
|
|
|
|
if(character.length > 4)
|
|
|
|
defaultColor = character[4].charAt(0);
|
|
|
|
//Ignore previously ignored players
|
|
|
|
if(character.length > 5)
|
|
|
|
{
|
|
|
|
String[] ignores = character[5].split(",");
|
|
|
|
if(ignores.length > 0)
|
|
|
|
{
|
|
|
|
for(String ignore : ignores)
|
|
|
|
ignoreList.add(ignore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Register the aliases
|
|
|
|
if(character.length > 6)
|
|
|
|
{
|
|
|
|
String[] allAliases = character[6].split(",");
|
|
|
|
if(allAliases.length > 0)
|
|
|
|
{
|
|
|
|
for(String singleAlias : allAliases)
|
|
|
|
{
|
|
|
|
String[] parts = singleAlias.split("@");
|
|
|
|
if(parts.length > 1)
|
|
|
|
{
|
|
|
|
aliasList.registerAlias(parts[0], parts[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-20 08:53:56 +01:00
|
|
|
//XYZ TP Back value
|
|
|
|
//Not sure if declaring a double this way will work or not
|
|
|
|
if(character.length > 7)
|
|
|
|
{
|
|
|
|
double tpx = new Double(character[7]).doubleValue();
|
|
|
|
}
|
|
|
|
if(character.length > 8)
|
|
|
|
{
|
|
|
|
double tpy = new Double(character[8]).doubleValue();
|
|
|
|
}
|
|
|
|
if(character.length > 9)
|
|
|
|
{
|
|
|
|
double tpz = new Double(character[9]).doubleValue();
|
|
|
|
}
|
2010-12-12 20:40:39 +01:00
|
|
|
in.close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
in.close();
|
2010-12-02 21:45:24 +01:00
|
|
|
} catch (Exception e) {
|
2010-12-08 05:00:32 +01:00
|
|
|
log.log(Level.SEVERE, "Exception while reading "
|
|
|
|
+ location + " (Are you sure you formatted it correctly?)", e);
|
2010-12-02 21:45:24 +01:00
|
|
|
}
|
2010-12-12 20:40:39 +01:00
|
|
|
return false;
|
2010-12-02 22:46:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
2010-12-02 22:42:59 +01:00
|
|
|
// Function: save
|
|
|
|
// Input: none
|
2010-12-02 22:46:50 +01:00
|
|
|
// Output: None
|
|
|
|
// Use: Writes current values of PlayerProfile to disk
|
|
|
|
// Call this function to save current values
|
2010-12-02 22:42:59 +01:00
|
|
|
//=====================================================================
|
2010-12-12 20:40:39 +01:00
|
|
|
public void save()
|
|
|
|
{
|
2010-12-02 22:42:59 +01:00
|
|
|
try {
|
2010-12-12 20:40:39 +01:00
|
|
|
//Open the file
|
|
|
|
FileReader file = new FileReader(location);
|
|
|
|
BufferedReader in = new BufferedReader(file);
|
|
|
|
StringBuilder writer = new StringBuilder();
|
|
|
|
String line = "";
|
|
|
|
|
|
|
|
//While not at the end of the file
|
|
|
|
while((line = in.readLine()) != null)
|
|
|
|
{
|
|
|
|
//Read the line in and copy it to the output it's not the player
|
|
|
|
//we want to edit
|
|
|
|
if(!line.split(":")[0].equalsIgnoreCase(playerName))
|
|
|
|
{
|
|
|
|
writer.append(line).append("\r\n");
|
|
|
|
|
|
|
|
//Otherwise write the new player information
|
|
|
|
} else {
|
|
|
|
writer.append(playerName + ":");
|
|
|
|
writer.append(tag + ":");
|
|
|
|
writer.append(nickName + ":");
|
|
|
|
writer.append(suffix + ":");
|
|
|
|
writer.append(defaultColor + ":");
|
2010-12-20 08:53:56 +01:00
|
|
|
|
2010-12-12 20:40:39 +01:00
|
|
|
int i = 0;
|
|
|
|
for(String ignore : ignoreList)
|
|
|
|
{
|
|
|
|
writer.append(ignore);
|
|
|
|
if(i < ignoreList.size() - 1)
|
|
|
|
writer.append(",");
|
|
|
|
}
|
|
|
|
writer.append(":");
|
|
|
|
writer.append(aliasList.toString());
|
2010-12-20 08:53:56 +01:00
|
|
|
writer.append(tpx + ":");
|
|
|
|
writer.append(tpy + ":");
|
|
|
|
writer.append(tpz + ":");
|
2010-12-12 20:40:39 +01:00
|
|
|
writer.append("\r\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
|
|
|
|
//Write the new file
|
|
|
|
FileWriter out = new FileWriter(location);
|
|
|
|
out.write(writer.toString());
|
|
|
|
out.close();
|
|
|
|
|
2010-12-02 22:42:59 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
|
|
|
|
}
|
2010-12-02 07:17:42 +01:00
|
|
|
}
|
2010-12-12 20:40:39 +01:00
|
|
|
|
|
|
|
public void addPlayer()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
//Open the file to write the player
|
2010-12-13 02:07:31 +01:00
|
|
|
FileWriter file = new FileWriter(location, true);
|
2010-12-12 20:40:39 +01:00
|
|
|
BufferedWriter out = new BufferedWriter(file);
|
|
|
|
|
|
|
|
//Add the player to the end
|
|
|
|
out.append(playerName + ":");
|
|
|
|
out.append(tag + ":");
|
|
|
|
out.append(nickName + ":");
|
|
|
|
out.append(suffix + ":");
|
|
|
|
out.append(defaultColor + ":");
|
2010-12-20 08:53:56 +01:00
|
|
|
|
2010-12-12 20:40:39 +01:00
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for(String ignore : ignoreList)
|
|
|
|
{
|
|
|
|
out.append(ignore);
|
|
|
|
if(i < ignoreList.size() - 1)
|
|
|
|
out.append(",");
|
|
|
|
}
|
|
|
|
out.append(":");
|
2010-12-20 08:53:56 +01:00
|
|
|
out.append(tpx + ":");
|
|
|
|
out.append(tpy + ":");
|
|
|
|
out.append(tpz + ":");
|
2010-12-12 20:40:39 +01:00
|
|
|
|
|
|
|
out.append(aliasList.toString());
|
2010-12-13 02:07:31 +01:00
|
|
|
out.newLine();
|
2010-12-12 20:40:39 +01:00
|
|
|
out.close();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
|
|
|
|
}
|
|
|
|
}
|
2010-12-02 07:17:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
2010-12-08 05:00:32 +01:00
|
|
|
//Function: isPlayer
|
2010-12-02 07:17:42 +01:00
|
|
|
//Input: None
|
|
|
|
//Output: Player: The player this profile belongs to
|
2010-12-08 05:00:32 +01:00
|
|
|
//Use: Finds if this profile belongs to a specified player
|
2010-12-02 07:17:42 +01:00
|
|
|
//=====================================================================
|
2010-12-08 05:00:32 +01:00
|
|
|
public boolean isPlayer(Player player)
|
|
|
|
{
|
|
|
|
return player.getName().equals(playerName);
|
|
|
|
}
|
2010-12-02 07:17:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: isIgnored
|
|
|
|
//Input: Player player: Checks if a player is ignored
|
|
|
|
//Output: boolean: If they're ignored
|
|
|
|
//Use: Finds if the specified player is in the ignore list
|
|
|
|
//=====================================================================
|
2010-12-08 20:29:13 +01:00
|
|
|
public boolean isIgnored(Player player){
|
2010-12-09 01:30:26 +01:00
|
|
|
return ignoreList.contains(player.getName());
|
|
|
|
}
|
2010-12-02 07:17:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: addIgnore
|
|
|
|
//Input: Player name: The player to ignore
|
2010-12-08 20:29:13 +01:00
|
|
|
//Output: boolean: If the player was successfully ignored
|
2010-12-02 07:17:42 +01:00
|
|
|
//Use: Ignores a player.
|
|
|
|
//=====================================================================
|
2010-12-08 20:29:13 +01:00
|
|
|
public boolean addIgnore(Player name)
|
2010-12-02 07:17:42 +01:00
|
|
|
{
|
|
|
|
if(!ignoreList.contains(name))
|
2010-12-08 20:29:13 +01:00
|
|
|
{
|
|
|
|
ignoreList.add(name.getName());
|
|
|
|
save();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-02 07:17:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: removeIgnore
|
2010-12-08 20:29:13 +01:00
|
|
|
//Input: Player name: The player to unignore
|
|
|
|
//Output: boolean: If the player was successfully unignored
|
|
|
|
//Use: Stops ignoring a player.
|
2010-12-02 07:17:42 +01:00
|
|
|
//=====================================================================
|
2010-12-08 20:29:13 +01:00
|
|
|
public boolean removeIgnore(Player name)
|
2010-12-02 07:17:42 +01:00
|
|
|
{
|
2010-12-08 20:29:13 +01:00
|
|
|
if(ignoreList.contains(name.getName()))
|
|
|
|
{
|
|
|
|
ignoreList.remove(name.getName());
|
|
|
|
save();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-02 07:17:42 +01:00
|
|
|
}
|
|
|
|
|
2010-12-10 02:18:35 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: removeIgnore
|
|
|
|
//Input: Player name: The player to unignore
|
|
|
|
//Output: boolean: If the player was successfully unignored
|
|
|
|
//Use: Stops ignoring a player.
|
|
|
|
//=====================================================================
|
|
|
|
public String[] listIgnore()
|
|
|
|
{
|
|
|
|
return ignoreList.toArray(new String[ignoreList.size()]);
|
|
|
|
}
|
|
|
|
|
2010-12-02 07:17:42 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: addAlias
|
|
|
|
//Input: String command: The command to try to call
|
|
|
|
// String[] args: The arguments for the command
|
|
|
|
//Output: None
|
|
|
|
//Use: Adds a command
|
|
|
|
//=====================================================================
|
|
|
|
public void addAlias(String name, String callCommand)
|
|
|
|
{
|
|
|
|
aliasList.registerAlias(name, callCommand);
|
2010-12-08 20:29:13 +01:00
|
|
|
save();
|
2010-12-02 07:17:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: callAlias
|
|
|
|
//Input: String command: The command to try to call
|
|
|
|
// Player player: Checks if a player is ignored
|
|
|
|
// String[] args: The arguments for the command
|
|
|
|
//Output: int: Exit code
|
|
|
|
//Use: Attempts to call a command
|
|
|
|
//=====================================================================
|
|
|
|
public int callAlias(String command, Player player, String[] args)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//Attemt to call the function
|
|
|
|
return aliasList.call(command, player, args);
|
|
|
|
}
|
|
|
|
catch (Throwable e)
|
|
|
|
{
|
|
|
|
//The function wasn't found, returns fail
|
|
|
|
return EXIT_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: setTag
|
|
|
|
//Input: String newTag: The tag to set for the player
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets a player tag
|
|
|
|
//=====================================================================
|
2010-12-12 20:40:39 +01:00
|
|
|
public void setTag(String newTag)
|
|
|
|
{
|
|
|
|
tag = newTag;
|
|
|
|
save();
|
|
|
|
}
|
2010-12-20 08:53:56 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: setTpback
|
|
|
|
//Input: None
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets a player's tpback xyz coordinates
|
|
|
|
//=====================================================================
|
|
|
|
public void setTpback(double x, double y, double z)
|
|
|
|
{
|
|
|
|
//Coordinates
|
|
|
|
x = tpx;
|
|
|
|
y = tpy;
|
|
|
|
z = tpz;
|
|
|
|
}
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getTpbx
|
|
|
|
//Input: None
|
|
|
|
//Output: Double: The player's tpback x coords
|
|
|
|
//Use: Gets the x value of tpback
|
|
|
|
//=====================================================================
|
|
|
|
public double getTpx() { return tpx; }
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getTpy
|
|
|
|
//Input: None
|
|
|
|
//Output: Double: The player's tpback x coords
|
|
|
|
//Use: Gets the x value of tpback
|
|
|
|
//=====================================================================
|
|
|
|
public double getTpy() { return tpy; }
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getTpz
|
|
|
|
//Input: None
|
|
|
|
//Output: Double: The player's tpback x coords
|
|
|
|
//Use: Gets the x value of tpback
|
|
|
|
//=====================================================================
|
|
|
|
public double getTpz() { return tpz; }
|
2010-12-02 07:17:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getTag
|
|
|
|
//Input: None
|
|
|
|
//Output: String: The player tag
|
|
|
|
//Use: Gets a player tag
|
|
|
|
//=====================================================================
|
|
|
|
public String getTag() { return tag; }
|
2010-12-08 05:00:32 +01:00
|
|
|
|
2010-12-10 03:09:42 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: setNick
|
|
|
|
//Input: String newTag: The nickname to set for the player
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets a player nickname
|
|
|
|
//=====================================================================
|
2010-12-12 20:40:39 +01:00
|
|
|
public void setNick(String newNick)
|
|
|
|
{
|
|
|
|
nickName = newNick;
|
|
|
|
save();
|
|
|
|
}
|
2010-12-10 03:09:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getNick
|
|
|
|
//Input: None
|
|
|
|
//Output: String: The player nickname
|
|
|
|
//Use: Gets a player nickname
|
|
|
|
//=====================================================================
|
|
|
|
public String getNick() { return nickName; }
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: setSuffix
|
|
|
|
//Input: String newTag: The suffix to set for the player
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets a player suffix
|
|
|
|
//=====================================================================
|
2010-12-12 20:40:39 +01:00
|
|
|
public void setSuffix(String newSuffix)
|
|
|
|
{
|
|
|
|
suffix = newSuffix;
|
|
|
|
save();
|
|
|
|
}
|
2010-12-10 03:09:42 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getSuffix
|
|
|
|
//Input: None
|
|
|
|
//Output: String: The player suffix
|
|
|
|
//Use: Gets a player suffix
|
|
|
|
//=====================================================================
|
|
|
|
public String getSuffix() { return suffix; }
|
|
|
|
|
2010-12-10 10:15:39 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: setColor
|
|
|
|
//Input: String newTag: The color to set for the player
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets a player color
|
|
|
|
//=====================================================================
|
2010-12-12 20:40:39 +01:00
|
|
|
public void setColor(String newColor)
|
|
|
|
{
|
|
|
|
defaultColor = newColor.charAt(0);
|
|
|
|
save();
|
|
|
|
}
|
2010-12-10 10:15:39 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getColor
|
|
|
|
//Input: None
|
|
|
|
//Output: String: The player color
|
|
|
|
//Use: Gets a player color
|
|
|
|
//=====================================================================
|
2010-12-12 20:40:39 +01:00
|
|
|
public String getColor() {return vMinecraftChat.colorChange(defaultColor);}
|
2010-12-10 10:15:39 +01:00
|
|
|
|
2010-12-08 05:00:32 +01:00
|
|
|
//=====================================================================
|
|
|
|
//Function: setMessage
|
|
|
|
//Input: String newName: The name of the player they last messaged
|
|
|
|
// or recieved a message from.
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets a player tag
|
|
|
|
//=====================================================================
|
|
|
|
public void setMessage(Player newName){ lastMessage = newName.getName(); }
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: getMessage
|
|
|
|
//Input: None
|
|
|
|
//Output: String: The player name
|
|
|
|
//Use: Gets the name of the player they last messaged or recieved
|
|
|
|
// a message from.
|
|
|
|
//=====================================================================
|
|
|
|
public Player getMessage()
|
|
|
|
{
|
2010-12-08 10:47:42 +01:00
|
|
|
if(lastMessage != null)
|
|
|
|
return etc.getServer().matchPlayer(lastMessage);
|
|
|
|
return null;
|
2010-12-08 05:00:32 +01:00
|
|
|
}
|
2010-12-14 01:15:04 +01:00
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: isDead
|
|
|
|
//Input: None
|
|
|
|
//Output: boolean: If the player is dead or not
|
|
|
|
//Use: Gets the player is dead or not.
|
|
|
|
//=====================================================================
|
|
|
|
public boolean isDead() {return dead;}
|
|
|
|
|
|
|
|
//=====================================================================
|
|
|
|
//Function: isDead
|
|
|
|
//Input: boolean isded: if the player is dead or not.
|
|
|
|
//Output: None
|
|
|
|
//Use: Sets if the player is dead or not
|
|
|
|
//=====================================================================
|
|
|
|
public void isDead(boolean isded){dead = isded;}
|
2010-12-02 07:17:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-02 23:13:23 +01:00
|
|
|
|