Multi-World travel now possible, not perfected at all

This commit is contained in:
Eric Stokes 2011-06-02 10:41:24 -04:00
parent 599bbcd16c
commit 5c144f31c2
3 changed files with 15 additions and 8 deletions

View File

@ -32,7 +32,7 @@ public class ListCommand extends BaseCommand {
} }
} }
String output = ChatColor.GREEN + "Worlds which you can view - \n"; String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
for (int i = 0; i < plugin.getServer().getWorlds().size(); i++) { for (int i = 0; i < plugin.getServer().getWorlds().size(); i++) {
World world = plugin.getServer().getWorlds().get(i); World world = plugin.getServer().getWorlds().get(i);
@ -54,7 +54,7 @@ public class ListCommand extends BaseCommand {
color = ChatColor.GREEN; color = ChatColor.GREEN;
} }
output += color + world.getName() + " - " + world.getEnvironment().toString() + " \n"; output += ChatColor.GOLD + world.getName() + ChatColor.WHITE + " - " + color + world.getEnvironment().toString() + " \n";
} }
String[] response = output.split("\n"); String[] response = output.split("\n");

View File

@ -1,24 +1,31 @@
package com.onarandombox.MultiverseCore.command.commands; package com.onarandombox.MultiverseCore.command.commands;
import java.util.logging.Logger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.onarandombox.MultiverseCore.MVTeleport;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
import com.onarandombox.utils.Destination; import com.onarandombox.utils.Destination;
import com.onarandombox.utils.DestinationType; import com.onarandombox.utils.DestinationType;
public class TeleportCommand extends BaseCommand { public class TeleportCommand extends BaseCommand {
private final Logger log = Logger.getLogger("Minecraft");
private MVTeleport playerTeleporter;
public TeleportCommand(MultiverseCore plugin) { public TeleportCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
name = "Teleport"; name = "Teleport";
description = "Teleports you to a different world."; description = "Teleports you to a different world.";
usage = "/mvcoord" + ChatColor.RED + "{WORLD}"; usage = "/mvtp" + ChatColor.GREEN + " {WORLD}";
minArgs = 1; minArgs = 1;
maxArgs = 1; maxArgs = 1;
identifiers.add("mvtp"); identifiers.add("mvtp");
playerTeleporter = new MVTeleport(plugin);
} }
@Override @Override
@ -31,12 +38,13 @@ public class TeleportCommand extends BaseCommand {
p.sendMessage("You do not have access to this command."); p.sendMessage("You do not have access to this command.");
return; return;
} }
Destination d = Destination.parseDestination(args[1]); Destination d = Destination.parseDestination(args[0]);
// TODO: I'd like to find a way to do these next bits inside Destination, so we're always valid --FF // TODO: I'd like to find a way to do these next bits inside Destination, so we're always valid --FF
// TODO: Support portals, but I didn't see the portals list --FF // TODO: Support portals, but I didn't see the portals list --FF
if (this.plugin.worlds.containsKey(d.getName().toLowerCase())) { if (this.plugin.worlds.containsKey(d.getName().toLowerCase())) {
if(d.getType() == DestinationType.World) { if (d.getType() == DestinationType.World) {
Location l = playerTeleporter.getSafeDestination(plugin.getServer().getWorld(d.getName()).getSpawnLocation());
p.teleport(l);
} }
} else { } else {
p.sendMessage("That was not a valid world (portals aren't yet supported)"); p.sendMessage("That was not a valid world (portals aren't yet supported)");

View File

@ -1,7 +1,6 @@
package com.onarandombox.utils; package com.onarandombox.utils;
public class Destination { public class Destination {
private String name; private String name;
private DestinationType type; private DestinationType type;
@ -34,7 +33,7 @@ public class Destination {
// If we only found one param, assume world // If we only found one param, assume world
// TODO: Check for a valid world // TODO: Check for a valid world
if (items.length == 0) { if (items.length == 1) {
return new Destination(items[0], DestinationType.World); return new Destination(items[0], DestinationType.World);
} }