|
|
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player; |
|
|
|
|
|
|
|
|
|
|
|
public class teleportWorld implements CommandExecutor { |
|
|
|
public class teleportWorld implements CommandExecutor { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Teleports player with OP to another world.
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { |
|
|
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { |
|
|
|
if (commandSender instanceof Player) { |
|
|
|
if (commandSender instanceof Player) { |
|
|
|
@ -20,28 +21,40 @@ public class teleportWorld implements CommandExecutor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
World world = Bukkit.getWorld(strings[0]); |
|
|
|
World world = Bukkit.getWorld(strings[0]); |
|
|
|
World playerWorld = player.getWorld(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playerWorld.equals(world)) { |
|
|
|
if (world == null) { |
|
|
|
player.sendMessage("You are already in this world!"); // Edit
|
|
|
|
player.sendMessage("This is not a valid world!"); |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (strings.length > 2) { |
|
|
|
if (strings.length > 1) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Player targetPlayer = Bukkit.getPlayer(strings[1]); |
|
|
|
Player targetPlayer = Bukkit.getPlayer(strings[1]); |
|
|
|
|
|
|
|
World targetPlayerWorld = targetPlayer.getWorld(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (targetPlayerWorld.equals(world)) { |
|
|
|
|
|
|
|
player.sendMessage(String.format("Player %s is already in this world!", strings[1])); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
targetPlayer.teleport(world.getSpawnLocation()); |
|
|
|
targetPlayer.teleport(world.getSpawnLocation()); |
|
|
|
targetPlayer.sendMessage(String.format("Successfully teleported %s from %s to %s.", targetPlayer, playerWorld, world)); // Edit
|
|
|
|
targetPlayer.sendMessage(String.format("Successfully teleported %s from %s to %s.", strings[1], targetPlayerWorld.getName(), world.getName())); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
player.sendMessage("This is not a valid player!"); |
|
|
|
player.sendMessage("This is not a valid player!"); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
World playerWorld = player.getWorld(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playerWorld.equals(world)) { |
|
|
|
|
|
|
|
player.sendMessage("You are already in this world!"); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
player.teleport(world.getSpawnLocation()); |
|
|
|
player.teleport(world.getSpawnLocation()); |
|
|
|
player.sendMessage(String.format("Successfully teleported from %s to %s.", playerWorld, world)); // Edit
|
|
|
|
player.sendMessage(String.format("Successfully teleported from %s to %s.", playerWorld.getName(), world.getName())); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|