Search in sources :

Example 6 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagIfRoleReplace method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitString = getSplit(from);
    from = removeFirstTag(from);
    boolean found = false;
    for (IRole r : command.user.roles) {
        if (StringUtils.containsIgnoreCase(r.getName(), splitString.get(0))) {
            found = true;
        }
    }
    if (found) {
        toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(2)));
    } else {
        toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(3)));
    }
    return from;
}
Also used : IRole(sx.blah.discord.handle.obj.IRole) ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Example 7 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagReplaceRandom method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitArgs = getSplit(from);
    Random random = new Random();
    int randomNum = random.nextInt(splitArgs.size() - 1);
    from = removeFirstTag(from);
    toReplace.add(new ReplaceObject(splitArgs.get(0), splitArgs.get(randomNum + 1)));
    return from;
}
Also used : Random(java.util.Random) ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Example 8 with ReplaceObject

use of com.github.vaerys.objects.ReplaceObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagIfArgsReplace method execute.

@Override
public String execute(String from, CommandObject command, String args, List<ReplaceObject> toReplace) {
    List<String> splitString = getSplit(from);
    from = removeFirstTag(from);
    if (StringUtils.containsIgnoreCase(args, splitString.get(0))) {
        toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(2)));
    } else {
        toReplace.add(new ReplaceObject(splitString.get(1), splitString.get(3)));
    }
    return from;
}
Also used : ReplaceObject(com.github.vaerys.objects.ReplaceObject) TagReplaceObject(com.github.vaerys.templates.TagReplaceObject)

Aggregations

ReplaceObject (com.github.vaerys.objects.ReplaceObject)8 TagReplaceObject (com.github.vaerys.templates.TagReplaceObject)8 Random (java.util.Random)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 IRole (sx.blah.discord.handle.obj.IRole)1