本文整理汇总了Java中org.bukkit.DyeColor.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java DyeColor.valueOf方法的具体用法?Java DyeColor.valueOf怎么用?Java DyeColor.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.DyeColor
的用法示例。
在下文中一共展示了DyeColor.valueOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseDye
import org.bukkit.DyeColor; //导入方法依赖的package包/类
public static DyeColor parseDye(String s) {
if (s == null) return DyeColor.BLACK;
try {
return DyeColor.valueOf(s.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
throw new InvalidConfigException("Cannot find dye color: \"" + s + "\"");
}
}
示例2: parseDyeColor
import org.bukkit.DyeColor; //导入方法依赖的package包/类
public static DyeColor parseDyeColor(Attribute attr) throws InvalidXMLException {
String name = attr.getValue().replace(" ", "_").toUpperCase();
try {
return DyeColor.valueOf(name);
}
catch(IllegalArgumentException e) {
throw new InvalidXMLException("Invalid dye color '" + attr.getValue() + "'", attr);
}
}
示例3: execute
import org.bukkit.DyeColor; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length < 2) {
Chat.player(sender, "&2[Pets] &cUsage: /pet color [pet name] [color]");
return true;
}
Player p = (Player) sender;
String username = p.getName();
for (PetInstance pet : PetInstance.getList()) {
if (pet.getName().equalsIgnoreCase(args[0])) {
if (pet.getOwner().equalsIgnoreCase(username)) {
if (pet.getType() != EntityType.SHEEP) {
Chat.player(p, "&2[Pets] &cYou can only change the color of sheep.");
return true;
}
String[] nameArray = Arrays.copyOfRange(args, 1, args.length);
String c = Joiner.on("_").join(nameArray);
DyeColor color = null;
try {
color = DyeColor.valueOf(c.toUpperCase());
}
catch (IllegalArgumentException e) {
Chat.player(p, "&2[Pets] &cUnknown color: " + c + "!");
Chat.player(p, "&cColors: &7&o" + Joiner.on(", ").join(DyeColor.values()).toLowerCase().replace("_", " "));
return true;
}
Chat.player(p, "&2[Pets] &aYou have changed the color of &e" + pet.getName() + "&a to " + c.replace("_", " "));
pet.setColor(color);
return true;
}
}
}
Chat.player(p, "&2[Pets] &cYou do not own a pet by the name of &e" + args[0] + "\n &7&oBuy customized pets at www.mczone.co/shop");
return true;
}