2011-07-15 22:22:22 +02:00
|
|
|
package com.onarandombox.MultiverseCore.commands;
|
2011-05-02 04:51:02 +02:00
|
|
|
|
2011-08-12 02:20:35 +02:00
|
|
|
import java.text.DecimalFormat;
|
2011-07-10 02:13:56 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2011-05-02 04:51:02 +02:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Material;
|
2011-07-31 16:45:10 +02:00
|
|
|
import org.bukkit.World;
|
2011-05-02 04:51:02 +02:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2011-07-17 21:06:21 +02:00
|
|
|
import org.bukkit.permissions.PermissionDefault;
|
2011-05-02 04:51:02 +02:00
|
|
|
|
2011-07-31 16:45:10 +02:00
|
|
|
import com.onarandombox.MultiverseCore.MVWorld;
|
2011-05-02 04:51:02 +02:00
|
|
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
|
|
|
import com.onarandombox.utils.LocationManipulation;
|
|
|
|
|
2011-07-17 17:12:12 +02:00
|
|
|
public class CoordCommand extends MultiverseCommand {
|
2011-05-02 04:51:02 +02:00
|
|
|
|
|
|
|
private LocationManipulation locMan = new LocationManipulation();
|
|
|
|
|
|
|
|
public CoordCommand(MultiverseCore plugin) {
|
|
|
|
super(plugin);
|
2011-07-17 21:06:21 +02:00
|
|
|
this.setName("Coordinates");
|
2011-07-30 08:53:55 +02:00
|
|
|
this.setCommandUsage("/mv coord");
|
2011-07-17 21:06:21 +02:00
|
|
|
this.setArgRange(0, 0);
|
|
|
|
this.addKey("mv coord");
|
|
|
|
this.addKey("mvcoord");
|
2011-07-31 16:45:10 +02:00
|
|
|
this.addKey("mvco");
|
2011-07-18 01:13:33 +02:00
|
|
|
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
|
2011-05-02 04:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-07-10 02:13:56 +02:00
|
|
|
public void runCommand(CommandSender sender, List<String> args) {
|
2011-05-02 04:51:02 +02:00
|
|
|
// Check if the command was sent from a Player.
|
|
|
|
if (sender instanceof Player) {
|
2011-07-09 16:33:18 +02:00
|
|
|
Player p = (Player) sender;
|
2011-07-31 16:45:10 +02:00
|
|
|
World world = p.getWorld();
|
2011-08-12 02:20:35 +02:00
|
|
|
|
|
|
|
if (!this.plugin.isMVWorld(world.getName())) {
|
2011-07-31 16:45:10 +02:00
|
|
|
this.plugin.showNotMVWorldMessage(sender, world.getName());
|
2011-07-18 03:15:33 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-08-12 02:20:35 +02:00
|
|
|
|
2011-07-31 16:45:10 +02:00
|
|
|
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
|
2011-08-01 01:11:59 +02:00
|
|
|
// TODO: Convert to fancy stuff
|
2011-08-12 02:20:35 +02:00
|
|
|
|
2011-08-01 01:11:59 +02:00
|
|
|
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
|
2011-07-31 16:45:10 +02:00
|
|
|
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
|
|
|
|
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
|
|
|
|
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
|
2011-08-12 02:20:35 +02:00
|
|
|
DecimalFormat df = new DecimalFormat();
|
|
|
|
df.setMinimumFractionDigits(0);
|
|
|
|
df.setMaximumFractionDigits(2);
|
|
|
|
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()) + ChatColor.GOLD + "Pitch: " + df.format(p.getLocation().getPitch()));
|
2011-08-09 06:02:56 +02:00
|
|
|
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
|
2011-07-31 16:45:10 +02:00
|
|
|
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
|
2011-05-02 04:51:02 +02:00
|
|
|
} else {
|
|
|
|
sender.sendMessage("This command needs to be used from a Player.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|