Search in sources :

Example 1 with CharacterObject

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

the class EditChar method execute.

@Override
public String execute(String args, CommandObject command) {
    SplitFirstObject charName = new SplitFirstObject(args);
    if (charName.getRest() == null || charName.getRest().isEmpty()) {
        return "> Mode Not Specified";
    }
    SplitFirstObject mode = new SplitFirstObject(charName.getRest());
    for (CharacterObject c : command.guild.characters.getCharacters(command.guild.get())) {
        if (c.getName().equalsIgnoreCase(charName.getFirstWord())) {
            if (c.getUserID() == command.user.longID || GuildHandler.canBypass(command.user.get(), command.guild.get())) {
                String rest = mode.getRest();
                if (rest == null) {
                    rest = "";
                }
                command.setAuthor(command.guild.getUserByID(c.getUserID()));
                switch(mode.getFirstWord().toLowerCase()) {
                    case "age":
                        return CharEditModes.age(rest, c, command);
                    case "gender":
                        return CharEditModes.gender(rest, c, command);
                    case "avatar":
                        return CharEditModes.avatar(rest, c, command);
                    case "bio":
                        return CharEditModes.desc(rest, c, command);
                    case "longdesc":
                        return CharEditModes.longDesc(rest, c);
                    case "weight":
                        return CharEditModes.weight(rest, c, command);
                    case "height":
                        return CharEditModes.height(rest, c, command);
                    default:
                        return "> Mode not Valid.";
                }
            } else {
                return command.user.notAllowed;
            }
        }
    }
    return "> Char with that name not found.";
}
Also used : CharacterObject(com.github.vaerys.objects.CharacterObject) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Example 2 with CharacterObject

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

the class SelectChar method execute.

@Override
public String execute(String args, CommandObject command) {
    for (CharacterObject c : command.guild.characters.getCharacters(command.guild.get())) {
        if (c.getName().equalsIgnoreCase(args)) {
            if (c.getUserID() == command.user.longID) {
                List<IRole> userRoles = command.guild.get().getRolesForUser(command.user.get());
                // resets User roles back to scratch.
                for (int i = 0; i < userRoles.size(); i++) {
                    if (command.guild.config.isRoleCosmetic(userRoles.get(i).getLongID())) {
                        userRoles.remove(i);
                    }
                }
                // loads new roles.
                for (long r : c.getRoleIDs()) {
                    userRoles.add(command.guild.getRoleByID(r));
                }
                RequestHandler.roleManagement(command.user.get(), command.guild.get(), userRoles);
                RequestHandler.updateUserNickName(command.user.get(), command.guild.get(), c.getNickname());
                return "> Character " + c.getNickname() + " Loaded.";
            } else {
                return "> " + c.getName() + " is not your character.";
            }
        }
    }
    return Constants.ERROR_CHAR_NOT_FOUND;
}
Also used : CharacterObject(com.github.vaerys.objects.CharacterObject) IRole(sx.blah.discord.handle.obj.IRole)

Example 3 with CharacterObject

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

the class UpdateChar method execute.

@Override
public String execute(String args, CommandObject command) {
    List<CharacterObject> userChars = command.user.characters;
    String charName = args.split(" ")[0];
    CharacterObject selectedChar = command.guild.characters.getCharByName(charName);
    List<IRole> cosmeticRoles = command.user.getCosmeticRoles(command);
    List<Long> cosmeticRoleIDs = cosmeticRoles.stream().map(iRole -> iRole.getLongID()).collect(Collectors.toList());
    String cosmeticString = command.guild.config.moduleRoles ? " and cosmetic roles" : "";
    if (selectedChar != null) {
        if (selectedChar.getUserID() != command.user.longID) {
            return "> That is not your character you cannot update it.";
        }
        if (selectedChar.getNickname().equals(command.user.displayName) && selectedChar.getRoleIDs().containsAll(cosmeticRoleIDs)) {
            return "> You haven't updated your details since the last time this character was updated.\n" + "Characters use your nickname " + cosmeticString + " to use as data.";
        }
        selectedChar.update(command.user.displayName, cosmeticRoles);
        String response = "> Your character has been updated using your nickname" + cosmeticString + ".";
        if (!UPDATE_CHAR.isSubCommand(command)) {
            response += "\nIf you were attempting to create a new character and not edit this character you need to specify a different character ID.";
        }
        return response;
    } else {
        int maxChars = command.guild.characters.maxCharsForUser(command);
        int rewardCount = command.user.getRewardValue(command);
        if (userChars.size() == maxChars) {
            if (command.guild.config.modulePixels && command.guild.config.xpGain && rewardCount != 4) {
                return "> You have reached the maximum allowed characters for your level," + " you will have to either rank up or delete an old character to make room.";
            }
            return "> You have reached the maximum allowed characters. You will have to delete an old character to make room.";
        }
        command.guild.characters.addChar(charName, cosmeticRoles, command.user);
        int remainingSlots = (maxChars - userChars.size() - 1);
        String response = "> New Character Created using your nickname " + cosmeticString + " to fill in data." + "\n(" + remainingSlots + " Character slot";
        if (remainingSlots != 1)
            response += "s";
        response += " remaining)";
        if (!UPDATE_CHAR.isSubCommand(command)) {
            response += "\nTo update the name";
            if (command.guild.config.moduleRoles)
                response += " or roles";
            response += " linked to this character just run this command again.";
        }
        return response;
    }
}
Also used : SubCommandObject(com.github.vaerys.objects.SubCommandObject) List(java.util.List) CommandObject(com.github.vaerys.commands.CommandObject) IRole(sx.blah.discord.handle.obj.IRole) CharacterObject(com.github.vaerys.objects.CharacterObject) ChannelSetting(com.github.vaerys.enums.ChannelSetting) SAILType(com.github.vaerys.enums.SAILType) Permissions(sx.blah.discord.handle.obj.Permissions) Command(com.github.vaerys.templates.Command) Collectors(java.util.stream.Collectors) CharacterObject(com.github.vaerys.objects.CharacterObject) IRole(sx.blah.discord.handle.obj.IRole)

