summaryrefslogtreecommitdiffstats
path: root/EssentialsSpawn
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-06-08 19:34:14 +0100
committerKHobbits <rob@khobbits.co.uk>2013-06-08 19:34:14 +0100
commit244592a9e2cb197009789096c80ca9160afe3d25 (patch)
treefa8e00ce414206afcb944a8570bcd6fd2b7fd95d /EssentialsSpawn
parente4e9b67dcd904969245aeba1557576617cc0334f (diff)
downloadEssentials-244592a9e2cb197009789096c80ca9160afe3d25.tar
Essentials-244592a9e2cb197009789096c80ca9160afe3d25.tar.gz
Essentials-244592a9e2cb197009789096c80ca9160afe3d25.tar.lz
Essentials-244592a9e2cb197009789096c80ca9160afe3d25.tar.xz
Essentials-244592a9e2cb197009789096c80ca9160afe3d25.zip
Essentials API cleanup and teleport possession fixing. (UNSTABLE)
Diffstat (limited to 'EssentialsSpawn')
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java
index b59f0a0fe..35edd172c 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java
@@ -22,13 +22,13 @@ public class Commandspawn extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
- {
+ {
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
if (args.length > 0 && user.isAuthorized("essentials.spawn.others"))
{
final User otherUser = getPlayer(server, user, args, 0);
- respawn(otherUser, charge);
+ respawn(user, otherUser, charge);
if (!otherUser.equals(user))
{
otherUser.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn"));
@@ -36,8 +36,8 @@ public class Commandspawn extends EssentialsCommand
}
}
else
- {
- respawn(user, charge);
+ {
+ respawn(user, user, charge);
}
throw new NoChargeException();
}
@@ -50,14 +50,22 @@ public class Commandspawn extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true, false);
- respawn(user, null);
+ respawn(null, user, null);
user.sendMessage(_("teleportAtoB", Console.NAME, "spawn"));
sender.sendMessage(_("teleporting"));
}
-
- private void respawn (final User user, final Trade charge) throws Exception {
+
+ private void respawn(final User teleportOwner, final User teleportee, final Trade charge) throws Exception
+ {
final SpawnStorage spawns = (SpawnStorage)this.module;
- final Location spawn = spawns.getSpawn(user.getGroup());
- user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND);
+ final Location spawn = spawns.getSpawn(teleportee.getGroup());
+ if (teleportOwner == null)
+ {
+ teleportee.getTeleport().now(spawn, false, TeleportCause.COMMAND);
+ }
+ else
+ {
+ teleportOwner.getTeleport().teleportPlayer(teleportee, spawn, charge, TeleportCause.COMMAND);
+ }
}
}