本文整理汇总了Java中org.pircbotx.Colors.RED属性的典型用法代码示例。如果您正苦于以下问题:Java Colors.RED属性的具体用法?Java Colors.RED怎么用?Java Colors.RED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.pircbotx.Colors
的用法示例。
在下文中一共展示了Colors.RED属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeCommand
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
StringBuilder sb = new StringBuilder("Testing ");
sb.append(StringUtils.getArgs(cmd)).append(": ");
int random = MathUtils.getRandom(0, CHECK_MATH_MAX);
String result;
if (random < CHECK_MATH_PANIC) {
result = Colors.WHITE + "[" + Colors.YELLOW + "PANIC" + Colors.WHITE + "]";
} else if (random < CHECK_MATH_FAIL) {
result = Colors.WHITE + "[" + Colors.RED + "FAIL" + Colors.WHITE + "]";
} else {
result = Colors.WHITE + "[" + Colors.GREEN + "PASS" + Colors.WHITE + "]";
}
sb.append(result);
return new BotResponse(BotIntention.CHAT, event.getUser(), sb.toString());
}
示例2: prism
public static String prism(char c, int number) {
String result = null;
System.out.println(number);
switch (number) {
case 1:
result = Colors.RED + c;
break;
case 2:
result = Colors.YELLOW + c;
break;
case 3:
result = Colors.DARK_GREEN + c;
break;
case 4:
result = Colors.CYAN + c;
break;
case 5:
result = Colors.BLUE + c;
break;
case 6:
result = Colors.MAGENTA + c;
break;
}
return result;
}
示例3: getTitle
public static String getTitle(String link) {
String response = "";
try {
HttpURLConnection conn = (HttpURLConnection) new URL(link).openConnection();
conn.addRequestProperty("User-Agent", USER_AGENT);
conn.setInstanceFollowRedirects(true);
String type = conn.getContentType();
int length = conn.getContentLength() / 1024;
response = String.format("HTTP %s: %s", conn.getResponseCode(), conn.getResponseMessage());
String info;
if (type.contains("text") || type.contains("application")) {
Document doc = Jsoup.connect(link).userAgent(USER_AGENT).followRedirects(true).get();
return (doc.title() == null || doc.title().isEmpty() ? "No title found!" : doc.title());
}
info = String.format("Content Type: %s Size: %skb", type, length);
return info;
} catch (IOException ex) {
if (ex.getMessage().contains("UnknownHostException")) {
return Colors.RED + "Unknown hostname!";
}
return response.isEmpty() ? Colors.RED + "An error occured" : response;
}
}
示例4: getTitle
public static String getTitle(String link) {
String response = "";
try {
HttpURLConnection conn = (HttpURLConnection) new URL(link).openConnection();
conn.addRequestProperty("User-Agent", USER_AGENT);
String type = conn.getContentType();
int length = conn.getContentLength() / 1024;
response = String.format("HTTP %s: %s", conn.getResponseCode(), conn.getResponseMessage());
String info;
if (type.contains("text") || type.contains("application")) {
Document doc = Jsoup.connect(link).userAgent(USER_AGENT).followRedirects(true).get();
String title = doc.title() == null || doc.title().isEmpty() ? "No title found!" : doc.title();
info = String.format("%s - (Content Type: %s Size: %skb)", title, type, length);
return info;
}
info = String.format("Content Type: %s Size: %skb", type, length);
return info;
} catch (IOException ex) {
if (ex.getMessage().contains("UnknownHostException")) {
return Colors.RED + "Unknown hostname!";
}
return response.isEmpty() ? Colors.RED + "An error occured" : response;
}
}
示例5: toString
/**
* String representation of the card with IRC color formatting.
* Gives the card a colour based on suit and adds a white background.
*
* @return a IRC colour formatted string with the card's face and suit
*/
@Override
public String toString(){
String color;
if (suit.equals(CardDeck.suits[0])){
color = Colors.RED;
} else if ( suit.equals(CardDeck.suits[1])){
color = Colors.BROWN;
} else if ( suit.equals(CardDeck.suits[2])){
color = Colors.DARK_BLUE;
} else {
color = Colors.BLACK;
}
return color + ",00" + face + suit;
}
示例6: onMessage
@Override
public void onMessage(MessageEvent event) throws Exception {
if (event.getMessage().startsWith(Helix.botPrefix + Commands.checkMinecraftAccount + " ") && event.getMessage().length() > (Commands.checkMinecraftAccount.length() + 2)) {
String a = event.getMessage().split(" ", 2)[1].replace(" ", "");
String m;
try {
JSONObject r = new JSONObject(Util.getHTTPResponse("https://api.mojang.com/users/profiles/minecraft/" + URLEncoder.encode(a, "UTF-8")));
String name = r.getString("name");
String id = r.getString("id");
JSONArray h = new JSONArray(Util.getHTTPResponse("https://api.mojang.com/user/profiles/" + id + "/names"));
m = "Username: " + Colors.GREEN + name + Colors.NORMAL + " UUID: " + Colors.MAGENTA + id + Colors.NORMAL + " Username history: " + Colors.BLUE + h.getJSONObject(0).getString("name") + Colors.NORMAL;
for (int i = 1; i < h.length(); i++){
m += ", " + Colors.BLUE + h.getJSONObject(i).getString("name") + Colors.NORMAL;
}
} catch (JSONException e) {
m = Colors.RED + "User " + a + " not found!";
}
event.getChannel().send().message(m);
}
}
示例7: onMessage
@Override
public void onMessage(MessageEvent event) throws Exception {
String msg = event.getMessage();
if (msg.startsWith(Helix.botPrefix + Commands.youTubeSearch) && ((msg.length() > (Commands.youTubeSearch.length()+2) && msg.charAt(Commands.youTubeSearch.length()+1) == ' ') || (msg.length() > (Commands.youTubeSearch.length()+3) && Arrays.asList(Helix.valid).contains(msg.charAt(Commands.youTubeSearch.length()+1)) && msg.charAt(Commands.youTubeSearch.length()+2) == ' '))){
String q = msg.split(" ", 2)[1];
String max = msg.charAt(3) == ' ' ? "1" : String.valueOf(msg.charAt(3));
String a = String.format("https://www.googleapis.com/youtube/v3/search?part=id&maxResults=%s®ionCode=br&type=video&q=%s&key=%s", max, URLEncoder.encode(q, "UTF-8"), Helix.properties.get("google.apikey"));
JSONObject v;
JSONObject snip;
String views;
String dislike;
String like;
String len;
String m;
try {
v = new JSONObject(Util.getHTTPResponse(String.format("https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,statistics&id=%s&key=%s", (new JSONObject(Util.getHTTPResponse(a))).getJSONArray("items").getJSONObject(Integer.valueOf(max) - 1).getJSONObject("id").getString("videoId"), Helix.properties.get("google.apikey")))).getJSONArray("items").getJSONObject(0);
snip = v.getJSONObject("snippet");
JSONObject stat = v.getJSONObject("statistics");
views = Helix.numberFormat.format(Long.parseLong(stat.getString("viewCount")));
dislike = Helix.numberFormat.format(Integer.parseInt(stat.getString("dislikeCount")));
like = Helix.numberFormat.format(Integer.parseInt(stat.getString("likeCount")));
len = v.getJSONObject("contentDetails").getString("duration");
m = Colors.BOLD + Colors.BLACK + ",00[You" + Colors.WHITE + ",04Tube]" + Colors.NORMAL + " " + snip.getString("title") + " [" + Colors.OLIVE + (len.equals("PT0S")? "Live" : Util.parseYouTubeTime(len)) + Colors.NORMAL + "] [" + Colors.TEAL + views + Colors.NORMAL + "] [" + Colors.DARK_GREEN + "+" + like + Colors.NORMAL + "] [" + Colors.RED + "-" + dislike + Colors.NORMAL + "] [" + Colors.MAGENTA + snip.getString("channelTitle") + Colors.NORMAL + "] http://youtu.be/" + v.getString("id");
} catch (JSONException e){
m = "Video not found! \"" + Colors.BOLD + q + Colors.NORMAL + "\"";
}
event.getChannel().send().message(m);
}
}
示例8: getColoredChangeText
/**
* Convenience method for getting colored change text depending on positive or negative change.
*
* @param change The change for whatever duration of time, be it positive or negative.
* @return The formatted string with colors.
*/
private String getColoredChangeText(final String change) {
if (change.startsWith("-")) {
return Colors.RED + change + "%" + Colors.NORMAL + Colors.TEAL;
}
return Colors.GREEN + "+" + change + "%" + Colors.NORMAL + Colors.TEAL;
}
示例9: executeCommand
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
if (event instanceof MessageEvent) {
Channel channel = ((MessageEvent) event).getChannel();
ImmutableSortedSet<User> users = channel.getUsers();
String victimName = "";
int totalUsers = users.size();
Random random = new Random();
int victimIndex = random.nextInt(totalUsers);
int i = 0;
for (User u : users) {
if (i < victimIndex) {
i++;
} else if (i == victimIndex) {
victimName = u.getNick();
break;
}
}
String message;
if (MathUtils.getRandom(0, DICE_MATH_MAX) < DICE_MATH_MID) {
message = Colors.WHITE + "rolls a huge " + totalUsers + " sided die and it flattens "
+ Colors.YELLOW + victimName + Colors.WHITE + " before coming to a halt on "
+ Colors.RED + "YOU LOSE" + Colors.NORMAL;
} else {
message = Colors.WHITE + "rolls a huge " + totalUsers + " sided die and it lands near "
+ Colors.YELLOW + victimName + Colors.WHITE + " before coming to a halt on "
+ Colors.GREEN + "YOU WIN" + Colors.NORMAL;
}
return new BotResponse(BotIntention.ME, null, message);
} else {
return new BotResponse(BotIntention.PRIVATE_MESSAGE, event.getUser(),
butt.getYamlConfigurationFile().getBotName() + " can't roll no dice here");
}
}
示例10: condenseMembers
private String condenseMembers() {
String s = "";
for(Playable p : members) {
s += (p.health <= 0 ? Colors.LIGHT_GRAY :Colors.RED) + p.getName() + " ["+p.health+"]"+Colors.NORMAL;
if(!members.get(members.size()-1).equals(p)) s += " ";
}
return s;
}
示例11: colorize
private String colorize(String characther) {
return (characther.equals("X") ? Colors.RED : characther.equals("O") ? Colors.DARK_BLUE : Colors.PURPLE ) + characther + Colors.NORMAL;
}
示例12: toBattleString
public String toBattleString() {
return getName() + Colors.BOLD +" ("+Colors.RED+health+Colors.NORMAL+"/"+Colors.RED+calcTotal(null)+Colors.NORMAL+") "+getColorNumber(Colors.BROWN, Type.Physical)+getColorNumber(Colors.BLUE, Type.Magical)+getColorNumber(Colors.PURPLE, Type.Emotional)+getColorNumber(Colors.DARK_BLUE, Type.Spiritual);
}
示例13: modifyMessage
private String modifyMessage(String string, Player p, int i, boolean isGood) {
String message = (isGood ? Colors.DARK_GREEN : Colors.RED) + string.replaceAll("%player", p.getName()).replaceAll("%money", ""+i);
return Event.replaceGender(message, p);
}
示例14: modifyMessage
private String modifyMessage(String string, Player p, Item i, boolean isGood) {
String message = (isGood ? Colors.DARK_GREEN : Colors.RED) + Event.replaceGender(string.replaceAll("%player", p.getName()).replaceAll("%item", i.getName()), p);
message += " ["+i.getValue()+"->"+Math.round(i.getValue()*(isGood ? 1.1 : 0.9))+"]";
return message;
}