本文整理汇总了Java中org.bukkit.ChatColor.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java ChatColor.valueOf方法的具体用法?Java ChatColor.valueOf怎么用?Java ChatColor.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.ChatColor
的用法示例。
在下文中一共展示了ChatColor.valueOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialize
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
public MapInfo deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
JsonObject json = jsonElement.getAsJsonObject();
String name = json.get("name").getAsString();
String version = json.get("version").getAsString();
List<String> authors = new ArrayList<>();
for (JsonElement authorJson : json.getAsJsonArray("authors")) {
authors.add(authorJson.getAsString());
}
GameType gameType = GameType.valueOf(json.get("gametype").getAsString());
List<ParsedTeam> parsedTeams = new ArrayList<>();
for (JsonElement teamElement : json.getAsJsonArray("teams")) {
JsonObject teamJson = teamElement.getAsJsonObject();
String teamId = teamJson.get("id").getAsString();
String teamName = teamJson.get("name").getAsString();
ChatColor teamColor = ChatColor.valueOf(teamJson.get("color").getAsString().toUpperCase().replace(" ", "_"));
int teamMax = teamJson.get("max").getAsInt();
int teamMin = teamJson.get("min").getAsInt();
parsedTeams.add(new ParsedTeam(teamId, teamName, teamColor, teamMax, teamMin));
}
return new MapInfo(name, version, authors, gameType, parsedTeams, json);
}
示例2: addSign
import org.bukkit.ChatColor; //导入方法依赖的package包/类
private void addSign(Player player, String[] args)
{
if (args.length < 5)
{
player.sendMessage(ChatColor.RED + "Usage: /sign add <game code name> <map> <color [default GREEN]> <template>");
return;
}
if (this.hub.getPlayerManager().getSelection(player) == null)
{
player.sendMessage(ChatColor.RED + "Vous devez sélectionner une zone pour l'ajouter.");
return;
}
Location selection = this.hub.getPlayerManager().getSelection(player);
String game = args[1];
String map = args[2];
ChatColor color = ChatColor.valueOf(args[3].toUpperCase());
String template = args[4];
if (!(selection.getBlock().getState() instanceof Sign))
{
player.sendMessage(ChatColor.RED + "Le bloc sélectionné n'est pas un panneau !");
return;
}
Sign sign = (Sign) selection.getBlock().getState();
this.hub.getSignManager().setSignForMap(game, map, color, template, sign);
}
示例3: chatColor
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public ChatColor chatColor(String color) {
return ChatColor.valueOf(color.toUpperCase().replace(" ", "_"));
}
示例4: reloadList
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public void reloadList()
{
this.log(Level.INFO, "Reloading game sign list...");
this.hub.getGameManager().getGames().values().forEach(net.samagames.hub.games.AbstractGame::clearSigns);
JsonArray signZonesArray = this.jsonConfig.load().getAsJsonArray("zones");
for (int i = 0; i < signZonesArray.size(); i++)
{
JsonObject signZoneObject = signZonesArray.get(i).getAsJsonObject();
String game = signZoneObject.get("game").getAsString();
JsonArray maps = signZoneObject.get("maps").getAsJsonArray();
for (int j = 0; j < maps.size(); j++)
{
JsonObject mapObject = maps.get(j).getAsJsonObject();
String map = mapObject.get("map").getAsString();
String template = mapObject.get("template").getAsString();
ChatColor color = ChatColor.valueOf(mapObject.get("color").getAsString());
Location sign = LocationUtils.str2loc(mapObject.get("sign").getAsString());
RestrictedVersion restrictedVersion = null;
if (mapObject.has("restricted-version"))
{
try
{
restrictedVersion = RestrictedVersion.parse(mapObject.get("restricted-version").getAsString());
}
catch (Exception e)
{
this.log(Level.SEVERE, "Wanted to register a game sign with an invalid restricted version! (" + e.getMessage() + ")");
continue;
}
}
AbstractGame gameObject = this.hub.getGameManager().getGameByIdentifier(game);
if (gameObject == null)
{
this.log(Level.SEVERE, "Wanted to register a game sign withing an unknown game!");
continue;
}
Block block = this.hub.getWorld().getBlockAt(sign);
if (!(block.getState() instanceof Sign))
{
this.log(Level.SEVERE, "Sign block for game '" + game + "' and map '" + map + "' is not a sign in the world!");
continue;
}
gameObject.addSignForMap(map.replace("_", " "), color, template, restrictedVersion, (Sign) block.getState());
this.log(Level.INFO, "Registered sign zone for the game '" + game + "' and the map '" + map + "'!");
}
}
this.log(Level.INFO, "Reloaded game sign list.");
}
示例5: getColor
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static ChatColor getColor(String name) {
return ChatColor.valueOf(getString("colors", name));
}