Cleaned up MVINFO Closes #47

This commit is contained in:
Eric Stokes 2011-07-31 08:45:10 -06:00
parent de9209b270
commit 9acc46f9d1
5 changed files with 43 additions and 18 deletions

View File

@ -4,10 +4,12 @@ import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.LocationManipulation; import com.onarandombox.utils.LocationManipulation;
@ -22,6 +24,7 @@ public class CoordCommand extends MultiverseCommand {
this.setArgRange(0, 0); this.setArgRange(0, 0);
this.addKey("mv coord"); this.addKey("mv coord");
this.addKey("mvcoord"); this.addKey("mvcoord");
this.addKey("mvco");
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP); this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
} }
@ -30,15 +33,21 @@ public class CoordCommand extends MultiverseCommand {
// Check if the command was sent from a Player. // Check if the command was sent from a Player.
if (sender instanceof Player) { if (sender instanceof Player) {
Player p = (Player) sender; Player p = (Player) sender;
if(!this.plugin.isMVWorld(p.getWorld().getName())) { World world = p.getWorld();
this.plugin.showNotMVWorldMessage(sender, p.getWorld().getName());
if(!this.plugin.isMVWorld(world.getName())) {
this.plugin.showNotMVWorldMessage(sender, world.getName());
return; return;
} }
p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName());
p.sendMessage(ChatColor.RED + "World Scale: " + ChatColor.WHITE + this.plugin.getMVWorld(p.getWorld().getName()).getScaling()); MVWorld mvworld = this.plugin.getMVWorld(world.getName());
p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation())); p.sendMessage(ChatColor.AQUA + "--- World Information ---");
p.sendMessage(ChatColor.RED + "Direction: " + ChatColor.WHITE + this.locMan.getDirection(p.getLocation())); p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
p.sendMessage(ChatColor.RED + "Block: " + ChatColor.WHITE + Material.getMaterial(p.getWorld().getBlockTypeIdAt(p.getLocation()))); p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + this.locMan.getDirection(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
} else { } else {
sender.sendMessage("This command needs to be used from a Player."); sender.sendMessage("This command needs to be used from a Player.");
} }

View File

@ -40,7 +40,18 @@ public class InfoCommand extends MultiverseCommand {
for (String s : buildEntireCommand(this.plugin.getMVWorld(worldName))) { for (String s : buildEntireCommand(this.plugin.getMVWorld(worldName))) {
sender.sendMessage(s); sender.sendMessage(s);
} }
} else if (this.plugin.getServer().getWorld(worldName) != null) {
sender.sendMessage("That world exists, but multiverse does not know about it!");
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
} }
// Leaving this in so we can have a laugh about it.
// else {
// sender.sendMessage("That world does not exist!");
// sender.sendMessage("You can create it with" + ChatColor.AQUA + "/mv create " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
// sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
// }
} }
private List<String> buildEntireCommand(MVWorld world) { private List<String> buildEntireCommand(MVWorld world) {

View File

@ -63,9 +63,9 @@ public class ModifySetCommand extends MultiverseCommand {
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) { if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
sender.sendMessage(value + " is not a valid color. Please see our Github Wiki for the complete color list."); sender.sendMessage(value + " is not a valid color. Please see our Github Wiki for the complete color list.");
} else if (world.setVariable(property, value)) { } else if (world.setVariable(property, value)) {
sender.sendMessage("Property " + property + " was set to " + value); sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + "Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
} else { } else {
sender.sendMessage("There was an error setting " + property); sender.sendMessage(ChatColor.RED + "There was an error setting " + ChatColor.GRAY + property);
} }
} }
} }

View File

@ -80,23 +80,24 @@ public class LocationManipulation {
* @return * @return
*/ */
public String getDirection(Location location) { public String getDirection(Location location) {
int r = (int) Math.abs((location.getYaw() - 90) % 360); double r = (location.getYaw() % 360) + 180;
// Remember, these numbers are every 45 degrees with a 22.5 offset, to detect boundaries.
String dir; String dir;
if (r < 23) if (r < 22.5)
dir = "N"; dir = "N";
else if (r < 68) else if (r < 67.5)
dir = "NE"; dir = "NE";
else if (r < 113) else if (r < 112.5)
dir = "E"; dir = "E";
else if (r < 158) else if (r < 157.5)
dir = "SE"; dir = "SE";
else if (r < 203) else if (r < 202.5)
dir = "S"; dir = "S";
else if (r < 248) else if (r < 247.5)
dir = "SW"; dir = "SW";
else if (r < 293) else if (r < 292.5)
dir = "W"; dir = "W";
else if (r < 338) else if (r < 337.5)
dir = "NW"; dir = "NW";
else else
dir = "N"; dir = "N";

View File

@ -160,6 +160,10 @@ commands:
usage: | usage: |
/<command> /<command>
mvversion: mvversion:
description: Prints out version invo.
usage: |
/<command>
mvco:
description: Prints out version invo. description: Prints out version invo.
usage: | usage: |
/<command> /<command>