Fix color checking, fix price reporting failure on successful set

This commit is contained in:
fernferret 2011-10-11 17:01:56 -04:00
parent c200d43f51
commit 750adcf376
3 changed files with 16 additions and 6 deletions

View File

@ -8,7 +8,7 @@
package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.EnglishChatColor;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.configuration.ConfigurationSection;
@ -347,8 +347,7 @@ public class MVWorld implements MultiverseWorld {
return true;
}
if (name.equalsIgnoreCase("aliascolor") || name.equalsIgnoreCase("color")) {
this.setColor(value);
return true;
return this.setColor(value);
}
if (name.equalsIgnoreCase("currency") || name.equalsIgnoreCase("curr")) {
try {
@ -361,6 +360,7 @@ public class MVWorld implements MultiverseWorld {
if (name.equalsIgnoreCase("price")) {
try {
this.setPrice(Double.parseDouble(value));
return true;
} catch (Exception e) {
return false;
}
@ -533,6 +533,7 @@ public class MVWorld implements MultiverseWorld {
if (scaling <= 0) {
// Disallow negative or 0 scalings.
scaling = 1.0;
this.plugin.log(Level.WARNING, "Someone tried to set a scale <= 0, defaulting to 1.");
success = false;
}
this.scaling = scaling;
@ -554,7 +555,6 @@ public class MVWorld implements MultiverseWorld {
}
public boolean isValidAliasColor(String aliasColor) {
System.out.print("Checking color... " + aliasColor);
return (EnglishChatColor.fromString(aliasColor) != null);
}

View File

@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -97,7 +98,8 @@ public class ModifySetCommand extends MultiverseCommand {
return;
}
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 pick one of the following:");
sender.sendMessage(EnglishChatColor.getAllColors());
} else if (world.setVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
} else {

View File

@ -5,7 +5,7 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
package com.onarandombox.MultiverseCore.enums;
import org.bukkit.ChatColor;
@ -47,6 +47,14 @@ public enum EnglishChatColor {
return this.color;
}
public static String getAllColors() {
String buffer = "";
for (EnglishChatColor c : EnglishChatColor.values()) {
buffer += c.getColor() + c.getText() + " ";
}
return buffer;
}
public static EnglishChatColor fromString(String text) {
if (text != null) {
for (EnglishChatColor c : EnglishChatColor.values()) {