Fix not being able to set world scaling. (Thanks krinsdeath) Add pitch to mvcoord, add missing variables to mvinfo

This commit is contained in:
Eric Stokes 2011-08-11 18:20:35 -06:00
parent 11ce604938
commit 06bc0dea02
5 changed files with 37 additions and 29 deletions

5
.gitignore vendored
View File

@ -30,4 +30,7 @@
*.iml
*.ipr
*.iws
.idea/
.idea/
# Fern's utils
uploadtoserver.sh

View File

@ -375,19 +375,6 @@ public class MVWorld {
saveConfig();
}
private boolean setVariable(String name, double value) {
if (name.equalsIgnoreCase("scaling") || name.equalsIgnoreCase("scale")) {
this.setScaling(value);
return true;
}
if (name.equalsIgnoreCase("price")) {
this.setPrice(value);
return true;
}
return false;
}
/**
* This is the one people have access to. It'll handle the rest.
*
@ -423,18 +410,19 @@ public class MVWorld {
} catch (Exception e) {
}
}
if (name.equalsIgnoreCase("scale") || name.equalsIgnoreCase("scaling")) {
try {
double doubValue = Double.parseDouble(value);
return this.setScaling(doubValue);
} catch (Exception e) {
}
}
try {
boolean boolValue = Boolean.parseBoolean(value);
return this.setVariable(name, boolValue);
} catch (Exception e) {
}
try {
double doubValue = Double.parseDouble(value);
return this.setVariable(name, doubValue);
} catch (Exception e) {
}
return false;
}
@ -535,7 +523,7 @@ public class MVWorld {
return this.scaling;
}
public void setScaling(Double scaling) {
public boolean setScaling(Double scaling) {
if (scaling <= 0) {
// Disallow negative or 0 scalings.
scaling = 1.0;
@ -543,6 +531,7 @@ public class MVWorld {
this.scaling = scaling;
this.config.setProperty("worlds." + this.name + ".scaling", scaling);
saveConfig();
return true;
}
/**
@ -642,4 +631,8 @@ public class MVWorld {
public boolean getWeatherEnabled() {
return this.allowWeather;
}
public boolean getKeepSpawnInMemory() {
return this.keepSpawnInMemory;
}
}

View File

@ -1,5 +1,6 @@
package com.onarandombox.MultiverseCore.commands;
import java.text.DecimalFormat;
import java.util.List;
import org.bukkit.ChatColor;
@ -34,20 +35,23 @@ public class CoordCommand extends MultiverseCommand {
if (sender instanceof Player) {
Player p = (Player) sender;
World world = p.getWorld();
if(!this.plugin.isMVWorld(world.getName())) {
if (!this.plugin.isMVWorld(world.getName())) {
this.plugin.showNotMVWorldMessage(sender, world.getName());
return;
}
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
// TODO: Convert to fancy stuff
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
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());
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()));
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()));
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
} else {

View File

@ -112,6 +112,9 @@ public class InfoCommand extends MultiverseCommand {
worldInfo.add(message);
// Page 2
message = new ArrayList<FancyText>();
message.add(new FancyHeader("More World Settings", colors));
message.add(new FancyMessage("Weather: ", world.getWeatherEnabled() + "", colors));
message.add(new FancyMessage("Keep spawn in memory: ", world.getKeepSpawnInMemory() + "", colors));
message.add(new FancyHeader("PVP Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.getPvp().toString(), colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));

View File

@ -1,8 +1,10 @@
package com.onarandombox.utils;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Vehicle;
@ -67,9 +69,12 @@ public class LocationManipulation {
*/
public String strCoords(Location l) {
String result = "";
result += "X: " + l.getBlockX() + " ";
result += "Y: " + l.getBlockY() + " ";
result += "Z: " + l.getBlockZ() + " ";
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
result += ChatColor.WHITE + "X: " + ChatColor.AQUA + df.format(l.getX()) + " ";
result += ChatColor.WHITE + "Y: " + ChatColor.AQUA + df.format(l.getY()) + " ";
result += ChatColor.WHITE + "Z: " + ChatColor.AQUA + df.format(l.getZ()) + " ";
return result;
}