Added /tpback, not exactly working correctly yet.

This commit is contained in:
nossr50 2010-12-19 23:53:56 -08:00
parent 30d4498039
commit 99a5f13b5e
2 changed files with 87 additions and 2 deletions

View File

@ -58,6 +58,7 @@ public class vMinecraftCommands{
cl.register("/freeze", "freeze"); cl.register("/freeze", "freeze");
cl.register("/tp", "teleport"); cl.register("/tp", "teleport");
cl.register("/tphere", "tphere"); cl.register("/tphere", "tphere");
cl.register("/tpback", "tpback");
cl.register("/masstp", "masstp", "Teleports those with lower permissions to you"); cl.register("/masstp", "masstp", "Teleports those with lower permissions to you");
//Health //Health
@ -177,6 +178,17 @@ public class vMinecraftCommands{
.globalmessages()); .globalmessages());
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
public static int tpback(Player player, String[] args){
if(player.canUseCommand("/tpback")){
double x = vMinecraftUsers.getProfile(player).getTpx();
double y = vMinecraftUsers.getProfile(player).getTpy();
double z = vMinecraftUsers.getProfile(player).getTpz();
player.teleportTo(x, y, z, 0, 0);
return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
}
//===================================================================== //=====================================================================
//Function: prefix (/prefix) //Function: prefix (/prefix)
//Input: Player player: The player using the command //Input: Player player: The player using the command
@ -1013,6 +1025,14 @@ public class vMinecraftCommands{
//If the player exists transport the user to the player //If the player exists transport the user to the player
else { else {
//Storing their previous location for tpback
double x = player.getLocation().x;
double y = player.getLocation().y;
double z = player.getLocation().z;
vMinecraftUsers.getProfile(player).setTpback(x, y, z);
if(player.canUseCommand("/tpback")){
player.sendMessage(Colors.DarkPurple + "Your previous location has been stored, use /tpback to return.");
}
vMinecraftChat.gmsg( player, vMinecraftChat.getName(player) vMinecraftChat.gmsg( player, vMinecraftChat.getName(player)
+ Colors.LightBlue + " has teleported to " + Colors.LightBlue + " has teleported to "
+ vMinecraftChat.getName(playerTarget)); + vMinecraftChat.getName(playerTarget));
@ -1094,6 +1114,14 @@ public class vMinecraftCommands{
log.log(Level.INFO, player.getName() + " teleported " log.log(Level.INFO, player.getName() + " teleported "
+ player.getName() + " to their self."); + player.getName() + " to their self.");
playerTarget.teleportTo(player); playerTarget.teleportTo(player);
double x = player.getLocation().x;
double y = player.getLocation().y;
double z = player.getLocation().z;
vMinecraftUsers.getProfile(playerTarget).setTpback(x, y, z);
if(playerTarget.canUseCommand("/tpback"))
{
playerTarget.sendMessage(Colors.DarkPurple + "Your previous location has been stored, use /tpback to return.");
}
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -153,6 +153,9 @@ class PlayerList
nickName, nickName,
tag, tag,
suffix; suffix;
private double tpx,
tpy,
tpz;
private boolean dead; private boolean dead;
@ -242,6 +245,20 @@ class PlayerList
} }
} }
} }
//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();
}
in.close(); in.close();
return true; return true;
} }
@ -285,7 +302,7 @@ class PlayerList
writer.append(nickName + ":"); writer.append(nickName + ":");
writer.append(suffix + ":"); writer.append(suffix + ":");
writer.append(defaultColor + ":"); writer.append(defaultColor + ":");
int i = 0; int i = 0;
for(String ignore : ignoreList) for(String ignore : ignoreList)
{ {
@ -294,8 +311,10 @@ class PlayerList
writer.append(","); writer.append(",");
} }
writer.append(":"); writer.append(":");
writer.append(aliasList.toString()); writer.append(aliasList.toString());
writer.append(tpx + ":");
writer.append(tpy + ":");
writer.append(tpz + ":");
writer.append("\r\n"); writer.append("\r\n");
} }
} }
@ -325,6 +344,7 @@ class PlayerList
out.append(nickName + ":"); out.append(nickName + ":");
out.append(suffix + ":"); out.append(suffix + ":");
out.append(defaultColor + ":"); out.append(defaultColor + ":");
int i = 0; int i = 0;
for(String ignore : ignoreList) for(String ignore : ignoreList)
@ -334,6 +354,9 @@ class PlayerList
out.append(","); out.append(",");
} }
out.append(":"); out.append(":");
out.append(tpx + ":");
out.append(tpy + ":");
out.append(tpz + ":");
out.append(aliasList.toString()); out.append(aliasList.toString());
out.newLine(); out.newLine();
@ -456,6 +479,40 @@ class PlayerList
tag = newTag; tag = newTag;
save(); save();
} }
//=====================================================================
//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; }
//===================================================================== //=====================================================================
//Function: getTag //Function: getTag