本文整理匯總了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;
}