use of com.github.vaerys.objects.RewardRoleObject in project DiscordSailv2 by Vaerys-Dawn.
the class ModulePixels method stats.
@Override
public String stats(CommandObject command) {
boolean hasManageServer = GuildHandler.testForPerms(command, Permissions.MANAGE_SERVER);
StringBuilder builder = new StringBuilder();
builder.append("**Pixels Per Message: ** " + command.guild.config.xpRate);
builder.append("\n**Pixel Modifier:** " + command.guild.config.xpModifier);
if (hasManageServer) {
IRole topTen = command.guild.getRoleByID(command.guild.config.topTenRoleID);
IRole xpDenied = command.guild.getRoleByID(command.guild.config.xpDeniedRoleID);
if (topTen != null)
builder.append("\n**Top Ten Role:** " + topTen.getName());
if (xpDenied != null)
builder.append("\n**Xp Denied Role:** " + xpDenied.getName());
}
if (command.guild.config.getRewardRoles().size() != 0) {
builder.append("\n\n**[REWARD ROLES]**");
for (RewardRoleObject r : command.guild.config.getRewardRoles()) {
IRole role = command.guild.getRoleByID(r.getRoleID());
if (role != null) {
builder.append("\n**" + role.getName() + "** - Lvl " + r.getLevel());
}
}
}
return builder.toString();
}
use of com.github.vaerys.objects.RewardRoleObject in project DiscordSailv2 by Vaerys-Dawn.
the class PixelHelp method execute.
@Override
public String execute(String args, CommandObject command) {
if (args.equalsIgnoreCase("Decay") && command.guild.config.xpDecay)
return decay(command);
if (args.equalsIgnoreCase("Rules"))
return rules(command);
SplitFirstObject obe = new SplitFirstObject(args);
String mode = obe.getFirstWord();
switch(mode.toLowerCase()) {
case "leveltoxp":
case "level2xp":
case "level->xp":
return levelToXp(obe.getRest());
case "xptolevel":
case "xp2level":
case "xp->level":
return xpToLevel(obe.getRest());
default:
StringBuilder builder = new StringBuilder();
XEmbedBuilder embed = new XEmbedBuilder(command);
embed.withTitle("Pixel System Information.");
embed.withDescription("Pixels are " + command.client.bot.displayName + "'s" + " form of xp, you can gain " + (int) (command.guild.config.xpRate * command.guild.config.xpModifier) + "xp" + " once per minute by sending a message that meets all of the specific message rules.\n\n");
if (command.guild.config.getRewardRoles().size() != 0) {
for (RewardRoleObject r : command.guild.config.getRewardRoles()) {
IRole reward = command.guild.getRoleByID(r.getRoleID());
if (reward == null) {
break;
}
builder.append("\n> **" + reward.getName() + "** -> Level: **" + r.getLevel() + "**");
}
embed.appendField("Reward Roles:", builder.toString(), true);
}
if (command.guild.config.xpModifier != 1) {
embed.appendField("\n**Current Xp Modifier:**\n", "> **x" + command.guild.config.xpModifier + "**.\n", true);
}
int random = new Random().nextInt(25);
if (random == 1) {
embed.withThumbnail(Constants.RANK_UP_IMAGE_URL);
} else {
embed.withThumbnail(Constants.LEVEL_UP_IMAGE_URL);
}
embed.appendField("Pixel and Level Calculators:", getModes(command) + "\n\n" + Utility.getCommandInfo(this, command), false);
RequestHandler.sendEmbedMessage("", embed, command.channel.get());
return null;
}
}
use of com.github.vaerys.objects.RewardRoleObject in project DiscordSailv2 by Vaerys-Dawn.
the class GuildConfig method getNextReward.
public RewardRoleObject getNextReward(RewardRoleObject rewardRole) {
validateRoles();
ArrayList<RewardRoleObject> compareRewards = (ArrayList<RewardRoleObject>) rewardRoles.clone();
RewardRoleObject lowestRole = null;
// remove reward roles that are above it or are it.
for (int i = 0; i < compareRewards.size(); i++) {
if (compareRewards.get(i).getLevel() <= rewardRole.getLevel()) {
compareRewards.remove(i);
}
}
if (compareRewards == null || compareRewards.size() == 0) {
return null;
}
for (RewardRoleObject r : compareRewards) {
if (lowestRole == null) {
lowestRole = r;
} else {
if (r.getLevel() < lowestRole.getLevel()) {
lowestRole = r;
}
}
}
return lowestRole;
}
use of com.github.vaerys.objects.RewardRoleObject in project DiscordSailv2 by Vaerys-Dawn.
the class PixelHandler method handleLevelUp.
/**
* Handler for user level ups.
*
* @param user the user that leveled up.
* @param object the container for all relevant API content.
*/
private static void handleLevelUp(ProfileObject user, CommandObject object) {
RewardRoleObject reward = null;
// get next level xp
long nextLevelXp = totalXPForLevel(user.getCurrentLevel() + 1);
// sanity check the level
if (user.getCurrentLevel() == -1) {
user.levelUp();
return;
}
// check if the user actually leveled up
if (user.getXP() < nextLevelXp)
return;
user.levelUp();
// check if the user ranked up
for (RewardRoleObject r : object.guild.config.getRewardRoles()) {
if (r.getLevel() == user.getCurrentLevel()) {
reward = r;
break;
}
}
// if denyAutoRole remove Reward.
if (user.getSettings().contains(DENY_AUTO_ROLE))
reward = null;
// logging
object.guild.sendDebugLog(object, "PIXELS", reward != null ? "RANKUP" : "LEVELUP", user.getCurrentLevel() + "");
// handle reactions
handleReactions(user, object);
// handle level up messages
handleMessage(user, object, reward);
// check user's roles for rank up purposes
checkUsersRoles(user.getUserID(), object.guild);
}
use of com.github.vaerys.objects.RewardRoleObject in project DiscordSailv2 by Vaerys-Dawn.
the class PixelHandler method getRewardCount.
public static int getRewardCount(GuildObject object, long userID) {
if (!object.config.modulePixels)
return 4;
ProfileObject userObject = object.users.getUserByID(userID);
if (userObject == null) {
return 0;
}
List<RewardRoleObject> userRewards = object.config.getAllRewards(userObject.getCurrentLevel());
List<RewardRoleObject> allRewards = object.config.getRewardRoles();
if (userRewards.size() == 0) {
return 0;
} else {
if (allRewards.size() < 4) {
float value = (userRewards.size() * 100.0f) / allRewards.size();
value = value / 25;
return (int) value;
} else {
if (userRewards.size() > 4) {
return 4;
} else {
return userRewards.size();
}
}
}
}
Aggregations