Example 4 with CharacterObject

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

the class PurgeBannedData method purgeData.

public void purgeData(long userID, CommandObject command) {
    ListIterator iterator = command.guild.users.profiles.listIterator();
    while (iterator.hasNext()) {
        ProfileObject object = (ProfileObject) iterator.next();
        if (userID == object.getUserID()) {
            iterator.remove();
            purgedProfiles++;
        }
    }
    iterator = command.guild.customCommands.getCommandList().listIterator();
    while (iterator.hasNext()) {
        CCommandObject ccObject = (CCommandObject) iterator.next();
        if (userID == ccObject.getUserID()) {
            iterator.remove();
            purgedCCs++;
        }
    }
    iterator = command.guild.characters.getCharacters(command.guild.get()).listIterator();
    while (iterator.hasNext()) {
        CharacterObject charObject = (CharacterObject) iterator.next();
        if (charObject.getUserID() == userID) {
            iterator.remove();
            purgedCharacters++;
        }
    }
    iterator = command.guild.servers.getServers().listIterator();
    while (iterator.hasNext()) {
        ServerObject serverObject = (ServerObject) iterator.next();
        if (serverObject.getCreatorID() == userID) {
            iterator.remove();
            purgedServers++;
        }
    }
// iterator = Globals.getDailyMessages().getMessages().listIterator();
// while (iterator.hasNext()) {
// DailyMessage dailyObject = (DailyMessage) iterator.next();
// if (dailyObject.getUserID() == userID) {
// iterator.remove();
// purgedDailyMessages++;
// }
// }
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) CharacterObject(com.github.vaerys.objects.CharacterObject) ServerObject(com.github.vaerys.objects.ServerObject) ListIterator(java.util.ListIterator) ProfileObject(com.github.vaerys.objects.ProfileObject)

Example 5 with CharacterObject

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

the class CharAvatar method execute.

@Override
public String execute(String args, CommandObject command) {
    CharacterObject charObject = command.guild.characters.getCharByName(args.split(" ")[0]);
    if (charObject == null)
        return "> Could not find any characters with that Character ID.";
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(charObject.getNickname());
    IUser user = command.guild.getUserByID(charObject.getUserID());
    builder.withFooterText("Author: " + user.getDisplayName(command.guild.get()) + " | Character ID: " + charObject.getName());
    command.guild.characters.validateRoles(command.guild.get());
    if (charObject.getRoleIDs().size() != 0) {
        builder.withColor(charObject.getColor(command.guild));
    }
    if (charObject.getAvatarURL() == null || charObject.getAvatarURL().isEmpty())
        return "> " + charObject.getNickname() + " Does not have an avatar set up.";
    builder.withImage(charObject.getAvatarURL());
    builder.send(command.channel);
    return "";
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) CharacterObject(com.github.vaerys.objects.CharacterObject) IUser(sx.blah.discord.handle.obj.IUser)

Aggregations

CharacterObject (com.github.vaerys.objects.CharacterObject)6 IRole (sx.blah.discord.handle.obj.IRole)3 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)2 IUser (sx.blah.discord.handle.obj.IUser)2 CommandObject (com.github.vaerys.commands.CommandObject)1 ChannelSetting (com.github.vaerys.enums.ChannelSetting)1 SAILType (com.github.vaerys.enums.SAILType)1 CCommandObject (com.github.vaerys.objects.CCommandObject)1 ProfileObject (com.github.vaerys.objects.ProfileObject)1 ServerObject (com.github.vaerys.objects.ServerObject)1 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 SubCommandObject (com.github.vaerys.objects.SubCommandObject)1 Command (com.github.vaerys.templates.Command)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListIterator (java.util.ListIterator)1 Collectors (java.util.stream.Collectors)1 Permissions (sx.blah.discord.handle.obj.Permissions)1