Search in sources :

Example 1 with ExecuteTimer

use of com.earth2me.essentials.ExecuteTimer in project Essentials by drtshock.

the class KeywordReplacer method replaceKeywords.

private void replaceKeywords(final CommandSource sender) {
    execTimer = new ExecuteTimer();
    execTimer.start();
    User user = null;
    if (sender.isPlayer()) {
        user = ess.getUser(sender.getPlayer());
    }
    execTimer.mark("User Grab");
    for (int i = 0; i < input.getLines().size(); i++) {
        String line = input.getLines().get(i);
        final Matcher matcher = KEYWORD.matcher(line);
        while (matcher.find()) {
            final String fullMatch = matcher.group(0);
            final String keywordMatch = matcher.group(1);
            final String[] matchTokens = KEYWORDSPLIT.split(keywordMatch);
            line = replaceLine(line, fullMatch, matchTokens, user);
        }
        replaced.add(line);
    }
    execTimer.mark("Text Replace");
    final String timeroutput = execTimer.end();
    if (ess.getSettings().isDebug()) {
        ess.getLogger().log(Level.INFO, "Keyword Replacer " + timeroutput);
    }
}
Also used : User(com.earth2me.essentials.User) Matcher(java.util.regex.Matcher) ExecuteTimer(com.earth2me.essentials.ExecuteTimer)

Aggregations

ExecuteTimer (com.earth2me.essentials.ExecuteTimer)1 User (com.earth2me.essentials.User)1 Matcher (java.util.regex.Matcher)1