本文整理汇总了Java中org.pircbotx.Colors.removeFormattingAndColors方法的典型用法代码示例。如果您正苦于以下问题:Java Colors.removeFormattingAndColors方法的具体用法?Java Colors.removeFormattingAndColors怎么用?Java Colors.removeFormattingAndColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.Colors
的用法示例。
在下文中一共展示了Colors.removeFormattingAndColors方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import org.pircbotx.Colors; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception
{
User user = event.getUser();
if (user == null)
return;
// Ignore own messages
if ( user.equals( bot.getUserBot() ) )
return;
// Don't bother with IRC formatting
String message = Colors.removeFormattingAndColors( event.getMessage() );
LOG.trace("Message from {}: {}", user.getNick(), message);
BRIDGE.onIRCMessage(user, message);
}
示例2: onAction
import org.pircbotx.Colors; //导入方法依赖的package包/类
@Override
public void onAction(ActionEvent event) throws Exception
{
User user = event.getUser();
if (user == null)
return;
// Ignore own messages
if ( user.equals( bot.getUserBot() ) )
return;
// Don't bother with IRC formatting
String action = Colors.removeFormattingAndColors( event.getAction() );
LOG.trace("Action from {}: {}", user.getNick(), action);
BRIDGE.onIRCAction(user, action);
}
示例3: handleLink
import org.pircbotx.Colors; //导入方法依赖的package包/类
/**
* Takes actions when specific links are sent
* @param message The message containing links
* @param channel The channel the message got sent in
* @param user The user the message got sent by
*/
public static void handleLink(String message, String channel, String user) throws Exception
{
outer:
for(String s : message.split(" "))
{
s = Colors.removeFormattingAndColors(s);
if(s.contains("www.") || s.contains("http://") || s.contains("https://"))
{
for(LinkAction la : linkActions)
{
if(la.isValid(channel, s))
{
la.handle(channel, user, s);
continue outer;
}
}
}
}
}
示例4: onPrivateMessage
import org.pircbotx.Colors; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
if (!e.getMessage().trim().split(" ")[0].equalsIgnoreCase("message")) return;
final User u = e.getUser();
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 2) {
e.respond("Usage: message [name] [message]");
return;
}
final String target = args[0];
String message = StringUtils.join(args, " ", 1, args.length);
final Player t = plugin.getServer().getPlayer(target);
if (t == null) {
e.respond("No such player.");
return;
}
if (Config.allowColors) message = RUtils.ircColorsToMinecraftColors(message);
else message = Colors.removeFormattingAndColors(message);
String send = Config.ituMessage;
send = send.replace("{server}", e.getBot().getServerInfo().getServerName());
send = send.replace("{name}", u.getNick());
send = send.replace("{message}", message);
t.sendMessage(send);
}
示例5: ircColorsToMinecraftColors
import org.pircbotx.Colors; //导入方法依赖的package包/类
public static String ircColorsToMinecraftColors(String s) {
s = s.replace(Colors.BLACK, ChatColor.BLACK.toString());
s = s.replace(Colors.BLUE, ChatColor.BLUE.toString());
s = s.replace(Colors.BOLD, ChatColor.BOLD.toString());
s = s.replace(Colors.BROWN, ChatColor.DARK_RED.toString());
s = s.replace(Colors.CYAN, ChatColor.BLUE.toString());
s = s.replace(Colors.DARK_BLUE, ChatColor.DARK_BLUE.toString());
s = s.replace(Colors.DARK_GRAY, ChatColor.DARK_GRAY.toString());
s = s.replace(Colors.DARK_GREEN, ChatColor.DARK_GREEN.toString());
s = s.replace(Colors.GREEN, ChatColor.GREEN.toString());
s = s.replace(Colors.LIGHT_GRAY, ChatColor.GRAY.toString());
s = s.replace(Colors.MAGENTA, ChatColor.DARK_PURPLE.toString());
s = s.replace(Colors.NORMAL, ChatColor.RESET.toString());
s = s.replace(Colors.OLIVE, ChatColor.DARK_GREEN.toString());
s = s.replace(Colors.PURPLE, ChatColor.LIGHT_PURPLE.toString());
s = s.replace(Colors.RED, ChatColor.RED.toString());
s = s.replace(Colors.REVERSE, "");
s = s.replace(Colors.TEAL, ChatColor.AQUA.toString());
s = s.replace(Colors.UNDERLINE, ChatColor.UNDERLINE.toString());
s = s.replace(Colors.WHITE, ChatColor.WHITE.toString());
s = s.replace(Colors.YELLOW, ChatColor.YELLOW.toString());
s = Colors.removeFormattingAndColors(s); // catch any stragglers
return s;
}
示例6: stripFormat
import org.pircbotx.Colors; //导入方法依赖的package包/类
public static String stripFormat(String message) {
String stripped = Colors.removeFormattingAndColors(message);
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < stripped.length(); i++) {
char c = stripped.charAt(i);
if (c != '\u001d') {
buffer.append(c);
}
}
return buffer.toString();
}
示例7: log
import org.pircbotx.Colors; //导入方法依赖的package包/类
/**
* Retains the original PircBotX.log() functionality, while adding the
* ability to output the log to a file.
* @param line the line to add to the log
*/
@Override
public void log(String line){
if (verbose) {
Date time = new Date(System.currentTimeMillis());
String output = Colors.removeFormattingAndColors(line);
System.out.println(timeFormat.format(time) + " " + output);
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(logFile,true)))) {
out.println(timeFormat.format(time) + " " + output);
} catch(IOException e) {
System.err.println("Error: unable to write to " + logFile);
}
}
}
示例8: executeCommand
import org.pircbotx.Colors; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
return new BotResponse(BotIntention.CHAT, null, Colors.removeFormattingAndColors(StringUtils.getArgs(cmd)));
}
示例9: removeColorsAndFormatting
import org.pircbotx.Colors; //导入方法依赖的package包/类
public static String[] removeColorsAndFormatting(String[] input) {
for (int i = 0; i < input.length; i++) {
input[i] = Colors.removeFormattingAndColors(input[i]);
}
return input;
}
示例10: sendToMinecraft
import org.pircbotx.Colors; //导入方法依赖的package包/类
public void sendToMinecraft(String s) {
if (Config.allowColors) s = RUtils.ircColorsToMinecraftColors(s);
else s = Colors.removeFormattingAndColors(s);
getServer().broadcastMessage(s);
}