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.";
}
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;
}
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;
}
}
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++;
// }
// }
}
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 "";
}
Aggregations