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
commitf48ed6988d27e053d0f94b2887c8199d87c3e086 (patch)
tree85f51af896ff70149e13e97e0e48fa112390f488 /EssentialsSpawn
parentb8300cc35a044a46fef73d123d4c9aac61fb57f2 (diff)
downloadEssentials-f48ed6988d27e053d0f94b2887c8199d87c3e086.tar
Essentials-f48ed6988d27e053d0f94b2887c8199d87c3e086.tar.gz
Essentials-f48ed6988d27e053d0f94b2887c8199d87c3e086.tar.lz
Essentials-f48ed6988d27e053d0f94b2887c8199d87c3e086.tar.xz
Essentials-f48ed6988d27e053d0f94b2887c8199d87c3e086.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);
+ }
}
}