Search in sources :

Example 1 with VoteModel

use of org.cubeengine.module.vote.storage.VoteModel in project modules-extra by CubeEngine.

the class VoteCommands method vote.

@Command(desc = "Shows your current vote situation")
public void vote(CommandSource context) {
    if (!(context instanceof Player)) {
        i18n.send(context, NEUTRAL, "Well you wont get any rewards.");
        if (!module.getConfig().voteUrl.isEmpty()) {
            i18n.send(context, NEUTRAL, "But here go vote anyways: {name#voteurl}", module.getConfig().voteUrl);
        }
        return;
    }
    VoteModel voteModel = db.getDSL().selectFrom(TABLE_VOTE).where(TABLE_VOTE.ID.eq(((Player) context).getUniqueId())).fetchOne();
    if (voteModel == null) {
        i18n.send(context, NEUTRAL, "Sorry but you do not have any registered votes on this server!");
        return;
    }
    i18n.send(context, POSITIVE, "You current vote-count is {amount}", voteModel.getVotes());
    if (voteModel.timePassed(module.getConfig().voteBonusTime.toMillis())) {
        i18n.send(context, NEUTRAL, "Sadly you did not vote in the last {input#time} so your vote-count will be reset to 1", TimeUtil.format(context.getLocale(), module.getConfig().voteBonusTime.toMillis()));
    } else if (voteModel.timePassed(DAYS.toMillis(1))) {
        i18n.send(context, NEUTRAL, "Voting now will increase your consecutive votes and result in higher reward!");
    } else {
        i18n.send(context, POSITIVE, "You voted {input#time} so you will probably not be able to vote again already!", TimeUtil.format(context.getLocale(), new Date(voteModel.getLastVote())));
    }
    if (!module.getConfig().voteUrl.isEmpty()) {
        i18n.send(context, POSITIVE, "You can vote here now: {name#voteurl}", module.getConfig().voteUrl);
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) VoteModel(org.cubeengine.module.vote.storage.VoteModel) Date(java.util.Date) Command(org.cubeengine.butler.parametric.Command)

Aggregations

Date (java.util.Date)1 Command (org.cubeengine.butler.parametric.Command)1 VoteModel (org.cubeengine.module.vote.storage.VoteModel)1 Player (org.spongepowered.api.entity.living.player.Player)1